@twilio/conversations 3.0.0-canary.5 → 3.0.0-canary2.100

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 (53) hide show
  1. package/README.md +22 -18
  2. package/builds/browser.js +1360 -2410
  3. package/builds/browser.js.map +1 -1
  4. package/builds/lib.d.ts +74 -69
  5. package/builds/lib.js +1360 -2410
  6. package/builds/lib.js.map +1 -1
  7. package/builds/twilio-conversations.js +25229 -25615
  8. package/builds/twilio-conversations.min.js +1 -16
  9. package/dist/aggregated-delivery-receipt.js +1 -1
  10. package/dist/aggregated-delivery-receipt.js.map +1 -1
  11. package/dist/client.js +99 -70
  12. package/dist/client.js.map +1 -1
  13. package/dist/command-executor.js +30 -12
  14. package/dist/command-executor.js.map +1 -1
  15. package/dist/configuration.js.map +1 -1
  16. package/dist/conversation.js +92 -23
  17. package/dist/conversation.js.map +1 -1
  18. package/dist/data/conversations.js +21 -5
  19. package/dist/data/conversations.js.map +1 -1
  20. package/dist/data/messages.js +13 -19
  21. package/dist/data/messages.js.map +1 -1
  22. package/dist/data/participants.js +6 -4
  23. package/dist/data/participants.js.map +1 -1
  24. package/dist/data/users.js +4 -2
  25. package/dist/data/users.js.map +1 -1
  26. package/dist/detailed-delivery-receipt.js.map +1 -1
  27. package/dist/index.js +6 -4
  28. package/dist/index.js.map +1 -1
  29. package/dist/interfaces/attributes.js.map +1 -1
  30. package/dist/interfaces/notification-types.js.map +1 -1
  31. package/dist/logger.js +2 -4
  32. package/dist/logger.js.map +1 -1
  33. package/dist/media.js.map +1 -1
  34. package/dist/message-builder.js.map +1 -1
  35. package/dist/message.js +24 -21
  36. package/dist/message.js.map +1 -1
  37. package/dist/node_modules/tslib/tslib.es6.js +1 -1
  38. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  39. package/dist/packages/conversations/package.json.js +1 -1
  40. package/dist/participant.js +2 -2
  41. package/dist/participant.js.map +1 -1
  42. package/dist/push-notification.js.map +1 -1
  43. package/dist/rest-paginator.js.map +1 -1
  44. package/dist/services/network.js +38 -15
  45. package/dist/services/network.js.map +1 -1
  46. package/dist/services/typing-indicator.js +7 -5
  47. package/dist/services/typing-indicator.js.map +1 -1
  48. package/dist/unsent-message.js.map +1 -1
  49. package/dist/user.js +2 -2
  50. package/dist/user.js.map +1 -1
  51. package/dist/util/deferred.js.map +1 -1
  52. package/dist/util/index.js.map +1 -1
  53. package/package.json +27 -23
@@ -134,7 +134,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
134
134
  * Contains aggregated information about delivery statuses of a message across all participants
135
135
  * of a conversation.
136
136
  *
137
- * At any moment during the message delivery to a participant, the message can have zero or more of following
137
+ * At any moment during the message delivery to a participant, the message can have zero or more of the following
138
138
  * delivery statuses:
139
139
  * * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
140
140
  * * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
