@twilio/conversations 2.1.0-rc.8 → 3.0.0-canary.5

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 (72) hide show
  1. package/README.md +7 -3
  2. package/builds/browser.js +2350 -1627
  3. package/builds/browser.js.map +1 -1
  4. package/builds/lib.d.ts +512 -304
  5. package/builds/lib.js +2350 -1627
  6. package/builds/lib.js.map +1 -1
  7. package/builds/twilio-conversations.js +3448 -3403
  8. package/builds/twilio-conversations.min.js +2 -2
  9. package/dist/client.js +402 -281
  10. package/dist/client.js.map +1 -1
  11. package/dist/command-executor.js.map +1 -1
  12. package/dist/configuration.js +2 -2
  13. package/dist/configuration.js.map +1 -1
  14. package/dist/conversation.js +408 -373
  15. package/dist/conversation.js.map +1 -1
  16. package/dist/data/conversations.js +9 -10
  17. package/dist/data/conversations.js.map +1 -1
  18. package/dist/data/messages.js +46 -26
  19. package/dist/data/messages.js.map +1 -1
  20. package/dist/data/participants.js +19 -10
  21. package/dist/data/participants.js.map +1 -1
  22. package/dist/data/users.js +2 -2
  23. package/dist/data/users.js.map +1 -1
  24. package/dist/media.js +36 -25
  25. package/dist/media.js.map +1 -1
  26. package/dist/message-builder.js +24 -18
  27. package/dist/message-builder.js.map +1 -1
  28. package/dist/message.js +46 -19
  29. package/dist/message.js.map +1 -1
  30. package/dist/packages/conversations/package.json.js +1 -1
  31. package/dist/participant.js.map +1 -1
  32. package/dist/push-notification.js.map +1 -1
  33. package/dist/services/typing-indicator.js +1 -1
  34. package/dist/services/typing-indicator.js.map +1 -1
  35. package/dist/unsent-message.js +13 -3
  36. package/dist/unsent-message.js.map +1 -1
  37. package/package.json +12 -10
  38. package/CHANGELOG.md +0 -404
  39. package/docs/assets/css/main.css +0 -2660
  40. package/docs/assets/images/icons.png +0 -0
  41. package/docs/assets/images/icons@2x.png +0 -0
  42. package/docs/assets/images/widgets.png +0 -0
  43. package/docs/assets/images/widgets@2x.png +0 -0
  44. package/docs/assets/js/main.js +0 -248
  45. package/docs/assets/js/search.js +0 -1
  46. package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
  47. package/docs/classes/Client.html +0 -4073
  48. package/docs/classes/Conversation.html +0 -4302
  49. package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
  50. package/docs/classes/Media.html +0 -3193
  51. package/docs/classes/Message.html +0 -3677
  52. package/docs/classes/MessageBuilder.html +0 -3254
  53. package/docs/classes/Participant.html +0 -3444
  54. package/docs/classes/PushNotification.html +0 -3130
  55. package/docs/classes/RestPaginator.html +0 -3160
  56. package/docs/classes/UnsentMessage.html +0 -3042
  57. package/docs/classes/User.html +0 -3349
  58. package/docs/index.html +0 -3512
  59. package/docs/interfaces/ClientOptions.html +0 -3034
  60. package/docs/interfaces/ConversationBindings.html +0 -3001
  61. package/docs/interfaces/ConversationEmailBinding.html +0 -3001
  62. package/docs/interfaces/ConversationLimits.html +0 -3098
  63. package/docs/interfaces/ConversationState.html +0 -3050
  64. package/docs/interfaces/CreateConversationOptions.html +0 -3066
  65. package/docs/interfaces/LastMessage.html +0 -3050
  66. package/docs/interfaces/Paginator.html +0 -3141
  67. package/docs/interfaces/ParticipantBindings.html +0 -3001
  68. package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
  69. package/docs/interfaces/PushNotificationData.html +0 -3066
  70. package/docs/interfaces/SendEmailOptions.html +0 -3034
  71. package/docs/interfaces/SendMediaOptions.html +0 -3068
  72. package/docs/modules.html +0 -3513
package/dist/client.js CHANGED
@@ -151,8 +151,9 @@ var commandExecutor = require('./command-executor.js');
151
151
  var replayEventEmitter = require('@twilio/replay-event-emitter');
152
152
 
153
153
  var Client_1;
154
- const log = logger.Logger.scope("Client");
155
- const SDK_VERSION = _package.version;
154
+ /**
155
+ * Client services.
156
+ */
156
157
  class ClientServices {
157
158
  }
158
159
  /**
@@ -160,9 +161,11 @@ class ClientServices {
160
161
  */
