@twilio/conversations 2.5.0 → 2.6.0-rc.1
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 +10730 -0
- package/builds/browser.esm.js.map +1 -0
- package/builds/browser.js +183 -9
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +6 -1
- package/builds/lib.esm.d.ts +3171 -0
- package/builds/lib.esm.js +10729 -0
- package/builds/lib.js +192 -9
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +324 -150
- 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 +207 -158
- 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 +42 -40
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +18 -22
- 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/assets/js/search.js +1 -1
- package/docs/classes/Client.html +4 -4
- package/docs/classes/Media.html +2 -2
- package/docs/classes/Message.html +8 -8
- package/docs/classes/MessageBuilder.html +2 -2
- package/docs/classes/UnsentMessage.html +2 -2
- package/docs/index.html +3 -7
- package/docs/modules.html +2 -6
- package/package.json +2 -2
- package/docs/classes/CancellablePromise.html +0 -3213
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");
|
@@ -280,6 +276,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
280
276
|
terminal: true,
|
281
277
|
message: "Twilsock has disconnected.",
|
282
278
|
});
|
279
|
+
this._initializeEnsureReady((options === null || options === void 0 ? void 0 : options.throwErrorsAlways) || false);
|
283
280
|
};
|
284
281
|
this._services.twilsockClient.once("connectionError", emitFailed);
|
285
282
|
this._services.twilsockClient.once("disconnected", emitDisconnected);
|
@@ -289,9 +286,9 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
289
286
|
this._services.twilsockClient.off("disconnected", emitDisconnected);
|
290
287
|
try {
|
291
288
|
const startupEvent = "conversations.client.startup";
|
292
|
-
this._services.twilsockClient.addPartialTelemetryEvent(new
|
289
|
+
this._services.twilsockClient.addPartialTelemetryEvent(new TelemetryEventDescription(startupEvent, "Conversations client startup", new Date()), startupEvent, TelemetryPoint.Start);
|
293
290
|
await this._initialize();
|
294
|
-
this._services.twilsockClient.addPartialTelemetryEvent(new
|
291
|
+
this._services.twilsockClient.addPartialTelemetryEvent(new TelemetryEventDescription("", "", new Date()), startupEvent, TelemetryPoint.End);
|
295
292
|
}
|
296
293
|
catch (err) {
|
297
294
|
// Fail ChatClient if initialization is incomplete
|
@@ -306,10 +303,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
306
303
|
});
|
307
304
|
}
|
308
305
|
});
|
309
|
-
this.
|
310
|
-
this._resolveEnsureReady = resolve;
|
311
|
-
this._rejectEnsureReady = reject;
|
312
|
-
}).catch(() => void 0); // @todo How to process unhandled rejection here?
|
306
|
+
this._initializeEnsureReady((options === null || options === void 0 ? void 0 : options.throwErrorsAlways) || false);
|
313
307
|
if (startTwilsock) {
|
314
308
|
this._services.twilsockClient.connect();
|
315
309
|
}
|
@@ -401,7 +395,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
401
395
|
body = ((_a = apsPayload.alert) === null || _a === void 0 ? void 0 : _a.body) || null;
|
402
396
|
title = ((_b = apsPayload.alert) === null || _b === void 0 ? void 0 : _b.title) || null;
|
403
397
|
}
|
404
|
-
return new
|
398
|
+
return new PushNotification({
|
405
399
|
title,
|
406
400
|
body,
|
407
401
|
sound: apsPayload.sound || null,
|
@@ -418,7 +412,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
418
412
|
throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
|
419
413
|
}
|
420
414
|
const data = Client_1._parsePushNotificationChatData(notificationPayload.data);
|
421
|
-
return new
|
415
|
+
return new PushNotification({
|
422
416
|
title: dataPayload.twi_title || null,
|
423
417
|
body: dataPayload.twi_body || null,
|
424
418
|
sound: dataPayload.twi_sound || null,
|
@@ -442,7 +436,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
442
436
|
continue;
|
443
437
|
}
|
444
438
|
if (key === "message_index" || key === "media_count") {
|
445
|
-
const number =
|
439
|
+
const number = parseToNumber(value);
|
446
440
|
if (number !== null) {
|
447
441
|
result[Client_1._supportedPushDataFields[key]] = number;
|
448
442
|
}
|
@@ -468,8 +462,8 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
468
462
|
* @param reg The init registration to populate.
|
469
463
|
*/
|
470
464
|
static populateInitRegistrations(reg) {
|
471
|
-
reg.populateInitRegistrations([
|
472
|
-
|
465
|
+
reg.populateInitRegistrations([NotificationTypes.TYPING_INDICATOR]);
|
466
|
+
SyncClient.populateInitRegistrations(reg);
|
473
467
|
}
|
474
468
|
/**
|
475
469
|
* Gracefully shut down the client.
|
@@ -505,7 +499,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
505
499
|
if (!conversation) {
|
506
500
|
conversation = await this.peekConversationBySid(conversationSid);
|
507
501
|
if (conversation) {
|
508
|
-
|
502
|
+
deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");
|
509
503
|
}
|
510
504
|
}
|
511
505
|
if (!conversation) {
|
@@ -629,7 +623,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
629
623
|
* @param mediaSids Set of media sids to query for the content URL.
|
630
624
|
*/
|
631
625
|
getTemporaryContentUrlsForMediaSids(mediaSids) {
|
632
|
-
return new
|
626
|
+
return new CancellablePromise(async (resolve, reject, onCancel) => {
|
633
627
|
if (!this._services.mcsClient || !mediaSids) {
|
634
628
|
reject(new Error("Media Content Service is unavailable"));
|
635
629
|
return;
|
@@ -672,13 +666,13 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
672
666
|
*/
|
673
667
|
async _initialize() {
|
674
668
|
const configurationResponse = await this._services.commandExecutor.fetchResource("Client/v2/Configuration");
|
675
|
-
this._configuration = new
|
676
|
-
this._services.channelMetadataClient = new
|
677
|
-
this._services.messageRecipientsClient = new
|
669
|
+
this._configuration = new Configuration(this._options, configurationResponse, Client_1._logger);
|
670
|
+
this._services.channelMetadataClient = new ChannelMetadataClient(this._services, this._configuration);
|
671
|
+
this._services.messageRecipientsClient = new MessageRecipientsClient(this._services, this._configuration);
|
678
672
|
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
|
673
|
+
this._services.typingIndicator = new TypingIndicator(this.getConversationBySid.bind(this), this._configuration, this._services);
|
674
|
+
this._services.network = new Network(this._configuration, this._services);
|
675
|
+
this._services.users = new Users(this._myself, this._configuration, this._services);
|
682
676
|
this._services.users.on("userSubscribed", (user) => {
|
683
677
|
this.emit("userSubscribed", user);
|
684
678
|
});
|
@@ -686,7 +680,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
686
680
|
this._services.users.on("userUnsubscribed", (user) => {
|
687
681
|
this.emit("userUnsubscribed", user);
|
688
682
|
});
|
689
|
-
this._conversationsEntity = new
|
683
|
+
this._conversationsEntity = new Conversations(this._configuration, this._services);
|
690
684
|
this._conversationsEntity.on("conversationAdded", (conversation) => {
|
691
685
|
this.emit("conversationAdded", conversation);
|
692
686
|
});
|
@@ -721,7 +715,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
721
715
|
await this._services.users.myself._ensureFetched();
|
722
716
|
Client_1._supportedPushChannels.forEach((channelType) => this._subscribeToPushNotifications(channelType));
|
723
717
|
this._services.typingIndicator.initialize();
|
724
|
-
this._services.mcsClient = new
|
718
|
+
this._services.mcsClient = new McsClient(this._fpaToken, this._configuration.links.mediaService, this._configuration.links.mediaSetService, Object.assign(Object.assign({}, this._options), { transport: undefined }));
|
725
719
|
this._resolveEnsureReady();
|
726
720
|
this.emit(Client_1.stateChanged, "initialized");
|
727
721
|
this.emit(Client_1.initialized);
|
@@ -732,11 +726,11 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
732
726
|
*/
|
733
727
|
_subscribeToPushNotifications(channelType) {
|
734
728
|
[
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
729
|
+
NotificationTypes.NEW_MESSAGE,
|
730
|
+
NotificationTypes.ADDED_TO_CONVERSATION,
|
731
|
+
NotificationTypes.REMOVED_FROM_CONVERSATION,
|
732
|
+
NotificationTypes.TYPING_INDICATOR,
|
733
|
+
NotificationTypes.CONSUMPTION_UPDATE,
|
740
734
|
].forEach((messageType) => {
|
741
735
|
this._services.notificationClient.subscribe(channelType, messageType);
|
742
736
|
});
|
@@ -747,15 +741,31 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
747
741
|
*/
|
748
742
|
_unsubscribeFromPushNotifications(channelType) {
|
749
743
|
[
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
744
|
+
NotificationTypes.NEW_MESSAGE,
|
745
|
+
NotificationTypes.ADDED_TO_CONVERSATION,
|
746
|
+
NotificationTypes.REMOVED_FROM_CONVERSATION,
|
747
|
+
NotificationTypes.TYPING_INDICATOR,
|
748
|
+
NotificationTypes.CONSUMPTION_UPDATE,
|
755
749
|
].forEach((messageType) => {
|
756
750
|
this._services.notificationClient.unsubscribe(channelType, messageType);
|
757
751
|
});
|
758
752
|
}
|
753
|
+
/**
|
754
|
+
* Initialize the ensureReady promise.
|
755
|
+
*/
|
756
|
+
_initializeEnsureReady(throwErrorsAlways) {
|
757
|
+
this._ensureReady = new Promise((resolve, reject) => {
|
758
|
+
this._resolveEnsureReady = resolve;
|
759
|
+
this._rejectEnsureReady = reject;
|
760
|
+
}).catch((error) => {
|
761
|
+
if (throwErrorsAlways) {
|
762
|
+
throw error;
|
763
|
+
}
|
764
|
+
else {
|
765
|
+
return void 0;
|
766
|
+
}
|
767
|
+
});
|
768
|
+
}
|
759
769
|
};
|
760
770
|
/**
|
761
771
|
* Fired when a conversation becomes visible to the client. The event is also
|
@@ -766,7 +776,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
766
776
|
* 1. {@link Conversation} `conversation` - the conversation in question
|
767
777
|
* @event
|
768
778
|
*/
|
769
|
-
|
779
|
+
Client.conversationAdded = "conversationAdded";
|
770
780
|
/**
|
771
781
|
* Fired when the client joins a conversation.
|
772
782
|
*
|
@@ -774,7 +784,7 @@ exports.Client.conversationAdded = "conversationAdded";
|
|
774
784
|
* 1. {@link Conversation} `conversation` - the conversation in question
|
775
785
|
* @event
|
776
786
|
*/
|
777
|
-
|
787
|
+
Client.conversationJoined = "conversationJoined";
|
778
788
|
/**
|
779
789
|
* Fired when the client leaves a conversation.
|
780
790
|
*
|
@@ -782,7 +792,7 @@ exports.Client.conversationJoined = "conversationJoined";
|
|
782
792
|
* 1. {@link Conversation} `conversation` - the conversation in question
|
783
793
|
* @event
|
784
794
|
*/
|
785
|
-
|
795
|
+
Client.conversationLeft = "conversationLeft";
|
786
796
|
/**
|
787
797
|
* Fired when a conversation is no longer visible to the client.
|
788
798
|
*
|
@@ -790,7 +800,7 @@ exports.Client.conversationLeft = "conversationLeft";
|
|
790
800
|
* 1. {@link Conversation} `conversation` - the conversation in question
|
791
801
|
* @event
|
792
802
|
*/
|
793
|
-
|
803
|
+
Client.conversationRemoved = "conversationRemoved";
|
794
804
|
/**
|
795
805
|
* Fired when the attributes or the metadata of a conversation have been
|
796
806
|
* updated. During conversation's creation and initialization, this event
|
@@ -805,7 +815,7 @@ exports.Client.conversationRemoved = "conversationRemoved";
|
|
805
815
|
* for the update
|
806
816
|
* @event
|
807
817
|
*/
|
808
|
-
|
818
|
+
Client.conversationUpdated = "conversationUpdated";
|
809
819
|
/**
|
810
820
|
* Fired when a participant has joined a conversation.
|
811
821
|
*
|
@@ -813,7 +823,7 @@ exports.Client.conversationUpdated = "conversationUpdated";
|
|
813
823
|
* 1. {@link Participant} `participant` - the participant in question
|
814
824
|
* @event
|
815
825
|
*/
|
816
|
-
|
826
|
+
Client.participantJoined = "participantJoined";
|
817
827
|
/**
|
818
828
|
* Fired when a participant has left a conversation.
|
819
829
|
*
|
@@ -821,7 +831,7 @@ exports.Client.participantJoined = "participantJoined";
|
|
821
831
|
* 1. {@link Participant} `participant` - the participant in question
|
822
832
|
* @event
|
823
833
|
*/
|
824
|
-
|
834
|
+
Client.participantLeft = "participantLeft";
|
825
835
|
/**
|
826
836
|
* Fired when a participant's fields have been updated.
|
827
837
|
*
|
@@ -833,7 +843,7 @@ exports.Client.participantLeft = "participantLeft";
|
|
833
843
|
* for the update
|
834
844
|
* @event
|
835
845
|
*/
|
836
|
-
|
846
|
+
Client.participantUpdated = "participantUpdated";
|
837
847
|
/**
|
838
848
|
* Fired when a new message has been added to the conversation on the server.
|
839
849
|
*
|
@@ -841,7 +851,7 @@ exports.Client.participantUpdated = "participantUpdated";
|
|
841
851
|
* 1. {@link Message} `message` - the message in question
|
842
852
|
* @event
|
843
853
|
*/
|
844
|
-
|
854
|
+
Client.messageAdded = "messageAdded";
|
845
855
|
/**
|
846
856
|
* Fired when a message is removed from the message list of a conversation.
|
847
857
|
*
|
@@ -849,7 +859,7 @@ exports.Client.messageAdded = "messageAdded";
|
|
849
859
|
* 1. {@link Message} `message` - the message in question
|
850
860
|
* @event
|
851
861
|
*/
|
852
|
-
|
862
|
+
Client.messageRemoved = "messageRemoved";
|
853
863
|
/**
|
854
864
|
* Fired when the fields of an existing message are updated with new values.
|
855
865
|
*
|
@@ -861,17 +871,17 @@ exports.Client.messageRemoved = "messageRemoved";
|
|
861
871
|
* the update
|
862
872
|
* @event
|
863
873
|
*/
|
864
|
-
|
874
|
+
Client.messageUpdated = "messageUpdated";
|
865
875
|
/**
|
866
876
|
* Fired when the token is about to expire and needs to be updated.
|
867
877
|
* @event
|
868
878
|
*/
|
869
|
-
|
879
|
+
Client.tokenAboutToExpire = "tokenAboutToExpire";
|
870
880
|
/**
|
871
881
|
* Fired when the token has expired.
|
872
882
|
* @event
|
873
883
|
*/
|
874
|
-
|
884
|
+
Client.tokenExpired = "tokenExpired";
|
875
885
|
/**
|
876
886
|
* Fired when a participant has stopped typing.
|
877
887
|
*
|
@@ -879,7 +889,7 @@ exports.Client.tokenExpired = "tokenExpired";
|
|
879
889
|
* 1. {@link Participant} `participant` - the participant in question
|
880
890
|
* @event
|
881
891
|
*/
|
882
|
-
|
892
|
+
Client.typingEnded = "typingEnded";
|
883
893
|
/**
|
884
894
|
* Fired when a participant has started typing.
|
885
895
|
*
|
@@ -887,7 +897,7 @@ exports.Client.typingEnded = "typingEnded";
|
|
887
897
|
* 1. {@link Participant} `participant` - the participant in question
|
888
898
|
* @event
|
889
899
|
*/
|
890
|
-
|
900
|
+
Client.typingStarted = "typingStarted";
|
891
901
|
/**
|
892
902
|
* Fired when the client has received (and parsed) a push notification via one
|
893
903
|
* of the push channels (apn or fcm).
|
@@ -897,7 +907,7 @@ exports.Client.typingStarted = "typingStarted";
|
|
897
907
|
* question
|
898
908
|
* @event
|
899
909
|
*/
|
900
|
-
|
910
|
+
Client.pushNotification = "pushNotification";
|
901
911
|
/**
|
902
912
|
* Fired when the client has subscribed to a user.
|
903
913
|
*
|
@@ -905,7 +915,7 @@ exports.Client.pushNotification = "pushNotification";
|
|
905
915
|
* 1. {@link User} `user` - the user in question
|
906
916
|
* @event
|
907
917
|
*/
|
908
|
-
|
918
|
+
Client.userSubscribed = "userSubscribed";
|
909
919
|
/**
|
910
920
|
* Fired when the client has unsubscribed from a user.
|
911
921
|
*
|
@@ -913,7 +923,7 @@ exports.Client.userSubscribed = "userSubscribed";
|
|
913
923
|
* 1. {@link User} `user` - the user in question
|
914
924
|
* @event
|
915
925
|
*/
|
916
|
-
|
926
|
+
Client.userUnsubscribed = "userUnsubscribed";
|
917
927
|
/**
|
918
928
|
* Fired when the properties or the reachability status of a user have been
|
919
929
|
* updated.
|
@@ -926,7 +936,7 @@ exports.Client.userUnsubscribed = "userUnsubscribed";
|
|
926
936
|
* update
|
927
937
|
* @event
|
928
938
|
*/
|
929
|
-
|
939
|
+
Client.userUpdated = "userUpdated";
|
930
940
|
/**
|
931
941
|
* @deprecated Use initialized or initFailed events instead
|
932
942
|
* Fired when the state of the client has been changed.
|
@@ -935,12 +945,12 @@ exports.Client.userUpdated = "userUpdated";
|
|
935
945
|
* 1. {@link State} `state` - the new client state
|
936
946
|
* @event
|
937
947
|
*/
|
938
|
-
|
948
|
+
Client.stateChanged = "stateChanged";
|
939
949
|
/**
|
940
950
|
* Fired when the client has completed initialization successfully.
|
941
951
|
* @event
|
942
952
|
*/
|
943
|
-
|
953
|
+
Client.initialized = "initialized";
|
944
954
|
/**
|
945
955
|
* Fired when the client initialization failed.
|
946
956
|
*
|
@@ -950,7 +960,7 @@ exports.Client.initialized = "initialized";
|
|
950
960
|
* * Error? `error` - the initialization error if present
|
951
961
|
* @event
|
952
962
|
*/
|
953
|
-
|
963
|
+
Client.initFailed = "initFailed";
|
954
964
|
/**
|
955
965
|
* Fired when the connection state of the client has been changed.
|
956
966
|
*
|
@@ -958,7 +968,7 @@ exports.Client.initFailed = "initFailed";
|
|
958
968
|
* 1. {@link ConnectionState} `state` - the new connection state
|
959
969
|
* @event
|
960
970
|
*/
|
961
|
-
|
971
|
+
Client.connectionStateChanged = "connectionStateChanged";
|
962
972
|
/**
|
963
973
|
* Fired when the connection is interrupted for an unexpected reason.
|
964
974
|
*
|
@@ -971,26 +981,26 @@ exports.Client.connectionStateChanged = "connectionStateChanged";
|
|
971
981
|
* * number? `errorCode` - Twilio public error code if available
|
972
982
|
* @event
|
973
983
|
*/
|
974
|
-
|
984
|
+
Client.connectionError = "connectionError";
|
975
985
|
/**
|
976
986
|
* Current version of the Conversations client.
|
977
987
|
*/
|
978
|
-
|
988
|
+
Client.version = version;
|
979
989
|
/**
|
980
990
|
* Logger instance.
|
981
991
|
*/
|
982
|
-
|
992
|
+
Client._logger = Logger.scope("Client");
|
983
993
|
/**
|
984
994
|
* Supported push notification channels.
|
985
995
|
*/
|
986
|
-
|
996
|
+
Client._supportedPushChannels = [
|
987
997
|
"fcm",
|
988
998
|
"apn",
|
989
999
|
];
|
990
1000
|
/**
|
991
1001
|
* Supported push data fields.
|
992
1002
|
*/
|
993
|
-
|
1003
|
+
Client._supportedPushDataFields = {
|
994
1004
|
conversation_sid: "conversationSid",
|
995
1005
|
conversation_title: "conversationTitle",
|
996
1006
|
message_sid: "messageSid",
|
@@ -998,72 +1008,111 @@ exports.Client._supportedPushDataFields = {
|
|
998
1008
|
media_count: "mediaCount",
|
999
1009
|
media: "media", // object
|
1000
1010
|
};
|
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
|
-
|
1011
|
+
__decorate([
|
1012
|
+
deprecated("token"),
|
1013
|
+
__metadata("design:type", String),
|
1014
|
+
__metadata("design:paramtypes", [])
|
1015
|
+
], Client.prototype, "token", null);
|
1016
|
+
__decorate([
|
1017
|
+
validateTypesAsync(nonEmptyString),
|
1018
|
+
__metadata("design:type", Function),
|
1019
|
+
__metadata("design:paramtypes", [String]),
|
1020
|
+
__metadata("design:returntype", Promise)
|
1021
|
+
], Client.prototype, "updateToken", null);
|
1022
|
+
__decorate([
|
1023
|
+
validateTypesAsync(nonEmptyString),
|
1024
|
+
__metadata("design:type", Function),
|
1025
|
+
__metadata("design:paramtypes", [String]),
|
1026
|
+
__metadata("design:returntype", Promise)
|
1027
|
+
], Client.prototype, "getConversationBySid", null);
|
1028
|
+
__decorate([
|
1029
|
+
validateTypesAsync(nonEmptyString),
|
1030
|
+
__metadata("design:type", Function),
|
1031
|
+
__metadata("design:paramtypes", [String]),
|
1032
|
+
__metadata("design:returntype", Promise)
|
1033
|
+
], Client.prototype, "peekConversationBySid", null);
|
1034
|
+
__decorate([
|
1035
|
+
validateTypesAsync(nonEmptyString),
|
1036
|
+
__metadata("design:type", Function),
|
1037
|
+
__metadata("design:paramtypes", [String]),
|
1038
|
+
__metadata("design:returntype", Promise)
|
1039
|
+
], Client.prototype, "getConversationByUniqueName", null);
|
1040
|
+
__decorate([
|
1041
|
+
validateTypesAsync([
|
1032
1042
|
"undefined",
|
1033
|
-
|
1043
|
+
objectSchema("conversation options", {
|
1034
1044
|
friendlyName: ["string", "undefined"],
|
1035
1045
|
isPrivate: ["boolean", "undefined"],
|
1036
1046
|
uniqueName: ["string", "undefined"],
|
1037
1047
|
}),
|
1038
1048
|
]),
|
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
|
-
],
|
1049
|
+
__metadata("design:type", Function),
|
1050
|
+
__metadata("design:paramtypes", [Object]),
|
1051
|
+
__metadata("design:returntype", Promise)
|
1052
|
+
], Client.prototype, "createConversation", null);
|
1053
|
+
__decorate([
|
1054
|
+
validateTypesAsync(literal("fcm", "apn"), "string"),
|
1055
|
+
__metadata("design:type", Function),
|
1056
|
+
__metadata("design:paramtypes", [String, String]),
|
1057
|
+
__metadata("design:returntype", Promise)
|
1058
|
+
], Client.prototype, "setPushRegistrationId", null);
|
1059
|
+
__decorate([
|
1060
|
+
validateTypesAsync(literal("fcm", "apn")),
|
1061
|
+
__metadata("design:type", Function),
|
1062
|
+
__metadata("design:paramtypes", [String]),
|
1063
|
+
__metadata("design:returntype", Promise)
|
1064
|
+
], Client.prototype, "unsetPushRegistrationId", null);
|
1065
|
+
__decorate([
|
1066
|
+
validateTypesAsync(literal("fcm", "apn"), nonEmptyString),
|
1067
|
+
__metadata("design:type", Function),
|
1068
|
+
__metadata("design:paramtypes", [String, String]),
|
1069
|
+
__metadata("design:returntype", Promise)
|
1070
|
+
], Client.prototype, "removePushRegistrations", null);
|
1071
|
+
__decorate([
|
1072
|
+
validateTypesAsync(pureObject),
|
1073
|
+
__metadata("design:type", Function),
|
1074
|
+
__metadata("design:paramtypes", [Object]),
|
1075
|
+
__metadata("design:returntype", Promise)
|
1076
|
+
], Client.prototype, "handlePushNotification", null);
|
1077
|
+
__decorate([
|
1078
|
+
validateTypesAsync(nonEmptyString),
|
1079
|
+
__metadata("design:type", Function),
|
1080
|
+
__metadata("design:paramtypes", [String]),
|
1081
|
+
__metadata("design:returntype", Promise)
|
1082
|
+
], Client.prototype, "getUser", null);
|
1083
|
+
__decorate([
|
1084
|
+
validateTypesAsync(nonEmptyArray("strings", "string")),
|
1085
|
+
__metadata("design:type", Function),
|
1086
|
+
__metadata("design:paramtypes", [Array]),
|
1087
|
+
__metadata("design:returntype", CancellablePromise)
|
1088
|
+
], Client.prototype, "getTemporaryContentUrlsForMediaSids", null);
|
1089
|
+
__decorate([
|
1090
|
+
validateTypesAsync(nonEmptyArray("media", Media)),
|
1091
|
+
__metadata("design:type", Function),
|
1092
|
+
__metadata("design:paramtypes", [Array]),
|
1093
|
+
__metadata("design:returntype", CancellablePromise)
|
1094
|
+
], Client.prototype, "getTemporaryContentUrlsForMedia", null);
|
1095
|
+
__decorate([
|
1096
|
+
deprecated("Client.create()", "new Client()"),
|
1097
|
+
validateTypesAsync("string", ["undefined", pureObject]),
|
1098
|
+
__metadata("design:type", Function),
|
1099
|
+
__metadata("design:paramtypes", [String, Object]),
|
1100
|
+
__metadata("design:returntype", Promise)
|
1101
|
+
], Client, "create", null);
|
1102
|
+
__decorate([
|
1103
|
+
validateTypes(pureObject),
|
1104
|
+
__metadata("design:type", Function),
|
1105
|
+
__metadata("design:paramtypes", [Object]),
|
1106
|
+
__metadata("design:returntype", PushNotification)
|
1107
|
+
], Client, "parsePushNotification", null);
|
1108
|
+
Client = Client_1 = __decorate([
|
1109
|
+
validateConstructorTypes(nonEmptyString, [pureObject, "undefined"]),
|
1110
|
+
__metadata("design:paramtypes", [String, Object])
|
1111
|
+
], Client);
|
1112
|
+
|
1113
|
+
export { Client };
|
1114
|
+
//# sourceMappingURL=client.js.map
|
1115
|
+
rts.Client.prototype, "handlePushNotification", null);
|
1067
1116
|
tslib_es6.__decorate([
|
1068
1117
|
declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
|
1069
1118
|
tslib_es6.__metadata("design:type", Function),
|