@twilio/conversations 3.0.0-canary.9 → 3.0.0-canary2.100
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 +22 -18
- package/builds/browser.js +1018 -2070
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +69 -67
- package/builds/lib.js +1018 -2070
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +24737 -25259
- package/builds/twilio-conversations.min.js +1 -1
- package/dist/aggregated-delivery-receipt.js +1 -1
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/client.js +85 -69
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +30 -12
- package/dist/command-executor.js.map +1 -1
- package/dist/conversation.js +87 -19
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +20 -4
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +13 -19
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +6 -4
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +4 -2
- package/dist/data/users.js.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +15 -12
- package/dist/message.js.map +1 -1
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js.map +1 -1
- package/dist/services/network.js +38 -15
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +7 -5
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +1 -1
- package/dist/user.js.map +1 -1
- package/dist/util/index.js.map +1 -1
- package/package.json +18 -16
package/builds/lib.d.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
/// <reference types="node" />
|
1
2
|
import { SyncClient, SyncDocument, SyncList } from "twilio-sync";
|
2
3
|
import { LogLevelDesc } from "loglevel";
|
3
|
-
import {
|
4
|
-
import { ConnectionState as TwilsockConnectionState } from "twilsock";
|
4
|
+
import { TwilsockClient, InitRegistration, HttpResponse } from "twilsock";
|
5
5
|
import { ReplayEventEmitter } from "@twilio/replay-event-emitter";
|
6
|
+
import { JSONValue } from "@twilio/shared";
|
6
7
|
import { ChannelType, Notifications } from "@twilio/notifications";
|
7
8
|
import { Notifications as NotificationClient } from "@twilio/notifications";
|
8
9
|
import { CancellablePromise, McsClient, MediaCategory, McsMedia } from "@twilio/mcs-client";
|
@@ -112,7 +113,7 @@ declare class Configuration {
|
|
112
113
|
constructor(options: ClientOptions, configurationResponse: ConfigurationResponse, logger: Logger);
|
113
114
|
}
|
114
115
|
interface CommandExecutorServices {
|
115
|
-
transport:
|
116
|
+
transport: TwilsockClient;
|
116
117
|
}
|
117
118
|
declare class CommandExecutor {
|
118
119
|
private _serviceUrl;
|
@@ -124,20 +125,6 @@ declare class CommandExecutor {
|
|
124
125
|
fetchResource<REQ = void, RESP = void>(url: string, requestBody?: REQ): Promise<RESP>;
|
125
126
|
mutateResource<REQ = void, RESP = void>(method: "post" | "delete", url: string, requestBody?: REQ): Promise<RESP>;
|
126
127
|
}
|
127
|
-
/**
|
128
|
-
* Represents a JSON value.
|
129
|
-
*/
|
130
|
-
type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
|
131
|
-
/**
|
132
|
-
* Represents a JSON object.
|
133
|
-
*/
|
134
|
-
type JSONObject = {
|
135
|
-
[x: string]: JSONValue;
|
136
|
-
};
|
137
|
-
/**
|
138
|
-
* Represents a JSON array.
|
139
|
-
*/
|
140
|
-
type JSONArray = JSONValue[];
|
141
128
|
type UserEvents = {
|
142
129
|
updated: (data: {
|
143
130
|
user: User;
|
@@ -269,7 +256,7 @@ declare class Network {
|
|
269
256
|
private cleanupCache;
|
270
257
|
pokeTimer(): void;
|
271
258
|
private executeWithRetry;
|
272
|
-
get<T>(url: string): Promise<
|
259
|
+
get<T>(url: string): Promise<HttpResponse>;
|
273
260
|
}
|
274
261
|
type UsersEvents = {
|
275
262
|
userUpdated: (data: {
|
@@ -567,7 +554,7 @@ interface AggregatedDeliveryDescriptor {
|
|
567
554
|
* Contains aggregated information about delivery statuses of a message across all participants
|
568
555
|
* of a conversation.
|
569
556
|
*
|
570
|
-
* At any moment during the message delivery to a participant, the message can have zero or more of following
|
557
|
+
* At any moment during the message delivery to a participant, the message can have zero or more of the following
|
571
558
|
* delivery statuses:
|
572
559
|
* * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
|
573
560
|
* * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
|
@@ -731,8 +718,8 @@ interface MessageData {
|
|
731
718
|
attributes?: JSONValue;
|
732
719
|
dateUpdated: string;
|
733
720
|
timestamp?: string;
|
734
|
-
medias
|
735
|
-
media
|
721
|
+
medias: MediaState[] | null;
|
722
|
+
media: MediaState | null;
|
736
723
|
memberSid?: string;
|
737
724
|
delivery?: AggregatedDeliveryDescriptor;
|
738
725
|
}
|
@@ -782,14 +769,15 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
|
|
782
769
|
*/
|
783
770
|
get dateUpdated(): Date | null;
|
784
771
|
/**
|
785
|
-
* Index of
|
786
|
-
*
|
772
|
+
* Index of this message in the conversation's list of messages.
|
773
|
+
*
|
774
|
+
* By design, the message indices may have arbitrary gaps between them,
|
787
775
|
* that does not necessarily mean they were deleted or otherwise modified - just that
|
788
776
|
* messages may have some non-contiguous indices even if they are being sent immediately one after another.
|
789
777
|
*
|
790
778
|
* Trying to use indices for some calculations is going to be unreliable.
|
791
779
|
*
|
792
|
-
* To calculate the number of unread messages it is better to use the
|
780
|
+
* To calculate the number of unread messages, it is better to use the Read Horizon API.
|
793
781
|
* See {@link Conversation.getUnreadMessagesCount} for details.
|
794
782
|
*/
|
795
783
|
get index(): number;
|
@@ -1024,6 +1012,7 @@ interface MessageResponse {
|
|
1024
1012
|
media: {
|
1025
1013
|
sid: string;
|
1026
1014
|
size: string;
|
1015
|
+
category: string;
|
1027
1016
|
content_type: string;
|
1028
1017
|
filename: string;
|
1029
1018
|
}[] | null;
|
@@ -1058,9 +1047,10 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
|
|
1058
1047
|
constructor(conversation: Conversation, configuration: Configuration, services: MessagesServices);
|
1059
1048
|
/**
|
1060
1049
|
* Subscribe to the Messages Event Stream
|
1061
|
-
* @param
|
1050
|
+
* @param arg - Name of the Sync object, or the SyncList itself, that
|
1051
|
+
* represents the Messages resource.
|
1062
1052
|
*/
|
1063
|
-
subscribe(
|
1053
|
+
subscribe(arg: string | SyncList): Promise<SyncList>;
|
1064
1054
|
unsubscribe(): Promise<void>;
|
1065
1055
|
/**
|
1066
1056
|
* Send a message to the conversation. The message could include text and multiple media attachments.
|
@@ -1092,7 +1082,7 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
|
|
1092
1082
|
*/
|
1093
1083
|
getMessages(pageSize: number | undefined, anchor: number | "end" | undefined, direction?: "forward" | "backwards"): Promise<SyncPaginator<Message>>;
|
1094
1084
|
private _wrapPaginator;
|
1095
|
-
|
1085
|
+
_upsertMessage(index: number, value: MessageData): Message;
|
1096
1086
|
/**
|
1097
1087
|
* Returns last messages from conversation
|
1098
1088
|
* @param {Number} [pageSize] Number of messages to return in single chunk. By default it's 30.
|
@@ -1489,10 +1479,18 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1489
1479
|
* Messages entity.
|
1490
1480
|
*/
|
1491
1481
|
private readonly _messagesEntity;
|
1482
|
+
/**
|
1483
|
+
* Sync list containing messages.
|
1484
|
+
*/
|
1485
|
+
private _messagesList?;
|
1492
1486
|
/**
|
1493
1487
|
* Participants entity.
|
1494
1488
|
*/
|
1495
1489
|
private readonly _participantsEntity;
|
1490
|
+
/**
|
1491
|
+
* Sync map containing participants.
|
1492
|
+
*/
|
1493
|
+
private _participantsMap?;
|
1496
1494
|
/**
|
1497
1495
|
* Source of the most recent update.
|
1498
1496
|
*/
|
@@ -1663,7 +1661,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1663
1661
|
*/
|
1664
1662
|
getMessagesCount(): Promise<number>;
|
1665
1663
|
/**
|
1666
|
-
* Get unread messages
|
1664
|
+
* Get count of unread messages for the user if they are a participant of this
|
1667
1665
|
* conversation. Rejects if the user is not a participant of the conversation.
|
1668
1666
|
*
|
1669
1667
|
* Use this method to obtain the number of unread messages together with
|
@@ -1671,12 +1669,19 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1671
1669
|
* message indices which may have gaps. See {@link Message.index} for details.
|
1672
1670
|
*
|
1673
1671
|
* This method is semi-realtime. This means that this data will be eventually
|
1674
|
-
* correct, but will also be possibly incorrect for a few seconds. The
|
1672
|
+
* correct, but it will also be possibly incorrect for a few seconds. The
|
1675
1673
|
* Conversations system does not provide real time events for counter values
|
1676
1674
|
* changes.
|
1677
1675
|
*
|
1678
1676
|
* This is useful for any UI badges, but it is not recommended to build any
|
1679
1677
|
* core application logic based on these counters being accurate in real time.
|
1678
|
+
*
|
1679
|
+
* If the read horizon is not set, this function will return null. This could mean
|
1680
|
+
* that all messages in the conversation are unread, or that the read horizon system
|
1681
|
+
* is not being used. How to interpret this `null` value is up to the customer application.
|
1682
|
+
*
|
1683
|
+
* @return Number of unread messages based on the current read horizon set for
|
1684
|
+
* the user or `null` if the read horizon is not set.
|
1680
1685
|
*/
|
1681
1686
|
getUnreadMessagesCount(): Promise<number | null>;
|
1682
1687
|
/**
|
@@ -1692,8 +1697,6 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1692
1697
|
* argument, it will assume that the string is an identity or SID.
|
1693
1698
|
* @param participant Identity, SID or the participant object to remove.
|
1694
1699
|
*/
|
1695
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
1696
|
-
// @ts-ignore TODO: fix validateTypesAsync typing
|
1697
1700
|
removeParticipant(participant: string | Participant): Promise<void>;
|
1698
1701
|
/**
|
1699
1702
|
* Send a message to the conversation.
|
@@ -1704,7 +1707,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1704
1707
|
* @param emailOptions Email options for the message.
|
1705
1708
|
* @return Index of the new message.
|
1706
1709
|
*/
|
1707
|
-
sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<
|
1710
|
+
sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<Message>;
|
1708
1711
|
/**
|
1709
1712
|
* New interface to prepare for sending a message.
|
1710
1713
|
* Use this instead of {@link Message.sendMessage}.
|
@@ -1719,7 +1722,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1719
1722
|
setAllMessagesRead(): Promise<number>;
|
1720
1723
|
/**
|
1721
1724
|
* Set all messages in the conversation unread.
|
1722
|
-
* @
|
1725
|
+
* @returns New count of unread messages after this update.
|
1723
1726
|
*/
|
1724
1727
|
setAllMessagesUnread(): Promise<number>;
|
1725
1728
|
/**
|
@@ -1748,7 +1751,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1748
1751
|
* Set the last read message index to the current read horizon.
|
1749
1752
|
* @param index Message index to set as last read. If null is provided, then
|
1750
1753
|
* the behavior is identical to {@link Conversation.setAllMessagesUnread}.
|
1751
|
-
* @returns
|
1754
|
+
* @returns New count of unread messages after this update.
|
1752
1755
|
*/
|
1753
1756
|
updateLastReadMessageIndex(index: number | null): Promise<number>;
|
1754
1757
|
/**
|
@@ -1764,6 +1767,16 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1764
1767
|
* @internal
|
1765
1768
|
*/
|
1766
1769
|
_subscribe(): Promise<SyncDocument>;
|
1770
|
+
/**
|
1771
|
+
* Fetch participants and messages of the conversation. This method needs to
|
1772
|
+
* be called during conversation initialization to catch broken conversations
|
1773
|
+
* (broken conversations are conversations that have essential Sync entities
|
1774
|
+
* missing, i.e. the conversation document, the messages list or the
|
1775
|
+
* participant map). In case of this conversation being broken, the method
|
1776
|
+
* will throw an exception that will be caught and handled gracefully.
|
1777
|
+
* @internal
|
1778
|
+
*/
|
1779
|
+
_fetchStreams(): Promise<void>;
|
1767
1780
|
/**
|
1768
1781
|
* Load the attributes of this conversation and instantiate its participants
|
1769
1782
|
* and messages. This or _subscribe will need to be called before any events
|
@@ -1836,7 +1849,7 @@ interface PushNotificationData {
|
|
1836
1849
|
*/
|
1837
1850
|
media?: Media;
|
1838
1851
|
/**
|
1839
|
-
*
|
1852
|
+
* Count of the attached media of the message.
|
1840
1853
|
*/
|
1841
1854
|
mediaCount?: number;
|
1842
1855
|
}
|
@@ -1912,11 +1925,11 @@ type ClientEvents = {
|
|
1912
1925
|
user: User;
|
1913
1926
|
updateReasons: UserUpdateReason[];
|
1914
1927
|
}) => void;
|
1915
|
-
|
1916
|
-
|
1928
|
+
initialized: () => void;
|
1929
|
+
initFailed: ({ error }: {
|
1917
1930
|
error?: ConnectionError;
|
1918
1931
|
}) => void;
|
1919
|
-
connectionStateChanged: (state:
|
1932
|
+
connectionStateChanged: (state: ConnectionState) => void;
|
1920
1933
|
connectionError: (data: ConnectionError) => void;
|
1921
1934
|
};
|
1922
1935
|
/**
|
@@ -1929,7 +1942,7 @@ type ClientEvents = {
|
|
1929
1942
|
* * `'denied'` - client connection is denied because of invalid JWT access
|
1930
1943
|
* token. User must refresh token in order to proceed
|
1931
1944
|
*/
|
1932
|
-
type ConnectionState =
|
1945
|
+
type ConnectionState = "disconnected" | "connecting" | "connected";
|
1933
1946
|
/**
|
1934
1947
|
* State of the client. Possible values are as follows:
|
1935
1948
|
* * `'failed'` - the client failed to initialize
|
@@ -1957,7 +1970,7 @@ interface ClientOptions {
|
|
1957
1970
|
region?: string;
|
1958
1971
|
productId?: string;
|
1959
1972
|
twilsockClient?: TwilsockClient;
|
1960
|
-
transport?:
|
1973
|
+
transport?: TwilsockClient;
|
1961
1974
|
notificationsClient?: NotificationClient;
|
1962
1975
|
syncClient?: SyncClient;
|
1963
1976
|
typingIndicatorTimeoutOverride?: number;
|
@@ -1977,6 +1990,10 @@ interface ClientOptions {
|
|
1977
1990
|
typingUri?: string;
|
1978
1991
|
apiUri?: string;
|
1979
1992
|
}
|
1993
|
+
type ConnectionError = {
|
1994
|
+
terminal: boolean;
|
1995
|
+
message: string;
|
1996
|
+
};
|
1980
1997
|
/**
|
1981
1998
|
* Options for {@link Client.createConversation}.
|
1982
1999
|
*/
|
@@ -2169,16 +2186,20 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2169
2186
|
*/
|
2170
2187
|
static readonly userUpdated = "userUpdated";
|
2171
2188
|
/**
|
2172
|
-
* Fired when the
|
2189
|
+
* Fired when the client has completed initialization successfully.
|
2190
|
+
* @event
|
2191
|
+
*/
|
2192
|
+
static readonly initialized = "initialized";
|
2193
|
+
/**
|
2194
|
+
* Fired when the client initialization failed.
|
2173
2195
|
*
|
2174
2196
|
* Parameters:
|
2175
2197
|
* 1. object `data` - info object provided with the event. It has the
|
2176
|
-
* following
|
2177
|
-
* * {@link State} `state` - the new client state
|
2198
|
+
* following property:
|
2178
2199
|
* * Error? `error` - the initialization error if present
|
2179
2200
|
* @event
|
2180
2201
|
*/
|
2181
|
-
static readonly
|
2202
|
+
static readonly initFailed = "initFailed";
|
2182
2203
|
/**
|
2183
2204
|
* Fired when the connection state of the client has been changed.
|
2184
2205
|
*
|
@@ -2223,7 +2244,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2223
2244
|
/**
|
2224
2245
|
* Client connection state.
|
2225
2246
|
*/
|
2226
|
-
connectionState: ConnectionState;
|
2247
|
+
connectionState: ConnectionState | "unknown";
|
2227
2248
|
/**
|
2228
2249
|
* Promise that resolves on successful initialization.
|
2229
2250
|
*/
|
@@ -2287,26 +2308,6 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2287
2308
|
* initialization was completed.
|
2288
2309
|
*/
|
2289
2310
|
get reachabilityEnabled(): boolean;
|
2290
|
-
/**
|
2291
|
-
* @deprecated Call constructor directly.
|
2292
|
-
*
|
2293
|
-
* Factory method to create a Conversations client instance.
|
2294
|
-
*
|
2295
|
-
* The factory method will automatically trigger connection.
|
2296
|
-
* Do not use it if you need finer-grained control.
|
2297
|
-
*
|
2298
|
-
* Since this method returns an already-initialized client, some of the events
|
2299
|
-
* will be lost because they happen *before* the initialization. It is
|
2300
|
-
* recommended that `client.onWithReplay` is used as opposed to `client.on`
|
2301
|
-
* for subscribing to client events. The `client.onWithReplay` will re-emit
|
2302
|
-
* the most recent value for a given event if it emitted before the
|
2303
|
-
* subscription.
|
2304
|
-
*
|
2305
|
-
* @param token Access token.
|
2306
|
-
* @param options Options to customize the client.
|
2307
|
-
* @returns Returns a fully initialized client.
|
2308
|
-
*/
|
2309
|
-
static create(token: string, options?: ClientOptions | null): Promise<Client>;
|
2310
2311
|
/**
|
2311
2312
|
* Static method for push notification payload parsing. Returns parsed push as
|
2312
2313
|
* a {@link PushNotification} object.
|
@@ -2342,7 +2343,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2342
2343
|
* @param conversationSid Conversation sid
|
2343
2344
|
* @internal
|
2344
2345
|
*/
|
2345
|
-
peekConversationBySid
|
2346
|
+
private peekConversationBySid;
|
2346
2347
|
/**
|
2347
2348
|
* Get a known conversation by its unique identifier name.
|
2348
2349
|
* @param uniqueName The unique identifier name of the conversation.
|
@@ -2442,4 +2443,5 @@ declare class NotificationTypes {
|
|
2442
2443
|
static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
|
2443
2444
|
static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
|
2444
2445
|
}
|
2445
|
-
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,
|
2446
|
+
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, CancellablePromise };
|
2447
|
+
export { JSONValue, JSONObject, JSONArray } from "@twilio/shared";
|