@twilio/conversations 2.0.0-rc.1 → 2.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +3 -3
- package/dist/browser.js +2338 -2672
- package/dist/browser.js.map +1 -1
- package/dist/docs/assets/js/search.js +1 -1
- package/dist/docs/classes/AggregatedDeliveryReceipt.html +22 -6
- package/dist/docs/classes/Client.html +78 -33
- package/dist/docs/classes/Conversation.html +33 -17
- package/dist/docs/classes/DetailedDeliveryReceipt.html +22 -6
- package/dist/docs/classes/Media.html +23 -7
- package/dist/docs/classes/Message.html +23 -7
- package/dist/docs/classes/MessageBuilder.html +3280 -0
- package/dist/docs/classes/Participant.html +23 -7
- package/dist/docs/classes/PushNotification.html +24 -8
- package/dist/docs/classes/RestPaginator.html +28 -9
- package/dist/docs/classes/UnsentMessage.html +3144 -0
- package/dist/docs/classes/User.html +25 -9
- package/dist/docs/index.html +67 -26
- package/dist/docs/interfaces/ClientOptions.html +22 -6
- package/dist/docs/interfaces/ConversationState.html +22 -6
- package/dist/docs/interfaces/CreateConversationOptions.html +22 -6
- package/dist/docs/interfaces/LastMessage.html +22 -6
- package/dist/docs/interfaces/Paginator.html +3243 -0
- package/dist/docs/interfaces/PushNotificationData.html +3168 -0
- package/dist/docs/interfaces/SendEmailOptions.html +22 -6
- package/dist/docs/interfaces/SendMediaOptions.html +22 -6
- package/dist/docs/modules.html +66 -25
- package/dist/lib.d.ts +232 -57
- package/dist/lib.js +2263 -2126
- package/dist/lib.js.map +1 -1
- package/dist/react-native.js +487 -868
- package/dist/react-native.js.map +1 -1
- package/dist/twilio-conversations.js +23616 -23207
- package/dist/twilio-conversations.min.js +14 -2
- package/package.json +5 -4
package/dist/lib.d.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import { EventEmitter } from "events";
|
2
1
|
import { SyncClient } from "twilio-sync";
|
3
2
|
import { Transport, TwilsockClient, InitRegistration } from "twilsock";
|
4
3
|
import { ConnectionState as TwilsockConnectionState } from "twilsock";
|
4
|
+
import { ReplayEventEmitter } from "@twilio/replay-event-emitter";
|
5
5
|
import { ChannelType, Notifications } from "@twilio/notifications";
|
6
6
|
import { Notifications as NotificationClient } from "@twilio/notifications";
|
7
7
|
import { McsClient, MediaCategory, McsMedia } from "@twilio/mcs-client";
|
8
|
+
import { MediaCategory as McsMediaCategory } from "@twilio/mcs-client";
|
8
9
|
interface ConfigurationResponse {
|
9
10
|
options: {
|
10
11
|
consumption_report_interval: string;
|
@@ -104,42 +105,53 @@ declare class CommandExecutor {
|
|
104
105
|
fetchResource<REQ = void, RESP = void>(url: string, requestBody?: REQ): Promise<RESP>;
|
105
106
|
mutateResource<REQ = void, RESP = void>(method: "post" | "delete", url: string, requestBody?: REQ): Promise<RESP>;
|
106
107
|
}
|
108
|
+
type UserEvents = {
|
109
|
+
updated: (data: {
|
110
|
+
user: User;
|
111
|
+
updateReasons: UserUpdateReason[];
|
112
|
+
}) => void;
|
113
|
+
userSubscribed: (user: User) => void;
|
114
|
+
userUnsubscribed: (user: User) => void;
|
115
|
+
};
|
107
116
|
interface UserServices {
|
108
117
|
syncClient: SyncClient;
|
109
118
|
commandExecutor: CommandExecutor;
|
110
119
|
}
|
111
|
-
interface UserLinks {
|
112
|
-
self: string;
|
113
|
-
}
|
114
120
|
/**
|
115
121
|
* The reason for the `updated` event being emitted by a user.
|
116
122
|
*/
|
117
123
|
type UserUpdateReason = "friendlyName" | "attributes" | "reachabilityOnline" | "reachabilityNotifiable";
|
124
|
+
interface UserUpdatedEventArgs {
|
125
|
+
user: User;
|
126
|
+
updateReasons: UserUpdateReason[];
|
127
|
+
}
|
118
128
|
/**
|
119
129
|
* Extended user information.
|
120
130
|
* Note that `isOnline` and `isNotifiable` properties are eligible
|
121
131
|
* for use only if the reachability function is enabled.
|
122
132
|
* You may check if it is enabled by reading the value of {@link Client.reachabilityEnabled}.
|
123
133
|
*/
|
124
|
-
declare class User extends
|
125
|
-
private
|
126
|
-
private
|
134
|
+
declare class User extends ReplayEventEmitter<UserEvents> {
|
135
|
+
private links;
|
136
|
+
private configuration;
|
127
137
|
private readonly services;
|
128
138
|
private entity;
|
129
139
|
private state;
|
130
140
|
private promiseToFetch;
|
131
141
|
private subscribed;
|
142
|
+
private _initializationPromise;
|
143
|
+
private _resolveInitializationPromise;
|
132
144
|
/**
|
133
145
|
* @internal
|
134
146
|
*/
|
135
|
-
constructor(identity: string, entityName: string,
|
147
|
+
constructor(identity: string, entityName: string, configuration: Configuration | null, services: UserServices);
|
136
148
|
/**
|
137
149
|
* Fired when the properties or the reachability status of the message has been updated.
|
138
150
|
*
|
139
151
|
* Parameters:
|
140
152
|
* 1. object `data` - info object provided with the event. It has the following properties:
|
141
|
-
* * {@link User} user - the user in question
|
142
|
-
* * {@link UserUpdateReason}[] updateReasons - array of reasons for the update
|
153
|
+
* * {@link User} `user` - the user in question
|
154
|
+
* * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
|
143
155
|
* @event
|
144
156
|
*/
|
145
157
|
readonly updated = "updated";
|
@@ -186,7 +198,7 @@ declare class User extends EventEmitter {
|
|
186
198
|
*/
|
187
199
|
get isSubscribed(): boolean;
|
188
200
|
// Handles service updates
|
189
|
-
_update(key: string, value: any): void
|
201
|
+
_update(key: string, value: any): Promise<void>;
|
190
202
|
// Fetch reachability info
|
191
203
|
private _updateReachabilityInfo;
|
192
204
|
// Fetch user
|
@@ -207,6 +219,7 @@ declare class User extends EventEmitter {
|
|
207
219
|
* @return A promise of completion.
|
208
220
|
*/
|
209
221
|
unsubscribe(): Promise<void>;
|
222
|
+
_resolveInitialization(configuration: Configuration, identity: string, entityName: string, emitUpdated: boolean): void;
|
210
223
|
}
|
211
224
|
declare class Network {
|
212
225
|
private readonly configuration;
|
@@ -221,22 +234,29 @@ declare class Network {
|
|
221
234
|
private executeWithRetry;
|
222
235
|
get(url: string): Promise<any>;
|
223
236
|
}
|
237
|
+
type UsersEvents = {
|
238
|
+
userUpdated: (data: {
|
239
|
+
user: User;
|
240
|
+
updateReasons: UserUpdateReason[];
|
241
|
+
}) => void;
|
242
|
+
userSubscribed: (user: User) => void;
|
243
|
+
userUnsubscribed: (user: User) => void;
|
244
|
+
};
|
224
245
|
interface UsersServices {
|
225
246
|
network: Network;
|
226
247
|
syncClient: SyncClient;
|
227
248
|
commandExecutor: CommandExecutor;
|
228
249
|
}
|
229
250
|
/**
|
230
|
-
*
|
231
|
-
* @fires Users#userUpdated
|
251
|
+
* Container for known users
|
232
252
|
*/
|
233
|
-
declare class Users extends
|
253
|
+
declare class Users extends ReplayEventEmitter<UsersEvents> {
|
234
254
|
private readonly configuration;
|
235
255
|
private readonly services;
|
236
256
|
private subscribedUsers;
|
237
257
|
private fifoStack;
|
238
258
|
readonly myself: User;
|
239
|
-
constructor(configuration: Configuration, services: UsersServices);
|
259
|
+
constructor(myself: User, configuration: Configuration, services: UsersServices);
|
240
260
|
private handleUnsubscribeUser;
|
241
261
|
private handleSubscribeUser;
|
242
262
|
/**
|
@@ -254,6 +274,14 @@ declare class Users extends EventEmitter {
|
|
254
274
|
*/
|
255
275
|
private getSyncUniqueName;
|
256
276
|
}
|
277
|
+
type ParticipantEvents = {
|
278
|
+
typingEnded: (participant: Participant) => void;
|
279
|
+
typingStarted: (participant: Participant) => void;
|
280
|
+
updated: (data: {
|
281
|
+
participant: Participant;
|
282
|
+
updateReasons: ParticipantUpdateReason[];
|
283
|
+
}) => void;
|
284
|
+
};
|
257
285
|
interface ParticipantDescriptor {
|
258
286
|
attributes?: Object;
|
259
287
|
dateCreated: any;
|
@@ -277,13 +305,17 @@ interface ParticipantLinks {
|
|
277
305
|
*/
|
278
306
|
type ParticipantUpdateReason = "attributes" | "dateCreated" | "dateUpdated" | "roleSid" | "lastReadMessageIndex" | "lastReadTimestamp";
|
279
307
|
/**
|
280
|
-
*
|
308
|
+
* Type of a participant.
|
281
309
|
*/
|
282
310
|
type ParticipantType = "chat" | "sms" | "whatsapp";
|
311
|
+
interface ParticipantUpdatedEventArgs {
|
312
|
+
participant: Participant;
|
313
|
+
updateReasons: ParticipantUpdateReason[];
|
314
|
+
}
|
283
315
|
/**
|
284
316
|
* A participant represents a remote client in a conversation.
|
285
317
|
*/
|
286
|
-
declare class Participant extends
|
318
|
+
declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
|
287
319
|
private state;
|
288
320
|
private readonly links;
|
289
321
|
private readonly services;
|
@@ -390,9 +422,16 @@ declare class Participant extends EventEmitter {
|
|
390
422
|
*/
|
391
423
|
updateAttributes(attributes: any): Promise<Participant>;
|
392
424
|
}
|
425
|
+
/**
|
426
|
+
* Category of media. Possible values are as follows:
|
427
|
+
* * `'media'`
|
428
|
+
* * `'body'`
|
429
|
+
* * `'history'`
|
430
|
+
*/
|
431
|
+
type MediaCategory$0 = McsMediaCategory;
|
393
432
|
interface MediaState {
|
394
433
|
sid: string;
|
395
|
-
category: MediaCategory;
|
434
|
+
category: MediaCategory$0;
|
396
435
|
filename?: string;
|
397
436
|
contentType: string;
|
398
437
|
size: number;
|
@@ -428,9 +467,9 @@ declare class Media {
|
|
428
467
|
*/
|
429
468
|
get size(): number;
|
430
469
|
/**
|
431
|
-
* Media category, can be one of the {MediaCategory} values.
|
470
|
+
* Media category, can be one of the {@link MediaCategory} values.
|
432
471
|
*/
|
433
|
-
get category(): MediaCategory;
|
472
|
+
get category(): MediaCategory$0;
|
434
473
|
/**
|
435
474
|
* Returns the direct content URL for the media.
|
436
475
|
*
|
@@ -593,6 +632,12 @@ declare class DetailedDeliveryReceipt {
|
|
593
632
|
*/
|
594
633
|
constructor(descriptor: DetailedDeliveryReceiptDescriptor);
|
595
634
|
}
|
635
|
+
type MessageEvents = {
|
636
|
+
updated: (data: {
|
637
|
+
message: Message;
|
638
|
+
updateReasons: MessageUpdateReason[];
|
639
|
+
}) => void;
|
640
|
+
};
|
596
641
|
interface MessageServices {
|
597
642
|
mcsClient: McsClient;
|
598
643
|
network: Network;
|
@@ -608,13 +653,17 @@ interface MessageLinks {
|
|
608
653
|
*/
|
609
654
|
type MessageUpdateReason = "body" | "lastUpdatedBy" | "dateCreated" | "dateUpdated" | "attributes" | "author" | "deliveryReceipt" | "subject";
|
610
655
|
/**
|
611
|
-
*
|
656
|
+
* Type of a message.
|
612
657
|
*/
|
613
658
|
type MessageType = "text" | "media";
|
659
|
+
interface MessageUpdatedEventArgs {
|
660
|
+
message: Message;
|
661
|
+
updateReasons: MessageUpdateReason[];
|
662
|
+
}
|
614
663
|
/**
|
615
664
|
* A message in a conversation.
|
616
665
|
*/
|
617
|
-
declare class Message extends
|
666
|
+
declare class Message extends ReplayEventEmitter<MessageEvents> {
|
618
667
|
/**
|
619
668
|
* Conversation that the message is in.
|
620
669
|
*/
|
@@ -739,29 +788,30 @@ declare class Message extends EventEmitter {
|
|
739
788
|
private _getDetailedDeliveryReceiptsPaginator;
|
740
789
|
}
|
741
790
|
/**
|
742
|
-
* Pagination helper
|
743
|
-
*
|
744
|
-
* @interface
|
745
|
-
* @property {Array} items Elements on current page
|
746
|
-
* @property {boolean} hasNextPage Indicates the existence of next page
|
747
|
-
* @property {boolean} hasPrevPage Indicates the existence of previous page
|
748
|
-
* @function {Promise<Paginator>} nextPage() Request next page. Does not modify existing object
|
749
|
-
* @function {Promise<Paginator>} prevPage() Request previous page. Does not modify existing object
|
791
|
+
* Pagination helper interface.
|
792
|
+
* @typeParam T The item type.
|
750
793
|
*/
|
751
794
|
interface Paginator<T> {
|
795
|
+
/**
|
796
|
+
* Indicates the existence of the next page.
|
797
|
+
*/
|
752
798
|
hasNextPage: boolean;
|
799
|
+
/**
|
800
|
+
* Indicates the existence of the previous page.
|
801
|
+
*/
|
753
802
|
hasPrevPage: boolean;
|
754
|
-
|
803
|
+
/**
|
804
|
+
* Array of elements of type T on the current page.
|
805
|
+
*/
|
806
|
+
items: T[];
|
755
807
|
/**
|
756
808
|
* Request next page.
|
757
|
-
* Does not modify existing object.
|
758
|
-
* @return {Promise<Paginator<T>>}
|
809
|
+
* Does not modify the existing object.
|
759
810
|
*/
|
760
811
|
nextPage(): Promise<Paginator<T>>;
|
761
812
|
/**
|
762
813
|
* Request previous page.
|
763
|
-
* Does not modify existing object.
|
764
|
-
* @return {Promise<Paginator<T>>}
|
814
|
+
* Does not modify the existing object.
|
765
815
|
*/
|
766
816
|
prevPage(): Promise<Paginator<T>>;
|
767
817
|
}
|
@@ -810,30 +860,94 @@ declare class TypingIndicator {
|
|
810
860
|
send(conversationSid: string): Promise<void>;
|
811
861
|
private _send;
|
812
862
|
}
|
863
|
+
/**
|
864
|
+
* An unsent message. Returned from {@link MessageBuilder.build}.
|
865
|
+
*/
|
813
866
|
declare class UnsentMessage {
|
814
867
|
private messagesEntity;
|
815
868
|
text?: string;
|
816
869
|
attributes: any;
|
817
870
|
mediaContent: [MediaCategory, FormData | SendMediaOptions][];
|
818
871
|
emailOptions?: SendEmailOptions;
|
872
|
+
/**
|
873
|
+
* @internal
|
874
|
+
*/
|
819
875
|
constructor(messagesEntity: any);
|
820
876
|
/**
|
821
877
|
* Send the prepared message to the conversation.
|
822
|
-
* @returns
|
878
|
+
* @returns Index of the new message in the conversation.
|
823
879
|
*/
|
824
880
|
send(): Promise<number>;
|
825
881
|
}
|
882
|
+
/**
|
883
|
+
* Message builder. Allows the message to be built and sent via method chaining.
|
884
|
+
*
|
885
|
+
* Example:
|
886
|
+
*
|
887
|
+
* ```ts
|
888
|
+
* await testConversation.prepareMessage()
|
889
|
+
* .setBody('Hello!')
|
890
|
+
* .setAttributes({foo: 'bar'})
|
891
|
+
* .addMedia(media1)
|
892
|
+
* .addMedia(media2)
|
893
|
+
* .build()
|
894
|
+
* .send();
|
895
|
+
* ```
|
896
|
+
*/
|
826
897
|
declare class MessageBuilder {
|
827
898
|
private readonly limits;
|
828
899
|
private readonly message;
|
900
|
+
/**
|
901
|
+
* @internal
|
902
|
+
*/
|
829
903
|
constructor(limits: Limits, messagesEntity: any);
|
904
|
+
/**
|
905
|
+
* Sets the message body.
|
906
|
+
* @param text Contents of the body.
|
907
|
+
*/
|
830
908
|
setBody(text: string): MessageBuilder;
|
909
|
+
/**
|
910
|
+
* Sets the message subject.
|
911
|
+
* @param subject Contents of the subject.
|
912
|
+
*/
|
831
913
|
setSubject(subject: string): MessageBuilder;
|
914
|
+
/**
|
915
|
+
* Sets the message attributes.
|
916
|
+
* @param attributes Message attributes.
|
917
|
+
*/
|
832
918
|
setAttributes(attributes: any): MessageBuilder;
|
919
|
+
/**
|
920
|
+
* Adds media to the message.
|
921
|
+
* @param payload Media to add.
|
922
|
+
*/
|
833
923
|
addMedia(payload: FormData | SendMediaOptions): MessageBuilder;
|
924
|
+
/**
|
925
|
+
* Builds the message, making it ready to be sent.
|
926
|
+
*/
|
834
927
|
build(): UnsentMessage;
|
835
928
|
private getPayloadContentType;
|
836
929
|
}
|
930
|
+
type ConversationEvents = {
|
931
|
+
participantJoined: (participant: Participant) => void;
|
932
|
+
participantLeft: (participant: Participant) => void;
|
933
|
+
participantUpdated: (data: {
|
934
|
+
participant: Participant;
|
935
|
+
updateReasons: ParticipantUpdateReason[];
|
936
|
+
}) => void;
|
937
|
+
messageAdded: (message: Message) => void;
|
938
|
+
messageRemoved: (message: Message) => void;
|
939
|
+
messageUpdated: (data: {
|
940
|
+
message: Message;
|
941
|
+
updateReasons: MessageUpdateReason[];
|
942
|
+
}) => void;
|
943
|
+
typingEnded: (participant: Participant) => void;
|
944
|
+
typingStarted: (participant: Participant) => void;
|
945
|
+
updated: (data: {
|
946
|
+
conversation: Conversation;
|
947
|
+
updateReasons: ConversationUpdateReason[];
|
948
|
+
}) => void;
|
949
|
+
removed: (conversation: Conversation) => void;
|
950
|
+
};
|
837
951
|
interface ConversationServices {
|
838
952
|
users: Users;
|
839
953
|
typingIndicator: TypingIndicator;
|
@@ -936,7 +1050,7 @@ interface LastMessage {
|
|
936
1050
|
/**
|
937
1051
|
* A conversation represents communication between multiple Conversations clients
|
938
1052
|
*/
|
939
|
-
declare class Conversation extends
|
1053
|
+
declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
940
1054
|
/**
|
941
1055
|
* Unique system identifier of the conversation.
|
942
1056
|
*/
|
@@ -1141,7 +1255,7 @@ declare class Conversation extends EventEmitter {
|
|
1141
1255
|
* @param address User address of the participant.
|
1142
1256
|
* @param attributes Attributes to be attached to the participant.
|
1143
1257
|
*/
|
1144
|
-
addNonChatParticipant(proxyAddress: string, address: string, attributes?:
|
1258
|
+
addNonChatParticipant(proxyAddress: string, address: string, attributes?: any): Promise<void>;
|
1145
1259
|
/**
|
1146
1260
|
* Advance the conversation's last read message index to the current read horizon.
|
1147
1261
|
* Rejects if the user is not a participant of the conversation.
|
@@ -1228,14 +1342,15 @@ declare class Conversation extends EventEmitter {
|
|
1228
1342
|
*/
|
1229
1343
|
leave(): Promise<Conversation>;
|
1230
1344
|
/**
|
1231
|
-
* Remove a participant from the conversation. When a string is passed as the
|
1232
|
-
*
|
1345
|
+
* Remove a participant from the conversation. When a string is passed as the
|
1346
|
+
* argument, it will assume that the string is an identity or SID.
|
1347
|
+
* @param participant Identity, SID or the participant object to remove.
|
1233
1348
|
*/
|
1234
1349
|
removeParticipant(participant: string | Participant): Promise<void>;
|
1235
1350
|
/**
|
1236
1351
|
* Send a message to the conversation.
|
1237
1352
|
* @param message Message body for the text message,
|
1238
|
-
* `FormData` or {@link
|
1353
|
+
* `FormData` or {@link SendMediaOptions} for media content. Sending FormData is supported only with the browser engine.
|
1239
1354
|
* @param messageAttributes Attributes for the message.
|
1240
1355
|
* @param emailOptions Email options for the message.
|
1241
1356
|
* @return Index of the new message.
|
@@ -1244,7 +1359,6 @@ declare class Conversation extends EventEmitter {
|
|
1244
1359
|
/**
|
1245
1360
|
* New interface to prepare for sending a message.
|
1246
1361
|
* Use instead of `sendMessage`.
|
1247
|
-
* @return {MessageBuilder} [description]
|
1248
1362
|
*/
|
1249
1363
|
prepareMessage(): MessageBuilder;
|
1250
1364
|
/**
|
@@ -1276,7 +1390,7 @@ declare class Conversation extends EventEmitter {
|
|
1276
1390
|
* Update the friendly name of the conversation.
|
1277
1391
|
* @param friendlyName New friendly name.
|
1278
1392
|
*/
|
1279
|
-
updateFriendlyName(friendlyName: string
|
1393
|
+
updateFriendlyName(friendlyName: string): Promise<Conversation>;
|
1280
1394
|
/**
|
1281
1395
|
* Set the last read message index to the current read horizon.
|
1282
1396
|
* @param index Message index to set as last read.
|
@@ -1342,7 +1456,7 @@ declare class PushNotification {
|
|
1342
1456
|
*/
|
1343
1457
|
readonly badge: number;
|
1344
1458
|
/**
|
1345
|
-
* Notification action (`click_action` in FCM
|
1459
|
+
* Notification action (`click_action` in FCM terms and `category` in APN terms).
|
1346
1460
|
*/
|
1347
1461
|
readonly action: string;
|
1348
1462
|
/**
|
@@ -1358,6 +1472,47 @@ declare class PushNotification {
|
|
1358
1472
|
*/
|
1359
1473
|
constructor(data: PushNotificationDescriptor);
|
1360
1474
|
}
|
1475
|
+
type ClientEvents = {
|
1476
|
+
conversationAdded: (conversation: Conversation) => void;
|
1477
|
+
conversationJoined: (conversation: Conversation) => void;
|
1478
|
+
conversationLeft: (conversation: Conversation) => void;
|
1479
|
+
conversationRemoved: (conversation: Conversation) => void;
|
1480
|
+
conversationUpdated: (data: {
|
1481
|
+
conversation: Conversation;
|
1482
|
+
updateReasons: ConversationUpdateReason[];
|
1483
|
+
}) => void;
|
1484
|
+
participantJoined: (participant: Participant) => void;
|
1485
|
+
participantLeft: (participant: Participant) => void;
|
1486
|
+
participantUpdated: (data: {
|
1487
|
+
participant: Participant;
|
1488
|
+
updateReasons: ParticipantUpdateReason[];
|
1489
|
+
}) => void;
|
1490
|
+
messageAdded: (message: Message) => void;
|
1491
|
+
messageRemoved: (message: Message) => void;
|
1492
|
+
messageUpdated: (data: {
|
1493
|
+
message: Message;
|
1494
|
+
updateReasons: MessageUpdateReason[];
|
1495
|
+
}) => void;
|
1496
|
+
tokenAboutToExpire: (ttl: number) => void;
|
1497
|
+
tokenExpired: () => void;
|
1498
|
+
typingEnded: (participant: Participant) => void;
|
1499
|
+
typingStarted: (participant: Participant) => void;
|
1500
|
+
pushNotification: (pushNotification: PushNotification) => void;
|
1501
|
+
userSubscribed: (user: User) => void;
|
1502
|
+
userUnsubscribed: (user: User) => void;
|
1503
|
+
userUpdated: (data: {
|
1504
|
+
user: User;
|
1505
|
+
updateReasons: UserUpdateReason[];
|
1506
|
+
}) => void;
|
1507
|
+
stateChanged: (state: State) => void;
|
1508
|
+
connectionStateChanged: (state: TwilsockConnectionState) => void;
|
1509
|
+
connectionError: (data: {
|
1510
|
+
terminal: boolean;
|
1511
|
+
message: string;
|
1512
|
+
httpStatusCode?: number;
|
1513
|
+
errorCode?: number;
|
1514
|
+
}) => void;
|
1515
|
+
};
|
1361
1516
|
/**
|
1362
1517
|
* Connection state of the client. Possible values are as follows:
|
1363
1518
|
* * `'connecting'` - client is offline and connection attempt is in process
|
@@ -1367,6 +1522,12 @@ declare class PushNotification {
|
|
1367
1522
|
* * `'denied'` - client connection is denied because of invalid JWT access token. User must refresh token in order to proceed
|
1368
1523
|
*/
|
1369
1524
|
type ConnectionState = TwilsockConnectionState;
|
1525
|
+
/**
|
1526
|
+
* State of the client. Possible values are as follows:
|
1527
|
+
* * `'failed'` - the client failed to initialize
|
1528
|
+
* * `'initialized'` - the client successfully initialized
|
1529
|
+
*/
|
1530
|
+
type State = "failed" | "initialized";
|
1370
1531
|
/**
|
1371
1532
|
* Notifications channel type. Possible values are as follows:
|
1372
1533
|
* * `'fcm'`
|
@@ -1423,7 +1584,7 @@ interface CreateConversationOptions {
|
|
1423
1584
|
/**
|
1424
1585
|
* A client is the starting point to the Twilio Conversations functionality.
|
1425
1586
|
*/
|
1426
|
-
declare class Client extends
|
1587
|
+
declare class Client extends ReplayEventEmitter<ClientEvents> {
|
1427
1588
|
/**
|
1428
1589
|
* Client connection state.
|
1429
1590
|
*/
|
@@ -1437,6 +1598,7 @@ declare class Client extends EventEmitter {
|
|
1437
1598
|
private conversations;
|
1438
1599
|
private readonly options;
|
1439
1600
|
private services;
|
1601
|
+
private readonly _myself;
|
1440
1602
|
/**
|
1441
1603
|
* Current version of the Conversations client.
|
1442
1604
|
*/
|
@@ -1493,7 +1655,7 @@ declare class Client extends EventEmitter {
|
|
1493
1655
|
static readonly conversationRemoved = "conversationRemoved";
|
1494
1656
|
/**
|
1495
1657
|
* Fired when the attributes or the metadata of a conversation have been updated.
|
1496
|
-
* During conversation's
|
1658
|
+
* During conversation's creation and initialization, this event might be fired multiple times
|
1497
1659
|
* for same joined or created conversation as new data is arriving from different sources.
|
1498
1660
|
*
|
1499
1661
|
* Parameters:
|
@@ -1503,14 +1665,6 @@ declare class Client extends EventEmitter {
|
|
1503
1665
|
* @event
|
1504
1666
|
*/
|
1505
1667
|
static readonly conversationUpdated = "conversationUpdated";
|
1506
|
-
/**
|
1507
|
-
* Fired when the connection state of the client has been changed.
|
1508
|
-
*
|
1509
|
-
* Parameters:
|
1510
|
-
* 1. {@link Conversation} `conversation` - the conversation in question
|
1511
|
-
* @event
|
1512
|
-
*/
|
1513
|
-
static readonly conversationStateChanged = "connectionStateChanged";
|
1514
1668
|
/**
|
1515
1669
|
* Fired when a participant has joined a conversation.
|
1516
1670
|
*
|
@@ -1565,6 +1719,8 @@ declare class Client extends EventEmitter {
|
|
1565
1719
|
static readonly messageUpdated = "messageUpdated";
|
1566
1720
|
/**
|
1567
1721
|
* Fired when the token is about to expire and needs to be updated.
|
1722
|
+
* * Parameters:
|
1723
|
+
* 1. number `message` - token's time to live
|
1568
1724
|
* @event
|
1569
1725
|
*/
|
1570
1726
|
static readonly tokenAboutToExpire = "tokenAboutToExpire";
|
@@ -1623,6 +1779,22 @@ declare class Client extends EventEmitter {
|
|
1623
1779
|
* @event
|
1624
1780
|
*/
|
1625
1781
|
static readonly userUpdated = "userUpdated";
|
1782
|
+
/**
|
1783
|
+
* Fired when the state of the client has been changed.
|
1784
|
+
*
|
1785
|
+
* Parameters:
|
1786
|
+
* 1. {@link State} `state` - the new client state
|
1787
|
+
* @event
|
1788
|
+
*/
|
1789
|
+
static readonly stateChanged = "stateChanged";
|
1790
|
+
/**
|
1791
|
+
* Fired when the connection state of the client has been changed.
|
1792
|
+
*
|
1793
|
+
* Paremeters:
|
1794
|
+
* 1. {@link ConnectionState} `state` - the new connection state
|
1795
|
+
* @event
|
1796
|
+
*/
|
1797
|
+
static readonly connectionStateChanged = "connectionStateChanged";
|
1626
1798
|
/**
|
1627
1799
|
* Fired when the connection is interrupted for an unexpected reason.
|
1628
1800
|
*
|
@@ -1649,11 +1821,14 @@ declare class Client extends EventEmitter {
|
|
1649
1821
|
*/
|
1650
1822
|
static create(token: string, options?: ClientOptions): Promise<Client>;
|
1651
1823
|
/**
|
1652
|
-
* Information of the logged-in user.
|
1824
|
+
* Information of the logged-in user. Before client initialization, returns an
|
1825
|
+
* uninitialized user. Will trigger a {@link Client.userUpdated} event after
|
1826
|
+
* initialization.
|
1653
1827
|
*/
|
1654
1828
|
get user(): User;
|
1655
1829
|
/**
|
1656
|
-
* Client reachability state.
|
1830
|
+
* Client reachability state. Throws if accessed before the client
|
1831
|
+
* initialization was completed.
|
1657
1832
|
*/
|
1658
1833
|
get reachabilityEnabled(): boolean;
|
1659
1834
|
get token(): string;
|
@@ -1766,4 +1941,4 @@ declare class RestPaginator<T> implements Paginator<T> {
|
|
1766
1941
|
*/
|
1767
1942
|
prevPage(): Promise<RestPaginator<T>>;
|
1768
1943
|
}
|
1769
|
-
export {
|
1944
|
+
export { Conversation, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, MediaCategory$0 as MediaCategory, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions };
|