@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.
Files changed (80) hide show
  1. package/README.md +2 -2
  2. package/builds/browser.esm.js +10713 -0
  3. package/builds/browser.esm.js.map +1 -0
  4. package/builds/browser.js +158 -1
  5. package/builds/browser.js.map +1 -1
  6. package/builds/lib.esm.d.ts +3166 -0
  7. package/builds/lib.esm.js +10712 -0
  8. package/builds/lib.js +167 -1
  9. package/builds/lib.js.map +1 -1
  10. package/builds/twilio-conversations.js +309 -322
  11. package/builds/twilio-conversations.min.js +1 -1
  12. package/dist/aggregated-delivery-receipt.js +3 -5
  13. package/dist/aggregated-delivery-receipt.js.map +1 -1
  14. package/dist/channel-metadata-client.js +7 -9
  15. package/dist/channel-metadata-client.js.map +1 -1
  16. package/dist/client.js +189 -154
  17. package/dist/client.js.map +1 -1
  18. package/dist/command-executor.js +8 -8
  19. package/dist/command-executor.js.map +1 -1
  20. package/dist/configuration.js +12 -9
  21. package/dist/configuration.js.map +1 -1
  22. package/dist/content-client.js +11 -8
  23. package/dist/content-client.js.map +1 -1
  24. package/dist/content-template.js +3 -5
  25. package/dist/content-template.js.map +1 -1
  26. package/dist/conversation.js +113 -87
  27. package/dist/conversation.js.map +1 -1
  28. package/dist/data/conversations.js +34 -42
  29. package/dist/data/conversations.js.map +1 -1
  30. package/dist/data/messages.js +23 -21
  31. package/dist/data/messages.js.map +1 -1
  32. package/dist/data/participants.js +25 -23
  33. package/dist/data/participants.js.map +1 -1
  34. package/dist/data/users.js +15 -13
  35. package/dist/data/users.js.map +1 -1
  36. package/dist/detailed-delivery-receipt.js +3 -5
  37. package/dist/detailed-delivery-receipt.js.map +1 -1
  38. package/dist/index.js +17 -49
  39. package/dist/index.js.map +1 -1
  40. package/dist/interfaces/notification-types.js +1 -5
  41. package/dist/interfaces/notification-types.js.map +1 -1
  42. package/dist/interfaces/rules.js +13 -10
  43. package/dist/interfaces/rules.js.map +1 -1
  44. package/dist/logger.js +25 -26
  45. package/dist/logger.js.map +1 -1
  46. package/dist/media.js +11 -8
  47. package/dist/media.js.map +1 -1
  48. package/dist/message-builder.js +48 -40
  49. package/dist/message-builder.js.map +1 -1
  50. package/dist/message-recipients-client.js +10 -12
  51. package/dist/message-recipients-client.js.map +1 -1
  52. package/dist/message.js +88 -75
  53. package/dist/message.js.map +1 -1
  54. package/dist/node_modules/quick-lru/index.js +1 -5
  55. package/dist/node_modules/quick-lru/index.js.map +1 -1
  56. package/dist/node_modules/tslib/tslib.es6.js +1 -7
  57. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  58. package/dist/packages/conversations/package.json.js +2 -6
  59. package/dist/packages/conversations/package.json.js.map +1 -1
  60. package/dist/participant.js +34 -29
  61. package/dist/participant.js.map +1 -1
  62. package/dist/push-notification.js +5 -4
  63. package/dist/push-notification.js.map +1 -1
  64. package/dist/rest-paginator.js +6 -4
  65. package/dist/rest-paginator.js.map +1 -1
  66. package/dist/services/network.js +3 -7
  67. package/dist/services/network.js.map +1 -1
  68. package/dist/services/typing-indicator.js +11 -8
  69. package/dist/services/typing-indicator.js.map +1 -1
  70. package/dist/unsent-message.js +9 -8
  71. package/dist/unsent-message.js.map +1 -1
  72. package/dist/user.js +27 -24
  73. package/dist/user.js.map +1 -1
  74. package/dist/util/deferred.js +6 -4
  75. package/dist/util/deferred.js.map +1 -1
  76. package/dist/util/index.js +1 -9
  77. package/dist/util/index.js.map +1 -1
  78. package/docs/index.html +3 -3
  79. package/docs/modules.html +2 -2
  80. 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