161
162
  exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventEmitter {
162
163
  /**
163
- * Returned Conversations instance is not yet fully initialized. Calling any operations will block until it is.
164
- * Use connection events to monitor when client becomes fully available (connectionStateChanged with state
165
- * 'connected') or not available (connectionStateChange with state 'denied', event tokenExpired, event connectionError).
164
+ * Returned Conversations instance is not yet fully initialized. Calling any
165
+ * operations will block until it is. Use connection events to monitor when
166
+ * client becomes fully available (connectionStateChanged with state
167
+ * 'connected') or not available (connectionStateChange with state 'denied',
168
+ * event tokenExpired, event connectionError).
166
169
  *
167
170
  * @param fpaToken Access token
168
171
  * @param options Options to customize the Client
@@ -171,6 +174,10 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
171
174
  constructor(fpaToken, options = {}) {
172
175
  var _a, _b, _c, _d, _e;
173
176
  super();
177
+ /**
178
+ * Current version of the Conversations client.
179
+ */
180
+ this.version = _package.version;
174
181
  /**
175
182
  * Client connection state.
176
183
  */
@@ -178,98 +185,96 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
178
185
  /**
179
186
  * Current version of the Conversations client.
180
187
  */
181
- this.version = SDK_VERSION;
182
188
  this.parsePushNotification = Client_1.parsePushNotification;
183
- this.fpaToken = fpaToken !== null && fpaToken !== void 0 ? fpaToken : "";
184
- this.options = options !== null && options !== void 0 ? options : {};
185
- if (!this.options.disableDeepClone) {
186
- let options = Object.assign(Object.assign({}, this.options), { transport: undefined, twilsockClient: undefined });
189
+ this._fpaToken = fpaToken !== null && fpaToken !== void 0 ? fpaToken : "";
190
+ this._options = options !== null && options !== void 0 ? options : {};
191
+ if (!this._options.disableDeepClone) {
192
+ let options = Object.assign(Object.assign({}, this._options), { transport: undefined, twilsockClient: undefined });
187
193
  options = index.deepClone(options);
188
- options.transport = this.options.transport;
189
- options.twilsockClient = this.options.twilsockClient;
190
- this.options = options;
194
+ options.transport = this._options.transport;
195
+ options.twilsockClient = this._options.twilsockClient;
196
+ this._options = options;
191
197
  }
192
- this.options.logLevel = (_a = this.options.logLevel) !== null && _a !== void 0 ? _a : "silent";
193
- log.setLevel(this.options.logLevel);
194
- const productId = (this.options.productId = "ip_messaging");
198
+ this._options.logLevel = (_a = this._options.logLevel) !== null && _a !== void 0 ? _a : "silent";
199
+ Client_1._logger.setLevel(this._options.logLevel);
200
+ const productId = (this._options.productId = "ip_messaging");
195
201
  // Filling ClientMetadata
196
- this.options.clientMetadata = this.options.clientMetadata || {};
197
- if (!this.options.clientMetadata.hasOwnProperty("type")) {
198
- this.options.clientMetadata.type = "conversations";
202
+ this._options.clientMetadata = this._options.clientMetadata || {};
203
+ if (!this._options.clientMetadata.hasOwnProperty("type")) {
204
+ this._options.clientMetadata.type = "conversations";
199
205
  }
200
- if (!this.options.clientMetadata.hasOwnProperty("sdk")) {
201
- this.options.clientMetadata.sdk = "JS";
202
- this.options.clientMetadata.sdkv = SDK_VERSION;
206
+ if (!this._options.clientMetadata.hasOwnProperty("sdk")) {
207
+ this._options.clientMetadata.sdk = "JS";
208
+ this._options.clientMetadata.sdkv = _package.version;
203
209
  }
204
210
  // Enable session local storage for Sync
205
- this.options.Sync = this.options.Sync || {};
206
- if (typeof this.options.Sync.enableSessionStorage === "undefined") {
207
- this.options.Sync.enableSessionStorage = true;
211
+ this._options.Sync = this._options.Sync || {};
212
+ if (typeof this._options.Sync.enableSessionStorage === "undefined") {
213
+ this._options.Sync.enableSessionStorage = true;
208
214
  }
209
- if (this.options.region) {
210
- this.options.Sync.region = this.options.region;
215
+ if (this._options.region) {
216
+ this._options.Sync.region = this._options.region;
211
217
  }
212
218
  if (!fpaToken) {
213
219
  throw new Error("A valid Twilio token should be provided");
214
220
  }
215
- this.services = new ClientServices();
216
- this._myself = new user.User("", "", null, this.services);
217
- const startTwilsock = !this.options.twilsockClient;
221
+ this._services = new ClientServices();
222
+ this._myself = new user.User("", "", null, this._services);
223
+ const startTwilsock = !this._options.twilsockClient;
218
224
  // Create default init registrations if none were provided.
219
225
  // Otherwise, the outside party have to list all the init registrations they
220
226
  // need.
221
227
  // Init registrations passed to the Conversations client will be passed down
222
228
  // to the Sync client as well.
223
- if (!this.options.initRegistrations) {
229
+ if (!this._options.initRegistrations) {
224
230
  const initRegistration = new twilsock.InitRegistration(productId);
225
231
  Client_1.populateInitRegistrations(initRegistration);
226
- this.options.initRegistrations = [initRegistration];
232
+ this._options.initRegistrations = [initRegistration];
227
233
  }
228
- this.services.twilsockClient = this.options.twilsockClient =
229
- (_b = this.options.twilsockClient) !== null && _b !== void 0 ? _b : new twilsock.TwilsockClient(fpaToken, productId, this.options);
230
- this.services.twilsockClient.on("tokenAboutToExpire", (ttl) => this.emit("tokenAboutToExpire", ttl));
231
- this.services.twilsockClient.on("tokenExpired", () => this.emit("tokenExpired"));
232
- this.services.twilsockClient.on("connectionError", (error) => this.emit("connectionError", error));
233
- this.services.twilsockClient.on("stateChanged", (state) => {
234
- log.debug(`Handling stateChanged for ConversationsClient: new state ${state}`);
234
+ this._services.twilsockClient = this._options.twilsockClient =
235
+ (_b = this._options.twilsockClient) !== null && _b !== void 0 ? _b : new twilsock.TwilsockClient(fpaToken, productId, this._options);
236
+ this._services.twilsockClient.on("tokenAboutToExpire", () => this.emit("tokenAboutToExpire"));
237
+ this._services.twilsockClient.on("tokenExpired", () => this.emit("tokenExpired"));
238
+ this._services.twilsockClient.on("connectionError", (error) => this.emit("connectionError", error));
239
+ this._services.twilsockClient.on("stateChanged", (state) => {
240
+ Client_1._logger.debug(`Handling stateChanged for ConversationsClient: new state ${state}`);
235
241
  if (state !== this.connectionState) {
236
242
  this.connectionState = state;
237
243
  this.emit("connectionStateChanged", this.connectionState);
238
244
  }
239
245
  });
240
- this.services.transport = this.options.transport = ((_c = this.options
241
- .transport) !== null && _c !== void 0 ? _c : this.options.twilsockClient);
242
- this.services.notificationClient = this.options.notificationsClient =
243
- (_d = this.options.notificationsClient) !== null && _d !== void 0 ? _d : new notifications.Notifications(fpaToken, this.options);
244
- this.services.syncClient = this.options.syncClient =
245
- (_e = this.options.syncClient) !== null && _e !== void 0 ? _e : new twilioSync.SyncClient(fpaToken, this.options);
246
+ this._services.transport = this._options.transport = ((_c = this._options
247
+ .transport) !== null && _c !== void 0 ? _c : this._options.twilsockClient);
248
+ this._services.notificationClient = this._options.notificationsClient =
249
+ (_d = this._options.notificationsClient) !== null && _d !== void 0 ? _d : new notifications.Notifications(fpaToken, this._options);
250
+ this._services.syncClient = this._options.syncClient =
251
+ (_e = this._options.syncClient) !== null && _e !== void 0 ? _e : new twilioSync.SyncClient(fpaToken, this._options);
246
252
  const configurationOptions = (options === null || options === void 0 ? void 0 : options.Chat) || (options === null || options === void 0 ? void 0 : options.IPMessaging) || options || {};
247
253
  const region = configurationOptions.region || (options === null || options === void 0 ? void 0 : options.region);
248
254
  const baseUrl = configurationOptions.apiUri ||
249
255
  configurationOptions.typingUri ||
250
256
  `https://aim.${region || "us1"}.twilio.com`;
251
- this.services.commandExecutor = new commandExecutor.CommandExecutor(baseUrl, { transport: this.options.transport }, productId);
252
- const emitFailed = (err) => {
253
- this._rejectEnsureReady(err);
254
- this.emit("stateChanged", "failed");
257
+ this._services.commandExecutor = new commandExecutor.CommandExecutor(baseUrl, { transport: this._options.transport }, productId);
258
+ const emitFailed = (error) => {
259
+ this._rejectEnsureReady(error);
260
+ this.emit("stateChanged", { state: "failed", error });
255
261
  };
256
- this.services.twilsockClient.once("connectionError", emitFailed);
257
- this.services.twilsockClient.once("disconnected", emitFailed);
258
- // ConversationsClient will be able to initialize only after twilsock is connected
259
- this.services.twilsockClient.once("connected", async () => {
260
- log.debug(`ConversationsClient started INITIALIZING`);
261
- this.services.twilsockClient.off("connectionError", emitFailed);
262
- this.services.twilsockClient.off("disconnected", emitFailed);
262
+ this._services.twilsockClient.onceWithReplay("connectionError", emitFailed);
263
+ this._services.twilsockClient.onceWithReplay("disconnected", emitFailed);
264
+ this._services.twilsockClient.onceWithReplay("connected", async () => {
265
+ Client_1._logger.debug(`ConversationsClient started INITIALIZING`);
266
+ this._services.twilsockClient.off("connectionError", emitFailed);
267
+ this._services.twilsockClient.off("disconnected", emitFailed);
263
268
  try {
264
269
  const startupEvent = "conversations.client.startup";
265
- this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription(startupEvent, "Conversations client startup", new Date()), startupEvent, twilsock.TelemetryPoint.Start);
270
+ this._services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription(startupEvent, "Conversations client startup", new Date()), startupEvent, twilsock.TelemetryPoint.Start);
266
271
  await this._initialize();
267
- this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription("", "", new Date()), startupEvent, twilsock.TelemetryPoint.End);
272
+ this._services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription("", "", new Date()), startupEvent, twilsock.TelemetryPoint.End);
268
273
  }
269
274
  catch (err) {
270
275
  // Fail ChatClient if initialization is incomplete
271
276
  this._rejectEnsureReady(err);
272
- this.emit("stateChanged", "failed");
277
+ this.emit("stateChanged", { state: "failed", error: err });
273
278
  }
274
279
  });
275
280
  this._ensureReady = new Promise((resolve, reject) => {
@@ -277,12 +282,28 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
277
282
  this._rejectEnsureReady = reject;
278
283
  }).catch(() => void 0); // @todo How to process unhandled rejection here?
279
284
  if (startTwilsock) {
280
- this.services.twilsockClient.connect();
285
+ this._services.twilsockClient.connect();
281
286
  }
282
287
  }
283
- static populateInitRegistrations(reg) {
284
- reg.populateInitRegistrations([notificationTypes.NotificationTypes.TYPING_INDICATOR]);
285
- twilioSync.SyncClient.populateInitRegistrations(reg);
288
+ /**
289
+ * Information of the logged-in user. Before client initialization, returns an
290
+ * uninitialized user. Will trigger a {@link Client.userUpdated} event after
291
+ * initialization.
292
+ */
293
+ get user() {
294
+ return this._myself;
295
+ }
296
+ /**
297
+ * Client reachability state. Throws an error if accessed before the client
298
+ * initialization was completed.
299
+ */
300
+ get reachabilityEnabled() {
301
+ if (!this._configuration) {
302
+ throw new Error("Reachability information could not yet be accessed as the client " +
303
+ "has not yet been initialized. Subscribe to the 'stateChanged' event " +
304
+ "to properly react to the client initialization.");
305
+ }
306
+ return this._configuration.reachabilityEnabled;
286
307
  }
287
308
  /**
288
309
  * @deprecated Call constructor directly.
@@ -320,109 +341,104 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
320
341
  return client;
321
342
  }
322
343
  /**
323
- * Information of the logged-in user. Before client initialization, returns an
324
- * uninitialized user. Will trigger a {@link Client.userUpdated} event after
325
- * initialization.
344
+ * Static method for push notification payload parsing. Returns parsed push as
345
+ * a {@link PushNotification} object.
346
+ * @param notificationPayload Push notification payload.
326
347
  */
327
- get user() {
328
- return this._myself;
348
+ static parsePushNotification(notificationPayload) {
349
+ Client_1._logger.debug("parsePushNotification, notificationPayload=", notificationPayload);
350
+ // APNS specifics
351
+ if (typeof notificationPayload.aps !== "undefined") {
352
+ if (!notificationPayload.twi_message_type) {
353
+ throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
354
+ }
355
+ const data = Client_1._parsePushNotificationChatData(notificationPayload);
356
+ const apsPayload = notificationPayload.aps;
357
+ let body;
358
+ let title = null;
359
+ if (typeof apsPayload.alert === "string") {
360
+ body = apsPayload.alert || null;
361
+ }
362
+ else {
363
+ body = apsPayload.alert.body || null;
364
+ title = apsPayload.alert.title || null;
365
+ }
366
+ return new pushNotification.PushNotification({
367
+ title,
368
+ body,
369
+ sound: apsPayload.sound || null,
370
+ badge: apsPayload.badge || null,
371
+ action: apsPayload.category || null,
372
+ type: notificationPayload.twi_message_type,
373
+ data: data,
374
+ });
375
+ }
376
+ // FCM specifics
377
+ if (typeof notificationPayload.data !== "undefined") {
378
+ const dataPayload = notificationPayload.data;
379
+ if (!dataPayload.twi_message_type) {
380
+ throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
381
+ }
382
+ const data = Client_1._parsePushNotificationChatData(notificationPayload.data);
383
+ return new pushNotification.PushNotification({
384
+ title: dataPayload.twi_title || null,
385
+ body: dataPayload.twi_body || null,
386
+ sound: dataPayload.twi_sound || null,
387
+ badge: null,
388
+ action: dataPayload.twi_action || null,
389
+ type: dataPayload.twi_message_type,
390
+ data: data,
391
+ });
392
+ }
393
+ throw new Error("Provided push notification payload is not Programmable Chat notification");
329
394
  }
330
395
  /**
331
- * Client reachability state. Throws if accessed before the client
332
- * initialization was completed.
396
+ * Static method for parsing push notification chat data.
397
+ * @param data Data to parse
333
398
  */
334
- get reachabilityEnabled() {
335
- if (!this.configuration) {
336
- throw new Error("Reachability information could not yet be accessed as the client " +
337
- "has not yet been initialized. Subscribe to the 'stateChanged' event " +
338
- "to properly react to the client initialization.");
399
+ static _parsePushNotificationChatData(data) {
400
+ const result = {};
401
+ for (const key in Client_1._supportedPushDataFields) {
402
+ const value = data[key];
403
+ if (typeof value === "undefined" || value === null) {
404
+ continue;
405
+ }
406
+ if (key === "message_index" || key === "media_count") {
407
+ const number = index.parseToNumber(value);
408
+ if (number !== null) {
409
+ result[Client_1._supportedPushDataFields[key]] = number;
410
+ }
411
+ continue;
412
+ }
413
+ if (key === "media") {
414
+ if (typeof value === "string") {
415
+ try {
416
+ result[Client_1._supportedPushDataFields[key]] = JSON.parse(value);
417
+ }
418
+ catch (_a) {
419
+ Client_1._logger.debug("Media message notification parsing error");
420
+ }
421
+ }
422
+ continue;
423
+ }
424
+ result[Client_1._supportedPushDataFields[key]] = value;
339
425
  }
340
- return this.configuration.reachabilityEnabled;
341
- }
342
- get token() {
343
- return this.fpaToken;
344
- }
345
- _subscribeToPushNotifications(channelType) {
346
- [
347
- notificationTypes.NotificationTypes.NEW_MESSAGE,
348
- notificationTypes.NotificationTypes.ADDED_TO_CONVERSATION,
349
- notificationTypes.NotificationTypes.REMOVED_FROM_CONVERSATION,
350
- notificationTypes.NotificationTypes.TYPING_INDICATOR,
351
- notificationTypes.NotificationTypes.CONSUMPTION_UPDATE,
352
- ].forEach((messageType) => {
353
- this.services.notificationClient.subscribe(channelType, messageType);
354
- });
355
- }
356
- _unsubscribeFromPushNotifications(channelType) {
357
- [
358
- notificationTypes.NotificationTypes.NEW_MESSAGE,
359
- notificationTypes.NotificationTypes.ADDED_TO_CONVERSATION,
360
- notificationTypes.NotificationTypes.REMOVED_FROM_CONVERSATION,
361
- notificationTypes.NotificationTypes.TYPING_INDICATOR,
362
- notificationTypes.NotificationTypes.CONSUMPTION_UPDATE,
363
- ].forEach((messageType) => {
364
- this.services.notificationClient.unsubscribe(channelType, messageType);
365
- });
426
+ return result;
366
427
  }
367
- async _initialize() {
368
- const configurationResponse = await this.services.commandExecutor.fetchResource("Client/v2/Configuration");
369
- this.configuration = new configuration.Configuration(this.options, configurationResponse, log);
370
- this._myself._resolveInitialization(this.configuration, this.configuration.userIdentity, this.configuration.userInfo, true);
371
- this.services.typingIndicator = new typingIndicator.TypingIndicator(this.getConversationBySid.bind(this), this.configuration, this.services);
372
- this.services.network = new network.Network(this.configuration, this.services);
373
- this.services.users = new users.Users(this._myself, this.configuration, this.services);
374
- this.services.users.on("userSubscribed", (user) => {
375
- this.emit("userSubscribed", user);
376
- });
377
- this.services.users.on("userUpdated", (args) => this.emit("userUpdated", args));
378
- this.services.users.on("userUnsubscribed", (user) => {
379
- this.emit("userUnsubscribed", user);
380
- });
381
- this.conversations = new conversations.Conversations(this.configuration, this.services);
382
- this.conversations.on("conversationAdded", (conversation) => {
383
- this.emit("conversationAdded", conversation);
384
- });
385
- this.conversations.on("conversationRemoved", (conversation) => {
386
- this.emit("conversationRemoved", conversation);
387
- });
388
- this.conversations.on("conversationJoined", (conversation) => {
389
- this.emit("conversationJoined", conversation);
390
- });
391
- this.conversations.on("conversationLeft", (conversation) => {
392
- this.emit("conversationLeft", conversation);
393
- });
394
- this.conversations.on("conversationUpdated", (args) => this.emit("conversationUpdated", args));
395
- this.conversations.on("participantJoined", (participant) => {
396
- this.emit("participantJoined", participant);
397
- });
398
- this.conversations.on("participantLeft", (participant) => {
399
- this.emit("participantLeft", participant);
400
- });
401
- this.conversations.on("participantUpdated", (args) => this.emit("participantUpdated", args));
402
- this.conversations.on("messageAdded", (message) => this.emit("messageAdded", message));
403
- this.conversations.on("messageUpdated", (args) => this.emit("messageUpdated", args));
404
- this.conversations.on("messageRemoved", (message) => this.emit("messageRemoved", message));
405
- this.conversations.on("typingStarted", (participant) => this.emit("typingStarted", participant));
406
- this.conversations.on("typingEnded", (participant) => this.emit("typingEnded", participant));
407
- this.conversationsPromise = this.conversations
408
- .fetchConversations()
409
- .then(() => this.conversations)
410
- .catch((error) => {
411
- throw error;
412
- });
413
- await this.services.users.myself._ensureFetched();
414
- Client_1.supportedPushChannels.forEach((channelType) => this._subscribeToPushNotifications(channelType));
415
- this.services.typingIndicator.initialize();
416
- this.services.mcsClient = new mcsClient.McsClient(this.fpaToken, this.configuration.links.mediaService, this.configuration.links.mediaSetService, Object.assign(Object.assign({}, this.options), { transport: undefined }));
417
- this._resolveEnsureReady();
418
- this.emit("stateChanged", "initialized");
428
+ /**
429
+ * Populate the client with init registrations.
430
+ * @param reg The init registration to populate.
431
+ */
432
+ static populateInitRegistrations(reg) {
433
+ reg.populateInitRegistrations([notificationTypes.NotificationTypes.TYPING_INDICATOR]);
434
+ twilioSync.SyncClient.populateInitRegistrations(reg);
419
435
  }
420
436
  /**
421
437
  * Gracefully shut down the client.
422
438
  */
423
439
  async shutdown() {
424
440
  await this._ensureReady;
425
- await this.services.twilsockClient.disconnect();
441
+ await this._services.twilsockClient.disconnect();
426
442
  }
427
443
  /**
428
444
  * Update the token used by the client and re-register with the Conversations services.
@@ -430,14 +446,14 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
430
446
  */
431
447
  async updateToken(token) {
432
448
  await this._ensureReady;
433
- log.info("updateToken");
434
- if (this.fpaToken === token) {
449
+ Client_1._logger.info("updateToken");
450
+ if (this._fpaToken === token) {
435
451
  return this;
436
452
  }
437
- await this.services.twilsockClient.updateToken(token);
438
- await this.services.notificationClient.updateToken(token);
439
- await this.services.mcsClient.updateToken(token);
440
- this.fpaToken = token;
453
+ await this._services.twilsockClient.updateToken(token);
454
+ await this._services.notificationClient.updateToken(token);
455
+ await this._services.mcsClient.updateToken(token);
456
+ this._fpaToken = token;
441
457
  return this;
442
458
  }
443
459
  /**
@@ -446,11 +462,21 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
446
462
  */
447
463
  async getConversationBySid(conversationSid) {
448
464
  await this._ensureReady;
449
- await this.conversations.myConversationsRead.promise;
450
- let conversation = await this.conversations.getConversation(conversationSid);
465
+ await this._conversationsEntity.myConversationsRead.promise;
466
+ const conversation = await this._conversationsEntity.getConversation(conversationSid);
451
467
  if (!conversation) {
452
- conversation = await this.conversations.peekConversation(conversationSid);
468
+ throw new Error(`Conversation with SID ${conversationSid} is not found.`);
453
469
  }
470
+ return conversation;
471
+ }
472
+ /**
473
+ * Peek a conversation by its SID.
474
+ * @param conversationSid Conversation sid
475
+ * @internal
476
+ */
477
+ async peekConversationBySid(conversationSid) {
478
+ await this._ensureReady;
479
+ const conversation = await this._conversationsEntity.peekConversation(conversationSid);
454
480
  if (!conversation) {
455
481
  throw new Error(`Conversation with SID ${conversationSid} is not found.`);
456
482
  }
@@ -462,8 +488,8 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
462
488
  */
463
489
  async getConversationByUniqueName(uniqueName) {
464
490
  await this._ensureReady;
465
- await this.conversations.myConversationsRead.promise;
466
- const conversation = await this.conversations.getConversationByUniqueName(uniqueName);
491
+ await this._conversationsEntity.myConversationsRead.promise;
492
+ const conversation = await this._conversationsEntity.getConversationByUniqueName(uniqueName);
467
493
  if (!conversation) {
468
494
  throw new Error(`Conversation with unique name ${uniqueName} is not found.`);
469
495
  }
@@ -474,7 +500,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
474
500
  */
475
501
  async getSubscribedConversations() {
476
502
  await this._ensureReady;
477
- return this.conversationsPromise.then((conversations) => conversations.getConversations());
503
+ return this._conversationsPromise.then((conversations) => conversations.getConversations());
478
504
  }
479
505
  /**
480
506
  * Create a conversation on the server and subscribe to its events.
@@ -484,18 +510,19 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
484
510
  async createConversation(options) {
485
511
  await this._ensureReady;
486
512
  options = options || {};
487
- return this.conversationsPromise.then((conversationsEntity) => conversationsEntity.addConversation(options));
513
+ return this._conversationsPromise.then((conversationsEntity) => conversationsEntity.addConversation(options));
488
514
  }
489
515
  /**
490
516
  * Register for push notifications.
491
517
  * @param channelType Channel type.
492
- * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
518
+ * @param registrationId Push notification ID provided by the FCM/APNS service
519
+ * on the platform.
493
520
  */
494
521
  async setPushRegistrationId(channelType, registrationId) {
495
522
  await this._ensureReady;
496
523
  this._subscribeToPushNotifications(channelType);
497
- this.services.notificationClient.setPushRegistrationId(channelType, registrationId);
498
- await this.services.notificationClient.commitChanges(); // Committing before this point is useless because we have no push id
524
+ this._services.notificationClient.setPushRegistrationId(channelType, registrationId);
525
+ await this._services.notificationClient.commitChanges(); // Committing before this point is useless because we have no push id
499
526
  }
500
527
  /**
501
528
  * Unregister from push notifications.
@@ -505,132 +532,180 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
505
532
  async unsetPushRegistrationId(channelType) {
506
533
  await this._ensureReady;
507
534
  this._unsubscribeFromPushNotifications(channelType);
508
- await this.services.notificationClient.commitChanges();
535
+ await this._services.notificationClient.commitChanges();
509
536
  }
510
537
  /**
511
538
  * Clear existing registrations directly using provided device token.
512
539
  * This is useful to ensure stopped subscriptions without resubscribing.
513
540
  *
514
- * This function goes completely beside the state machine and removes all registrations.
515
- * Use with caution: if it races with current state machine operations, madness will ensue.
541
+ * This function goes completely beside the state machine and removes all
542
+ * registrations.
543
+ * Use with caution: if it races with current state machine operations,
544
+ * madness will ensue.
516
545
  *
517
546
  * @param channelType Channel type.
518
- * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
547
+ * @param registrationId Push notification ID provided by the FCM/APNS service
548
+ * on the platform.
519
549
  */
520
550
  async removePushRegistrations(channelType, registrationId) {
521
551
  // do not await this._ensureReady() here - it could be called at any moment
522
- await this.services.notificationClient.removeRegistrations(channelType, registrationId);
523
- }
524
- static parsePushNotificationChatData(data) {
525
- const result = {};
526
- for (const key in Client_1.supportedPushDataFields) {
527
- if (typeof data[key] === "undefined" || data[key] === null) {
528
- continue;
529
- }
530
- if (key !== "message_index") {
531
- result[Client_1.supportedPushDataFields[key]] = data[key];
532
- continue;
533
- }
534
- if (index.parseToNumber(data[key]) !== null) {
535
- result[Client_1.supportedPushDataFields[key]] = Number(data[key]);
536
- }
537
- }
538
- return result;
552
+ await this._services.notificationClient.removeRegistrations(channelType, registrationId);
539
553
  }
540
554
  /**
541
- * Static method for push notification payload parsing. Returns parsed push as a {@link PushNotification} object.
542
- * @param notificationPayload Push notification payload.
543
- */
544
- static parsePushNotification(notificationPayload) {
545
- log.debug("parsePushNotification, notificationPayload=", notificationPayload);
546
- // APNS specifics
547
- if (typeof notificationPayload.aps !== "undefined") {
548
- if (!notificationPayload.twi_message_type) {
549
- throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
550
- }
551
- const data = Client_1.parsePushNotificationChatData(notificationPayload);
552
- const apsPayload = notificationPayload.aps;
553
- let body;
554
- let title = null;
555
- if (typeof apsPayload.alert === "string") {
556
- body = apsPayload.alert || null;
557
- }
558
- else {
559
- body = apsPayload.alert.body || null;
560
- title = apsPayload.alert.title || null;
561
- }
562
- return new pushNotification.PushNotification({
563
- title,
564
- body,
565
- sound: apsPayload.sound || null,
566
- badge: apsPayload.badge || null,
567
- action: apsPayload.category || null,
568
- type: notificationPayload.twi_message_type,
569
- data: data,
570
- });
571
- }
572
- // FCM specifics
573
- if (typeof notificationPayload.data !== "undefined") {
574
- const dataPayload = notificationPayload.data;
575
- if (!dataPayload.twi_message_type) {
576
- throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
577
- }
578
- const data = Client_1.parsePushNotificationChatData(notificationPayload.data);
579
- return new pushNotification.PushNotification({
580
- title: dataPayload.twi_title || null,
581
- body: dataPayload.twi_body || null,
582
- sound: dataPayload.twi_sound || null,
583
- badge: null,
584
- action: dataPayload.twi_action || null,
585
- type: dataPayload.twi_message_type,
586
- data: data,
587
- });
588
- }
589
- throw new Error("Provided push notification payload is not Programmable Chat notification");
590
- }
591
- /**
592
- * Handle push notification payload parsing and emit the {@link Client.pushNotification} event on this {@link Client} instance.
555
+ * Handle push notification payload parsing and emit the
556
+ * {@link Client.pushNotification} event on this {@link Client} instance.
593
557
  * @param notificationPayload Push notification payload
594
558
  */
595
559
  async handlePushNotification(notificationPayload) {
596
560
  await this._ensureReady;
597
- log.debug("handlePushNotification, notificationPayload=", notificationPayload);
561
+ Client_1._logger.debug("handlePushNotification, notificationPayload=", notificationPayload);
598
562
  this.emit("pushNotification", Client_1.parsePushNotification(notificationPayload));
599
563
  }
600
564
  /**
601
- * Gets a user with the given identity. If it's in the subscribed list, then return the user object from it;
565
+ * Gets a user with the given identity. If it's in the subscribed list, then
566
+ * return the user object from it;
602
567
  * if not, then subscribe and add user to the subscribed list.
603
568
  * @param identity Identity of the user.
604
569
  * @returns A fully initialized user.
605
570
  */
606
571
  async getUser(identity) {
607
572
  await this._ensureReady;
608
- return this.services.users.getUser(identity);
573
+ return this._services.users.getUser(identity);
609
574
  }
610
575
  /**
611
576
  * Get a list of subscribed user objects.
612
577
  */
613
578
  async getSubscribedUsers() {
614
579
  await this._ensureReady;
615
- return this.services.users.getSubscribedUsers();
580
+ return this._services.users.getSubscribedUsers();
581
+ }
582
+ /**
583
+ * Get content URLs for all media attachments in the given set of media sids
584
+ * using a single operation.
585
+ * @param mediaSids Set of media sids to query for the content URL.
586
+ */
587
+ getTemporaryContentUrlsForMediaSids(mediaSids) {
588
+ return new mcsClient.CancellablePromise(async (resolve, reject, onCancel) => {
589
+ if (!this._services.mcsClient || !mediaSids) {
590
+ reject(new Error("Media Content Service is unavailable"));
591
+ return;
592
+ }
593
+ const request = this._services.mcsClient.mediaSetGetContentUrls(mediaSids);
594
+ onCancel(() => {
595
+ request.cancel();
596
+ });
597
+ try {
598
+ const urls = await request;
599
+ resolve(urls);
600
+ }
601
+ catch (e) {
602
+ reject(e);
603
+ }
604
+ });
605
+ }
606
+ /**
607
+ * Get content URLs for all media attachments in the given set using a single
608
+ * operation.
609
+ * @param contentSet Set of media attachments to query content URLs.
610
+ */
611
+ getTemporaryContentUrlsForMedia(contentSet) {
612
+ // We ignore existing mcsMedia members of each of the media entries.
613
+ // Instead, we just collect their sids and pull new descriptors from a
614
+ // mediaSet GET endpoint.
615
+ const sids = contentSet.map((m) => m.sid);
616
+ return this.getTemporaryContentUrlsForMediaSids(sids);
617
+ }
618
+ /**
619
+ * Initialize the client.
620
+ */
621
+ async _initialize() {
622
+ const configurationResponse = await this._services.commandExecutor.fetchResource("Client/v2/Configuration");
623
+ this._configuration = new configuration.Configuration(this._options, configurationResponse, Client_1._logger);
624
+ this._myself._resolveInitialization(this._configuration, this._configuration.userIdentity, this._configuration.userInfo, true);
625
+ this._services.typingIndicator = new typingIndicator.TypingIndicator(this.getConversationBySid.bind(this), this._configuration, this._services);
626
+ this._services.network = new network.Network(this._configuration, this._services);
627
+ this._services.users = new users.Users(this._myself, this._configuration, this._services);
628
+ this._services.users.on("userSubscribed", (user) => {
629
+ this.emit("userSubscribed", user);
630
+ });
631
+ this._services.users.on("userUpdated", (args) => this.emit("userUpdated", args));
632
+ this._services.users.on("userUnsubscribed", (user) => {
633
+ this.emit("userUnsubscribed", user);
634
+ });
635
+ this._conversationsEntity = new conversations.Conversations(this._configuration, this._services);
636
+ this._conversationsEntity.on("conversationAdded", (conversation) => {
637
+ this.emit("conversationAdded", conversation);
638
+ });
639
+ this._conversationsEntity.on("conversationRemoved", (conversation) => {
640
+ this.emit("conversationRemoved", conversation);
641
+ });
642
+ this._conversationsEntity.on("conversationJoined", (conversation) => {
643
+ this.emit("conversationJoined", conversation);
644
+ });
645
+ this._conversationsEntity.on("conversationLeft", (conversation) => {
646
+ this.emit("conversationLeft", conversation);
647
+ });
648
+ this._conversationsEntity.on("conversationUpdated", (args) => this.emit("conversationUpdated", args));
649
+ this._conversationsEntity.on("participantJoined", (participant) => {
650
+ this.emit("participantJoined", participant);
651
+ });
652
+ this._conversationsEntity.on("participantLeft", (participant) => {
653
+ this.emit("participantLeft", participant);
654
+ });
655
+ this._conversationsEntity.on("participantUpdated", (args) => this.emit("participantUpdated", args));
656
+ this._conversationsEntity.on("messageAdded", (message) => this.emit("messageAdded", message));
657
+ this._conversationsEntity.on("messageUpdated", (args) => this.emit("messageUpdated", args));
658
+ this._conversationsEntity.on("messageRemoved", (message) => this.emit("messageRemoved", message));
659
+ this._conversationsEntity.on("typingStarted", (participant) => this.emit("typingStarted", participant));
660
+ this._conversationsEntity.on("typingEnded", (participant) => this.emit("typingEnded", participant));
661
+ this._conversationsPromise = this._conversationsEntity
662
+ .fetchConversations()
663
+ .then(() => this._conversationsEntity)
664
+ .catch((error) => {
665
+ throw error;
666
+ });
667
+ await this._services.users.myself._ensureFetched();
668
+ Client_1._supportedPushChannels.forEach((channelType) => this._subscribeToPushNotifications(channelType));
669
+ this._services.typingIndicator.initialize();
670
+ this._services.mcsClient = new mcsClient.McsClient(this._fpaToken, this._configuration.links.mediaService, this._configuration.links.mediaSetService, Object.assign(Object.assign({}, this._options), { transport: undefined }));
671
+ this._resolveEnsureReady();
672
+ this.emit("stateChanged", { state: "initialized" });
673
+ }
674
+ /**
675
+ * Subscribe to push notifications.
676
+ * @param channelType The channel type to subscribe to.
677
+ */
678
+ _subscribeToPushNotifications(channelType) {
679
+ [
680
+ notificationTypes.NotificationTypes.NEW_MESSAGE,
681
+ notificationTypes.NotificationTypes.ADDED_TO_CONVERSATION,
682
+ notificationTypes.NotificationTypes.REMOVED_FROM_CONVERSATION,
683
+ notificationTypes.NotificationTypes.TYPING_INDICATOR,
684
+ notificationTypes.NotificationTypes.CONSUMPTION_UPDATE,
685
+ ].forEach((messageType) => {
686
+ this._services.notificationClient.subscribe(channelType, messageType);
687
+ });
688
+ }
689
+ /**
690
+ * Unsubscribe from push notifications.
691
+ * @param channelType The channel type to unsubscribe from.
692
+ */
693
+ _unsubscribeFromPushNotifications(channelType) {
694
+ [
695
+ notificationTypes.NotificationTypes.NEW_MESSAGE,
696
+ notificationTypes.NotificationTypes.ADDED_TO_CONVERSATION,
697
+ notificationTypes.NotificationTypes.REMOVED_FROM_CONVERSATION,
698
+ notificationTypes.NotificationTypes.TYPING_INDICATOR,
699
+ notificationTypes.NotificationTypes.CONSUMPTION_UPDATE,
700
+ ].forEach((messageType) => {
701
+ this._services.notificationClient.unsubscribe(channelType, messageType);
702
+ });
616
703
  }
617
704
  };
618
705
  /**
619
- * Current version of the Conversations client.
620
- */
621
- exports.Client.version = SDK_VERSION;
622
- exports.Client.supportedPushChannels = [
623
- "fcm",
624
- "apn",
625
- ];
626
- exports.Client.supportedPushDataFields = {
627
- conversation_sid: "conversationSid",
628
- message_sid: "messageSid",
629
- message_index: "messageIndex",
630
- };
631
- /**
632
- * Fired when a conversation becomes visible to the client. The event is also triggered when the client creates a new conversation.
633
- * Fired for all conversations client has joined.
706
+ * Fired when a conversation becomes visible to the client. The event is also
707
+ * triggered when the client creates a new conversation.
708
+ * Fired for all conversations that the client has joined.
634
709
  *
635
710
  * Parameters:
636
711
  * 1. {@link Conversation} `conversation` - the conversation in question
@@ -662,14 +737,17 @@ exports.Client.conversationLeft = "conversationLeft";
662
737
  */
663
738
  exports.Client.conversationRemoved = "conversationRemoved";
664
739
  /**
665
- * Fired when the attributes or the metadata of a conversation have been updated.
666
- * During conversation's creation and initialization, this event might be fired multiple times
667
- * for same joined or created conversation as new data is arriving from different sources.
740
+ * Fired when the attributes or the metadata of a conversation have been
741
+ * updated. During conversation's creation and initialization, this event
742
+ * might be fired multiple times for same joined or created conversation as
743
+ * new data is arriving from different sources.
668
744
  *
669
745
  * Parameters:
670
- * 1. object `data` - info object provided with the event. It has the following properties:
746
+ * 1. object `data` - info object provided with the event. It has the
747
+ * following properties:
671
748
  * * {@link Conversation} `conversation` - the conversation in question
672
- * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for the update
749
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
750
+ * for the update
673
751
  * @event
674
752
  */
675
753
  exports.Client.conversationUpdated = "conversationUpdated";
@@ -693,9 +771,11 @@ exports.Client.participantLeft = "participantLeft";
693
771
  * Fired when a participant's fields have been updated.
694
772
  *
695
773
  * Parameters:
696
- * 1. object `data` - info object provided with the event. It has the following properties:
774
+ * 1. object `data` - info object provided with the event. It has the
775
+ * following properties:
697
776
  * * {@link Participant} `participant` - the participant in question
698
- * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for the update
777
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
778
+ * for the update
699
779
  * @event
700
780
  */
701
781
  exports.Client.participantUpdated = "participantUpdated";
@@ -719,16 +799,16 @@ exports.Client.messageRemoved = "messageRemoved";
719
799
  * Fired when the fields of an existing message are updated with new values.
720
800
  *
721
801
  * Parameters:
722
- * 1. object `data` - info object provided with the event. It has the following properties:
802
+ * 1. object `data` - info object provided with the event. It has the
803
+ * following properties:
723
804
  * * {@link Message} `message` - the message in question
724
- * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for the update
805
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
806
+ * the update
725
807
  * @event
726
808
  */
727
809
  exports.Client.messageUpdated = "messageUpdated";
728
810
  /**
729
811
  * Fired when the token is about to expire and needs to be updated.
730
- * * Parameters:
731
- * 1. number `message` - token's time to live
732
812
  * @event
733
813
  */
734
814
  exports.Client.tokenAboutToExpire = "tokenAboutToExpire";
@@ -754,10 +834,12 @@ exports.Client.typingEnded = "typingEnded";
754
834
  */
755
835
  exports.Client.typingStarted = "typingStarted";
756
836
  /**
757
- * Fired when the client has received (and parsed) a push notification via one of the push channels (apn or fcm).
837
+ * Fired when the client has received (and parsed) a push notification via one
838
+ * of the push channels (apn or fcm).
758
839
  *
759
840
  * Parameters:
760
- * 1. {@link PushNotification} `pushNotification` - the push notification in question
841
+ * 1. {@link PushNotification} `pushNotification` - the push notification in
842
+ * question
761
843
  * @event
762
844
  */
763
845
  exports.Client.pushNotification = "pushNotification";
@@ -778,12 +860,15 @@ exports.Client.userSubscribed = "userSubscribed";
778
860
  */
779
861
  exports.Client.userUnsubscribed = "userUnsubscribed";
780
862
  /**
781
- * Fired when the properties or the reachability status of a user have been updated.
863
+ * Fired when the properties or the reachability status of a user have been
864
+ * updated.
782
865
  *
783
866
  * Parameters:
784
- * 1. object `data` - info object provided with the event. It has the following properties:
867
+ * 1. object `data` - info object provided with the event. It has the
868
+ * following properties:
785
869
  * * {@link User} `user` - the user in question
786
- * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
870
+ * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the
871
+ * update
787
872
  * @event
788
873
  */
789
874
  exports.Client.userUpdated = "userUpdated";
@@ -791,14 +876,17 @@ exports.Client.userUpdated = "userUpdated";
791
876
  * Fired when the state of the client has been changed.
792
877
  *
793
878
  * Parameters:
794
- * 1. {@link State} `state` - the new client state
879
+ * 1. object `data` - info object provided with the event. It has the
880
+ * following properties:
881
+ * * {@link State} `state` - the new client state
882
+ * * Error? `error` - the initialization error if present
795
883
  * @event
796
884
  */
797
885
  exports.Client.stateChanged = "stateChanged";
798
886
  /**
799
887
  * Fired when the connection state of the client has been changed.
800
888
  *
801
- * Paremeters:
889
+ * Parameters:
802
890
  * 1. {@link ConnectionState} `state` - the new connection state
803
891
  * @event
804
892
  */
@@ -807,7 +895,8 @@ exports.Client.connectionStateChanged = "connectionStateChanged";
807
895
  * Fired when the connection is interrupted for an unexpected reason.
808
896
  *
809
897
  * Parameters:
810
- * 1. object `data` - info object provided with the event. It has the following properties:
898
+ * 1. object `data` - info object provided with the event. It has the
899
+ * following properties:
811
900
  * * boolean `terminal` - Twilsock will stop connection attempts if true
812
901
  * * string `message` - the error message of the root cause
813
902
  * * number? `httpStatusCode` - http status code if available
@@ -815,6 +904,32 @@ exports.Client.connectionStateChanged = "connectionStateChanged";
815
904
  * @event
816
905
  */
817
906
  exports.Client.connectionError = "connectionError";
907
+ /**
908
+ * Current version of the Conversations client.
909
+ */
910
+ exports.Client.version = _package.version;
911
+ /**
912
+ * Logger instance.
913
+ */
914
+ exports.Client._logger = logger.Logger.scope("Client");
915
+ /**
916
+ * Supported push notification channels.
917
+ */
918
+ exports.Client._supportedPushChannels = [
919
+ "fcm",
920
+ "apn",
921
+ ];
922
+ /**
923
+ * Supported push data fields.
924
+ */
925
+ exports.Client._supportedPushDataFields = {
926
+ conversation_sid: "conversationSid",
927
+ conversation_title: "conversationTitle",
928
+ message_sid: "messageSid",
929
+ message_index: "messageIndex",
930
+ media_count: "mediaCount",
931
+ media: "media", // object
932
+ };
818
933
  tslib_es6.__decorate([
819
934
  declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
820
935
  tslib_es6.__metadata("design:type", Function),
@@ -827,6 +942,12 @@ tslib_es6.__decorate([
827
942
  tslib_es6.__metadata("design:paramtypes", [String]),
828
943
  tslib_es6.__metadata("design:returntype", Promise)
829
944
  ], exports.Client.prototype, "getConversationBySid", null);
945
+ tslib_es6.__decorate([
946
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
947
+ tslib_es6.__metadata("design:type", Function),
948
+ tslib_es6.__metadata("design:paramtypes", [String]),
949
+ tslib_es6.__metadata("design:returntype", Promise)
950
+ ], exports.Client.prototype, "peekConversationBySid", null);
830
951
  tslib_es6.__decorate([
831
952
  declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
832
953
  tslib_es6.__metadata("design:type", Function),