@twilio/conversations 2.5.0 → 2.6.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/builds/browser.esm.js +10713 -0
- package/builds/browser.esm.js.map +1 -0
- package/builds/browser.js +158 -1
- package/builds/browser.js.map +1 -1
- package/builds/lib.esm.d.ts +3166 -0
- package/builds/lib.esm.js +10712 -0
- package/builds/lib.js +167 -1
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +309 -322
- package/builds/twilio-conversations.min.js +1 -1
- package/dist/aggregated-delivery-receipt.js +3 -5
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/channel-metadata-client.js +7 -9
- package/dist/channel-metadata-client.js.map +1 -1
- package/dist/client.js +189 -154
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +8 -8
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +12 -9
- package/dist/configuration.js.map +1 -1
- package/dist/content-client.js +11 -8
- package/dist/content-client.js.map +1 -1
- package/dist/content-template.js +3 -5
- package/dist/content-template.js.map +1 -1
- package/dist/conversation.js +113 -87
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +34 -42
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +23 -21
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +25 -23
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +15 -13
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js +3 -5
- package/dist/detailed-delivery-receipt.js.map +1 -1
- package/dist/index.js +17 -49
- package/dist/index.js.map +1 -1
- package/dist/interfaces/notification-types.js +1 -5
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/interfaces/rules.js +13 -10
- package/dist/interfaces/rules.js.map +1 -1
- package/dist/logger.js +25 -26
- package/dist/logger.js.map +1 -1
- package/dist/media.js +11 -8
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +48 -40
- package/dist/message-builder.js.map +1 -1
- package/dist/message-recipients-client.js +10 -12
- package/dist/message-recipients-client.js.map +1 -1
- package/dist/message.js +88 -75
- package/dist/message.js.map +1 -1
- package/dist/node_modules/quick-lru/index.js +1 -5
- package/dist/node_modules/quick-lru/index.js.map +1 -1
- package/dist/node_modules/tslib/tslib.es6.js +1 -7
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/packages/conversations/package.json.js +2 -6
- package/dist/packages/conversations/package.json.js.map +1 -1
- package/dist/participant.js +34 -29
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js +5 -4
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js +6 -4
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +3 -7
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +11 -8
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js +9 -8
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +27 -24
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js +6 -4
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js +1 -9
- package/dist/util/index.js.map +1 -1
- package/docs/index.html +3 -3
- package/docs/modules.html +2 -2
- package/package.json +7 -7
package/dist/client.js
CHANGED
@@ -126,8 +126,6 @@ This software includes platform.js under the following license.
|
|
126
126
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
127
127
|
|
128
128
|
*/
|
129
|
-
'use strict';
|
130
|
-
|
131
129
|
var global =
|
132
130
|
typeof global !== "undefined"
|
133
131
|
? global
|
@@ -137,32 +135,30 @@ var global =
|
|
137
135
|
? window
|
138
136
|
: {};
|
139
137
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
var channelMetadataClient = require('./channel-metadata-client.js');
|
165
|
-
var messageRecipientsClient = require('./message-recipients-client.js');
|
138
|
+
import { __decorate, __metadata } from './node_modules/tslib/tslib.es6.js';
|
139
|
+
import { Logger } from './logger.js';
|
140
|
+
import { Configuration } from './configuration.js';
|
141
|
+
import { User } from './user.js';
|
142
|
+
import { Network } from './services/network.js';
|
143
|
+
import { NotificationTypes } from './interfaces/notification-types.js';
|
144
|
+
import { InitRegistration, TwilsockClient, TelemetryEventDescription, TelemetryPoint } from 'twilsock';
|
145
|
+
import { Notifications } from '@twilio/notifications';
|
146
|
+
import { SyncClient } from 'twilio-sync';
|
147
|
+
import { CancellablePromise, McsClient } from '@twilio/mcs-client';
|
148
|
+
import { Conversations } from './data/conversations.js';
|
149
|
+
import { Users } from './data/users.js';
|
150
|
+
import { TypingIndicator } from './services/typing-indicator.js';
|
151
|
+
import { PushNotification } from './push-notification.js';
|
152
|
+
import { deepClone, parseToNumber } from './util/index.js';
|
153
|
+
import { validateTypesAsync, nonEmptyString, objectSchema, literal, pureObject, nonEmptyArray, validateTypes, validateConstructorTypes } from '@twilio/declarative-type-validator';
|
154
|
+
import { version } from './packages/conversations/package.json.js';
|
155
|
+
import { CommandExecutor } from './command-executor.js';
|
156
|
+
import { ReplayEventEmitter } from '@twilio/replay-event-emitter';
|
157
|
+
import { Media } from './media.js';
|
158
|
+
import { deprecated, deprecationWarning } from '@twilio/deprecation-decorator';
|
159
|
+
import { ContentClient } from './content-client.js';
|
160
|
+
import { ChannelMetadataClient } from './channel-metadata-client.js';
|
161
|
+
import { MessageRecipientsClient } from './message-recipients-client.js';
|
166
162
|
|
167
163
|
var Client_1;
|
168
164
|
/**
|
@@ -173,7 +169,7 @@ class ClientServices {
|
|
173
169
|
/**
|
174
170
|
* A client is the starting point to the Twilio Conversations functionality.
|
175
171
|
*/
|
176
|
-
|
172
|
+
let Client = Client_1 = class Client extends ReplayEventEmitter {
|
177
173
|
/**
|
178
174
|
* Returned Conversations Client instance is not yet fully initialized. Calling any
|
179
175
|
* operations will block until it is. Use connection events to monitor when
|
@@ -191,7 +187,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
191
187
|
/**
|
192
188
|
* Current version of the Conversations client.
|
193
189
|
*/
|
194
|
-
this.version =
|
190
|
+
this.version = version;
|
195
191
|
/**
|
196
192
|
* Client connection state.
|
197
193
|
*/
|
@@ -204,7 +200,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
204
200
|
this._options = options !== null && options !== void 0 ? options : {};
|
205
201
|
if (!this._options.disableDeepClone) {
|
206
202
|
let options = Object.assign(Object.assign({}, this._options), { transport: undefined, twilsockClient: undefined });
|
207
|
-
options =
|
203
|
+
options = deepClone(options);
|
208
204
|
options.transport = this._options.transport;
|
209
205
|
options.twilsockClient = this._options.twilsockClient;
|
210
206
|
this._options = options;
|
@@ -219,7 +215,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
219
215
|
}
|
220
216
|
if (!this._options.clientMetadata.hasOwnProperty("sdk")) {
|
221
217
|
this._options.clientMetadata.sdk = "JS";
|
222
|
-
this._options.clientMetadata.sdkv =
|
218
|
+
this._options.clientMetadata.sdkv = version;
|
223
219
|
}
|
224
220
|
// Enable session local storage for Sync
|
225
221
|
this._options.Sync = this._options.Sync || {};
|
@@ -233,7 +229,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
233
229
|
throw new Error("A valid Twilio token should be provided");
|
234
230
|
}
|
235
231
|
this._services = new ClientServices();
|
236
|
-
this._myself = new
|
232
|
+
this._myself = new User("", "", null, this._services);
|
237
233
|
const startTwilsock = !this._options.twilsockClient;
|
238
234
|
// Create default init registrations if none were provided.
|
239
235
|
// Otherwise, the outside party have to list all the init registrations they
|
@@ -241,12 +237,12 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
241
237
|
// Init registrations passed to the Conversations client will be passed down
|
242
238
|
// to the Sync client as well.
|
243
239
|
if (!this._options.initRegistrations) {
|
244
|
-
const initRegistration = new
|
240
|
+
const initRegistration = new InitRegistration(productId);
|
245
241
|
Client_1.populateInitRegistrations(initRegistration);
|
246
242
|
this._options.initRegistrations = [initRegistration];
|
247
243
|
}
|
248
244
|
this._services.twilsockClient = this._options.twilsockClient =
|
249
|
-
(_b = this._options.twilsockClient) !== null && _b !== void 0 ? _b : new
|
245
|
+
(_b = this._options.twilsockClient) !== null && _b !== void 0 ? _b : new TwilsockClient(fpaToken, productId, this._options);
|
250
246
|
this._services.twilsockClient.on(Client_1.tokenAboutToExpire, () => this.emit(Client_1.tokenAboutToExpire));
|
251
247
|
this._services.twilsockClient.on(Client_1.tokenExpired, () => this.emit(Client_1.tokenExpired));
|
252
248
|
this._services.twilsockClient.on(Client_1.connectionError, (error) => this.emit(Client_1.connectionError, error));
|
@@ -260,16 +256,16 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
260
256
|
this._services.transport = this._options.transport = ((_c = this._options
|
261
257
|
.transport) !== null && _c !== void 0 ? _c : this._options.twilsockClient);
|
262
258
|
this._services.notificationClient = this._options.notificationsClient =
|
263
|
-
(_d = this._options.notificationsClient) !== null && _d !== void 0 ? _d : new
|
259
|
+
(_d = this._options.notificationsClient) !== null && _d !== void 0 ? _d : new Notifications(fpaToken, this._options);
|
264
260
|
this._services.syncClient = this._options.syncClient =
|
265
|
-
(_e = this._options.syncClient) !== null && _e !== void 0 ? _e : new
|
261
|
+
(_e = this._options.syncClient) !== null && _e !== void 0 ? _e : new SyncClient(fpaToken, this._options);
|
266
262
|
const configurationOptions = (options === null || options === void 0 ? void 0 : options.Chat) || (options === null || options === void 0 ? void 0 : options.IPMessaging) || options || {};
|
267
263
|
const region = configurationOptions.region || (options === null || options === void 0 ? void 0 : options.region);
|
268
264
|
const baseUrl = configurationOptions.apiUri ||
|
269
265
|
configurationOptions.typingUri ||
|
270
266
|
`https://aim.${region || "us1"}.twilio.com`;
|
271
|
-
this._services.commandExecutor = new
|
272
|
-
this._services.contentClient = new
|
267
|
+
this._services.commandExecutor = new CommandExecutor(baseUrl, { transport: this._options.transport }, productId);
|
268
|
+
this._services.contentClient = new ContentClient(this._services);
|
273
269
|
const emitFailed = (error) => {
|
274
270
|
this._rejectEnsureReady(error);
|
275
271
|
this.emit(Client_1.stateChanged, "failed");
|
@@ -289,9 +285,9 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
289
285
|
this._services.twilsockClient.off("disconnected", emitDisconnected);
|
290
286
|
try {
|
291
287
|
const startupEvent = "conversations.client.startup";
|
292
|
-
this._services.twilsockClient.addPartialTelemetryEvent(new
|
288
|
+
this._services.twilsockClient.addPartialTelemetryEvent(new TelemetryEventDescription(startupEvent, "Conversations client startup", new Date()), startupEvent, TelemetryPoint.Start);
|
293
289
|
await this._initialize();
|
294
|
-
this._services.twilsockClient.addPartialTelemetryEvent(new
|
290
|
+
this._services.twilsockClient.addPartialTelemetryEvent(new TelemetryEventDescription("", "", new Date()), startupEvent, TelemetryPoint.End);
|
295
291
|
}
|
296
292
|
catch (err) {
|
297
293
|
// Fail ChatClient if initialization is incomplete
|
@@ -401,7 +397,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
401
397
|
body = ((_a = apsPayload.alert) === null || _a === void 0 ? void 0 : _a.body) || null;
|
402
398
|
title = ((_b = apsPayload.alert) === null || _b === void 0 ? void 0 : _b.title) || null;
|
403
399
|
}
|
404
|
-
return new
|
400
|
+
return new PushNotification({
|
405
401
|
title,
|
406
402
|
body,
|
407
403
|
sound: apsPayload.sound || null,
|
@@ -418,7 +414,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
418
414
|
throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
|
419
415
|
}
|
420
416
|
const data = Client_1._parsePushNotificationChatData(notificationPayload.data);
|
421
|
-
return new
|
417
|
+
return new PushNotification({
|
422
418
|
title: dataPayload.twi_title || null,
|
423
419
|
body: dataPayload.twi_body || null,
|
424
420
|
sound: dataPayload.twi_sound || null,
|
@@ -442,7 +438,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
442
438
|
continue;
|
443
439
|
}
|
444
440
|
if (key === "message_index" || key === "media_count") {
|
445
|
-
const number =
|
441
|
+
const number = parseToNumber(value);
|
446
442
|
if (number !== null) {
|
447
443
|
result[Client_1._supportedPushDataFields[key]] = number;
|
448
444
|
}
|
@@ -468,8 +464,8 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
468
464
|
* @param reg The init registration to populate.
|
469
465
|
*/
|
470
466
|
static populateInitRegistrations(reg) {
|
471
|
-
reg.populateInitRegistrations([
|
472
|
-
|
467
|
+
reg.populateInitRegistrations([NotificationTypes.TYPING_INDICATOR]);
|
468
|
+
SyncClient.populateInitRegistrations(reg);
|
473
469
|
}
|
474
470
|
/**
|
475
471
|
* Gracefully shut down the client.
|
@@ -505,7 +501,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
505
501
|
if (!conversation) {
|
506
502
|
conversation = await this.peekConversationBySid(conversationSid);
|
507
503
|
if (conversation) {
|
508
|
-
|
504
|
+
deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");
|
509
505
|
}
|
510
506
|
}
|
511
507
|
if (!conversation) {
|
@@ -629,7 +625,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
629
625
|
* @param mediaSids Set of media sids to query for the content URL.
|
630
626
|
*/
|
631
627
|
getTemporaryContentUrlsForMediaSids(mediaSids) {
|
632
|
-
return new
|
628
|
+
return new CancellablePromise(async (resolve, reject, onCancel) => {
|
633
629
|
if (!this._services.mcsClient || !mediaSids) {
|
634
630
|
reject(new Error("Media Content Service is unavailable"));
|
635
631
|
return;
|
@@ -672,13 +668,13 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
672
668
|
*/
|
673
669
|
async _initialize() {
|
674
670
|
const configurationResponse = await this._services.commandExecutor.fetchResource("Client/v2/Configuration");
|
675
|
-
this._configuration = new
|
676
|
-
this._services.channelMetadataClient = new
|
677
|
-
this._services.messageRecipientsClient = new
|
671
|
+
this._configuration = new Configuration(this._options, configurationResponse, Client_1._logger);
|
672
|
+
this._services.channelMetadataClient = new ChannelMetadataClient(this._services, this._configuration);
|
673
|
+
this._services.messageRecipientsClient = new MessageRecipientsClient(this._services, this._configuration);
|
678
674
|
this._myself._resolveInitialization(this._configuration, this._configuration.userIdentity, this._configuration.userInfo, true);
|
679
|
-
this._services.typingIndicator = new
|
680
|
-
this._services.network = new
|
681
|
-
this._services.users = new
|
675
|
+
this._services.typingIndicator = new TypingIndicator(this.getConversationBySid.bind(this), this._configuration, this._services);
|
676
|
+
this._services.network = new Network(this._configuration, this._services);
|
677
|
+
this._services.users = new Users(this._myself, this._configuration, this._services);
|
682
678
|
this._services.users.on("userSubscribed", (user) => {
|
683
679
|
this.emit("userSubscribed", user);
|
684
680
|
});
|
@@ -686,7 +682,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
686
682
|
this._services.users.on("userUnsubscribed", (user) => {
|
687
683
|
this.emit("userUnsubscribed", user);
|
688
684
|
});
|
689
|
-
this._conversationsEntity = new
|
685
|
+
this._conversationsEntity = new Conversations(this._configuration, this._services);
|
690
686
|
this._conversationsEntity.on("conversationAdded", (conversation) => {
|
691
687
|
this.emit("conversationAdded", conversation);
|
692
688
|
});
|
@@ -721,7 +717,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
721
717
|
await this._services.users.myself._ensureFetched();
|
722
718
|
Client_1._supportedPushChannels.forEach((channelType) => this._subscribeToPushNotifications(channelType));
|
723
719
|
this._services.typingIndicator.initialize();
|
724
|
-
this._services.mcsClient = new
|
720
|
+
this._services.mcsClient = new McsClient(this._fpaToken, this._configuration.links.mediaService, this._configuration.links.mediaSetService, Object.assign(Object.assign({}, this._options), { transport: undefined }));
|
725
721
|
this._resolveEnsureReady();
|
726
722
|
this.emit(Client_1.stateChanged, "initialized");
|
727
723
|
this.emit(Client_1.initialized);
|
@@ -732,11 +728,11 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
732
728
|
*/
|
733
729
|
_subscribeToPushNotifications(channelType) {
|
734
730
|
[
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
731
|
+
NotificationTypes.NEW_MESSAGE,
|
732
|
+
NotificationTypes.ADDED_TO_CONVERSATION,
|
733
|
+
NotificationTypes.REMOVED_FROM_CONVERSATION,
|
734
|
+
NotificationTypes.TYPING_INDICATOR,
|
735
|
+
NotificationTypes.CONSUMPTION_UPDATE,
|
740
736
|
].forEach((messageType) => {
|
741
737
|
this._services.notificationClient.subscribe(channelType, messageType);
|
742
738
|
});
|
@@ -747,11 +743,11 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
747
743
|
*/
|
748
744
|
_unsubscribeFromPushNotifications(channelType) {
|
749
745
|
[
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
746
|
+
NotificationTypes.NEW_MESSAGE,
|
747
|
+
NotificationTypes.ADDED_TO_CONVERSATION,
|
748
|
+
NotificationTypes.REMOVED_FROM_CONVERSATION,
|
749
|
+
NotificationTypes.TYPING_INDICATOR,
|
750
|
+
NotificationTypes.CONSUMPTION_UPDATE,
|
755
751
|
].forEach((messageType) => {
|
756
752
|
this._services.notificationClient.unsubscribe(channelType, messageType);
|
757
753
|
});
|
@@ -766,7 +762,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
766
762
|
* 1. {@link Conversation} `conversation` - the conversation in question
|
767
763
|
* @event
|
768
764
|
*/
|
769
|
-
|
765
|
+
Client.conversationAdded = "conversationAdded";
|
770
766
|
/**
|
771
767
|
* Fired when the client joins a conversation.
|
772
768
|
*
|
@@ -774,7 +770,7 @@ exports.Client.conversationAdded = "conversationAdded";
|
|
774
770
|
* 1. {@link Conversation} `conversation` - the conversation in question
|
775
771
|
* @event
|
776
772
|
*/
|
777
|
-
|
773
|
+
Client.conversationJoined = "conversationJoined";
|
778
774
|
/**
|
779
775
|
* Fired when the client leaves a conversation.
|
780
776
|
*
|
@@ -782,7 +778,7 @@ exports.Client.conversationJoined = "conversationJoined";
|
|
782
778
|
* 1. {@link Conversation} `conversation` - the conversation in question
|
783
779
|
* @event
|
784
780
|
*/
|
785
|
-
|
781
|
+
Client.conversationLeft = "conversationLeft";
|
786
782
|
/**
|
787
783
|
* Fired when a conversation is no longer visible to the client.
|
788
784
|
*
|
@@ -790,7 +786,7 @@ exports.Client.conversationLeft = "conversationLeft";
|
|
790
786
|
* 1. {@link Conversation} `conversation` - the conversation in question
|
791
787
|
* @event
|
792
788
|
*/
|
793
|
-
|
789
|
+
Client.conversationRemoved = "conversationRemoved";
|
794
790
|
/**
|
795
791
|
* Fired when the attributes or the metadata of a conversation have been
|
796
792
|
* updated. During conversation's creation and initialization, this event
|
@@ -805,7 +801,7 @@ exports.Client.conversationRemoved = "conversationRemoved";
|
|
805
801
|
* for the update
|
806
802
|
* @event
|
807
803
|
*/
|
808
|
-
|
804
|
+
Client.conversationUpdated = "conversationUpdated";
|
809
805
|
/**
|
810
806
|
* Fired when a participant has joined a conversation.
|
811
807
|
*
|
@@ -813,7 +809,7 @@ exports.Client.conversationUpdated = "conversationUpdated";
|
|
813
809
|
* 1. {@link Participant} `participant` - the participant in question
|
814
810
|
* @event
|
815
811
|
*/
|
816
|
-
|
812
|
+
Client.participantJoined = "participantJoined";
|
817
813
|
/**
|
818
814
|
* Fired when a participant has left a conversation.
|
819
815
|
*
|
@@ -821,7 +817,7 @@ exports.Client.participantJoined = "participantJoined";
|
|
821
817
|
* 1. {@link Participant} `participant` - the participant in question
|
822
818
|
* @event
|
823
819
|
*/
|
824
|
-
|
820
|
+
Client.participantLeft = "participantLeft";
|
825
821
|
/**
|
826
822
|
* Fired when a participant's fields have been updated.
|
827
823
|
*
|
@@ -833,7 +829,7 @@ exports.Client.participantLeft = "participantLeft";
|
|
833
829
|
* for the update
|
834
830
|
* @event
|
835
831
|
*/
|
836
|
-
|
832
|
+
Client.participantUpdated = "participantUpdated";
|
837
833
|
/**
|
838
834
|
* Fired when a new message has been added to the conversation on the server.
|
839
835
|
*
|
@@ -841,7 +837,7 @@ exports.Client.participantUpdated = "participantUpdated";
|
|
841
837
|
* 1. {@link Message} `message` - the message in question
|
842
838
|
* @event
|
843
839
|
*/
|
844
|
-
|
840
|
+
Client.messageAdded = "messageAdded";
|
845
841
|
/**
|
846
842
|
* Fired when a message is removed from the message list of a conversation.
|
847
843
|
*
|
@@ -849,7 +845,7 @@ exports.Client.messageAdded = "messageAdded";
|
|
849
845
|
* 1. {@link Message} `message` - the message in question
|
850
846
|
* @event
|
851
847
|
*/
|
852
|
-
|
848
|
+
Client.messageRemoved = "messageRemoved";
|
853
849
|
/**
|
854
850
|
* Fired when the fields of an existing message are updated with new values.
|
855
851
|
*
|
@@ -861,17 +857,17 @@ exports.Client.messageRemoved = "messageRemoved";
|
|
861
857
|
* the update
|
862
858
|
* @event
|
863
859
|
*/
|
864
|
-
|
860
|
+
Client.messageUpdated = "messageUpdated";
|
865
861
|
/**
|
866
862
|
* Fired when the token is about to expire and needs to be updated.
|
867
863
|
* @event
|
868
864
|
*/
|
869
|
-
|
865
|
+
Client.tokenAboutToExpire = "tokenAboutToExpire";
|
870
866
|
/**
|
871
867
|
* Fired when the token has expired.
|
872
868
|
* @event
|
873
869
|
*/
|
874
|
-
|
870
|
+
Client.tokenExpired = "tokenExpired";
|
875
871
|
/**
|
876
872
|
* Fired when a participant has stopped typing.
|
877
873
|
*
|
@@ -879,7 +875,7 @@ exports.Client.tokenExpired = "tokenExpired";
|
|
879
875
|
* 1. {@link Participant} `participant` - the participant in question
|
880
876
|
* @event
|
881
877
|
*/
|
882
|
-
|
878
|
+
Client.typingEnded = "typingEnded";
|
883
879
|
/**
|
884
880
|
* Fired when a participant has started typing.
|
885
881
|
*
|
@@ -887,7 +883,7 @@ exports.Client.typingEnded = "typingEnded";
|
|
887
883
|
* 1. {@link Participant} `participant` - the participant in question
|
888
884
|
* @event
|
889
885
|
*/
|
890
|
-
|
886
|
+
Client.typingStarted = "typingStarted";
|
891
887
|
/**
|
892
888
|
* Fired when the client has received (and parsed) a push notification via one
|
893
889
|
* of the push channels (apn or fcm).
|
@@ -897,7 +893,7 @@ exports.Client.typingStarted = "typingStarted";
|
|
897
893
|
* question
|
898
894
|
* @event
|
899
895
|
*/
|
900
|
-
|
896
|
+
Client.pushNotification = "pushNotification";
|
901
897
|
/**
|
902
898
|
* Fired when the client has subscribed to a user.
|
903
899
|
*
|
@@ -905,7 +901,7 @@ exports.Client.pushNotification = "pushNotification";
|
|
905
901
|
* 1. {@link User} `user` - the user in question
|
906
902
|
* @event
|
907
903
|
*/
|
908
|
-
|
904
|
+
Client.userSubscribed = "userSubscribed";
|
909
905
|
/**
|
910
906
|
* Fired when the client has unsubscribed from a user.
|
911
907
|
*
|
@@ -913,7 +909,7 @@ exports.Client.userSubscribed = "userSubscribed";
|
|
913
909
|
* 1. {@link User} `user` - the user in question
|
914
910
|
* @event
|
915
911
|
*/
|
916
|
-
|
912
|
+
Client.userUnsubscribed = "userUnsubscribed";
|
917
913
|
/**
|
918
914
|
* Fired when the properties or the reachability status of a user have been
|
919
915
|
* updated.
|
@@ -926,7 +922,7 @@ exports.Client.userUnsubscribed = "userUnsubscribed";
|
|
926
922
|
* update
|
927
923
|
* @event
|
928
924
|
*/
|
929
|
-
|
925
|
+
Client.userUpdated = "userUpdated";
|
930
926
|
/**
|
931
927
|
* @deprecated Use initialized or initFailed events instead
|
932
928
|
* Fired when the state of the client has been changed.
|
@@ -935,12 +931,12 @@ exports.Client.userUpdated = "userUpdated";
|
|
935
931
|
* 1. {@link State} `state` - the new client state
|
936
932
|
* @event
|
937
933
|
*/
|
938
|
-
|
934
|
+
Client.stateChanged = "stateChanged";
|
939
935
|
/**
|
940
936
|
* Fired when the client has completed initialization successfully.
|
941
937
|
* @event
|
942
938
|
*/
|
943
|
-
|
939
|
+
Client.initialized = "initialized";
|
944
940
|
/**
|
945
941
|
* Fired when the client initialization failed.
|
946
942
|
*
|
@@ -950,7 +946,7 @@ exports.Client.initialized = "initialized";
|
|
950
946
|
* * Error? `error` - the initialization error if present
|
951
947
|
* @event
|
952
948
|
*/
|
953
|
-
|
949
|
+
Client.initFailed = "initFailed";
|
954
950
|
/**
|
955
951
|
* Fired when the connection state of the client has been changed.
|
956
952
|
*
|
@@ -958,7 +954,7 @@ exports.Client.initFailed = "initFailed";
|
|
958
954
|
* 1. {@link ConnectionState} `state` - the new connection state
|
959
955
|
* @event
|
960
956
|
*/
|
961
|
-
|
957
|
+
Client.connectionStateChanged = "connectionStateChanged";
|
962
958
|
/**
|
963
959
|
* Fired when the connection is interrupted for an unexpected reason.
|
964
960
|
*
|
@@ -971,26 +967,26 @@ exports.Client.connectionStateChanged = "connectionStateChanged";
|
|
971
967
|
* * number? `errorCode` - Twilio public error code if available
|
972
968
|
* @event
|
973
969
|
*/
|
974
|
-
|
970
|
+
Client.connectionError = "connectionError";
|
975
971
|
/**
|
976
972
|
* Current version of the Conversations client.
|
977
973
|
*/
|
978
|
-
|
974
|
+
Client.version = version;
|
979
975
|
/**
|
980
976
|
* Logger instance.
|
981
977
|
*/
|
982
|
-
|
978
|
+
Client._logger = Logger.scope("Client");
|
983
979
|
/**
|
984
980
|
* Supported push notification channels.
|
985
981
|
*/
|
986
|
-
|
982
|
+
Client._supportedPushChannels = [
|
987
983
|
"fcm",
|
988
984
|
"apn",
|
989
985
|
];
|
990
986
|
/**
|
991
987
|
* Supported push data fields.
|
992
988
|
*/
|
993
|
-
|
989
|
+
Client._supportedPushDataFields = {
|
994
990
|
conversation_sid: "conversationSid",
|
995
991
|
conversation_title: "conversationTitle",
|
996
992
|
message_sid: "messageSid",
|
@@ -998,72 +994,111 @@ exports.Client._supportedPushDataFields = {
|
|
998
994
|
media_count: "mediaCount",
|
999
995
|
media: "media", // object
|
1000
996
|
};
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
],
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
],
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
],
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
],
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
],
|
1030
|
-
|
1031
|
-
|
997
|
+
__decorate([
|
998
|
+
deprecated("token"),
|
999
|
+
__metadata("design:type", String),
|
1000
|
+
__metadata("design:paramtypes", [])
|
1001
|
+
], Client.prototype, "token", null);
|
1002
|
+
__decorate([
|
1003
|
+
validateTypesAsync(nonEmptyString),
|
1004
|
+
__metadata("design:type", Function),
|
1005
|
+
__metadata("design:paramtypes", [String]),
|
1006
|
+
__metadata("design:returntype", Promise)
|
1007
|
+
], Client.prototype, "updateToken", null);
|
1008
|
+
__decorate([
|
1009
|
+
validateTypesAsync(nonEmptyString),
|
1010
|
+
__metadata("design:type", Function),
|
1011
|
+
__metadata("design:paramtypes", [String]),
|
1012
|
+
__metadata("design:returntype", Promise)
|
1013
|
+
], Client.prototype, "getConversationBySid", null);
|
1014
|
+
__decorate([
|
1015
|
+
validateTypesAsync(nonEmptyString),
|
1016
|
+
__metadata("design:type", Function),
|
1017
|
+
__metadata("design:paramtypes", [String]),
|
1018
|
+
__metadata("design:returntype", Promise)
|
1019
|
+
], Client.prototype, "peekConversationBySid", null);
|
1020
|
+
__decorate([
|
1021
|
+
validateTypesAsync(nonEmptyString),
|
1022
|
+
__metadata("design:type", Function),
|
1023
|
+
__metadata("design:paramtypes", [String]),
|
1024
|
+
__metadata("design:returntype", Promise)
|
1025
|
+
], Client.prototype, "getConversationByUniqueName", null);
|
1026
|
+
__decorate([
|
1027
|
+
validateTypesAsync([
|
1032
1028
|
"undefined",
|
1033
|
-
|
1029
|
+
objectSchema("conversation options", {
|
1034
1030
|
friendlyName: ["string", "undefined"],
|
1035
1031
|
isPrivate: ["boolean", "undefined"],
|
1036
1032
|
uniqueName: ["string", "undefined"],
|
1037
1033
|
}),
|
1038
1034
|
]),
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
],
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
],
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
],
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
],
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
],
|
1035
|
+
__metadata("design:type", Function),
|
1036
|
+
__metadata("design:paramtypes", [Object]),
|
1037
|
+
__metadata("design:returntype", Promise)
|
1038
|
+
], Client.prototype, "createConversation", null);
|
1039
|
+
__decorate([
|
1040
|
+
validateTypesAsync(literal("fcm", "apn"), "string"),
|
1041
|
+
__metadata("design:type", Function),
|
1042
|
+
__metadata("design:paramtypes", [String, String]),
|
1043
|
+
__metadata("design:returntype", Promise)
|
1044
|
+
], Client.prototype, "setPushRegistrationId", null);
|
1045
|
+
__decorate([
|
1046
|
+
validateTypesAsync(literal("fcm", "apn")),
|
1047
|
+
__metadata("design:type", Function),
|
1048
|
+
__metadata("design:paramtypes", [String]),
|
1049
|
+
__metadata("design:returntype", Promise)
|
1050
|
+
], Client.prototype, "unsetPushRegistrationId", null);
|
1051
|
+
__decorate([
|
1052
|
+
validateTypesAsync(literal("fcm", "apn"), nonEmptyString),
|
1053
|
+
__metadata("design:type", Function),
|
1054
|
+
__metadata("design:paramtypes", [String, String]),
|
1055
|
+
__metadata("design:returntype", Promise)
|
1056
|
+
], Client.prototype, "removePushRegistrations", null);
|
1057
|
+
__decorate([
|
1058
|
+
validateTypesAsync(pureObject),
|
1059
|
+
__metadata("design:type", Function),
|
1060
|
+
__metadata("design:paramtypes", [Object]),
|
1061
|
+
__metadata("design:returntype", Promise)
|
1062
|
+
], Client.prototype, "handlePushNotification", null);
|
1063
|
+
__decorate([
|
1064
|
+
validateTypesAsync(nonEmptyString),
|
1065
|
+
__metadata("design:type", Function),
|
1066
|
+
__metadata("design:paramtypes", [String]),
|
1067
|
+
__metadata("design:returntype", Promise)
|
1068
|
+
], Client.prototype, "getUser", null);
|
1069
|
+
__decorate([
|
1070
|
+
validateTypesAsync(nonEmptyArray("strings", "string")),
|
1071
|
+
__metadata("design:type", Function),
|
1072
|
+
__metadata("design:paramtypes", [Array]),
|
1073
|
+
__metadata("design:returntype", CancellablePromise)
|
1074
|
+
], Client.prototype, "getTemporaryContentUrlsForMediaSids", null);
|
1075
|
+
__decorate([
|
1076
|
+
validateTypesAsync(nonEmptyArray("media", Media)),
|
1077
|
+
__metadata("design:type", Function),
|
1078
|
+
__metadata("design:paramtypes", [Array]),
|
1079
|
+
__metadata("design:returntype", CancellablePromise)
|
1080
|
+
], Client.prototype, "getTemporaryContentUrlsForMedia", null);
|
1081
|
+
__decorate([
|
1082
|
+
deprecated("Client.create()", "new Client()"),
|
1083
|
+
validateTypesAsync("string", ["undefined", pureObject]),
|
1084
|
+
__metadata("design:type", Function),
|
1085
|
+
__metadata("design:paramtypes", [String, Object]),
|
1086
|
+
__metadata("design:returntype", Promise)
|
1087
|
+
], Client, "create", null);
|
1088
|
+
__decorate([
|
1089
|
+
validateTypes(pureObject),
|
1090
|
+
__metadata("design:type", Function),
|
1091
|
+
__metadata("design:paramtypes", [Object]),
|
1092
|
+
__metadata("design:returntype", PushNotification)
|
1093
|
+
], Client, "parsePushNotification", null);
|
1094
|
+
Client = Client_1 = __decorate([
|
1095
|
+
validateConstructorTypes(nonEmptyString, [pureObject, "undefined"]),
|
1096
|
+
__metadata("design:paramtypes", [String, Object])
|
1097
|
+
], Client);
|
1098
|
+
|
1099
|
+
export { Client };
|
1100
|
+
//# sourceMappingURL=client.js.map
|
1101
|
+
rts.Client.prototype, "handlePushNotification", null);
|
1067
1102
|
tslib_es6.__decorate([
|
1068
1103
|
declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
|
1069
1104
|
tslib_es6.__metadata("design:type", Function),
|