- Object.defineProperty(exports, '__esModule', { value: true });
141
-
142
- var tslib_es6 = require('./node_modules/tslib/tslib.es6.js');
143
- var logger = require('./logger.js');
144
- var configuration = require('./configuration.js');
145
- var user = require('./user.js');
146
- var network = require('./services/network.js');
147
- var notificationTypes = require('./interfaces/notification-types.js');
148
- var twilsock = require('twilsock');
149
- var notifications = require('@twilio/notifications');
150
- var twilioSync = require('twilio-sync');
151
- var mcsClient = require('@twilio/mcs-client');
152
- var conversations = require('./data/conversations.js');
153
- var users = require('./data/users.js');
154
- var typingIndicator = require('./services/typing-indicator.js');
155
- var pushNotification = require('./push-notification.js');
156
- var index = require('./util/index.js');
157
- var declarativeTypeValidator = require('@twilio/declarative-type-validator');
158
- var _package = require('./packages/conversations/package.json.js');
159
- var commandExecutor = require('./command-executor.js');
160
- var replayEventEmitter = require('@twilio/replay-event-emitter');
161
- var media = require('./media.js');
162
- var deprecationDecorator = require('@twilio/deprecation-decorator');
163
- var contentClient = require('./content-client.js');
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
- exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventEmitter {
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 = _package.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 = index.deepClone(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 = _package.version;
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 user.User("", "", null, this._services);
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 twilsock.InitRegistration(productId);
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 twilsock.TwilsockClient(fpaToken, productId, this._options);
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 notifications.Notifications(fpaToken, this._options);
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 twilioSync.SyncClient(fpaToken, this._options);
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 commandExecutor.CommandExecutor(baseUrl, { transport: this._options.transport }, productId);
272
- this._services.contentClient = new contentClient.ContentClient(this._services);
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 twilsock.TelemetryEventDescription(startupEvent, "Conversations client startup", new Date()), startupEvent, twilsock.TelemetryPoint.Start);
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 twilsock.TelemetryEventDescription("", "", new Date()), startupEvent, twilsock.TelemetryPoint.End);
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 pushNotification.PushNotification({
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 pushNotification.PushNotification({
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 = index.parseToNumber(value);
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([notificationTypes.NotificationTypes.TYPING_INDICATOR]);
472
- twilioSync.SyncClient.populateInitRegistrations(reg);
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
- deprecationDecorator.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");
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 mcsClient.CancellablePromise(async (resolve, reject, onCancel) => {
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 configuration.Configuration(this._options, configurationResponse, Client_1._logger);
676
- this._services.channelMetadataClient = new channelMetadataClient.ChannelMetadataClient(this._services, this._configuration);
677
- this._services.messageRecipientsClient = new messageRecipientsClient.MessageRecipientsClient(this._services, this._configuration);
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 typingIndicator.TypingIndicator(this.getConversationBySid.bind(this), this._configuration, this._services);
680
- this._services.network = new network.Network(this._configuration, this._services);
681
- this._services.users = new users.Users(this._myself, this._configuration, this._services);
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 conversations.Conversations(this._configuration, this._services);
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 mcsClient.McsClient(this._fpaToken, this._configuration.links.mediaService, this._configuration.links.mediaSetService, Object.assign(Object.assign({}, this._options), { transport: undefined }));
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
- notificationTypes.NotificationTypes.NEW_MESSAGE,
736
- notificationTypes.NotificationTypes.ADDED_TO_CONVERSATION,
737
- notificationTypes.NotificationTypes.REMOVED_FROM_CONVERSATION,
738
- notificationTypes.NotificationTypes.TYPING_INDICATOR,
739
- notificationTypes.NotificationTypes.CONSUMPTION_UPDATE,
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
- notificationTypes.NotificationTypes.NEW_MESSAGE,
751
- notificationTypes.NotificationTypes.ADDED_TO_CONVERSATION,
752
- notificationTypes.NotificationTypes.REMOVED_FROM_CONVERSATION,
753
- notificationTypes.NotificationTypes.TYPING_INDICATOR,
754
- notificationTypes.NotificationTypes.CONSUMPTION_UPDATE,
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
- exports.Client.conversationAdded = "conversationAdded";
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
- exports.Client.conversationJoined = "conversationJoined";
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
- exports.Client.conversationLeft = "conversationLeft";
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
- exports.Client.conversationRemoved = "conversationRemoved";
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
- exports.Client.conversationUpdated = "conversationUpdated";
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
- exports.Client.participantJoined = "participantJoined";
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
- exports.Client.participantLeft = "participantLeft";
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
- exports.Client.participantUpdated = "participantUpdated";
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
- exports.Client.messageAdded = "messageAdded";
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
- exports.Client.messageRemoved = "messageRemoved";
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
- exports.Client.messageUpdated = "messageUpdated";
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
- exports.Client.tokenAboutToExpire = "tokenAboutToExpire";
865
+ Client.tokenAboutToExpire = "tokenAboutToExpire";
870
866
  /**
871
867
  * Fired when the token has expired.
872
868
  * @event
873
869
  */
874
- exports.Client.tokenExpired = "tokenExpired";
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
- exports.Client.typingEnded = "typingEnded";
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
- exports.Client.typingStarted = "typingStarted";
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
- exports.Client.pushNotification = "pushNotification";
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
- exports.Client.userSubscribed = "userSubscribed";
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
- exports.Client.userUnsubscribed = "userUnsubscribed";
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
- exports.Client.userUpdated = "userUpdated";
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
- exports.Client.stateChanged = "stateChanged";
934
+ Client.stateChanged = "stateChanged";
939
935
  /**
940
936
  * Fired when the client has completed initialization successfully.
941
937
  * @event
942
938
  */
943
- exports.Client.initialized = "initialized";
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
- exports.Client.initFailed = "initFailed";
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
- exports.Client.connectionStateChanged = "connectionStateChanged";
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
- exports.Client.connectionError = "connectionError";
970
+ Client.connectionError = "connectionError";
975
971
  /**
976
972
  * Current version of the Conversations client.
977
973
  */
978
- exports.Client.version = _package.version;
974
+ Client.version = version;
979
975
  /**
980
976
  * Logger instance.
981
977
  */
982
- exports.Client._logger = logger.Logger.scope("Client");
978
+ Client._logger = Logger.scope("Client");
983
979
  /**
984
980
  * Supported push notification channels.
985
981
  */
986
- exports.Client._supportedPushChannels = [
982
+ Client._supportedPushChannels = [
987
983
  "fcm",
988
984
  "apn",
989
985
  ];
990
986
  /**
991
987
  * Supported push data fields.
992
988
  */
993
- exports.Client._supportedPushDataFields = {
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
- tslib_es6.__decorate([
1002
- deprecationDecorator.deprecated("token"),
1003
- tslib_es6.__metadata("design:type", String),
1004
- tslib_es6.__metadata("design:paramtypes", [])
1005
- ], exports.Client.prototype, "token", null);
1006
- tslib_es6.__decorate([
1007
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
1008
- tslib_es6.__metadata("design:type", Function),
1009
- tslib_es6.__metadata("design:paramtypes", [String]),
1010
- tslib_es6.__metadata("design:returntype", Promise)
1011
- ], exports.Client.prototype, "updateToken", null);
1012
- tslib_es6.__decorate([
1013
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
1014
- tslib_es6.__metadata("design:type", Function),
1015
- tslib_es6.__metadata("design:paramtypes", [String]),
1016
- tslib_es6.__metadata("design:returntype", Promise)
1017
- ], exports.Client.prototype, "getConversationBySid", null);
1018
- tslib_es6.__decorate([
1019
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
1020
- tslib_es6.__metadata("design:type", Function),
1021
- tslib_es6.__metadata("design:paramtypes", [String]),
1022
- tslib_es6.__metadata("design:returntype", Promise)
1023
- ], exports.Client.prototype, "peekConversationBySid", null);
1024
- tslib_es6.__decorate([
1025
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
1026
- tslib_es6.__metadata("design:type", Function),
1027
- tslib_es6.__metadata("design:paramtypes", [String]),
1028
- tslib_es6.__metadata("design:returntype", Promise)
1029
- ], exports.Client.prototype, "getConversationByUniqueName", null);
1030
- tslib_es6.__decorate([
1031
- declarativeTypeValidator.validateTypesAsync([
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
- declarativeTypeValidator.objectSchema("conversation options", {
1029
+ objectSchema("conversation options", {
1034
1030
  friendlyName: ["string", "undefined"],
1035
1031
  isPrivate: ["boolean", "undefined"],
1036
1032
  uniqueName: ["string", "undefined"],
1037
1033
  }),
1038
1034
  ]),
1039
- tslib_es6.__metadata("design:type", Function),
1040
- tslib_es6.__metadata("design:paramtypes", [Object]),
1041
- tslib_es6.__metadata("design:returntype", Promise)
1042
- ], exports.Client.prototype, "createConversation", null);
1043
- tslib_es6.__decorate([
1044
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("fcm", "apn"), "string"),
1045
- tslib_es6.__metadata("design:type", Function),
1046
- tslib_es6.__metadata("design:paramtypes", [String, String]),
1047
- tslib_es6.__metadata("design:returntype", Promise)
1048
- ], exports.Client.prototype, "setPushRegistrationId", null);
1049
- tslib_es6.__decorate([
1050
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("fcm", "apn")),
1051
- tslib_es6.__metadata("design:type", Function),
1052
- tslib_es6.__metadata("design:paramtypes", [String]),
1053
- tslib_es6.__metadata("design:returntype", Promise)
1054
- ], exports.Client.prototype, "unsetPushRegistrationId", null);
1055
- tslib_es6.__decorate([
1056
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("fcm", "apn"), declarativeTypeValidator.nonEmptyString),
1057
- tslib_es6.__metadata("design:type", Function),
1058
- tslib_es6.__metadata("design:paramtypes", [String, String]),
1059
- tslib_es6.__metadata("design:returntype", Promise)
1060
- ], exports.Client.prototype, "removePushRegistrations", null);
1061
- tslib_es6.__decorate([
1062
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.pureObject),
1063
- tslib_es6.__metadata("design:type", Function),
1064
- tslib_es6.__metadata("design:paramtypes", [Object]),
1065
- tslib_es6.__metadata("design:returntype", Promise)
1066
- ], exports.Client.prototype, "handlePushNotification", null);
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),