@@ -1 +1 @@
1
- {"version":3,"file":"aggregated-delivery-receipt.js","sources":["../src/aggregated-delivery-receipt.ts"],"sourcesContent":["/**\n * Signifies the amount of participants which have the status for the message.\n */\ntype DeliveryAmount = \"none\" | \"some\" | \"all\";\n\ninterface AggregatedDeliveryDescriptor {\n total: number;\n delivered: DeliveryAmount;\n failed: DeliveryAmount;\n read: DeliveryAmount;\n sent: DeliveryAmount;\n undelivered: DeliveryAmount;\n}\n\n/**\n * Contains aggregated information about delivery statuses of a message across all participants\n * of a conversation.\n *\n * At any moment during the message delivery to a participant, the message can have zero or more of following\n * delivery statuses:\n * * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.\n * * Message is considered as **delivered** to a participant if Twilio has received confirmation of message\n * delivery from the upstream carrier, and, where available, the destination handset.\n * * Message considered as **undelivered** to a participant if Twilio has received a delivery receipt\n * indicating that the message was not delivered. This can happen for many reasons including carrier content\n * filtering and the availability of the destination handset.\n * * Message considered as **read** by a participant if the message has been delivered and opened by the\n * recipient in a conversation. The recipient must have enabled the read receipts.\n * * Message considered as **failed** to be delivered to a participant if the message could not be sent.\n * This can happen for various reasons including queue overflows, account suspensions and media\n * errors (in the case of MMS for instance).\n *\n * {@link AggregatedDeliveryReceipt} class contains an aggregated value {@link DeliveryAmount} for each delivery status.\n */\nclass AggregatedDeliveryReceipt {\n private state: AggregatedDeliveryDescriptor;\n\n /**\n * @internal\n */\n constructor(data: AggregatedDeliveryDescriptor) {\n this.state = data;\n }\n\n /**\n * Maximum number of delivery events expected for the message.\n */\n public get total(): number {\n return this.state.total;\n }\n\n /**\n * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.\n *\n * @return Amount of participants that have the **sent** delivery status for the message.\n */\n public get sent(): DeliveryAmount {\n return this.state.sent;\n }\n\n /**\n * Message is considered as **delivered** to a participant if Twilio has received confirmation of message\n * delivery from the upstream carrier, and, where available, the destination handset.\n *\n * @return Amount of participants that have the **delivered** delivery status for the message.\n */\n public get delivered(): DeliveryAmount {\n return this.state.delivered;\n }\n\n /**\n * Message is considered as **read** by a participant, if the message has been delivered and opened by the\n * recipient in a conversation. The recipient must have enabled the read receipts.\n *\n * @return Amount of participants that have the **read** delivery status for the message.\n */\n public get read(): DeliveryAmount {\n return this.state.read;\n }\n\n /**\n * Message is considered as **undelivered** to a participant if Twilio has received a delivery receipt\n * indicating that the message was not delivered. This can happen for many reasons including carrier content\n * filtering and the availability of the destination handset.\n *\n * @return Ammount of participants that have the **undelivered** delivery status for the message.\n */\n public get undelivered(): DeliveryAmount {\n return this.state.undelivered;\n }\n\n /**\n * Message is considered as **failed** to be delivered to a participant if the message could not be sent.\n * This can happen for various reasons including queue overflows, account suspensions and media\n * errors (in the case of MMS for instance). Twilio does not charge you for failed messages.\n *\n * @return Amount of participants that have the **failed** delivery status for the message.\n */\n public get failed(): DeliveryAmount {\n return this.state.failed;\n }\n\n _update(data: AggregatedDeliveryDescriptor): void {\n this.state = data;\n }\n\n _isEquals(data: AggregatedDeliveryDescriptor): boolean {\n const isTotalSame = this.total === data.total;\n const isSentSame = this.sent === data.sent;\n const isDeliveredSame = this.delivered === data.delivered;\n const isReadSame = this.read === data.read;\n const isUndeliveredSame = this.undelivered === data.undelivered;\n const isFailedSame = this.failed === data.failed;\n\n return (\n isTotalSame &&\n isSentSame &&\n isDeliveredSame &&\n isReadSame &&\n isUndeliveredSame &&\n isFailedSame\n );\n }\n}\n\nexport {\n AggregatedDeliveryReceipt,\n AggregatedDeliveryDescriptor,\n DeliveryAmount,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,yBAAyB;;;;IAM7B,YAAY,IAAkC;QAC5C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;KACnB;;;;IAKD,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;KACzB;;;;;;IAOD,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;KACxB;;;;;;;IAQD,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;KAC7B;;;;;;;IAQD,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;KACxB;;;;;;;;IASD,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;KAC/B;;;;;;;;IASD,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;KAC1B;IAED,OAAO,CAAC,IAAkC;QACxC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;KACnB;IAED,SAAS,CAAC,IAAkC;QAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC;QAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;QAC3C,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC;QAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;QAC3C,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,CAAC;QAChE,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC;QAEjD,QACE,WAAW;YACX,UAAU;YACV,eAAe;YACf,UAAU;YACV,iBAAiB;YACjB,YAAY,EACZ;KACH;;;;;"}
1
+ {"version":3,"file":"aggregated-delivery-receipt.js","sources":["../src/aggregated-delivery-receipt.ts"],"sourcesContent":["/**\n * Signifies the amount of participants which have the status for the message.\n */\ntype DeliveryAmount = \"none\" | \"some\" | \"all\";\n\ninterface AggregatedDeliveryDescriptor {\n total: number;\n delivered: DeliveryAmount;\n failed: DeliveryAmount;\n read: DeliveryAmount;\n sent: DeliveryAmount;\n undelivered: DeliveryAmount;\n}\n\n/**\n * Contains aggregated information about delivery statuses of a message across all participants\n * of a conversation.\n *\n * At any moment during the message delivery to a participant, the message can have zero or more of the following\n * delivery statuses:\n * * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.\n * * Message is considered as **delivered** to a participant if Twilio has received confirmation of message\n * delivery from the upstream carrier, and, where available, the destination handset.\n * * Message considered as **undelivered** to a participant if Twilio has received a delivery receipt\n * indicating that the message was not delivered. This can happen for many reasons including carrier content\n * filtering and the availability of the destination handset.\n * * Message considered as **read** by a participant if the message has been delivered and opened by the\n * recipient in a conversation. The recipient must have enabled the read receipts.\n * * Message considered as **failed** to be delivered to a participant if the message could not be sent.\n * This can happen for various reasons including queue overflows, account suspensions and media\n * errors (in the case of MMS for instance).\n *\n * {@link AggregatedDeliveryReceipt} class contains an aggregated value {@link DeliveryAmount} for each delivery status.\n */\nclass AggregatedDeliveryReceipt {\n private state: AggregatedDeliveryDescriptor;\n\n /**\n * @internal\n */\n constructor(data: AggregatedDeliveryDescriptor) {\n this.state = data;\n }\n\n /**\n * Maximum number of delivery events expected for the message.\n */\n public get total(): number {\n return this.state.total;\n }\n\n /**\n * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.\n *\n * @return Amount of participants that have the **sent** delivery status for the message.\n */\n public get sent(): DeliveryAmount {\n return this.state.sent;\n }\n\n /**\n * Message is considered as **delivered** to a participant if Twilio has received confirmation of message\n * delivery from the upstream carrier, and, where available, the destination handset.\n *\n * @return Amount of participants that have the **delivered** delivery status for the message.\n */\n public get delivered(): DeliveryAmount {\n return this.state.delivered;\n }\n\n /**\n * Message is considered as **read** by a participant, if the message has been delivered and opened by the\n * recipient in a conversation. The recipient must have enabled the read receipts.\n *\n * @return Amount of participants that have the **read** delivery status for the message.\n */\n public get read(): DeliveryAmount {\n return this.state.read;\n }\n\n /**\n * Message is considered as **undelivered** to a participant if Twilio has received a delivery receipt\n * indicating that the message was not delivered. This can happen for many reasons including carrier content\n * filtering and the availability of the destination handset.\n *\n * @return Ammount of participants that have the **undelivered** delivery status for the message.\n */\n public get undelivered(): DeliveryAmount {\n return this.state.undelivered;\n }\n\n /**\n * Message is considered as **failed** to be delivered to a participant if the message could not be sent.\n * This can happen for various reasons including queue overflows, account suspensions and media\n * errors (in the case of MMS for instance). Twilio does not charge you for failed messages.\n *\n * @return Amount of participants that have the **failed** delivery status for the message.\n */\n public get failed(): DeliveryAmount {\n return this.state.failed;\n }\n\n _update(data: AggregatedDeliveryDescriptor): void {\n this.state = data;\n }\n\n _isEquals(data: AggregatedDeliveryDescriptor): boolean {\n const isTotalSame = this.total === data.total;\n const isSentSame = this.sent === data.sent;\n const isDeliveredSame = this.delivered === data.delivered;\n const isReadSame = this.read === data.read;\n const isUndeliveredSame = this.undelivered === data.undelivered;\n const isFailedSame = this.failed === data.failed;\n\n return (\n isTotalSame &&\n isSentSame &&\n isDeliveredSame &&\n isReadSame &&\n isUndeliveredSame &&\n isFailedSame\n );\n }\n}\n\nexport {\n AggregatedDeliveryReceipt,\n AggregatedDeliveryDescriptor,\n DeliveryAmount,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;;;;;;;;;;;;;;;;AAmBG;AACH,MAAM,yBAAyB,CAAA;AAG7B;;AAEG;AACH,IAAA,WAAA,CAAY,IAAkC,EAAA;AAC5C,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;KACnB;AAED;;AAEG;AACH,IAAA,IAAW,KAAK,GAAA;AACd,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;KACzB;AAED;;;;AAIG;AACH,IAAA,IAAW,IAAI,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;KACxB;AAED;;;;;AAKG;AACH,IAAA,IAAW,SAAS,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;KAC7B;AAED;;;;;AAKG;AACH,IAAA,IAAW,IAAI,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;KACxB;AAED;;;;;;AAMG;AACH,IAAA,IAAW,WAAW,GAAA;AACpB,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;KAC/B;AAED;;;;;;AAMG;AACH,IAAA,IAAW,MAAM,GAAA;AACf,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;KAC1B;AAED,IAAA,OAAO,CAAC,IAAkC,EAAA;AACxC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;KACnB;AAED,IAAA,SAAS,CAAC,IAAkC,EAAA;QAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC;QAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;QAC3C,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC;QAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;QAC3C,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,CAAC;QAChE,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC;AAEjD,QAAA,QACE,WAAW;YACX,UAAU;YACV,eAAe;YACf,UAAU;YACV,iBAAiB;AACjB,YAAA,YAAY,EACZ;KACH;AACF;;;;"}
package/dist/client.js CHANGED
@@ -149,6 +149,7 @@ var declarativeTypeValidator = require('@twilio/declarative-type-validator');
149
149
  var _package = require('./packages/conversations/package.json.js');
150
150
  var commandExecutor = require('./command-executor.js');
151
151
  var replayEventEmitter = require('@twilio/replay-event-emitter');
152
+ var media = require('./media.js');
152
153
 
153
154
  var Client_1;
154
155
  /**
@@ -232,14 +233,37 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
232
233
  this._options.initRegistrations = [initRegistration];
233
234
  }
234
235
  this._services.twilsockClient = this._options.twilsockClient =
235
- (_b = this._options.twilsockClient) !== null && _b !== void 0 ? _b : new twilsock.TwilsockClient(fpaToken, productId, this._options);
236
+ (_b = this._options.twilsockClient) !== null && _b !== void 0 ? _b :
237
+ // todo: remove any after the release of new Twilsock
238
+ new twilsock.TwilsockClient(fpaToken, productId, this._options);
236
239
  this._services.twilsockClient.on("tokenAboutToExpire", () => this.emit("tokenAboutToExpire"));
237
240
  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}`);
241
- if (state !== this.connectionState) {
242
- this.connectionState = state;
241
+ // this._services.twilsockClient.on("connectionError", (error) =>
242
+ // this.emit("connectionError", error)
243
+ // );
244
+ // this._services.twilsockClient.on(
245
+ // "stateChanged",
246
+ // (state: ConnectionState) => {
247
+ // }
248
+ // );
249
+ this._services.twilsockClient.on("disconnected", () => {
250
+ Client_1._logger.debug(`Handling stateChanged for ConversationsClient: new state disconnected`);
251
+ if ("disconnected" !== this.connectionState) {
252
+ this.connectionState = "disconnected";
253
+ this.emit("connectionStateChanged", this.connectionState);
254
+ }
255
+ });
256
+ this._services.twilsockClient.on("connecting", () => {
257
+ Client_1._logger.debug(`Handling stateChanged for ConversationsClient: new state connecting`);
258
+ if ("connecting" !== this.connectionState) {
259
+ this.connectionState = "connecting";
260
+ this.emit("connectionStateChanged", this.connectionState);
261
+ }
262
+ });
263
+ this._services.twilsockClient.on("connected", () => {
264
+ Client_1._logger.debug(`Handling stateChanged for ConversationsClient: new state connected`);
265
+ if ("connected" !== this.connectionState) {
266
+ this.connectionState = "connected";
243
267
  this.emit("connectionStateChanged", this.connectionState);
244
268
  }
245
269
  });
@@ -248,7 +272,12 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
248
272
  this._services.notificationClient = this._options.notificationsClient =
249
273
  (_d = this._options.notificationsClient) !== null && _d !== void 0 ? _d : new notifications.Notifications(fpaToken, this._options);
250
274
  this._services.syncClient = this._options.syncClient =
251
- (_e = this._options.syncClient) !== null && _e !== void 0 ? _e : new twilioSync.SyncClient(fpaToken, this._options);
275
+ (_e = this._options.syncClient) !== null && _e !== void 0 ? _e :
276
+ // TwilsockClient is different between versions 0.12.2
277
+ // (dep of twilio-sync@3.2.2) and 0.13.1 (dep of current
278
+ // @twilio/conversations). Thus, casting to any.
279
+ // todo: fix sync caching and migrate to that version of sync.
280
+ new twilioSync.SyncClient(fpaToken, this._options);
252
281
  const configurationOptions = (options === null || options === void 0 ? void 0 : options.Chat) || (options === null || options === void 0 ? void 0 : options.IPMessaging) || options || {};
253
282
  const region = configurationOptions.region || (options === null || options === void 0 ? void 0 : options.region);
254
283
  const baseUrl = configurationOptions.apiUri ||
@@ -257,24 +286,48 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
257
286
  this._services.commandExecutor = new commandExecutor.CommandExecutor(baseUrl, { transport: this._options.transport }, productId);
258
287
  const emitFailed = (error) => {
259
288
  this._rejectEnsureReady(error);
260
- this.emit("stateChanged", { state: "failed", error });
289
+ this.emit("initFailed", { error });
261
290
  };
262
- this._services.twilsockClient.onceWithReplay("connectionError", emitFailed);
263
- this._services.twilsockClient.onceWithReplay("disconnected", emitFailed);
264
- this._services.twilsockClient.onceWithReplay("connected", async () => {
291
+ const emitDisconnected = () => {
292
+ emitFailed({
293
+ terminal: true,
294
+ message: "Twilsock has disconnected.",
295
+ });
296
+ };
297
+ // this._services.twilsockClient.once("connectionError", emitFailed);
298
+ this._services.twilsockClient.once("disconnected", emitDisconnected);
299
+ this._services.twilsockClient.once("connected", async () => {
265
300
  Client_1._logger.debug(`ConversationsClient started INITIALIZING`);
266
- this._services.twilsockClient.off("connectionError", emitFailed);
267
- this._services.twilsockClient.off("disconnected", emitFailed);
301
+ // this._services.twilsockClient.off("connectionError", emitFailed);
302
+ this._services.twilsockClient.off("disconnected", emitDisconnected);
268
303
  try {
269
304
  const startupEvent = "conversations.client.startup";
270
- this._services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription(startupEvent, "Conversations client startup", new Date()), startupEvent, twilsock.TelemetryPoint.Start);
305
+ // this._services.twilsockClient.addPartialTelemetryEvent(
306
+ // new TelemetryEventDescription(
307
+ // startupEvent,
308
+ // "Conversations client startup",
309
+ // new Date()
310
+ // ),
311
+ // startupEvent,
312
+ // TelemetryPoint.Start
313
+ // );
271
314
  await this._initialize();
272
- this._services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription("", "", new Date()), startupEvent, twilsock.TelemetryPoint.End);
315
+ // this._services.twilsockClient.addPartialTelemetryEvent(
316
+ // new TelemetryEventDescription("", "", new Date()),
317
+ // startupEvent,
318
+ // TelemetryPoint.End
319
+ // );
273
320
  }
274
321
  catch (err) {
275
322
  // Fail ChatClient if initialization is incomplete
276
- this._rejectEnsureReady(err);
277
- this.emit("stateChanged", { state: "failed", error: err });
323
+ const connectionError = {
324
+ terminal: true,
325
+ message: err.message,
326
+ };
327
+ this._rejectEnsureReady(connectionError);
328
+ this.emit("initFailed", {
329
+ error: connectionError,
330
+ });
278
331
  }
279
332
  });
280
333
  this._ensureReady = new Promise((resolve, reject) => {
@@ -300,52 +353,18 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
300
353
  get reachabilityEnabled() {
301
354
  if (!this._configuration) {
302
355
  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.");
356
+ "has not yet been initialized. Subscribe to 'initialized' and " +
357
+ "'initFailed' events to properly react to the client initialization.");
305
358
  }
306
359
  return this._configuration.reachabilityEnabled;
307
360
  }
308
- /**
309
- * @deprecated Call constructor directly.
310
- *
311
- * Factory method to create a Conversations client instance.
312
- *
313
- * The factory method will automatically trigger connection.
314
- * Do not use it if you need finer-grained control.
315
- *
316
- * Since this method returns an already-initialized client, some of the events
317
- * will be lost because they happen *before* the initialization. It is
318
- * recommended that `client.onWithReplay` is used as opposed to `client.on`
319
- * for subscribing to client events. The `client.onWithReplay` will re-emit
320
- * the most recent value for a given event if it emitted before the
321
- * subscription.
322
- *
323
- * @param token Access token.
324
- * @param options Options to customize the client.
325
- * @returns Returns a fully initialized client.
326
- */
327
- static async create(token, options) {
328
- // The logic is as follows:
329
- // - If twilsock is not passed in, then the ConversationsClient constructor will call twilsock.connect() by itself
330
- // and we do not need to do it here.
331
- // - If twilsock was passed in from the outside, but customer called ConversationsClient.create() then they are
332
- // using an obsolete workflow and the startup sequence will never complete.
333
- if (options === null || options === void 0 ? void 0 : options.twilsockClient) {
334
- throw new Error("Obsolete usage of ConversationsClient.create() " +
335
- "factory method: if you pass twilsock from the outside then you must " +
336
- "use ConversationsClient constructor and be prepared to work with " +
337
- "uninitialized client.");
338
- }
339
- const client = new Client_1(token, options);
340
- await client._ensureReady;
341
- return client;
342
- }
343
361
  /**
344
362
  * Static method for push notification payload parsing. Returns parsed push as
345
363
  * a {@link PushNotification} object.
346
364
  * @param notificationPayload Push notification payload.
347
365
  */
348
366
  static parsePushNotification(notificationPayload) {
367
+ var _a, _b;
349
368
  Client_1._logger.debug("parsePushNotification, notificationPayload=", notificationPayload);
350
369
  // APNS specifics
351
370
  if (typeof notificationPayload.aps !== "undefined") {
@@ -360,8 +379,8 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
360
379
  body = apsPayload.alert || null;
361
380
  }
362
381
  else {
363
- body = apsPayload.alert.body || null;
364
- title = apsPayload.alert.title || null;
382
+ body = ((_a = apsPayload.alert) === null || _a === void 0 ? void 0 : _a.body) || null;
383
+ title = ((_b = apsPayload.alert) === null || _b === void 0 ? void 0 : _b.title) || null;
365
384
  }
366
385
  return new pushNotification.PushNotification({
367
386
  title,
@@ -430,8 +449,8 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
430
449
  * @param reg The init registration to populate.
431
450
  */
432
451
  static populateInitRegistrations(reg) {
433
- reg.populateInitRegistrations([notificationTypes.NotificationTypes.TYPING_INDICATOR]);
434
- twilioSync.SyncClient.populateInitRegistrations(reg);
452
+ // reg.populateInitRegistrations([NotificationTypes.TYPING_INDICATOR]);
453
+ // SyncClient.populateInitRegistrations(reg);
435
454
  }
436
455
  /**
437
456
  * Gracefully shut down the client.
@@ -465,7 +484,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
465
484
  await this._conversationsEntity.myConversationsRead.promise;
466
485
  const conversation = await this._conversationsEntity.getConversation(conversationSid);
467
486
  if (!conversation) {
468
- throw new Error(`Conversation with SID ${conversationSid} is not found.`);
487
+ throw new Error(`Conversation with SID ${conversationSid} was not found.`);
469
488
  }
470
489
  return conversation;
471
490
  }
@@ -478,7 +497,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
478
497
  await this._ensureReady;
479
498
  const conversation = await this._conversationsEntity.peekConversation(conversationSid);
480
499
  if (!conversation) {
481
- throw new Error(`Conversation with SID ${conversationSid} is not found.`);
500
+ throw new Error(`Conversation with SID ${conversationSid} was not found.`);
482
501
  }
483
502
  return conversation;
484
503
  }
@@ -491,7 +510,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
491
510
  await this._conversationsEntity.myConversationsRead.promise;
492
511
  const conversation = await this._conversationsEntity.getConversationByUniqueName(uniqueName);
493
512
  if (!conversation) {
494
- throw new Error(`Conversation with unique name ${uniqueName} is not found.`);
513
+ throw new Error(`Conversation with unique name ${uniqueName} was not found.`);
495
514
  }
496
515
  return conversation;
497
516
  }
@@ -669,7 +688,7 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
669
688
  this._services.typingIndicator.initialize();
670
689
  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
690
  this._resolveEnsureReady();
672
- this.emit("stateChanged", { state: "initialized" });
691
+ this.emit("initialized");
673
692
  }
674
693
  /**
675
694
  * Subscribe to push notifications.
@@ -873,16 +892,20 @@ exports.Client.userUnsubscribed = "userUnsubscribed";
873
892
  */
874
893
  exports.Client.userUpdated = "userUpdated";
875
894
  /**
876
- * Fired when the state of the client has been changed.
895
+ * Fired when the client has completed initialization successfully.
896
+ * @event
897
+ */
898
+ exports.Client.initialized = "initialized";
899
+ /**
900
+ * Fired when the client initialization failed.
877
901
  *
878
902
  * Parameters:
879
903
  * 1. object `data` - info object provided with the event. It has the
880
- * following properties:
881
- * * {@link State} `state` - the new client state
904
+ * following property:
882
905
  * * Error? `error` - the initialization error if present
883
906
  * @event
884
907
  */
885
- exports.Client.stateChanged = "stateChanged";
908
+ exports.Client.initFailed = "initFailed";
886
909
  /**
887
910
  * Fired when the connection state of the client has been changed.
888
911
  *
@@ -998,11 +1021,17 @@ tslib_es6.__decorate([
998
1021
  tslib_es6.__metadata("design:returntype", Promise)
999
1022
  ], exports.Client.prototype, "getUser", null);
1000
1023
  tslib_es6.__decorate([
1001
- declarativeTypeValidator.validateTypesAsync("string", ["undefined", declarativeTypeValidator.pureObject]),
1024
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyArray("strings", "string")),
1002
1025
  tslib_es6.__metadata("design:type", Function),
1003
- tslib_es6.__metadata("design:paramtypes", [String, Object]),
1004
- tslib_es6.__metadata("design:returntype", Promise)
1005
- ], exports.Client, "create", null);
1026
+ tslib_es6.__metadata("design:paramtypes", [Array]),
1027
+ tslib_es6.__metadata("design:returntype", mcsClient.CancellablePromise)
1028
+ ], exports.Client.prototype, "getTemporaryContentUrlsForMediaSids", null);
1029
+ tslib_es6.__decorate([
1030
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyArray("media", media.Media)),
1031
+ tslib_es6.__metadata("design:type", Function),
1032
+ tslib_es6.__metadata("design:paramtypes", [Array]),
1033
+ tslib_es6.__metadata("design:returntype", mcsClient.CancellablePromise)
1034
+ ], exports.Client.prototype, "getTemporaryContentUrlsForMedia", null);
1006
1035
  tslib_es6.__decorate([
1007
1036
  declarativeTypeValidator.validateTypes(declarativeTypeValidator.pureObject),
1008
1037
  tslib_es6.__metadata("design:type", Function),