@twilio/conversations 1.3.0-rc7 → 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 +201 -0
- package/README.md +5 -5
- package/dist/browser.js +7866 -0
- package/dist/browser.js.map +1 -0
- package/dist/docs/assets/css/main.css +2660 -0
- package/dist/docs/assets/images/icons.png +0 -0
- package/dist/docs/assets/images/icons@2x.png +0 -0
- package/dist/docs/assets/images/widgets.png +0 -0
- package/dist/docs/assets/images/widgets@2x.png +0 -0
- package/dist/docs/assets/js/main.js +248 -0
- package/dist/docs/assets/js/search.js +1 -0
- package/dist/docs/classes/AggregatedDeliveryReceipt.html +3286 -0
- package/dist/docs/classes/Client.html +4181 -0
- package/dist/docs/classes/Conversation.html +4397 -0
- package/dist/docs/classes/DetailedDeliveryReceipt.html +3265 -0
- package/dist/docs/classes/Media.html +3295 -0
- package/dist/docs/classes/Message.html +3713 -0
- package/dist/docs/classes/MessageBuilder.html +3280 -0
- package/dist/docs/classes/Participant.html +3517 -0
- package/dist/docs/classes/PushNotification.html +3232 -0
- package/dist/docs/classes/RestPaginator.html +3262 -0
- package/dist/docs/classes/UnsentMessage.html +3144 -0
- package/dist/docs/classes/User.html +3451 -0
- package/dist/docs/index.html +3387 -212
- package/dist/docs/interfaces/ClientOptions.html +3136 -0
- package/dist/docs/interfaces/ConversationState.html +3152 -0
- package/dist/docs/interfaces/CreateConversationOptions.html +3168 -0
- package/dist/docs/interfaces/LastMessage.html +3152 -0
- package/dist/docs/interfaces/Paginator.html +3243 -0
- package/dist/docs/interfaces/PushNotificationData.html +3168 -0
- package/dist/docs/interfaces/SendEmailOptions.html +3136 -0
- package/dist/docs/interfaces/SendMediaOptions.html +3169 -0
- package/dist/docs/modules.html +3418 -0
- package/dist/lib.d.ts +1944 -0
- package/dist/lib.js +7866 -0
- package/dist/lib.js.map +1 -0
- package/dist/post-install.js +29 -0
- package/dist/react-native.js +4031 -0
- package/dist/react-native.js.map +1 -0
- package/dist/twilio-conversations.js +40905 -0
- package/dist/twilio-conversations.min.js +156 -0
- package/package.json +59 -48
- package/.circleci/config.yml +0 -650
- package/.deepsource.toml +0 -6
- package/.env.example +0 -13
- package/browser/aggregateddeliveryreceipt.js +0 -152
- package/browser/client.js +0 -991
- package/browser/configuration.js +0 -80
- package/browser/conversation.js +0 -1826
- package/browser/data/conversations.js +0 -665
- package/browser/data/messages.js +0 -522
- package/browser/data/participants.js +0 -411
- package/browser/data/users.js +0 -281
- package/browser/detaileddeliveryreceipt.js +0 -44
- package/browser/index.js +0 -4
- package/browser/interfaces/limits.js +0 -3
- package/browser/interfaces/notificationtypes.js +0 -21
- package/browser/interfaces/paginator.js +0 -53
- package/browser/interfaces/responsecodes.js +0 -20
- package/browser/interfaces/transport.js +0 -3
- package/browser/logger.js +0 -141
- package/browser/media.js +0 -198
- package/browser/message.js +0 -685
- package/browser/participant.js +0 -415
- package/browser/pushnotification.js +0 -49
- package/browser/restpaginator.js +0 -74
- package/browser/services/network.js +0 -223
- package/browser/services/readhorizon.js +0 -181
- package/browser/services/typingindicator.js +0 -142
- package/browser/session.js +0 -505
- package/browser/sessionerror.js +0 -93
- package/browser/sri.json +0 -1
- package/browser/synclist.js +0 -90
- package/browser/synclistdescriptor.js +0 -29
- package/browser/syncpaginator.js +0 -63
- package/browser/user.js +0 -431
- package/browser/util/deferred.js +0 -56
- package/browser/util/index.js +0 -108
- package/dist/@twilio/conversations.js +0 -35565
- package/dist/@twilio/conversations.min.js +0 -204
- package/dist/docs/AggregatedDeliveryReceipt.html +0 -948
- package/dist/docs/Client.html +0 -5075
- package/dist/docs/Conversation.html +0 -6018
- package/dist/docs/DetailedDeliveryReceipt.html +0 -641
- package/dist/docs/Media.html +0 -694
- package/dist/docs/Message.html +0 -1934
- package/dist/docs/Paginator.html +0 -605
- package/dist/docs/Participant.html +0 -1510
- package/dist/docs/PushNotification.html +0 -836
- package/dist/docs/SessionError.html +0 -379
- package/dist/docs/User.html +0 -1315
- package/dist/docs/classes.list.html +0 -4431
- package/dist/docs/fonts/glyphicons-halflings-regular.eot +0 -0
- package/dist/docs/fonts/glyphicons-halflings-regular.svg +0 -288
- package/dist/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/dist/docs/fonts/glyphicons-halflings-regular.woff +0 -0
- package/dist/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/dist/docs/img/glyphicons-halflings-white.png +0 -0
- package/dist/docs/img/glyphicons-halflings.png +0 -0
- package/dist/docs/quicksearch.html +0 -31
- package/dist/docs/scripts/docstrap.lib.js +0 -11
- package/dist/docs/scripts/fulltext-search-ui.js +0 -89
- package/dist/docs/scripts/fulltext-search.js +0 -36
- package/dist/docs/scripts/lunr.min.js +0 -6
- package/dist/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/dist/docs/scripts/prettify/jquery.min.js +0 -6
- package/dist/docs/scripts/prettify/lang-css.js +0 -21
- package/dist/docs/scripts/prettify/prettify.js +0 -496
- package/dist/docs/scripts/sunlight.js +0 -1157
- package/dist/docs/scripts/toc.js +0 -203
- package/dist/docs/styles/darkstrap.css +0 -960
- package/dist/docs/styles/prettify-tomorrow.css +0 -132
- package/dist/docs/styles/site.cerulean.css +0 -7008
- package/dist/docs/styles/site.cosmo.css +0 -7061
- package/dist/docs/styles/site.cyborg.css +0 -7048
- package/dist/docs/styles/site.darkly.css +0 -7171
- package/dist/docs/styles/site.darkstrap.css +0 -5638
- package/dist/docs/styles/site.dibs-bootstrap.css +0 -5899
- package/dist/docs/styles/site.flatly.css +0 -7147
- package/dist/docs/styles/site.journal.css +0 -6973
- package/dist/docs/styles/site.lumen.css +0 -7298
- package/dist/docs/styles/site.paper.css +0 -7623
- package/dist/docs/styles/site.readable.css +0 -6997
- package/dist/docs/styles/site.sandstone.css +0 -7035
- package/dist/docs/styles/site.simplex.css +0 -7023
- package/dist/docs/styles/site.slate.css +0 -7343
- package/dist/docs/styles/site.spacelab.css +0 -7055
- package/dist/docs/styles/site.superhero.css +0 -7131
- package/dist/docs/styles/site.united.css +0 -6895
- package/dist/docs/styles/site.yeti.css +0 -7195
- package/dist/docs/styles/sunlight.dark.css +0 -345
- package/dist/docs/styles/sunlight.default.css +0 -344
- package/dist/sri.json +0 -1
- package/lib/aggregateddeliveryreceipt.d.ts +0 -98
- package/lib/aggregateddeliveryreceipt.js +0 -112
- package/lib/client.d.ts +0 -317
- package/lib/client.js +0 -633
- package/lib/configuration.d.ts +0 -21
- package/lib/configuration.js +0 -41
- package/lib/conversation.d.ts +0 -460
- package/lib/conversation.js +0 -940
- package/lib/data/conversations.d.ts +0 -57
- package/lib/data/conversations.js +0 -318
- package/lib/data/messages.d.ts +0 -75
- package/lib/data/messages.js +0 -208
- package/lib/data/participants.d.ts +0 -94
- package/lib/data/participants.js +0 -204
- package/lib/data/users.d.ts +0 -42
- package/lib/data/users.js +0 -113
- package/lib/detaileddeliveryreceipt.d.ts +0 -45
- package/lib/detaileddeliveryreceipt.js +0 -34
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -3
- package/lib/interfaces/limits.d.ts +0 -8
- package/lib/interfaces/limits.js +0 -2
- package/lib/interfaces/notificationtypes.d.ts +0 -8
- package/lib/interfaces/notificationtypes.js +0 -11
- package/lib/interfaces/paginator.d.ts +0 -52
- package/lib/interfaces/paginator.js +0 -28
- package/lib/interfaces/responsecodes.d.ts +0 -8
- package/lib/interfaces/responsecodes.js +0 -10
- package/lib/interfaces/transport.d.ts +0 -13
- package/lib/interfaces/transport.js +0 -2
- package/lib/logger.d.ts +0 -18
- package/lib/logger.js +0 -35
- package/lib/media.d.ts +0 -52
- package/lib/media.js +0 -69
- package/lib/message.d.ts +0 -136
- package/lib/message.js +0 -305
- package/lib/participant.d.ts +0 -142
- package/lib/participant.js +0 -219
- package/lib/pushnotification.d.ts +0 -48
- package/lib/pushnotification.js +0 -39
- package/lib/restpaginator.d.ts +0 -19
- package/lib/restpaginator.js +0 -36
- package/lib/services/network.d.ts +0 -22
- package/lib/services/network.js +0 -87
- package/lib/services/readhorizon.d.ts +0 -28
- package/lib/services/readhorizon.js +0 -112
- package/lib/services/typingindicator.d.ts +0 -50
- package/lib/services/typingindicator.js +0 -102
- package/lib/session.d.ts +0 -63
- package/lib/session.js +0 -213
- package/lib/sessionerror.d.ts +0 -12
- package/lib/sessionerror.js +0 -24
- package/lib/sri.json +0 -1
- package/lib/synclist.d.ts +0 -24
- package/lib/synclist.js +0 -28
- package/lib/synclistdescriptor.d.ts +0 -27
- package/lib/synclistdescriptor.js +0 -19
- package/lib/syncpaginator.d.ts +0 -22
- package/lib/syncpaginator.js +0 -37
- package/lib/user.d.ts +0 -98
- package/lib/user.js +0 -219
- package/lib/util/deferred.d.ts +0 -12
- package/lib/util/deferred.js +0 -22
- package/lib/util/index.d.ts +0 -28
- package/lib/util/index.js +0 -82
- package/tools/rtd-sdk-cdn-pin/.gitrepo +0 -12
- package/tools/rtd-sdk-cdn-pin/README.md +0 -54
- package/tools/rtd-sdk-cdn-pin/bintray-settings.xml.template +0 -16
- package/tools/rtd-sdk-cdn-pin/cdn-common/cdn-prepare.sh +0 -67
- package/tools/rtd-sdk-cdn-pin/cdn-pin-latest.sh +0 -19
- package/tools/rtd-sdk-cdn-pin/cdn-pin.sh +0 -19
- package/tools/rtd-sdk-cdn-pin/cdn-upload.sh +0 -13
- package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-bintray-android.sh +0 -34
- package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-npm.sh +0 -18
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-android.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-js.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-android.sh +0 -6
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-js.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-android.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-js.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch-artifact.sh +0 -26
- package/tools/sdk-release-tool/.gitrepo +0 -12
- package/tools/sdk-release-tool/Makefile +0 -49
- package/tools/sdk-release-tool/README.md +0 -275
- package/tools/sdk-release-tool/delete +0 -3
- package/tools/sdk-release-tool/download +0 -3
- package/tools/sdk-release-tool/get-cors +0 -3
- package/tools/sdk-release-tool/list +0 -3
- package/tools/sdk-release-tool/pin +0 -3
- package/tools/sdk-release-tool/pin-latest +0 -3
- package/tools/sdk-release-tool/requirements.txt +0 -4
- package/tools/sdk-release-tool/sdk-release-tool +0 -3
- package/tools/sdk-release-tool/sdk_release_tools/__init__.py +0 -0
- package/tools/sdk-release-tool/sdk_release_tools/__main__.py +0 -110
- package/tools/sdk-release-tool/sdk_release_tools/aws.py +0 -70
- package/tools/sdk-release-tool/sdk_release_tools/cli.py +0 -181
- package/tools/sdk-release-tool/sdk_release_tools/log.py +0 -24
- package/tools/sdk-release-tool/sdk_release_tools/ops.py +0 -295
- package/tools/sdk-release-tool/sdk_release_tools/rpm.py +0 -28
- package/tools/sdk-release-tool/sdk_release_tools/util.py +0 -186
- package/tools/sdk-release-tool/sdk_release_tools/versions.py +0 -362
- package/tools/sdk-release-tool/signal-sdk-js.json +0 -28
- package/tools/sdk-release-tool/tests/test_versions.py +0 -94
- package/tools/sdk-release-tool/twilio-accessmanager-android.json +0 -19
- package/tools/sdk-release-tool/twilio-accessmanager-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-auth-ios.json +0 -29
- package/tools/sdk-release-tool/twilio-authenticator-ios.json +0 -29
- package/tools/sdk-release-tool/twilio-chat-android-2.json +0 -19
- package/tools/sdk-release-tool/twilio-chat-android.json +0 -22
- package/tools/sdk-release-tool/twilio-chat-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-chat-js.json +0 -27
- package/tools/sdk-release-tool/twilio-client-android-aar.json +0 -22
- package/tools/sdk-release-tool/twilio-client-android.json +0 -22
- package/tools/sdk-release-tool/twilio-client-ios.json +0 -20
- package/tools/sdk-release-tool/twilio-client-js.json +0 -17
- package/tools/sdk-release-tool/twilio-client-sounds-js.json +0 -14
- package/tools/sdk-release-tool/twilio-common-android-maven.json +0 -16
- package/tools/sdk-release-tool/twilio-common-android.json +0 -22
- package/tools/sdk-release-tool/twilio-common-ios-rtc.json +0 -25
- package/tools/sdk-release-tool/twilio-common-ios.json +0 -25
- package/tools/sdk-release-tool/twilio-common-js.json +0 -19
- package/tools/sdk-release-tool/twilio-conversations-android.json +0 -22
- package/tools/sdk-release-tool/twilio-conversations-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-conversations-js.json +0 -27
- package/tools/sdk-release-tool/twilio-flex-js.json +0 -20
- package/tools/sdk-release-tool/twilio-flex-webchat-js.json +0 -16
- package/tools/sdk-release-tool/twilio-frame-chat-android.json +0 -22
- package/tools/sdk-release-tool/twilio-frame-chat-ios.json +0 -23
- package/tools/sdk-release-tool/twilio-frame-chat-js.json +0 -23
- package/tools/sdk-release-tool/twilio-ip-messaging-android-maven.json +0 -16
- package/tools/sdk-release-tool/twilio-ip-messaging-android.json +0 -22
- package/tools/sdk-release-tool/twilio-ip-messaging-ios.json +0 -25
- package/tools/sdk-release-tool/twilio-ip-messaging-js.json +0 -21
- package/tools/sdk-release-tool/twilio-sync-android.json +0 -22
- package/tools/sdk-release-tool/twilio-sync-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-sync-js.json +0 -39
- package/tools/sdk-release-tool/twilio-taskrouter-js.json +0 -17
- package/tools/sdk-release-tool/twilio-video-android.json +0 -22
- package/tools/sdk-release-tool/twilio-video-cpp-linux-cross-rootfs.json +0 -13
- package/tools/sdk-release-tool/twilio-video-cpp.json +0 -33
- package/tools/sdk-release-tool/twilio-video-ios.json +0 -25
- package/tools/sdk-release-tool/twilio-video-js.json +0 -19
- package/tools/sdk-release-tool/twilio-video-jsdocs.json +0 -14
- package/tools/sdk-release-tool/twilio-voice-android.json +0 -22
- package/tools/sdk-release-tool/twilio-voice-ios.json +0 -29
- package/tools/sdk-release-tool/unpin +0 -3
- package/tools/sdk-release-tool/unpin-latest +0 -3
- package/tools/sdk-release-tool/upload +0 -3
- package/twilio-chat.js.iml +0 -9
package/lib/participant.d.ts
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { EventEmitter } from 'events';
|
3
|
-
import { Users } from './data/users';
|
4
|
-
import { User } from './user';
|
5
|
-
import { Session } from './session';
|
6
|
-
import { Conversation } from './conversation';
|
7
|
-
interface ParticipantDescriptor {
|
8
|
-
attributes?: Object;
|
9
|
-
dateCreated: any;
|
10
|
-
dateUpdated: any;
|
11
|
-
identity: string;
|
12
|
-
roleSid?: string;
|
13
|
-
lastConsumedMessageIndex: number;
|
14
|
-
lastConsumptionTimestamp: number;
|
15
|
-
type: Participant.Type;
|
16
|
-
userInfo: string;
|
17
|
-
bindings?: Object;
|
18
|
-
}
|
19
|
-
export interface ParticipantServices {
|
20
|
-
users: Users;
|
21
|
-
session: Session;
|
22
|
-
}
|
23
|
-
declare namespace Participant {
|
24
|
-
type UpdateReason = 'attributes' | 'dateCreated' | 'dateUpdated' | 'roleSid' | 'lastReadMessageIndex' | 'lastReadTimestamp' | 'bindings';
|
25
|
-
type Type = 'chat' | 'sms' | 'whatsapp' | 'email';
|
26
|
-
interface UpdatedEventArgs {
|
27
|
-
participant: Participant;
|
28
|
-
updateReasons: Participant.UpdateReason[];
|
29
|
-
}
|
30
|
-
interface Bindings {
|
31
|
-
email?: EmailBinding;
|
32
|
-
}
|
33
|
-
type EmailLevel = 'to' | 'cc';
|
34
|
-
interface EmailBinding {
|
35
|
-
name: string;
|
36
|
-
address: string;
|
37
|
-
level: EmailLevel;
|
38
|
-
}
|
39
|
-
}
|
40
|
-
/**
|
41
|
-
* @classdesc A Participant represents a remote Client in a Conversation.
|
42
|
-
* @property {any} attributes - Object with custom attributes for Participant
|
43
|
-
* @property {Conversation} conversation - The Conversation the remote Client is a Participant of
|
44
|
-
* @property {Date} dateCreated - The Date this Participant was created
|
45
|
-
* @property {Date} dateUpdated - The Date this Participant was last updated
|
46
|
-
* @property {String} identity - The identity of the remote Client
|
47
|
-
* @property {Boolean} isTyping - Whether or not this Participant is currently typing
|
48
|
-
* @property {Number|null} lastReadMessageIndex - Latest read Message index by this Participant.
|
49
|
-
* Note that just retrieving messages on a client endpoint does not mean that messages are read,
|
50
|
-
* please consider reading about [Read Horizon feature]{@link https://www.twilio.com/docs/api/chat/guides/consumption-horizon}
|
51
|
-
* to find out how to mark messages as read.
|
52
|
-
* @property {Date} lastReadTimestamp - Date when Participant has updated his read horizon
|
53
|
-
* @property {String} sid - The server-assigned unique identifier for the Participant
|
54
|
-
* @property {Participant#Type} type - The type of Participant
|
55
|
-
* @fires Participant#typingEnded
|
56
|
-
* @fires Participant#typingStarted
|
57
|
-
* @fires Participant#updated
|
58
|
-
*/
|
59
|
-
declare class Participant extends EventEmitter {
|
60
|
-
private state;
|
61
|
-
private services;
|
62
|
-
readonly conversation: Conversation;
|
63
|
-
get sid(): string;
|
64
|
-
get attributes(): Object;
|
65
|
-
get dateCreated(): Date;
|
66
|
-
get dateUpdated(): Date;
|
67
|
-
get identity(): string;
|
68
|
-
get isTyping(): boolean;
|
69
|
-
get lastReadMessageIndex(): number | null;
|
70
|
-
get lastReadTimestamp(): Date;
|
71
|
-
get roleSid(): string;
|
72
|
-
get type(): Participant.Type;
|
73
|
-
/**
|
74
|
-
* Get the bindings mapping for the current participant.
|
75
|
-
* Available binding depends on the participant type.
|
76
|
-
* You could access it as `participant.bindings.sms?.address` or
|
77
|
-
* using the type dynamically `participant.bindings[participant.type]`
|
78
|
-
* just be aware that the binding information has different structure for
|
79
|
-
* each participant type.
|
80
|
-
* See also {EmailBinding}, the only available binding descriptor available currently.
|
81
|
-
*/
|
82
|
-
get bindings(): Participant.Bindings;
|
83
|
-
/**
|
84
|
-
* The update reason for <code>updated</code> event emitted on Participant
|
85
|
-
* @typedef {('attributes' | 'dateCreated' | 'dateUpdated' | 'roleSid' |
|
86
|
-
'lastReadMessageIndex' | 'lastReadTimestamp' | 'bindings')} Participant#UpdateReason
|
87
|
-
*/
|
88
|
-
/**
|
89
|
-
* The type of Participant
|
90
|
-
* @typedef {('chat' | 'sms' | 'whatsapp' | 'email')} Participant#Type
|
91
|
-
*/
|
92
|
-
constructor(services: ParticipantServices, conversation: Conversation, data: ParticipantDescriptor, sid: string);
|
93
|
-
/**
|
94
|
-
* Private method used to start or reset the typing indicator timeout (with event emitting)
|
95
|
-
* @private
|
96
|
-
*/
|
97
|
-
_startTyping(timeout: any): this;
|
98
|
-
/**
|
99
|
-
* Private method function used to stop typing indicator (with event emitting)
|
100
|
-
* @private
|
101
|
-
*/
|
102
|
-
_endTyping(): void;
|
103
|
-
/**
|
104
|
-
* Private method function used update local object's property roleSid with new value
|
105
|
-
* @private
|
106
|
-
*/
|
107
|
-
_update(data: any): this;
|
108
|
-
/**
|
109
|
-
* Gets User for this participant and subscribes to it. Supported only for <code>chat</code> type of Participants
|
110
|
-
* @returns {Promise<User>}
|
111
|
-
*/
|
112
|
-
getUser(): Promise<User>;
|
113
|
-
/**
|
114
|
-
* Remove Participant from the Conversation.
|
115
|
-
* @returns {Promise<void>}
|
116
|
-
*/
|
117
|
-
remove(): Promise<void>;
|
118
|
-
/**
|
119
|
-
* Edit participant attributes.
|
120
|
-
* @param {any} attributes new attributes for Participant.
|
121
|
-
* @returns {Promise<Participant>}
|
122
|
-
*/
|
123
|
-
updateAttributes(attributes: any): Promise<Participant>;
|
124
|
-
}
|
125
|
-
export { ParticipantDescriptor, Participant };
|
126
|
-
/**
|
127
|
-
* Fired when Participant started to type.
|
128
|
-
* @event Participant#typingStarted
|
129
|
-
* @type {Participant}
|
130
|
-
*/
|
131
|
-
/**
|
132
|
-
* Fired when Participant ended to type.
|
133
|
-
* @event Participant#typingEnded
|
134
|
-
* @type {Participant}
|
135
|
-
*/
|
136
|
-
/**
|
137
|
-
* Fired when Participant's fields has been updated.
|
138
|
-
* @event Participant#updated
|
139
|
-
* @type {Object}
|
140
|
-
* @property {Participant} participant - Updated Participant
|
141
|
-
* @property {Participant#UpdateReason[]} updateReasons - Array of Participant's updated event reasons
|
142
|
-
*/
|
package/lib/participant.js
DELETED
@@ -1,219 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
-
};
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
const events_1 = require("events");
|
13
|
-
const util_1 = require("./util");
|
14
|
-
const logger_1 = require("./logger");
|
15
|
-
const twilio_sdk_type_validator_1 = require("twilio-sdk-type-validator");
|
16
|
-
const log = logger_1.Logger.scope('Participant');
|
17
|
-
/**
|
18
|
-
* @classdesc A Participant represents a remote Client in a Conversation.
|
19
|
-
* @property {any} attributes - Object with custom attributes for Participant
|
20
|
-
* @property {Conversation} conversation - The Conversation the remote Client is a Participant of
|
21
|
-
* @property {Date} dateCreated - The Date this Participant was created
|
22
|
-
* @property {Date} dateUpdated - The Date this Participant was last updated
|
23
|
-
* @property {String} identity - The identity of the remote Client
|
24
|
-
* @property {Boolean} isTyping - Whether or not this Participant is currently typing
|
25
|
-
* @property {Number|null} lastReadMessageIndex - Latest read Message index by this Participant.
|
26
|
-
* Note that just retrieving messages on a client endpoint does not mean that messages are read,
|
27
|
-
* please consider reading about [Read Horizon feature]{@link https://www.twilio.com/docs/api/chat/guides/consumption-horizon}
|
28
|
-
* to find out how to mark messages as read.
|
29
|
-
* @property {Date} lastReadTimestamp - Date when Participant has updated his read horizon
|
30
|
-
* @property {String} sid - The server-assigned unique identifier for the Participant
|
31
|
-
* @property {Participant#Type} type - The type of Participant
|
32
|
-
* @fires Participant#typingEnded
|
33
|
-
* @fires Participant#typingStarted
|
34
|
-
* @fires Participant#updated
|
35
|
-
*/
|
36
|
-
class Participant extends events_1.EventEmitter {
|
37
|
-
/**
|
38
|
-
* The update reason for <code>updated</code> event emitted on Participant
|
39
|
-
* @typedef {('attributes' | 'dateCreated' | 'dateUpdated' | 'roleSid' |
|
40
|
-
'lastReadMessageIndex' | 'lastReadTimestamp' | 'bindings')} Participant#UpdateReason
|
41
|
-
*/
|
42
|
-
/**
|
43
|
-
* The type of Participant
|
44
|
-
* @typedef {('chat' | 'sms' | 'whatsapp' | 'email')} Participant#Type
|
45
|
-
*/
|
46
|
-
constructor(services, conversation, data, sid) {
|
47
|
-
var _a;
|
48
|
-
super();
|
49
|
-
this.conversation = conversation;
|
50
|
-
this.services = services;
|
51
|
-
this.state = {
|
52
|
-
attributes: util_1.parseAttributes(data.attributes, 'Retrieved malformed attributes from the server for participant: ' + sid, log),
|
53
|
-
dateCreated: data.dateCreated ? util_1.parseTime(data.dateCreated) : null,
|
54
|
-
dateUpdated: data.dateCreated ? util_1.parseTime(data.dateUpdated) : null,
|
55
|
-
sid: sid,
|
56
|
-
typingTimeout: null,
|
57
|
-
isTyping: false,
|
58
|
-
identity: data.identity || null,
|
59
|
-
roleSid: data.roleSid || null,
|
60
|
-
lastReadMessageIndex: Number.isInteger(data.lastConsumedMessageIndex) ? data.lastConsumedMessageIndex : null,
|
61
|
-
lastReadTimestamp: data.lastConsumptionTimestamp ? util_1.parseTime(data.lastConsumptionTimestamp) : null,
|
62
|
-
type: data.type || 'chat',
|
63
|
-
userInfo: data.userInfo,
|
64
|
-
bindings: (_a = data.bindings, (_a !== null && _a !== void 0 ? _a : {})),
|
65
|
-
};
|
66
|
-
if (!data.identity && !data.type) {
|
67
|
-
throw new Error('Received invalid Participant object from server: Missing identity or type of Participant.');
|
68
|
-
}
|
69
|
-
}
|
70
|
-
get sid() { return this.state.sid; }
|
71
|
-
get attributes() { return this.state.attributes; }
|
72
|
-
get dateCreated() { return this.state.dateCreated; }
|
73
|
-
get dateUpdated() { return this.state.dateUpdated; }
|
74
|
-
get identity() { return this.state.identity; }
|
75
|
-
get isTyping() { return this.state.isTyping; }
|
76
|
-
get lastReadMessageIndex() { return this.state.lastReadMessageIndex; }
|
77
|
-
get lastReadTimestamp() { return this.state.lastReadTimestamp; }
|
78
|
-
get roleSid() { return this.state.roleSid; }
|
79
|
-
get type() { return this.state.type; }
|
80
|
-
/**
|
81
|
-
* Get the bindings mapping for the current participant.
|
82
|
-
* Available binding depends on the participant type.
|
83
|
-
* You could access it as `participant.bindings.sms?.address` or
|
84
|
-
* using the type dynamically `participant.bindings[participant.type]`
|
85
|
-
* just be aware that the binding information has different structure for
|
86
|
-
* each participant type.
|
87
|
-
* See also {EmailBinding}, the only available binding descriptor available currently.
|
88
|
-
*/
|
89
|
-
get bindings() { return this.state.bindings; }
|
90
|
-
/**
|
91
|
-
* Private method used to start or reset the typing indicator timeout (with event emitting)
|
92
|
-
* @private
|
93
|
-
*/
|
94
|
-
_startTyping(timeout) {
|
95
|
-
clearTimeout(this.state.typingTimeout);
|
96
|
-
this.state.isTyping = true;
|
97
|
-
this.emit('typingStarted', this);
|
98
|
-
this.conversation.emit('typingStarted', this);
|
99
|
-
this.state.typingTimeout = setTimeout(() => this._endTyping(), timeout);
|
100
|
-
return this;
|
101
|
-
}
|
102
|
-
/**
|
103
|
-
* Private method function used to stop typing indicator (with event emitting)
|
104
|
-
* @private
|
105
|
-
*/
|
106
|
-
_endTyping() {
|
107
|
-
if (!this.state.typingTimeout) {
|
108
|
-
return;
|
109
|
-
}
|
110
|
-
this.state.isTyping = false;
|
111
|
-
this.emit('typingEnded', this);
|
112
|
-
this.conversation.emit('typingEnded', this);
|
113
|
-
clearInterval(this.state.typingTimeout);
|
114
|
-
this.state.typingTimeout = null;
|
115
|
-
}
|
116
|
-
/**
|
117
|
-
* Private method function used update local object's property roleSid with new value
|
118
|
-
* @private
|
119
|
-
*/
|
120
|
-
_update(data) {
|
121
|
-
let updateReasons = [];
|
122
|
-
let updateAttributes = util_1.parseAttributes(data.attributes, 'Retrieved malformed attributes from the server for participant: ' + this.state.sid, log);
|
123
|
-
if (data.attributes && !util_1.isDeepEqual(this.state.attributes, updateAttributes)) {
|
124
|
-
this.state.attributes = updateAttributes;
|
125
|
-
updateReasons.push('attributes');
|
126
|
-
}
|
127
|
-
let updatedDateUpdated = util_1.parseTime(data.dateUpdated);
|
128
|
-
if (data.dateUpdated &&
|
129
|
-
updatedDateUpdated.getTime() !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
|
130
|
-
this.state.dateUpdated = updatedDateUpdated;
|
131
|
-
updateReasons.push('dateUpdated');
|
132
|
-
}
|
133
|
-
let updatedDateCreated = util_1.parseTime(data.dateCreated);
|
134
|
-
if (data.dateCreated &&
|
135
|
-
updatedDateCreated.getTime() !== (this.state.dateCreated && this.state.dateCreated.getTime())) {
|
136
|
-
this.state.dateCreated = updatedDateCreated;
|
137
|
-
updateReasons.push('dateCreated');
|
138
|
-
}
|
139
|
-
if (data.roleSid && this.state.roleSid !== data.roleSid) {
|
140
|
-
this.state.roleSid = data.roleSid;
|
141
|
-
updateReasons.push('roleSid');
|
142
|
-
}
|
143
|
-
if ((Number.isInteger(data.lastConsumedMessageIndex) || data.lastConsumedMessageIndex === null)
|
144
|
-
&& this.state.lastReadMessageIndex !== data.lastConsumedMessageIndex) {
|
145
|
-
this.state.lastReadMessageIndex = data.lastConsumedMessageIndex;
|
146
|
-
updateReasons.push('lastReadMessageIndex');
|
147
|
-
}
|
148
|
-
if (data.lastConsumptionTimestamp) {
|
149
|
-
let lastReadTimestamp = new Date(data.lastConsumptionTimestamp);
|
150
|
-
if (!this.state.lastReadTimestamp ||
|
151
|
-
this.state.lastReadTimestamp.getTime() !== lastReadTimestamp.getTime()) {
|
152
|
-
this.state.lastReadTimestamp = lastReadTimestamp;
|
153
|
-
updateReasons.push('lastReadTimestamp');
|
154
|
-
}
|
155
|
-
}
|
156
|
-
if (data.bindings && !util_1.isDeepEqual(this.state.bindings, data.bindings)) {
|
157
|
-
this.state.bindings = data.bindings;
|
158
|
-
updateReasons.push('bindings');
|
159
|
-
}
|
160
|
-
if (updateReasons.length > 0) {
|
161
|
-
this.emit('updated', { participant: this, updateReasons: updateReasons });
|
162
|
-
}
|
163
|
-
return this;
|
164
|
-
}
|
165
|
-
/**
|
166
|
-
* Gets User for this participant and subscribes to it. Supported only for <code>chat</code> type of Participants
|
167
|
-
* @returns {Promise<User>}
|
168
|
-
*/
|
169
|
-
async getUser() {
|
170
|
-
if (this.type != 'chat') {
|
171
|
-
throw new Error('Getting User is not supported for this Participant type: ' + this.type);
|
172
|
-
}
|
173
|
-
return this.services.users.getUser(this.state.identity, this.state.userInfo);
|
174
|
-
}
|
175
|
-
/**
|
176
|
-
* Remove Participant from the Conversation.
|
177
|
-
* @returns {Promise<void>}
|
178
|
-
*/
|
179
|
-
async remove() {
|
180
|
-
return this.conversation.removeParticipant(this);
|
181
|
-
}
|
182
|
-
/**
|
183
|
-
* Edit participant attributes.
|
184
|
-
* @param {any} attributes new attributes for Participant.
|
185
|
-
* @returns {Promise<Participant>}
|
186
|
-
*/
|
187
|
-
async updateAttributes(attributes) {
|
188
|
-
await this.services.session.addCommand('editMemberAttributes', {
|
189
|
-
channelSid: this.conversation.sid,
|
190
|
-
memberSid: this.sid,
|
191
|
-
attributes: JSON.stringify(attributes)
|
192
|
-
});
|
193
|
-
return this;
|
194
|
-
}
|
195
|
-
}
|
196
|
-
__decorate([
|
197
|
-
twilio_sdk_type_validator_1.validateTypesAsync(['string', 'number', 'boolean', 'object', twilio_sdk_type_validator_1.literal(null)]),
|
198
|
-
__metadata("design:type", Function),
|
199
|
-
__metadata("design:paramtypes", [Object]),
|
200
|
-
__metadata("design:returntype", Promise)
|
201
|
-
], Participant.prototype, "updateAttributes", null);
|
202
|
-
exports.Participant = Participant;
|
203
|
-
/**
|
204
|
-
* Fired when Participant started to type.
|
205
|
-
* @event Participant#typingStarted
|
206
|
-
* @type {Participant}
|
207
|
-
*/
|
208
|
-
/**
|
209
|
-
* Fired when Participant ended to type.
|
210
|
-
* @event Participant#typingEnded
|
211
|
-
* @type {Participant}
|
212
|
-
*/
|
213
|
-
/**
|
214
|
-
* Fired when Participant's fields has been updated.
|
215
|
-
* @event Participant#updated
|
216
|
-
* @type {Object}
|
217
|
-
* @property {Participant} participant - Updated Participant
|
218
|
-
* @property {Participant#UpdateReason[]} updateReasons - Array of Participant's updated event reasons
|
219
|
-
*/
|
@@ -1,48 +0,0 @@
|
|
1
|
-
declare namespace PushNotification {
|
2
|
-
type Type = 'twilio.conversations.new_message' | 'twilio.conversations.added_to_conversation' | 'twilio.conversations.removed_from_conversation';
|
3
|
-
interface Descriptor {
|
4
|
-
title: string;
|
5
|
-
body: string;
|
6
|
-
sound: string;
|
7
|
-
badge: number;
|
8
|
-
action: string;
|
9
|
-
type: PushNotification.Type;
|
10
|
-
data: Object;
|
11
|
-
}
|
12
|
-
}
|
13
|
-
/**
|
14
|
-
* @classdesc Push notification representation within Conversations Client
|
15
|
-
* @property {String} [action] - Notification action (`click_action` in FCM/GCM terms and `category` in APN terms)
|
16
|
-
* @property {Number} [badge] - Number for the badge
|
17
|
-
* @property {String} body - Notification text
|
18
|
-
* @property {PushNotification#ConversationData} data - Additional Conversation data
|
19
|
-
* @property {String} [sound] - Notification sound
|
20
|
-
* @property {String} [title] - Notification title
|
21
|
-
* @property {PushNotification#NotificationType} type - Notification type
|
22
|
-
*/
|
23
|
-
declare class PushNotification {
|
24
|
-
readonly title: string;
|
25
|
-
readonly body: string;
|
26
|
-
readonly sound: string;
|
27
|
-
readonly badge: number;
|
28
|
-
readonly action: string;
|
29
|
-
readonly type: PushNotification.Type;
|
30
|
-
readonly data: Object;
|
31
|
-
/**
|
32
|
-
* Conversation push notification type
|
33
|
-
* @typedef {('twilio.conversations.new_message' | 'twilio.conversations.added_to_conversation'
|
34
|
-
| 'twilio.conversations.removed_from_conversation')} PushNotification#NotificationType
|
35
|
-
*/
|
36
|
-
/**
|
37
|
-
* Additional Conversations data for given Push Notification
|
38
|
-
* @typedef {Object} PushNotification#ConversationData
|
39
|
-
* @property {String} [conversationSid] - SID of Conversation
|
40
|
-
* @property {Number} [messageIndex] - Index of Message in Conversation
|
41
|
-
* @property {String} [messageSid] - SID of Message
|
42
|
-
*/
|
43
|
-
/**
|
44
|
-
* @param {PushNotification.Descriptor} data - initial data for PushNotification
|
45
|
-
*/
|
46
|
-
constructor(data: PushNotification.Descriptor);
|
47
|
-
}
|
48
|
-
export { PushNotification };
|
package/lib/pushnotification.js
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
/**
|
4
|
-
* @classdesc Push notification representation within Conversations Client
|
5
|
-
* @property {String} [action] - Notification action (`click_action` in FCM/GCM terms and `category` in APN terms)
|
6
|
-
* @property {Number} [badge] - Number for the badge
|
7
|
-
* @property {String} body - Notification text
|
8
|
-
* @property {PushNotification#ConversationData} data - Additional Conversation data
|
9
|
-
* @property {String} [sound] - Notification sound
|
10
|
-
* @property {String} [title] - Notification title
|
11
|
-
* @property {PushNotification#NotificationType} type - Notification type
|
12
|
-
*/
|
13
|
-
class PushNotification {
|
14
|
-
/**
|
15
|
-
* Conversation push notification type
|
16
|
-
* @typedef {('twilio.conversations.new_message' | 'twilio.conversations.added_to_conversation'
|
17
|
-
| 'twilio.conversations.removed_from_conversation')} PushNotification#NotificationType
|
18
|
-
*/
|
19
|
-
/**
|
20
|
-
* Additional Conversations data for given Push Notification
|
21
|
-
* @typedef {Object} PushNotification#ConversationData
|
22
|
-
* @property {String} [conversationSid] - SID of Conversation
|
23
|
-
* @property {Number} [messageIndex] - Index of Message in Conversation
|
24
|
-
* @property {String} [messageSid] - SID of Message
|
25
|
-
*/
|
26
|
-
/**
|
27
|
-
* @param {PushNotification.Descriptor} data - initial data for PushNotification
|
28
|
-
*/
|
29
|
-
constructor(data) {
|
30
|
-
this.title = data.title || null;
|
31
|
-
this.body = data.body || null;
|
32
|
-
this.sound = data.sound || null;
|
33
|
-
this.badge = data.badge || null;
|
34
|
-
this.action = data.action || null;
|
35
|
-
this.type = data.type || null;
|
36
|
-
this.data = data.data || {};
|
37
|
-
}
|
38
|
-
}
|
39
|
-
exports.PushNotification = PushNotification;
|
package/lib/restpaginator.d.ts
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import { Paginator } from './interfaces/paginator';
|
2
|
-
/**
|
3
|
-
* @class Paginator
|
4
|
-
* @classdesc Pagination helper class
|
5
|
-
*
|
6
|
-
* @property {Array} items Array of elements on current page
|
7
|
-
* @property {boolean} hasNextPage Indicates the existence of next page
|
8
|
-
* @property {boolean} hasPrevPage Indicates the existence of previous page
|
9
|
-
*/
|
10
|
-
declare class RestPaginator<T> implements Paginator<T> {
|
11
|
-
private state;
|
12
|
-
get hasNextPage(): boolean;
|
13
|
-
get hasPrevPage(): boolean;
|
14
|
-
get items(): Array<T>;
|
15
|
-
constructor(items: any, source: any, prevToken: any, nextToken: any);
|
16
|
-
nextPage(): Promise<RestPaginator<T>>;
|
17
|
-
prevPage(): Promise<RestPaginator<T>>;
|
18
|
-
}
|
19
|
-
export { RestPaginator };
|
package/lib/restpaginator.js
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
/**
|
4
|
-
* @class Paginator
|
5
|
-
* @classdesc Pagination helper class
|
6
|
-
*
|
7
|
-
* @property {Array} items Array of elements on current page
|
8
|
-
* @property {boolean} hasNextPage Indicates the existence of next page
|
9
|
-
* @property {boolean} hasPrevPage Indicates the existence of previous page
|
10
|
-
*/
|
11
|
-
class RestPaginator {
|
12
|
-
/*
|
13
|
-
* @constructor
|
14
|
-
* @param {Array} items Array of element for current page
|
15
|
-
* @param {Object} params
|
16
|
-
* @private
|
17
|
-
*/
|
18
|
-
constructor(items, source, prevToken, nextToken) {
|
19
|
-
this.state = {
|
20
|
-
prevToken,
|
21
|
-
nextToken,
|
22
|
-
source,
|
23
|
-
items
|
24
|
-
};
|
25
|
-
}
|
26
|
-
get hasNextPage() { return !!this.state.nextToken; }
|
27
|
-
get hasPrevPage() { return !!this.state.prevToken; }
|
28
|
-
get items() { return this.state.items; }
|
29
|
-
nextPage() {
|
30
|
-
return this.hasNextPage ? this.state.source(this.state.nextToken) : Promise.reject(new Error('No next page'));
|
31
|
-
}
|
32
|
-
prevPage() {
|
33
|
-
return this.hasPrevPage ? this.state.source(this.state.prevToken) : Promise.reject(new Error('No previous page'));
|
34
|
-
}
|
35
|
-
}
|
36
|
-
exports.RestPaginator = RestPaginator;
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { Session } from '../session';
|
2
|
-
import { Transport } from '../interfaces/transport';
|
3
|
-
export interface NetworkServices {
|
4
|
-
session: Session;
|
5
|
-
transport: Transport;
|
6
|
-
}
|
7
|
-
declare class Network {
|
8
|
-
private readonly config;
|
9
|
-
private readonly services;
|
10
|
-
private cacheLifetime;
|
11
|
-
private readonly cache;
|
12
|
-
private timer;
|
13
|
-
constructor(config: any, services: any);
|
14
|
-
private backoffConfig;
|
15
|
-
private retryWhenThrottled;
|
16
|
-
private isExpired;
|
17
|
-
private cleanupCache;
|
18
|
-
pokeTimer(): void;
|
19
|
-
private executeWithRetry;
|
20
|
-
get(url: string): Promise<any>;
|
21
|
-
}
|
22
|
-
export { Network };
|
package/lib/services/network.js
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const operation_retrier_1 = require("operation-retrier");
|
4
|
-
class Network {
|
5
|
-
constructor(config, services) {
|
6
|
-
this.config = config;
|
7
|
-
this.services = services;
|
8
|
-
this.cache = new Map();
|
9
|
-
this.cacheLifetime = 0;
|
10
|
-
this.services.session.getHttpCacheInterval().then(seconds => {
|
11
|
-
this.cacheLifetime = seconds * 1000;
|
12
|
-
this.cleanupCache();
|
13
|
-
});
|
14
|
-
}
|
15
|
-
backoffConfig() {
|
16
|
-
return Object.assign(this.config.backoffConfigDefault, this.config.backoffConfigOverride);
|
17
|
-
}
|
18
|
-
retryWhenThrottled() {
|
19
|
-
if (typeof this.config.retryWhenThrottledOverride !== 'undefined') {
|
20
|
-
return this.config.retryWhenThrottledOverride;
|
21
|
-
}
|
22
|
-
if (typeof this.config.retryWhenThrottledDefault !== 'undefined') {
|
23
|
-
return this.config.retryWhenThrottledDefault;
|
24
|
-
}
|
25
|
-
return false;
|
26
|
-
}
|
27
|
-
isExpired(timestamp) {
|
28
|
-
return !this.cacheLifetime || (Date.now() - timestamp) > this.cacheLifetime;
|
29
|
-
}
|
30
|
-
cleanupCache() {
|
31
|
-
for (let [k, v] of this.cache) {
|
32
|
-
if (this.isExpired(v.timestamp)) {
|
33
|
-
this.cache.delete(k);
|
34
|
-
}
|
35
|
-
}
|
36
|
-
if (this.cache.size === 0) {
|
37
|
-
clearInterval(this.timer);
|
38
|
-
}
|
39
|
-
}
|
40
|
-
pokeTimer() {
|
41
|
-
this.timer = this.timer || setInterval(() => this.cleanupCache(), this.cacheLifetime * 2);
|
42
|
-
}
|
43
|
-
executeWithRetry(request, retryWhenThrottled = false) {
|
44
|
-
return new Promise((resolve, reject) => {
|
45
|
-
let codesToRetryOn = [502, 503, 504];
|
46
|
-
if (retryWhenThrottled) {
|
47
|
-
codesToRetryOn.push(429);
|
48
|
-
}
|
49
|
-
let retrier = new operation_retrier_1.Retrier(this.backoffConfig());
|
50
|
-
retrier.on('attempt', () => {
|
51
|
-
request()
|
52
|
-
.then(result => retrier.succeeded(result))
|
53
|
-
.catch(err => {
|
54
|
-
if (codesToRetryOn.indexOf(err.status) > -1) {
|
55
|
-
retrier.failed(err);
|
56
|
-
}
|
57
|
-
else if (err.message === 'Twilsock disconnected') {
|
58
|
-
// Ugly hack. We must make a proper exceptions for twilsock
|
59
|
-
retrier.failed(err);
|
60
|
-
}
|
61
|
-
else {
|
62
|
-
// Fatal error
|
63
|
-
retrier.removeAllListeners();
|
64
|
-
retrier.cancel();
|
65
|
-
reject(err);
|
66
|
-
}
|
67
|
-
});
|
68
|
-
});
|
69
|
-
retrier.on('succeeded', result => { resolve(result); });
|
70
|
-
retrier.on('cancelled', err => reject(err));
|
71
|
-
retrier.on('failed', err => reject(err));
|
72
|
-
retrier.start();
|
73
|
-
});
|
74
|
-
}
|
75
|
-
async get(url) {
|
76
|
-
let cacheEntry = this.cache.get(url);
|
77
|
-
if (cacheEntry && !this.isExpired(cacheEntry.timestamp)) {
|
78
|
-
return cacheEntry.response;
|
79
|
-
}
|
80
|
-
const headers = {};
|
81
|
-
let response = await this.executeWithRetry(() => this.services.transport.get(url, headers, this.config.productId), this.retryWhenThrottled());
|
82
|
-
this.cache.set(url, { response, timestamp: Date.now() });
|
83
|
-
this.pokeTimer();
|
84
|
-
return response;
|
85
|
-
}
|
86
|
-
}
|
87
|
-
exports.Network = Network;
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import { Session } from '../session';
|
2
|
-
export interface ReadHorizonServices {
|
3
|
-
session: Session;
|
4
|
-
}
|
5
|
-
/**
|
6
|
-
* @classdesc Provides read horizon management functionality
|
7
|
-
*/
|
8
|
-
declare class ReadHorizon {
|
9
|
-
private readonly services;
|
10
|
-
private readonly readHorizonRequests;
|
11
|
-
private readHorizonUpdateTimer;
|
12
|
-
constructor(services: ReadHorizonServices);
|
13
|
-
private getReportInterval;
|
14
|
-
private delayedSendReadHorizon;
|
15
|
-
private sendConsumptionReport;
|
16
|
-
private processConsumptionReportResponse;
|
17
|
-
private processConsumptionReportError;
|
18
|
-
/**
|
19
|
-
* Updates read horizon value without any checks
|
20
|
-
*/
|
21
|
-
updateLastReadMessageIndexForConversation(conversationSid: string, messageIdx: number): Promise<number>;
|
22
|
-
/**
|
23
|
-
* Move read horizon forward
|
24
|
-
*/
|
25
|
-
advanceLastReadMessageIndexForConversation(conversationSid: string, messageIdx: number, currentConversationLastReadIndex: number): Promise<number>;
|
26
|
-
private addPendingConsumptionHorizonRequest;
|
27
|
-
}
|
28
|
-
export { ReadHorizon };
|