@twilio/conversations 3.0.1-rc.103 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/builds/browser.esm.js +10846 -0
- package/builds/browser.esm.js.map +1 -0
- package/builds/browser.js +579 -218
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +40 -27
- package/builds/lib.esm.d.ts +3178 -0
- package/builds/lib.esm.js +10845 -0
- package/builds/lib.js +588 -218
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +9111 -10398
- package/builds/twilio-conversations.js.map +1 -0
- package/builds/twilio-conversations.min.js +2 -1
- package/builds/twilio-conversations.min.js.map +1 -0
- package/dist/aggregated-delivery-receipt.js +1 -5
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/channel-metadata-client.js +5 -10
- package/dist/channel-metadata-client.js.map +1 -1
- package/dist/client.js +218 -206
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +6 -10
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +6 -10
- package/dist/configuration.js.map +1 -1
- package/dist/content-client.js +5 -9
- package/dist/content-client.js.map +1 -1
- package/dist/content-template.js +1 -7
- package/dist/content-template.js.map +1 -1
- package/dist/conversation.js +166 -136
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +44 -46
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +18 -22
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +22 -25
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +10 -14
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js +1 -5
- package/dist/detailed-delivery-receipt.js.map +1 -1
- package/dist/index.js +17 -49
- package/dist/index.js.map +1 -1
- package/dist/interfaces/notification-types.js +1 -5
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/interfaces/rules.js +7 -13
- package/dist/interfaces/rules.js.map +1 -1
- package/dist/logger.js +9 -29
- package/dist/logger.js.map +1 -1
- package/dist/media.js +32 -25
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +43 -47
- package/dist/message-builder.js.map +1 -1
- package/dist/message-recipients-client.js +10 -16
- package/dist/message-recipients-client.js.map +1 -1
- package/dist/message.js +114 -98
- package/dist/message.js.map +1 -1
- package/dist/node_modules/quick-lru/index.js +1 -5
- package/dist/node_modules/quick-lru/index.js.map +1 -1
- package/dist/node_modules/tslib/tslib.es6.js +7 -6
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/packages/conversations/package.json.js +2 -6
- package/dist/packages/conversations/package.json.js.map +1 -1
- package/dist/participant.js +32 -37
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js +1 -5
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js +1 -5
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +3 -7
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +7 -10
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js +5 -9
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +21 -30
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js +1 -5
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js +36 -9
- package/dist/util/index.js.map +1 -1
- package/dist/utils/uuid.js +145 -0
- package/dist/utils/uuid.js.map +1 -0
- package/package.json +14 -17
- package/docs/assets/css/main.css +0 -2660
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -248
- package/docs/assets/js/search.js +0 -1
- package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
- package/docs/classes/CancellablePromise.html +0 -3213
- package/docs/classes/ChannelMetadata.html +0 -3050
- package/docs/classes/Client.html +0 -4278
- package/docs/classes/ContentTemplate.html +0 -3116
- package/docs/classes/ContentTemplateVariable.html +0 -3116
- package/docs/classes/Conversation.html +0 -4382
- package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
- package/docs/classes/EmailRecipientDescriptor.html +0 -3098
- package/docs/classes/Media.html +0 -3167
- package/docs/classes/Message.html +0 -3826
- package/docs/classes/MessageBuilder.html +0 -3318
- package/docs/classes/Participant.html +0 -3444
- package/docs/classes/PushNotification.html +0 -3130
- package/docs/classes/RestPaginator.html +0 -3160
- package/docs/classes/UnknownRecipientDescriptor.html +0 -3067
- package/docs/classes/UnsentMessage.html +0 -3042
- package/docs/classes/User.html +0 -3349
- package/docs/index.html +0 -4373
- package/docs/interfaces/ClientOptions.html +0 -3066
- package/docs/interfaces/ConversationBindings.html +0 -3001
- package/docs/interfaces/ConversationEmailBinding.html +0 -3001
- package/docs/interfaces/ConversationLimits.html +0 -3098
- package/docs/interfaces/ConversationState.html +0 -3050
- package/docs/interfaces/ConversationUpdatedEventArgs.html +0 -3001
- package/docs/interfaces/CreateConversationOptions.html +0 -3066
- package/docs/interfaces/LastMessage.html +0 -3050
- package/docs/interfaces/Paginator.html +0 -3141
- package/docs/interfaces/ParticipantBindings.html +0 -3001
- package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
- package/docs/interfaces/PushNotificationData.html +0 -3114
- package/docs/interfaces/SendEmailOptions.html +0 -3034
- package/docs/interfaces/SendMediaOptions.html +0 -3068
- package/docs/modules.html +0 -4374
package/builds/browser.js
CHANGED
|
@@ -154,10 +154,10 @@ var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
|
|
|
154
154
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
155
155
|
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
156
156
|
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
157
|
-
require('core-js/modules/es.object.to-string.js');
|
|
158
|
-
require('core-js/modules/es.promise.js');
|
|
159
157
|
require('core-js/modules/es.array.map.js');
|
|
158
|
+
require('core-js/modules/es.object.to-string.js');
|
|
160
159
|
require('core-js/modules/web.dom-collections.for-each.js');
|
|
160
|
+
require('core-js/modules/es.promise.js');
|
|
161
161
|
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
162
162
|
var _typeof = require('@babel/runtime/helpers/typeof');
|
|
163
163
|
require('core-js/modules/es.array.concat.js');
|
|
@@ -176,7 +176,6 @@ var declarativeTypeValidator = require('@twilio/declarative-type-validator');
|
|
|
176
176
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
177
177
|
require('core-js/modules/es.array.includes.js');
|
|
178
178
|
var replayEventEmitter = require('@twilio/replay-event-emitter');
|
|
179
|
-
var isEqual = require('lodash.isequal');
|
|
180
179
|
require('core-js/modules/es.array.slice.js');
|
|
181
180
|
require('core-js/modules/es.function.name.js');
|
|
182
181
|
require('core-js/modules/es.regexp.test.js');
|
|
@@ -217,16 +216,15 @@ require('core-js/modules/es.typed-array.subarray.js');
|
|
|
217
216
|
require('core-js/modules/es.typed-array.to-locale-string.js');
|
|
218
217
|
require('core-js/modules/es.typed-array.to-string.js');
|
|
219
218
|
require('core-js/modules/es.array-buffer.constructor.js');
|
|
220
|
-
require('isomorphic-form-data');
|
|
221
219
|
require('core-js/modules/es.array.sort.js');
|
|
222
220
|
require('core-js/modules/es.string.includes.js');
|
|
223
221
|
require('core-js/modules/es.string.starts-with.js');
|
|
222
|
+
require('core-js/modules/es.weak-set.js');
|
|
224
223
|
var deprecationDecorator = require('@twilio/deprecation-decorator');
|
|
225
224
|
require('core-js/modules/es.object.entries.js');
|
|
226
225
|
require('core-js/modules/es.array.find.js');
|
|
227
226
|
require('core-js/modules/es.array.splice.js');
|
|
228
227
|
var _wrapNativeSuper = require('@babel/runtime/helpers/wrapNativeSuper');
|
|
229
|
-
var uuid = require('uuid');
|
|
230
228
|
require('core-js/modules/es.object.freeze.js');
|
|
231
229
|
|
|
232
230
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -261,7 +259,6 @@ var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regenerat
|
|
|
261
259
|
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
262
260
|
var loglevelLog__namespace = /*#__PURE__*/_interopNamespace(loglevelLog);
|
|
263
261
|
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
264
|
-
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
265
262
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
266
263
|
var _wrapNativeSuper__default = /*#__PURE__*/_interopDefaultLegacy(_wrapNativeSuper);
|
|
267
264
|
|
|
@@ -301,11 +298,13 @@ var Logger = /*#__PURE__*/function () {
|
|
|
301
298
|
}, {
|
|
302
299
|
key: "trace",
|
|
303
300
|
value: function trace() {
|
|
304
|
-
|
|
305
|
-
args
|
|
306
|
-
|
|
301
|
+
if (log$7.getLevel() == log$7.levels.TRACE) {
|
|
302
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
303
|
+
args[_key] = arguments[_key];
|
|
304
|
+
}
|
|
307
305
|
|
|
308
|
-
|
|
306
|
+
log$7.debug.apply(null, prepareLine(this.prefix + "T", args));
|
|
307
|
+
}
|
|
309
308
|
}
|
|
310
309
|
}, {
|
|
311
310
|
key: "debug",
|
|
@@ -356,11 +355,13 @@ var Logger = /*#__PURE__*/function () {
|
|
|
356
355
|
}, {
|
|
357
356
|
key: "trace",
|
|
358
357
|
value: function trace() {
|
|
359
|
-
|
|
360
|
-
args
|
|
361
|
-
|
|
358
|
+
if (log$7.getLevel() == log$7.levels.TRACE) {
|
|
359
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
360
|
+
args[_key6] = arguments[_key6];
|
|
361
|
+
}
|
|
362
362
|
|
|
363
|
-
|
|
363
|
+
log$7.debug.apply(null, prepareLine("T", args));
|
|
364
|
+
}
|
|
364
365
|
}
|
|
365
366
|
}, {
|
|
366
367
|
key: "debug",
|
|
@@ -570,6 +571,56 @@ var UriBuilder = /*#__PURE__*/function () {
|
|
|
570
571
|
|
|
571
572
|
return UriBuilder;
|
|
572
573
|
}();
|
|
574
|
+
/**
|
|
575
|
+
* Deep equality check for objects
|
|
576
|
+
* @param a - first value to compare
|
|
577
|
+
* @param b - second value to compare
|
|
578
|
+
* @returns true if values are deeply equal
|
|
579
|
+
*/
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
function isEqual(a, b) {
|
|
583
|
+
if (a === b) {
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
if (a === null || b === null || a === undefined || b === undefined) {
|
|
588
|
+
return a === b;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
if (_typeof__default["default"](a) !== _typeof__default["default"](b)) {
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
if (_typeof__default["default"](a) !== "object") {
|
|
596
|
+
return a === b;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
600
|
+
if (a.length !== b.length) {
|
|
601
|
+
return false;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
return a.every(function (item, index) {
|
|
605
|
+
return isEqual(item, b[index]);
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
var aKeys = Object.keys(a);
|
|
614
|
+
var bKeys = Object.keys(b);
|
|
615
|
+
|
|
616
|
+
if (aKeys.length !== bKeys.length) {
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return aKeys.every(function (key) {
|
|
621
|
+
return isEqual(a[key], b[key]);
|
|
622
|
+
});
|
|
623
|
+
}
|
|
573
624
|
|
|
574
625
|
var json = declarativeTypeValidator.custom(function (value) {
|
|
575
626
|
return [["string", "number", "boolean", "object"].includes(_typeof__default["default"](value)), "a JSON type"];
|
|
@@ -650,6 +701,22 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
650
701
|
* @event
|
|
651
702
|
*/
|
|
652
703
|
|
|
704
|
+
/**
|
|
705
|
+
* Fired when the client has subscribed to the user.
|
|
706
|
+
*
|
|
707
|
+
* Parameters:
|
|
708
|
+
* 1. {@link User} `user` - the user in question
|
|
709
|
+
* @event
|
|
710
|
+
*/
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Fired when the client has unsubscribed from the user.
|
|
714
|
+
*
|
|
715
|
+
* Parameters:
|
|
716
|
+
* 1. {@link User} `user` - the user in question
|
|
717
|
+
* @event
|
|
718
|
+
*/
|
|
719
|
+
|
|
653
720
|
|
|
654
721
|
_createClass__default["default"](User, [{
|
|
655
722
|
key: "identity",
|
|
@@ -744,7 +811,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
744
811
|
case 9:
|
|
745
812
|
updateAttributes = parseAttributes(value.value, "Retrieved malformed attributes from the server for user: ".concat(this.state.identity), log$6);
|
|
746
813
|
|
|
747
|
-
if (!
|
|
814
|
+
if (!isEqual(this.state.attributes, updateAttributes)) {
|
|
748
815
|
this.state.attributes = updateAttributes;
|
|
749
816
|
updateReasons.push("attributes");
|
|
750
817
|
}
|
|
@@ -1322,6 +1389,24 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1322
1389
|
* @event
|
|
1323
1390
|
*/
|
|
1324
1391
|
|
|
1392
|
+
/**
|
|
1393
|
+
* Fired when the participant has stopped typing.
|
|
1394
|
+
*
|
|
1395
|
+
* Parameters:
|
|
1396
|
+
* 1. {@link Participant} `participant` - the participant in question
|
|
1397
|
+
* @event
|
|
1398
|
+
*/
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* Fired when the fields of the participant have been updated.
|
|
1402
|
+
*
|
|
1403
|
+
* Parameters:
|
|
1404
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
|
1405
|
+
* * {@link Participant} participant - the participant in question
|
|
1406
|
+
* * {@link ParticipantUpdateReason}[] updateReasons - array of reasons for the update
|
|
1407
|
+
* @event
|
|
1408
|
+
*/
|
|
1409
|
+
|
|
1325
1410
|
|
|
1326
1411
|
_createClass__default["default"](Participant, [{
|
|
1327
1412
|
key: "sid",
|
|
@@ -1448,8 +1533,9 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1448
1533
|
}
|
|
1449
1534
|
|
|
1450
1535
|
this.state.isTyping = true;
|
|
1451
|
-
this.emit(
|
|
1452
|
-
this.conversation.emit(
|
|
1536
|
+
this.emit(Participant.typingStarted, this);
|
|
1537
|
+
this.conversation.emit(Conversation.typingStarted, this); // @fixme layering violation
|
|
1538
|
+
|
|
1453
1539
|
this.state.typingTimeout = Number(setTimeout(function () {
|
|
1454
1540
|
return _this2._endTyping();
|
|
1455
1541
|
}, timeout));
|
|
@@ -1468,8 +1554,8 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1468
1554
|
}
|
|
1469
1555
|
|
|
1470
1556
|
this.state.isTyping = false;
|
|
1471
|
-
this.emit(
|
|
1472
|
-
this.conversation.emit(
|
|
1557
|
+
this.emit(Participant.typingEnded, this);
|
|
1558
|
+
this.conversation.emit(Conversation.typingEnded, this);
|
|
1473
1559
|
clearInterval(this.state.typingTimeout);
|
|
1474
1560
|
this.state.typingTimeout = null;
|
|
1475
1561
|
}
|
|
@@ -1484,7 +1570,7 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1484
1570
|
var updateReasons = [];
|
|
1485
1571
|
var updateAttributes = parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + this.state.sid, log$5);
|
|
1486
1572
|
|
|
1487
|
-
if (data.attributes && !
|
|
1573
|
+
if (data.attributes && !isEqual(this.state.attributes, updateAttributes)) {
|
|
1488
1574
|
this.state.attributes = updateAttributes;
|
|
1489
1575
|
updateReasons.push("attributes");
|
|
1490
1576
|
}
|
|
@@ -1522,13 +1608,13 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1522
1608
|
}
|
|
1523
1609
|
}
|
|
1524
1610
|
|
|
1525
|
-
if (data.bindings && !
|
|
1611
|
+
if (data.bindings && !isEqual(this.state.bindings, data.bindings)) {
|
|
1526
1612
|
this.state.bindings = data.bindings;
|
|
1527
1613
|
updateReasons.push("bindings");
|
|
1528
1614
|
}
|
|
1529
1615
|
|
|
1530
1616
|
if (updateReasons.length > 0) {
|
|
1531
|
-
this.emit(
|
|
1617
|
+
this.emit(Participant.updated, {
|
|
1532
1618
|
participant: this,
|
|
1533
1619
|
updateReasons: updateReasons
|
|
1534
1620
|
});
|
|
@@ -1664,7 +1750,8 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1664
1750
|
|
|
1665
1751
|
var _super = _createSuper$7(Participants);
|
|
1666
1752
|
|
|
1667
|
-
|
|
1753
|
+
// passed in from Conversation
|
|
1754
|
+
function Participants(conversation, participants, links, services) {
|
|
1668
1755
|
var _this;
|
|
1669
1756
|
|
|
1670
1757
|
_classCallCheck__default["default"](this, Participants);
|
|
@@ -1676,7 +1763,6 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1676
1763
|
_this.conversation = conversation;
|
|
1677
1764
|
_this.participants = participants;
|
|
1678
1765
|
_this.links = links;
|
|
1679
|
-
_this.configuration = configuration;
|
|
1680
1766
|
_this.services = services;
|
|
1681
1767
|
return _this;
|
|
1682
1768
|
}
|
|
@@ -1727,14 +1813,14 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1727
1813
|
mode: "open_existing"
|
|
1728
1814
|
}) : Promise.resolve(arg);
|
|
1729
1815
|
return this.rosterEntityPromise = this.rosterEntityPromise || participantsMapPromise.then(function (rosterMap) {
|
|
1730
|
-
rosterMap.on(
|
|
1816
|
+
rosterMap.on(twilioSync.SyncMap.itemAdded, function (args) {
|
|
1731
1817
|
log$4.debug(_this2.conversation.sid + " itemAdded: " + args.item.key);
|
|
1732
1818
|
|
|
1733
1819
|
_this2.upsertParticipant(args.item.key, args.item.data).then(function (participant) {
|
|
1734
|
-
_this2.emit(
|
|
1820
|
+
_this2.emit(Conversation.participantJoined, participant);
|
|
1735
1821
|
});
|
|
1736
1822
|
});
|
|
1737
|
-
rosterMap.on(
|
|
1823
|
+
rosterMap.on(twilioSync.SyncMap.itemRemoved, function (args) {
|
|
1738
1824
|
log$4.debug(_this2.conversation.sid + " itemRemoved: " + args.key);
|
|
1739
1825
|
var participantSid = args.key;
|
|
1740
1826
|
|
|
@@ -1750,12 +1836,14 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1750
1836
|
return;
|
|
1751
1837
|
}
|
|
1752
1838
|
|
|
1753
|
-
_this2.emit(
|
|
1839
|
+
_this2.emit(Conversation.participantLeft, leftParticipant);
|
|
1754
1840
|
});
|
|
1755
|
-
rosterMap.on(
|
|
1841
|
+
rosterMap.on(twilioSync.SyncMap.itemUpdated, function (args) {
|
|
1756
1842
|
log$4.debug(_this2.conversation.sid + " itemUpdated: " + args.item.key);
|
|
1757
1843
|
|
|
1758
|
-
_this2.upsertParticipant(args.item.key, args.item.data)
|
|
1844
|
+
_this2.upsertParticipant(args.item.key, args.item.data).catch(function (e) {
|
|
1845
|
+
return log$4.error(e);
|
|
1846
|
+
});
|
|
1759
1847
|
});
|
|
1760
1848
|
var participantsPromises = [];
|
|
1761
1849
|
|
|
@@ -1849,8 +1937,8 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1849
1937
|
};
|
|
1850
1938
|
participant = new Participant(data, participantSid, this.conversation, links, this.services);
|
|
1851
1939
|
this.participants.set(participantSid, participant);
|
|
1852
|
-
participant.on(
|
|
1853
|
-
return _this3.emit(
|
|
1940
|
+
participant.on(Participant.updated, function (args) {
|
|
1941
|
+
return _this3.emit(Conversation.participantUpdated, args);
|
|
1854
1942
|
});
|
|
1855
1943
|
return _context3.abrupt("return", participant);
|
|
1856
1944
|
|
|
@@ -2114,6 +2202,8 @@ var Media = /*#__PURE__*/function () {
|
|
|
2114
2202
|
* @internal
|
|
2115
2203
|
*/
|
|
2116
2204
|
function Media(data, services) {
|
|
2205
|
+
var _data$filename;
|
|
2206
|
+
|
|
2117
2207
|
_classCallCheck__default["default"](this, Media);
|
|
2118
2208
|
|
|
2119
2209
|
_defineProperty__default["default"](this, "mcsMedia", null);
|
|
@@ -2127,7 +2217,7 @@ var Media = /*#__PURE__*/function () {
|
|
|
2127
2217
|
this.state = {
|
|
2128
2218
|
sid: data.sid,
|
|
2129
2219
|
category: data.category,
|
|
2130
|
-
filename: data.filename,
|
|
2220
|
+
filename: (_data$filename = data.filename) !== null && _data$filename !== void 0 ? _data$filename : null,
|
|
2131
2221
|
contentType: data.contentType,
|
|
2132
2222
|
size: data.size
|
|
2133
2223
|
};
|
|
@@ -2200,10 +2290,12 @@ var Media = /*#__PURE__*/function () {
|
|
|
2200
2290
|
while (1) {
|
|
2201
2291
|
switch (_context.prev = _context.next) {
|
|
2202
2292
|
case 0:
|
|
2203
|
-
fetchMediaRequest = _this._fetchMcsMedia();
|
|
2293
|
+
fetchMediaRequest = _this.mcsMedia ? undefined : _this._fetchMcsMedia();
|
|
2204
2294
|
contentUrlRequest = (_this$mcsMedia = _this.mcsMedia) === null || _this$mcsMedia === void 0 ? void 0 : _this$mcsMedia.getContentUrl();
|
|
2205
2295
|
onCancel(function () {
|
|
2206
|
-
fetchMediaRequest
|
|
2296
|
+
if (fetchMediaRequest) {
|
|
2297
|
+
fetchMediaRequest.cancel();
|
|
2298
|
+
}
|
|
2207
2299
|
|
|
2208
2300
|
if (contentUrlRequest) {
|
|
2209
2301
|
contentUrlRequest.cancel();
|
|
@@ -2211,7 +2303,7 @@ var Media = /*#__PURE__*/function () {
|
|
|
2211
2303
|
});
|
|
2212
2304
|
_context.prev = 3;
|
|
2213
2305
|
|
|
2214
|
-
if (
|
|
2306
|
+
if (contentUrlRequest) {
|
|
2215
2307
|
_context.next = 9;
|
|
2216
2308
|
break;
|
|
2217
2309
|
}
|
|
@@ -2221,7 +2313,7 @@ var Media = /*#__PURE__*/function () {
|
|
|
2221
2313
|
|
|
2222
2314
|
case 7:
|
|
2223
2315
|
mcsMedia = _context.sent;
|
|
2224
|
-
contentUrlRequest = mcsMedia.getContentUrl();
|
|
2316
|
+
contentUrlRequest = mcsMedia === null || mcsMedia === void 0 ? void 0 : mcsMedia.getContentUrl();
|
|
2225
2317
|
|
|
2226
2318
|
case 9:
|
|
2227
2319
|
_context.t0 = resolve;
|
|
@@ -2278,13 +2370,11 @@ var Media = /*#__PURE__*/function () {
|
|
|
2278
2370
|
while (1) {
|
|
2279
2371
|
switch (_context2.prev = _context2.next) {
|
|
2280
2372
|
case 0:
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
if (!_this2.services.mcsClient) {
|
|
2284
|
-
_context2.next = 14;
|
|
2285
|
-
break;
|
|
2373
|
+
if (_this2.services.mcsClient === null) {
|
|
2374
|
+
reject(new Error("Media Content Service is unavailable"));
|
|
2286
2375
|
}
|
|
2287
2376
|
|
|
2377
|
+
request = _this2.services.mcsClient.get(_this2.state.sid);
|
|
2288
2378
|
onCancel(function () {
|
|
2289
2379
|
return request.cancel();
|
|
2290
2380
|
});
|
|
@@ -2294,27 +2384,22 @@ var Media = /*#__PURE__*/function () {
|
|
|
2294
2384
|
|
|
2295
2385
|
case 6:
|
|
2296
2386
|
_this2.mcsMedia = _context2.sent;
|
|
2387
|
+
_this2.state = _this2.mcsMedia._state();
|
|
2297
2388
|
resolve(_this2.mcsMedia);
|
|
2298
|
-
_context2.next =
|
|
2389
|
+
_context2.next = 14;
|
|
2299
2390
|
break;
|
|
2300
2391
|
|
|
2301
|
-
case
|
|
2302
|
-
_context2.prev =
|
|
2392
|
+
case 11:
|
|
2393
|
+
_context2.prev = 11;
|
|
2303
2394
|
_context2.t0 = _context2["catch"](3);
|
|
2304
2395
|
reject(_context2.t0);
|
|
2305
2396
|
|
|
2306
|
-
case 13:
|
|
2307
|
-
return _context2.abrupt("return");
|
|
2308
|
-
|
|
2309
2397
|
case 14:
|
|
2310
|
-
reject(new Error("Media Content Service is unavailable"));
|
|
2311
|
-
|
|
2312
|
-
case 15:
|
|
2313
2398
|
case "end":
|
|
2314
2399
|
return _context2.stop();
|
|
2315
2400
|
}
|
|
2316
2401
|
}
|
|
2317
|
-
}, _callee2, null, [[3,
|
|
2402
|
+
}, _callee2, null, [[3, 11]]);
|
|
2318
2403
|
}));
|
|
2319
2404
|
|
|
2320
2405
|
return function (_x4, _x5, _x6) {
|
|
@@ -2322,6 +2407,15 @@ var Media = /*#__PURE__*/function () {
|
|
|
2322
2407
|
};
|
|
2323
2408
|
}());
|
|
2324
2409
|
}
|
|
2410
|
+
/**
|
|
2411
|
+
* @internal
|
|
2412
|
+
*/
|
|
2413
|
+
|
|
2414
|
+
}, {
|
|
2415
|
+
key: "_state",
|
|
2416
|
+
value: function _state() {
|
|
2417
|
+
return this.state;
|
|
2418
|
+
}
|
|
2325
2419
|
}]);
|
|
2326
2420
|
|
|
2327
2421
|
return Media;
|
|
@@ -2819,6 +2913,12 @@ function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
2819
2913
|
function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
|
|
2820
2914
|
|
|
2821
2915
|
function _isNativeReflectConstruct$6() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
2916
|
+
|
|
2917
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
2918
|
+
|
|
2919
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
2920
|
+
|
|
2921
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
2822
2922
|
var log$3 = Logger.scope("Message");
|
|
2823
2923
|
|
|
2824
2924
|
var XHR = // eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
@@ -2828,6 +2928,10 @@ global["XMLHttpRequest"] || {};
|
|
|
2828
2928
|
*/
|
|
2829
2929
|
|
|
2830
2930
|
|
|
2931
|
+
var _wrapMedia = /*#__PURE__*/new WeakSet();
|
|
2932
|
+
|
|
2933
|
+
var _assignMedias = /*#__PURE__*/new WeakSet();
|
|
2934
|
+
|
|
2831
2935
|
var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2832
2936
|
_inherits__default["default"](Message, _ReplayEventEmitter);
|
|
2833
2937
|
|
|
@@ -2841,13 +2945,18 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2841
2945
|
* @internal
|
|
2842
2946
|
*/
|
|
2843
2947
|
function Message(index, data, conversation, links, configuration, services) {
|
|
2844
|
-
var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid, _data$channelMetadata;
|
|
2948
|
+
var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid, _data$channelMetadata, _data$medias, _data$media;
|
|
2845
2949
|
|
|
2846
2950
|
var _this;
|
|
2847
2951
|
|
|
2848
2952
|
_classCallCheck__default["default"](this, Message);
|
|
2849
2953
|
|
|
2850
2954
|
_this = _super.call(this);
|
|
2955
|
+
|
|
2956
|
+
_classPrivateMethodInitSpec(_assertThisInitialized__default["default"](_this), _assignMedias);
|
|
2957
|
+
|
|
2958
|
+
_classPrivateMethodInitSpec(_assertThisInitialized__default["default"](_this), _wrapMedia);
|
|
2959
|
+
|
|
2851
2960
|
_this.conversation = conversation;
|
|
2852
2961
|
_this.links = links;
|
|
2853
2962
|
_this.configuration = configuration;
|
|
@@ -2864,16 +2973,15 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2864
2973
|
lastUpdatedBy: (_data$lastUpdatedBy = data.lastUpdatedBy) !== null && _data$lastUpdatedBy !== void 0 ? _data$lastUpdatedBy : null,
|
|
2865
2974
|
attributes: parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(data.sid), log$3),
|
|
2866
2975
|
type: (_data$type = data.type) !== null && _data$type !== void 0 ? _data$type : "text",
|
|
2867
|
-
media:
|
|
2868
|
-
medias:
|
|
2869
|
-
return new Media(m, _this.services);
|
|
2870
|
-
}) : data.type === "media" && data.media && !data.medias ? [new Media(_objectSpread$4(_objectSpread$4({}, data.media), {}, {
|
|
2871
|
-
category: "media"
|
|
2872
|
-
}), _this.services)] : null,
|
|
2976
|
+
media: null,
|
|
2977
|
+
medias: null,
|
|
2873
2978
|
participantSid: (_data$memberSid = data.memberSid) !== null && _data$memberSid !== void 0 ? _data$memberSid : null,
|
|
2874
2979
|
aggregatedDeliveryReceipt: data.delivery ? new AggregatedDeliveryReceipt(data.delivery) : null,
|
|
2875
2980
|
hasChannelMetadata: (_data$channelMetadata = data.channelMetadata) !== null && _data$channelMetadata !== void 0 ? _data$channelMetadata : false
|
|
2876
2981
|
};
|
|
2982
|
+
|
|
2983
|
+
_classPrivateMethodGet(_assertThisInitialized__default["default"](_this), _assignMedias, _assignMedias2).call(_assertThisInitialized__default["default"](_this), (_data$medias = data.medias) !== null && _data$medias !== void 0 ? _data$medias : null, (_data$media = data.media) !== null && _data$media !== void 0 ? _data$media : null);
|
|
2984
|
+
|
|
2877
2985
|
return _this;
|
|
2878
2986
|
}
|
|
2879
2987
|
/**
|
|
@@ -3095,6 +3203,12 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3095
3203
|
}, {
|
|
3096
3204
|
key: "_update",
|
|
3097
3205
|
value: function _update(data) {
|
|
3206
|
+
var _data$medias2,
|
|
3207
|
+
_this2 = this,
|
|
3208
|
+
_this$state$medias2,
|
|
3209
|
+
_classPrivateMethodGe2,
|
|
3210
|
+
_this$state$media;
|
|
3211
|
+
|
|
3098
3212
|
var updateReasons = [];
|
|
3099
3213
|
|
|
3100
3214
|
if ((data.text || typeof data.text === "string") && data.text !== this.state.body) {
|
|
@@ -3129,7 +3243,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3129
3243
|
|
|
3130
3244
|
var updatedAttributes = parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(this.sid), log$3);
|
|
3131
3245
|
|
|
3132
|
-
if (!
|
|
3246
|
+
if (!isEqual(this.state.attributes, updatedAttributes)) {
|
|
3133
3247
|
this.state.attributes = updatedAttributes;
|
|
3134
3248
|
updateReasons.push("attributes");
|
|
3135
3249
|
}
|
|
@@ -3147,6 +3261,29 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3147
3261
|
|
|
3148
3262
|
updateReasons.push("deliveryReceipt");
|
|
3149
3263
|
}
|
|
3264
|
+
} // @fixme: This is a fairly heavy check.
|
|
3265
|
+
// Map data back and forth to perform a necessary field massage.
|
|
3266
|
+
|
|
3267
|
+
|
|
3268
|
+
var input = ((_data$medias2 = data.medias) !== null && _data$medias2 !== void 0 ? _data$medias2 : []).map(function (value) {
|
|
3269
|
+
var _classPrivateMethodGe;
|
|
3270
|
+
|
|
3271
|
+
return (_classPrivateMethodGe = _classPrivateMethodGet(_this2, _wrapMedia, _wrapMedia2).call(_this2, value)) === null || _classPrivateMethodGe === void 0 ? void 0 : _classPrivateMethodGe._state();
|
|
3272
|
+
}).filter(function (el) {
|
|
3273
|
+
return !(el === null);
|
|
3274
|
+
});
|
|
3275
|
+
var current = ((_this$state$medias2 = this.state.medias) !== null && _this$state$medias2 !== void 0 ? _this$state$medias2 : []).map(function (value) {
|
|
3276
|
+
return value._state();
|
|
3277
|
+
}).filter(function (el) {
|
|
3278
|
+
return !(el === null);
|
|
3279
|
+
});
|
|
3280
|
+
|
|
3281
|
+
if (!isEqual(input, current) || !isEqual((_classPrivateMethodGe2 = _classPrivateMethodGet(this, _wrapMedia, _wrapMedia2).call(this, data.media)) === null || _classPrivateMethodGe2 === void 0 ? void 0 : _classPrivateMethodGe2._state(), (_this$state$media = this.state.media) === null || _this$state$media === void 0 ? void 0 : _this$state$media._state())) {
|
|
3282
|
+
var _data$medias3, _data$media2;
|
|
3283
|
+
|
|
3284
|
+
_classPrivateMethodGet(this, _assignMedias, _assignMedias2).call(this, (_data$medias3 = data.medias) !== null && _data$medias3 !== void 0 ? _data$medias3 : null, (_data$media2 = data.media) !== null && _data$media2 !== void 0 ? _data$media2 : null);
|
|
3285
|
+
|
|
3286
|
+
updateReasons.push("media");
|
|
3150
3287
|
}
|
|
3151
3288
|
|
|
3152
3289
|
if (updateReasons.length > 0) {
|
|
@@ -3164,9 +3301,9 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3164
3301
|
key: "getParticipant",
|
|
3165
3302
|
value: function () {
|
|
3166
3303
|
var _getParticipant = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
3167
|
-
var
|
|
3304
|
+
var _this3 = this;
|
|
3168
3305
|
|
|
3169
|
-
var participant,
|
|
3306
|
+
var participant, errorMessage;
|
|
3170
3307
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
3171
3308
|
while (1) {
|
|
3172
3309
|
switch (_context.prev = _context.next) {
|
|
@@ -3180,7 +3317,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3180
3317
|
|
|
3181
3318
|
_context.next = 4;
|
|
3182
3319
|
return this.conversation.getParticipantBySid(this.state.participantSid).catch(function () {
|
|
3183
|
-
log$3.debug("Participant with sid \"".concat(
|
|
3320
|
+
log$3.debug("Participant with sid \"".concat(_this3.participantSid, "\" not found for message ").concat(_this3.sid));
|
|
3184
3321
|
return null;
|
|
3185
3322
|
});
|
|
3186
3323
|
|
|
@@ -3195,7 +3332,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3195
3332
|
|
|
3196
3333
|
_context.next = 8;
|
|
3197
3334
|
return this.conversation.getParticipantByIdentity(this.state.author).catch(function () {
|
|
3198
|
-
log$3.debug("Participant with identity \"".concat(
|
|
3335
|
+
log$3.debug("Participant with identity \"".concat(_this3.author, "\" not found for message ").concat(_this3.sid));
|
|
3199
3336
|
return null;
|
|
3200
3337
|
});
|
|
3201
3338
|
|
|
@@ -3211,26 +3348,26 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3211
3348
|
return _context.abrupt("return", participant);
|
|
3212
3349
|
|
|
3213
3350
|
case 11:
|
|
3214
|
-
|
|
3351
|
+
errorMessage = "Participant with ";
|
|
3215
3352
|
|
|
3216
3353
|
if (this.state.participantSid) {
|
|
3217
|
-
|
|
3354
|
+
errorMessage += "SID '" + this.state.participantSid + "' ";
|
|
3218
3355
|
}
|
|
3219
3356
|
|
|
3220
3357
|
if (this.state.author) {
|
|
3221
3358
|
if (this.state.participantSid) {
|
|
3222
|
-
|
|
3359
|
+
errorMessage += "or ";
|
|
3223
3360
|
}
|
|
3224
3361
|
|
|
3225
|
-
|
|
3362
|
+
errorMessage += "identity '" + this.state.author + "' ";
|
|
3226
3363
|
}
|
|
3227
3364
|
|
|
3228
|
-
if (
|
|
3229
|
-
|
|
3365
|
+
if (errorMessage === "Participant with ") {
|
|
3366
|
+
errorMessage = "Participant ";
|
|
3230
3367
|
}
|
|
3231
3368
|
|
|
3232
|
-
|
|
3233
|
-
throw new Error(
|
|
3369
|
+
errorMessage += "was not found";
|
|
3370
|
+
throw new Error(errorMessage);
|
|
3234
3371
|
|
|
3235
3372
|
case 17:
|
|
3236
3373
|
case "end":
|
|
@@ -3410,7 +3547,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3410
3547
|
key: "attachTemporaryUrlsFor",
|
|
3411
3548
|
value: function () {
|
|
3412
3549
|
var _attachTemporaryUrlsFor = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(contentSet) {
|
|
3413
|
-
var
|
|
3550
|
+
var _this4 = this;
|
|
3414
3551
|
|
|
3415
3552
|
var sids;
|
|
3416
3553
|
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context6) {
|
|
@@ -3433,7 +3570,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3433
3570
|
|
|
3434
3571
|
case 4:
|
|
3435
3572
|
return _context6.abrupt("return", _context6.sent.map(function (item) {
|
|
3436
|
-
return new Media(item,
|
|
3573
|
+
return new Media(item, _this4.services);
|
|
3437
3574
|
}));
|
|
3438
3575
|
|
|
3439
3576
|
case 7:
|
|
@@ -3476,7 +3613,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3476
3613
|
}, {
|
|
3477
3614
|
key: "getTemporaryContentUrlsForMediaSids",
|
|
3478
3615
|
value: function getTemporaryContentUrlsForMediaSids(mediaSids) {
|
|
3479
|
-
var
|
|
3616
|
+
var _this5 = this;
|
|
3480
3617
|
|
|
3481
3618
|
return new mcsClient.CancellablePromise( /*#__PURE__*/function () {
|
|
3482
3619
|
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(resolve, reject, onCancel) {
|
|
@@ -3485,9 +3622,9 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3485
3622
|
while (1) {
|
|
3486
3623
|
switch (_context7.prev = _context7.next) {
|
|
3487
3624
|
case 0:
|
|
3488
|
-
mediaGetRequest =
|
|
3625
|
+
mediaGetRequest = _this5.services.mcsClient.mediaSetGetContentUrls(mediaSids !== null && mediaSids !== void 0 ? mediaSids : []);
|
|
3489
3626
|
|
|
3490
|
-
if (!(!
|
|
3627
|
+
if (!(!_this5.services.mcsClient || !mediaSids)) {
|
|
3491
3628
|
_context7.next = 4;
|
|
3492
3629
|
break;
|
|
3493
3630
|
}
|
|
@@ -3546,7 +3683,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3546
3683
|
key: "_getDetailedDeliveryReceiptsPaginator",
|
|
3547
3684
|
value: function () {
|
|
3548
3685
|
var _getDetailedDeliveryReceiptsPaginator2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8(options) {
|
|
3549
|
-
var
|
|
3686
|
+
var _this6 = this;
|
|
3550
3687
|
|
|
3551
3688
|
var messagesReceiptsUrl, url, response;
|
|
3552
3689
|
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context8) {
|
|
@@ -3563,7 +3700,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3563
3700
|
return _context8.abrupt("return", new RestPaginator(response.body.delivery_receipts.map(function (x) {
|
|
3564
3701
|
return new DetailedDeliveryReceipt(x);
|
|
3565
3702
|
}), function (pageToken, pageSize) {
|
|
3566
|
-
return
|
|
3703
|
+
return _this6._getDetailedDeliveryReceiptsPaginator({
|
|
3567
3704
|
pageToken: pageToken,
|
|
3568
3705
|
pageSize: pageSize
|
|
3569
3706
|
});
|
|
@@ -3591,7 +3728,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3591
3728
|
}, {
|
|
3592
3729
|
key: "getContentData",
|
|
3593
3730
|
value: function getContentData() {
|
|
3594
|
-
var
|
|
3731
|
+
var _this7 = this;
|
|
3595
3732
|
|
|
3596
3733
|
return new mcsClient.CancellablePromise( /*#__PURE__*/function () {
|
|
3597
3734
|
var _ref2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9(resolve, reject, onCancel) {
|
|
@@ -3600,7 +3737,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3600
3737
|
while (1) {
|
|
3601
3738
|
switch (_context9.prev = _context9.next) {
|
|
3602
3739
|
case 0:
|
|
3603
|
-
if (!(
|
|
3740
|
+
if (!(_this7.state.contentSid === null)) {
|
|
3604
3741
|
_context9.next = 3;
|
|
3605
3742
|
break;
|
|
3606
3743
|
}
|
|
@@ -3609,7 +3746,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3609
3746
|
return _context9.abrupt("return");
|
|
3610
3747
|
|
|
3611
3748
|
case 3:
|
|
3612
|
-
bodies =
|
|
3749
|
+
bodies = _this7.getMediaByCategories(["body"]);
|
|
3613
3750
|
|
|
3614
3751
|
if (!(bodies === null)) {
|
|
3615
3752
|
_context9.next = 7;
|
|
@@ -3802,6 +3939,28 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3802
3939
|
return Message;
|
|
3803
3940
|
}(replayEventEmitter.ReplayEventEmitter);
|
|
3804
3941
|
|
|
3942
|
+
function _wrapMedia2(media) {
|
|
3943
|
+
var category = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
3944
|
+
return media ? category ? new Media(_objectSpread$4(_objectSpread$4({}, media), {}, {
|
|
3945
|
+
category: category
|
|
3946
|
+
}), this.services) : new Media(media, this.services) : null;
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3949
|
+
function _assignMedias2(medias, media) {
|
|
3950
|
+
var _this8 = this;
|
|
3951
|
+
|
|
3952
|
+
this.state.media = _classPrivateMethodGet(this, _wrapMedia, _wrapMedia2).call(this, media); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3953
|
+
// @ts-ignore
|
|
3954
|
+
|
|
3955
|
+
this.state.medias = medias ? medias.map(function (m) {
|
|
3956
|
+
return _classPrivateMethodGet(_this8, _wrapMedia, _wrapMedia2).call(_this8, m);
|
|
3957
|
+
}).filter(function (el) {
|
|
3958
|
+
return el !== null;
|
|
3959
|
+
}) : media && !medias ? [_classPrivateMethodGet(this, _wrapMedia, _wrapMedia2).call(this, media, "media")].filter(function (el) {
|
|
3960
|
+
return el !== null;
|
|
3961
|
+
}) : null;
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3805
3964
|
_defineProperty__default["default"](Message, "updated", "updated");
|
|
3806
3965
|
|
|
3807
3966
|
__decorate([deprecationDecorator.deprecated("getMediaByCategory", "getMediaByCategories"), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", Array)], Message.prototype, "getMediaByCategory", null);
|
|
@@ -4830,6 +4989,68 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
4830
4989
|
* Logger instance.
|
|
4831
4990
|
*/
|
|
4832
4991
|
|
|
4992
|
+
/**
|
|
4993
|
+
* Unique system identifier of the conversation.
|
|
4994
|
+
*/
|
|
4995
|
+
|
|
4996
|
+
/**
|
|
4997
|
+
* Conversation links for REST requests.
|
|
4998
|
+
* @internal
|
|
4999
|
+
*/
|
|
5000
|
+
|
|
5001
|
+
/**
|
|
5002
|
+
* Configuration of the client that the conversation belongs to.
|
|
5003
|
+
*/
|
|
5004
|
+
|
|
5005
|
+
/**
|
|
5006
|
+
* Conversation service objects.
|
|
5007
|
+
*/
|
|
5008
|
+
|
|
5009
|
+
/**
|
|
5010
|
+
* Internal state of the conversation.
|
|
5011
|
+
*/
|
|
5012
|
+
|
|
5013
|
+
/**
|
|
5014
|
+
* Name of the conversation entity document.
|
|
5015
|
+
*/
|
|
5016
|
+
|
|
5017
|
+
/**
|
|
5018
|
+
* Messages entity.
|
|
5019
|
+
*/
|
|
5020
|
+
|
|
5021
|
+
/**
|
|
5022
|
+
* Sync list containing messages.
|
|
5023
|
+
*/
|
|
5024
|
+
|
|
5025
|
+
/**
|
|
5026
|
+
* Map of participants.
|
|
5027
|
+
* @internal
|
|
5028
|
+
*/
|
|
5029
|
+
|
|
5030
|
+
/**
|
|
5031
|
+
* Participants entity.
|
|
5032
|
+
*/
|
|
5033
|
+
|
|
5034
|
+
/**
|
|
5035
|
+
* Sync map containing participants.
|
|
5036
|
+
*/
|
|
5037
|
+
|
|
5038
|
+
/**
|
|
5039
|
+
* Source of the most recent update.
|
|
5040
|
+
*/
|
|
5041
|
+
|
|
5042
|
+
/**
|
|
5043
|
+
* Promise for the conversation entity document.
|
|
5044
|
+
*/
|
|
5045
|
+
|
|
5046
|
+
/**
|
|
5047
|
+
* Promise for the messages list.
|
|
5048
|
+
*/
|
|
5049
|
+
|
|
5050
|
+
/**
|
|
5051
|
+
* Conversation entity document.
|
|
5052
|
+
*/
|
|
5053
|
+
|
|
4833
5054
|
/**
|
|
4834
5055
|
* @param descriptor Conversation descriptor.
|
|
4835
5056
|
* @param sid Conversation SID.
|
|
@@ -4871,32 +5092,39 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
4871
5092
|
participants: _this._links.participants
|
|
4872
5093
|
};
|
|
4873
5094
|
_this._participants = new Map();
|
|
4874
|
-
_this._participantsEntity = new Participants(_assertThisInitialized__default["default"](_this), _this._participants,
|
|
5095
|
+
_this._participantsEntity = new Participants(_assertThisInitialized__default["default"](_this), _this._participants, // state leak
|
|
5096
|
+
participantsLinks, _this._services);
|
|
4875
5097
|
|
|
4876
|
-
_this._participantsEntity.on(
|
|
4877
|
-
return
|
|
5098
|
+
_this._participantsEntity.on(Conversation.participantJoined, function (participant) {
|
|
5099
|
+
return (// @todo update participants map here??
|
|
5100
|
+
_this.emit(Conversation.participantJoined, participant)
|
|
5101
|
+
);
|
|
4878
5102
|
});
|
|
4879
5103
|
|
|
4880
|
-
_this._participantsEntity.on(
|
|
4881
|
-
return
|
|
5104
|
+
_this._participantsEntity.on(Conversation.participantLeft, function (participant) {
|
|
5105
|
+
return (// @todo update participants map here??
|
|
5106
|
+
_this.emit(Conversation.participantLeft, participant)
|
|
5107
|
+
);
|
|
4882
5108
|
});
|
|
4883
5109
|
|
|
4884
|
-
_this._participantsEntity.on(
|
|
4885
|
-
return
|
|
5110
|
+
_this._participantsEntity.on(Conversation.participantUpdated, function (args) {
|
|
5111
|
+
return (// @todo update participants map here??
|
|
5112
|
+
_this.emit(Conversation.participantUpdated, args)
|
|
5113
|
+
);
|
|
4886
5114
|
});
|
|
4887
5115
|
|
|
4888
5116
|
_this._messagesEntity = new Messages(_assertThisInitialized__default["default"](_this), configuration, services);
|
|
4889
5117
|
|
|
4890
|
-
_this._messagesEntity.on(
|
|
5118
|
+
_this._messagesEntity.on(Conversation.messageAdded, function (message) {
|
|
4891
5119
|
return _this._onMessageAdded(message);
|
|
4892
5120
|
});
|
|
4893
5121
|
|
|
4894
|
-
_this._messagesEntity.on(
|
|
4895
|
-
return _this.emit(
|
|
5122
|
+
_this._messagesEntity.on(Conversation.messageUpdated, function (args) {
|
|
5123
|
+
return _this.emit(Conversation.messageUpdated, args);
|
|
4896
5124
|
});
|
|
4897
5125
|
|
|
4898
|
-
_this._messagesEntity.on(
|
|
4899
|
-
return _this.emit(
|
|
5126
|
+
_this._messagesEntity.on(Conversation.messageRemoved, function (message) {
|
|
5127
|
+
return _this.emit(Conversation.messageRemoved, message);
|
|
4900
5128
|
});
|
|
4901
5129
|
|
|
4902
5130
|
return _this;
|
|
@@ -4999,7 +5227,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
4999
5227
|
return (_this$_internalState$3 = this._internalState.notificationLevel) !== null && _this$_internalState$3 !== void 0 ? _this$_internalState$3 : "default";
|
|
5000
5228
|
}
|
|
5001
5229
|
/**
|
|
5002
|
-
* Conversation bindings.
|
|
5230
|
+
* Conversation bindings. An undocumented feature (for now).
|
|
5003
5231
|
* @internal
|
|
5004
5232
|
*/
|
|
5005
5233
|
|
|
@@ -5981,18 +6209,19 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5981
6209
|
}()
|
|
5982
6210
|
/**
|
|
5983
6211
|
* Get recipients of all messages in the conversation.
|
|
6212
|
+
* @param options Optional configuration, set pageSize to request a specific pagination page size. Page size specifies a number of messages to include in a single batch. Each message may include multiple recipients.
|
|
5984
6213
|
*/
|
|
5985
6214
|
|
|
5986
6215
|
}, {
|
|
5987
6216
|
key: "getMessageRecipients",
|
|
5988
6217
|
value: function () {
|
|
5989
|
-
var _getMessageRecipients = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee24() {
|
|
6218
|
+
var _getMessageRecipients = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee24(options) {
|
|
5990
6219
|
return _regeneratorRuntime__default["default"].wrap(function _callee24$(_context24) {
|
|
5991
6220
|
while (1) {
|
|
5992
6221
|
switch (_context24.prev = _context24.next) {
|
|
5993
6222
|
case 0:
|
|
5994
6223
|
_context24.next = 2;
|
|
5995
|
-
return this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid);
|
|
6224
|
+
return this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid, options);
|
|
5996
6225
|
|
|
5997
6226
|
case 2:
|
|
5998
6227
|
return _context24.abrupt("return", _context24.sent);
|
|
@@ -6005,7 +6234,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6005
6234
|
}, _callee24, this);
|
|
6006
6235
|
}));
|
|
6007
6236
|
|
|
6008
|
-
function getMessageRecipients() {
|
|
6237
|
+
function getMessageRecipients(_x19) {
|
|
6009
6238
|
return _getMessageRecipients.apply(this, arguments);
|
|
6010
6239
|
}
|
|
6011
6240
|
|
|
@@ -6014,7 +6243,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6014
6243
|
/**
|
|
6015
6244
|
* Load and subscribe to this conversation and do not subscribe to its
|
|
6016
6245
|
* participants and messages. This or _subscribeStreams will need to be called
|
|
6017
|
-
* before any events
|
|
6246
|
+
* before any events in the conversation will fire.
|
|
6018
6247
|
* @internal
|
|
6019
6248
|
*/
|
|
6020
6249
|
|
|
@@ -6047,12 +6276,12 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6047
6276
|
case 6:
|
|
6048
6277
|
this._entity = _context25.sent;
|
|
6049
6278
|
|
|
6050
|
-
this._entity.on(
|
|
6279
|
+
this._entity.on(twilioSync.SyncDocument.updated, function (args) {
|
|
6051
6280
|
return _this2._update(args.data);
|
|
6052
6281
|
});
|
|
6053
6282
|
|
|
6054
|
-
this._entity.on(
|
|
6055
|
-
return _this2.emit(
|
|
6283
|
+
this._entity.on(twilioSync.SyncDocument.removed, function () {
|
|
6284
|
+
return _this2.emit(Conversation.removed, _this2);
|
|
6056
6285
|
});
|
|
6057
6286
|
|
|
6058
6287
|
this._update(this._entity.data);
|
|
@@ -6100,44 +6329,95 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6100
6329
|
}, {
|
|
6101
6330
|
key: "_fetchStreams",
|
|
6102
6331
|
value: function () {
|
|
6103
|
-
var _fetchStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
6104
|
-
var
|
|
6332
|
+
var _fetchStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee27() {
|
|
6333
|
+
var _this3 = this;
|
|
6105
6334
|
|
|
6106
|
-
|
|
6107
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee26$(_context26) {
|
|
6335
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee27$(_context27) {
|
|
6108
6336
|
while (1) {
|
|
6109
|
-
switch (
|
|
6337
|
+
switch (_context27.prev = _context27.next) {
|
|
6110
6338
|
case 0:
|
|
6111
|
-
|
|
6112
|
-
|
|
6339
|
+
if (!this._streamsPromise) {
|
|
6340
|
+
_context27.next = 2;
|
|
6341
|
+
break;
|
|
6342
|
+
}
|
|
6113
6343
|
|
|
6114
|
-
|
|
6115
|
-
Conversation._logger.trace("_streamsAvailable, this.entity.data=", (_this$_entity = this._entity) === null || _this$_entity === void 0 ? void 0 : _this$_entity.data);
|
|
6344
|
+
return _context27.abrupt("return", this._streamsPromise);
|
|
6116
6345
|
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6346
|
+
case 2:
|
|
6347
|
+
this._streamsPromise = new Promise( /*#__PURE__*/function () {
|
|
6348
|
+
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee26(resolve, reject) {
|
|
6349
|
+
var _this3$_entity, _this3$_entity2;
|
|
6350
|
+
|
|
6351
|
+
var data, messagesPromise, participantsPromise;
|
|
6352
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee26$(_context26) {
|
|
6353
|
+
while (1) {
|
|
6354
|
+
switch (_context26.prev = _context26.next) {
|
|
6355
|
+
case 0:
|
|
6356
|
+
_context26.prev = 0;
|
|
6357
|
+
_context26.next = 3;
|
|
6358
|
+
return _this3._subscribe();
|
|
6359
|
+
|
|
6360
|
+
case 3:
|
|
6361
|
+
_context26.next = 9;
|
|
6362
|
+
break;
|
|
6123
6363
|
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6364
|
+
case 5:
|
|
6365
|
+
_context26.prev = 5;
|
|
6366
|
+
_context26.t0 = _context26["catch"](0);
|
|
6367
|
+
|
|
6368
|
+
Conversation._logger.trace("Failed to subscribe to conversation", _context26.t0);
|
|
6369
|
+
|
|
6370
|
+
return _context26.abrupt("return", reject(_context26.t0));
|
|
6371
|
+
|
|
6372
|
+
case 9:
|
|
6373
|
+
Conversation._logger.trace("_streamsAvailable, this.entity.data=", (_this3$_entity = _this3._entity) === null || _this3$_entity === void 0 ? void 0 : _this3$_entity.data);
|
|
6374
|
+
|
|
6375
|
+
data = (_this3$_entity2 = _this3._entity) === null || _this3$_entity2 === void 0 ? void 0 : _this3$_entity2.data;
|
|
6376
|
+
messagesPromise = _this3._services.syncClient.list({
|
|
6377
|
+
id: data.messages,
|
|
6378
|
+
mode: "open_existing"
|
|
6379
|
+
}).then(function (list) {
|
|
6380
|
+
_this3._messagesList = list;
|
|
6381
|
+
return list;
|
|
6382
|
+
});
|
|
6383
|
+
participantsPromise = _this3._services.syncClient.map({
|
|
6384
|
+
id: data.roster,
|
|
6385
|
+
mode: "open_existing"
|
|
6386
|
+
}).then(function (map) {
|
|
6387
|
+
_this3._participantsMap = map;
|
|
6388
|
+
return map;
|
|
6389
|
+
});
|
|
6390
|
+
Promise.all([messagesPromise, participantsPromise]).then(function () {
|
|
6391
|
+
return resolve(true);
|
|
6392
|
+
}).catch(function (err) {
|
|
6393
|
+
Conversation._logger.trace("Failed to fetch conversation streams for conversation", _this3.sid, err);
|
|
6394
|
+
|
|
6395
|
+
reject(err);
|
|
6396
|
+
});
|
|
6397
|
+
|
|
6398
|
+
case 14:
|
|
6399
|
+
case "end":
|
|
6400
|
+
return _context26.stop();
|
|
6401
|
+
}
|
|
6402
|
+
}
|
|
6403
|
+
}, _callee26, null, [[0, 5]]);
|
|
6404
|
+
}));
|
|
6131
6405
|
|
|
6132
|
-
|
|
6133
|
-
|
|
6406
|
+
return function (_x20, _x21) {
|
|
6407
|
+
return _ref.apply(this, arguments);
|
|
6408
|
+
};
|
|
6409
|
+
}());
|
|
6410
|
+
return _context27.abrupt("return", this._streamsPromise.catch(function (err) {
|
|
6411
|
+
_this3._streamsPromise = null;
|
|
6412
|
+
throw err;
|
|
6413
|
+
}));
|
|
6134
6414
|
|
|
6135
|
-
case
|
|
6415
|
+
case 4:
|
|
6136
6416
|
case "end":
|
|
6137
|
-
return
|
|
6417
|
+
return _context27.stop();
|
|
6138
6418
|
}
|
|
6139
6419
|
}
|
|
6140
|
-
},
|
|
6420
|
+
}, _callee27, this);
|
|
6141
6421
|
}));
|
|
6142
6422
|
|
|
6143
6423
|
function _fetchStreams() {
|
|
@@ -6157,48 +6437,48 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6157
6437
|
}, {
|
|
6158
6438
|
key: "_subscribeStreams",
|
|
6159
6439
|
value: function () {
|
|
6160
|
-
var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
6161
|
-
var _this$
|
|
6440
|
+
var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee28() {
|
|
6441
|
+
var _this$_entity, _this$_entity2, _this$_messagesList, _this$_participantsMa, data, messagesObjectName, rosterObjectName;
|
|
6162
6442
|
|
|
6163
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6443
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee28$(_context28) {
|
|
6164
6444
|
while (1) {
|
|
6165
|
-
switch (
|
|
6445
|
+
switch (_context28.prev = _context28.next) {
|
|
6166
6446
|
case 0:
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
return this.
|
|
6447
|
+
_context28.prev = 0;
|
|
6448
|
+
_context28.next = 3;
|
|
6449
|
+
return this._fetchStreams();
|
|
6170
6450
|
|
|
6171
6451
|
case 3:
|
|
6172
|
-
Conversation._logger.trace("_subscribeStreams, this.entity.data=", (_this$
|
|
6452
|
+
Conversation._logger.trace("_subscribeStreams, this.entity.data=", (_this$_entity = this._entity) === null || _this$_entity === void 0 ? void 0 : _this$_entity.data);
|
|
6173
6453
|
|
|
6174
|
-
data = (_this$
|
|
6454
|
+
data = (_this$_entity2 = this._entity) === null || _this$_entity2 === void 0 ? void 0 : _this$_entity2.data;
|
|
6175
6455
|
messagesObjectName = data.messages;
|
|
6176
6456
|
rosterObjectName = data.roster;
|
|
6177
|
-
|
|
6457
|
+
_context28.next = 9;
|
|
6178
6458
|
return Promise.all([this._messagesEntity.subscribe((_this$_messagesList = this._messagesList) !== null && _this$_messagesList !== void 0 ? _this$_messagesList : messagesObjectName), this._participantsEntity.subscribe((_this$_participantsMa = this._participantsMap) !== null && _this$_participantsMa !== void 0 ? _this$_participantsMa : rosterObjectName)]);
|
|
6179
6459
|
|
|
6180
6460
|
case 9:
|
|
6181
|
-
|
|
6461
|
+
_context28.next = 16;
|
|
6182
6462
|
break;
|
|
6183
6463
|
|
|
6184
6464
|
case 11:
|
|
6185
|
-
|
|
6186
|
-
|
|
6465
|
+
_context28.prev = 11;
|
|
6466
|
+
_context28.t0 = _context28["catch"](0);
|
|
6187
6467
|
|
|
6188
6468
|
if (this._services.syncClient.connectionState !== "disconnected") {
|
|
6189
|
-
Conversation._logger.error("Failed to subscribe on conversation objects", this.sid,
|
|
6469
|
+
Conversation._logger.error("Failed to subscribe on conversation objects", this.sid, _context28.t0);
|
|
6190
6470
|
}
|
|
6191
6471
|
|
|
6192
|
-
Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid,
|
|
6472
|
+
Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context28.t0);
|
|
6193
6473
|
|
|
6194
|
-
throw
|
|
6474
|
+
throw _context28.t0;
|
|
6195
6475
|
|
|
6196
6476
|
case 16:
|
|
6197
6477
|
case "end":
|
|
6198
|
-
return
|
|
6478
|
+
return _context28.stop();
|
|
6199
6479
|
}
|
|
6200
6480
|
}
|
|
6201
|
-
},
|
|
6481
|
+
}, _callee28, this, [[0, 11]]);
|
|
6202
6482
|
}));
|
|
6203
6483
|
|
|
6204
6484
|
function _subscribeStreams() {
|
|
@@ -6215,32 +6495,26 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6215
6495
|
}, {
|
|
6216
6496
|
key: "_unsubscribe",
|
|
6217
6497
|
value: function () {
|
|
6218
|
-
var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
6219
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6498
|
+
var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee29() {
|
|
6499
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee29$(_context29) {
|
|
6220
6500
|
while (1) {
|
|
6221
|
-
switch (
|
|
6501
|
+
switch (_context29.prev = _context29.next) {
|
|
6222
6502
|
case 0:
|
|
6223
|
-
if (
|
|
6224
|
-
|
|
6225
|
-
break;
|
|
6226
|
-
}
|
|
6503
|
+
if (this._entity) {
|
|
6504
|
+
this._entity.close();
|
|
6227
6505
|
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
case 3:
|
|
6232
|
-
this._entity = null;
|
|
6233
|
-
this._entityPromise = null;
|
|
6506
|
+
this._entity = null;
|
|
6507
|
+
this._entityPromise = null;
|
|
6508
|
+
}
|
|
6234
6509
|
|
|
6235
|
-
|
|
6236
|
-
return _context28.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
|
|
6510
|
+
return _context29.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
|
|
6237
6511
|
|
|
6238
|
-
case
|
|
6512
|
+
case 2:
|
|
6239
6513
|
case "end":
|
|
6240
|
-
return
|
|
6514
|
+
return _context29.stop();
|
|
6241
6515
|
}
|
|
6242
6516
|
}
|
|
6243
|
-
},
|
|
6517
|
+
}, _callee29, this);
|
|
6244
6518
|
}));
|
|
6245
6519
|
|
|
6246
6520
|
function _unsubscribe() {
|
|
@@ -6257,7 +6531,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6257
6531
|
}, {
|
|
6258
6532
|
key: "_setStatus",
|
|
6259
6533
|
value: function _setStatus(status, source) {
|
|
6260
|
-
var
|
|
6534
|
+
var _this4 = this;
|
|
6261
6535
|
|
|
6262
6536
|
this._dataSource = source;
|
|
6263
6537
|
|
|
@@ -6271,7 +6545,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6271
6545
|
this._subscribeStreams().catch(function (err) {
|
|
6272
6546
|
Conversation._logger.debug("ERROR while setting conversation status " + status, err);
|
|
6273
6547
|
|
|
6274
|
-
if (
|
|
6548
|
+
if (_this4._services.syncClient.connectionState !== "disconnected") {
|
|
6275
6549
|
throw err;
|
|
6276
6550
|
}
|
|
6277
6551
|
});
|
|
@@ -6283,7 +6557,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6283
6557
|
this._unsubscribe().catch(function (err) {
|
|
6284
6558
|
Conversation._logger.debug("ERROR while setting conversation status " + status, err);
|
|
6285
6559
|
|
|
6286
|
-
if (
|
|
6560
|
+
if (_this4._services.syncClient.connectionState !== "disconnected") {
|
|
6287
6561
|
throw err;
|
|
6288
6562
|
}
|
|
6289
6563
|
});
|
|
@@ -6323,7 +6597,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6323
6597
|
break;
|
|
6324
6598
|
|
|
6325
6599
|
case fieldMappings.attributes:
|
|
6326
|
-
if (
|
|
6600
|
+
if (isEqual(this._internalState.attributes, update.attributes)) {
|
|
6327
6601
|
break;
|
|
6328
6602
|
}
|
|
6329
6603
|
|
|
@@ -6359,7 +6633,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6359
6633
|
updateReasons.add(localKey);
|
|
6360
6634
|
}
|
|
6361
6635
|
|
|
6362
|
-
if (
|
|
6636
|
+
if (isEqual(this._internalState.lastMessage, {})) {
|
|
6363
6637
|
delete this._internalState.lastMessage;
|
|
6364
6638
|
}
|
|
6365
6639
|
|
|
@@ -6372,7 +6646,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6372
6646
|
state.dateUpdated = new Date(state.dateUpdated);
|
|
6373
6647
|
}
|
|
6374
6648
|
|
|
6375
|
-
if (
|
|
6649
|
+
if (isEqual(this._internalState.state, state)) {
|
|
6376
6650
|
break;
|
|
6377
6651
|
}
|
|
6378
6652
|
|
|
@@ -6381,7 +6655,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6381
6655
|
break;
|
|
6382
6656
|
|
|
6383
6657
|
case fieldMappings.bindings:
|
|
6384
|
-
if (
|
|
6658
|
+
if (isEqual(this._internalState.bindings, update.bindings)) {
|
|
6385
6659
|
break;
|
|
6386
6660
|
}
|
|
6387
6661
|
|
|
@@ -6404,7 +6678,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6404
6678
|
}
|
|
6405
6679
|
|
|
6406
6680
|
if (updateReasons.size > 0) {
|
|
6407
|
-
this.emit(
|
|
6681
|
+
this.emit(Conversation.updated, {
|
|
6408
6682
|
conversation: this,
|
|
6409
6683
|
updateReasons: _toConsumableArray__default["default"](updateReasons)
|
|
6410
6684
|
});
|
|
@@ -6436,7 +6710,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6436
6710
|
_iterator.f();
|
|
6437
6711
|
}
|
|
6438
6712
|
|
|
6439
|
-
this.emit(
|
|
6713
|
+
this.emit(Conversation.messageAdded, message);
|
|
6440
6714
|
}
|
|
6441
6715
|
/**
|
|
6442
6716
|
* Set last read message index.
|
|
@@ -6446,30 +6720,30 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6446
6720
|
}, {
|
|
6447
6721
|
key: "_setLastReadMessageIndex",
|
|
6448
6722
|
value: function () {
|
|
6449
|
-
var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
6723
|
+
var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee30(index) {
|
|
6450
6724
|
var result;
|
|
6451
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6725
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee30$(_context30) {
|
|
6452
6726
|
while (1) {
|
|
6453
|
-
switch (
|
|
6727
|
+
switch (_context30.prev = _context30.next) {
|
|
6454
6728
|
case 0:
|
|
6455
|
-
|
|
6729
|
+
_context30.next = 2;
|
|
6456
6730
|
return this._services.commandExecutor.mutateResource("post", "".concat(this._configuration.links.myConversations, "/").concat(this.sid), {
|
|
6457
6731
|
last_read_message_index: index
|
|
6458
6732
|
});
|
|
6459
6733
|
|
|
6460
6734
|
case 2:
|
|
6461
|
-
result =
|
|
6462
|
-
return
|
|
6735
|
+
result = _context30.sent;
|
|
6736
|
+
return _context30.abrupt("return", result.unread_messages_count);
|
|
6463
6737
|
|
|
6464
6738
|
case 4:
|
|
6465
6739
|
case "end":
|
|
6466
|
-
return
|
|
6740
|
+
return _context30.stop();
|
|
6467
6741
|
}
|
|
6468
6742
|
}
|
|
6469
|
-
},
|
|
6743
|
+
}, _callee30, this);
|
|
6470
6744
|
}));
|
|
6471
6745
|
|
|
6472
|
-
function _setLastReadMessageIndex(
|
|
6746
|
+
function _setLastReadMessageIndex(_x22) {
|
|
6473
6747
|
return _setLastReadMessageIndex2.apply(this, arguments);
|
|
6474
6748
|
}
|
|
6475
6749
|
|
|
@@ -6549,7 +6823,7 @@ _defineProperty__default["default"](Conversation, "_logger", Logger.scope("Conve
|
|
|
6549
6823
|
|
|
6550
6824
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, optionalJson), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "add", null);
|
|
6551
6825
|
|
|
6552
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString, optionalJson), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "addNonChatParticipant", null);
|
|
6826
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString, optionalJson, optionalJson), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "addNonChatParticipant", null);
|
|
6553
6827
|
|
|
6554
6828
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonNegativeInteger), __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", Promise)], Conversation.prototype, "advanceLastReadMessageIndex", null);
|
|
6555
6829
|
|
|
@@ -6685,6 +6959,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6685
6959
|
return this.services.commandExecutor.mutateResource("post", this.configuration.links.conversations, {
|
|
6686
6960
|
friendly_name: options.friendlyName,
|
|
6687
6961
|
unique_name: options.uniqueName,
|
|
6962
|
+
access: options.access,
|
|
6688
6963
|
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
|
|
6689
6964
|
});
|
|
6690
6965
|
|
|
@@ -6746,7 +7021,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6746
7021
|
return addConversation;
|
|
6747
7022
|
}()
|
|
6748
7023
|
/**
|
|
6749
|
-
* Fetch conversations list and instantiate all necessary objects
|
|
7024
|
+
* Fetch conversations' list and instantiate all necessary objects
|
|
6750
7025
|
*/
|
|
6751
7026
|
|
|
6752
7027
|
}, {
|
|
@@ -6767,12 +7042,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6767
7042
|
|
|
6768
7043
|
case 3:
|
|
6769
7044
|
map = _context2.sent;
|
|
6770
|
-
map.on(
|
|
7045
|
+
map.on(twilioSync.SyncMap.itemAdded, function (args) {
|
|
6771
7046
|
log$1.debug("itemAdded: ".concat(args.item.key));
|
|
6772
7047
|
|
|
6773
7048
|
_this2._upsertConversation("sync", args.item.key, args.item.data);
|
|
6774
7049
|
});
|
|
6775
|
-
map.on(
|
|
7050
|
+
map.on(twilioSync.SyncMap.itemRemoved, function (args) {
|
|
6776
7051
|
log$1.debug("itemRemoved: ".concat(args.key));
|
|
6777
7052
|
var sid = args.key;
|
|
6778
7053
|
|
|
@@ -6798,7 +7073,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6798
7073
|
|
|
6799
7074
|
conversation.emit("removed", conversation);
|
|
6800
7075
|
});
|
|
6801
|
-
map.on(
|
|
7076
|
+
map.on(twilioSync.SyncMap.itemUpdated, function (args) {
|
|
6802
7077
|
log$1.debug("itemUpdated: ".concat(args.item.key));
|
|
6803
7078
|
|
|
6804
7079
|
_this2._upsertConversation("sync", args.item.key, args.item.data);
|
|
@@ -6969,6 +7244,8 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6969
7244
|
createdBy: body.created_by,
|
|
6970
7245
|
attributes: body.attributes,
|
|
6971
7246
|
channel: body.sync_objects.conversation,
|
|
7247
|
+
roster: body.sync_objects.participants,
|
|
7248
|
+
messages: body.sync_objects.messages,
|
|
6972
7249
|
notificationLevel: body === null || body === void 0 ? void 0 : body.notification_level,
|
|
6973
7250
|
sid: sid
|
|
6974
7251
|
};
|
|
@@ -7014,8 +7291,10 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
7014
7291
|
uniqueName: body.unique_name,
|
|
7015
7292
|
createdBy: body.created_by,
|
|
7016
7293
|
attributes: body.attributes,
|
|
7017
|
-
channel: "".concat(sid, ".channel"),
|
|
7018
|
-
|
|
7294
|
+
channel: body.sync_objects.conversation || "".concat(sid, ".channel"),
|
|
7295
|
+
roster: body.sync_objects.participants,
|
|
7296
|
+
messages: body.sync_objects.messages,
|
|
7297
|
+
notificationLevel: body === null || body === void 0 ? void 0 : body.notification_level,
|
|
7019
7298
|
sid: sid
|
|
7020
7299
|
};
|
|
7021
7300
|
return _context6.abrupt("return", this._upsertConversation("sync", sid, data));
|
|
@@ -7155,7 +7434,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
7155
7434
|
updateData.lastConsumedMessageIndex = data.lastConsumedMessageIndex;
|
|
7156
7435
|
}
|
|
7157
7436
|
|
|
7158
|
-
if (!
|
|
7437
|
+
if (!isEqual(updateData, {})) {
|
|
7159
7438
|
conversation._update(updateData);
|
|
7160
7439
|
}
|
|
7161
7440
|
|
|
@@ -7352,7 +7631,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
7352
7631
|
status: conversationDescriptor.status,
|
|
7353
7632
|
channel: conversationDescriptor.sync_objects.conversation,
|
|
7354
7633
|
messages: conversationDescriptor.sync_objects.messages,
|
|
7355
|
-
roster: "".concat(conversationDescriptor.conversation_sid, ".roster"),
|
|
7634
|
+
roster: conversationDescriptor.sync_objects.participants || "".concat(conversationDescriptor.conversation_sid, ".roster"),
|
|
7356
7635
|
lastConsumedMessageIndex: conversationDescriptor.last_read_message_index,
|
|
7357
7636
|
notificationLevel: conversationDescriptor.notification_level
|
|
7358
7637
|
};
|
|
@@ -7775,7 +8054,7 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
|
7775
8054
|
}
|
|
7776
8055
|
|
|
7777
8056
|
conversation._participants.forEach(function (participant) {
|
|
7778
|
-
if (participant.identity !== message.identity) {
|
|
8057
|
+
if (participant.identity !== message.identity && participant.type !== "apple") {
|
|
7779
8058
|
return;
|
|
7780
8059
|
}
|
|
7781
8060
|
|
|
@@ -7891,7 +8170,15 @@ function PushNotification(data) {
|
|
|
7891
8170
|
this.data = data.data || {};
|
|
7892
8171
|
});
|
|
7893
8172
|
|
|
7894
|
-
var version = "3.0.1
|
|
8173
|
+
var version = "3.0.1";
|
|
8174
|
+
|
|
8175
|
+
/**
|
|
8176
|
+
* Generate a random UUID using the Web Crypto API.
|
|
8177
|
+
* Available in Node.js 14.17+, modern browsers, and React Native.
|
|
8178
|
+
*/
|
|
8179
|
+
var randomUUID = function randomUUID() {
|
|
8180
|
+
return crypto.randomUUID();
|
|
8181
|
+
};
|
|
7895
8182
|
|
|
7896
8183
|
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7897
8184
|
|
|
@@ -7900,6 +8187,7 @@ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
7900
8187
|
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
|
|
7901
8188
|
|
|
7902
8189
|
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
8190
|
+
var uuidv4 = randomUUID;
|
|
7903
8191
|
|
|
7904
8192
|
var trimSlashes = function trimSlashes(url) {
|
|
7905
8193
|
return url.replace(/(^\/+|\/+$)/g, "");
|
|
@@ -8124,7 +8412,7 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
|
8124
8412
|
case 0:
|
|
8125
8413
|
_context4.next = 2;
|
|
8126
8414
|
return this._makeRequest(method, url, requestBody, {
|
|
8127
|
-
"X-Twilio-Mutation-Id":
|
|
8415
|
+
"X-Twilio-Mutation-Id": uuidv4()
|
|
8128
8416
|
});
|
|
8129
8417
|
|
|
8130
8418
|
case 2:
|
|
@@ -8764,6 +9052,22 @@ var EmailRecipientDescriptor = /*#__PURE__*/_createClass__default["default"](
|
|
|
8764
9052
|
* Type of recipient.
|
|
8765
9053
|
*/
|
|
8766
9054
|
|
|
9055
|
+
/**
|
|
9056
|
+
* Sid of the message that this recipient belongs to.
|
|
9057
|
+
*/
|
|
9058
|
+
|
|
9059
|
+
/**
|
|
9060
|
+
* Email recipient level.
|
|
9061
|
+
*/
|
|
9062
|
+
|
|
9063
|
+
/**
|
|
9064
|
+
* Name of the recipient.
|
|
9065
|
+
*/
|
|
9066
|
+
|
|
9067
|
+
/**
|
|
9068
|
+
* Address of the recipient.
|
|
9069
|
+
*/
|
|
9070
|
+
|
|
8767
9071
|
/**
|
|
8768
9072
|
* @internal
|
|
8769
9073
|
*/
|
|
@@ -8886,7 +9190,7 @@ var MessageRecipientsClient = /*#__PURE__*/function () {
|
|
|
8886
9190
|
while (1) {
|
|
8887
9191
|
switch (_context2.prev = _context2.next) {
|
|
8888
9192
|
case 0:
|
|
8889
|
-
url = new UriBuilder(this._configuration.links.conversations).path(conversationSid).path("MessageRecipients").arg("PageToken", (_paginatorOptions$pag = paginatorOptions === null || paginatorOptions === void 0 ? void 0 : paginatorOptions.pageToken) !== null && _paginatorOptions$pag !== void 0 ? _paginatorOptions$pag :
|
|
9193
|
+
url = new UriBuilder(this._configuration.links.conversations).path(conversationSid).path("MessageRecipients").arg("PageToken", (_paginatorOptions$pag = paginatorOptions === null || paginatorOptions === void 0 ? void 0 : paginatorOptions.pageToken) !== null && _paginatorOptions$pag !== void 0 ? _paginatorOptions$pag : undefined).arg("PageSize", (_paginatorOptions$pag2 = paginatorOptions === null || paginatorOptions === void 0 ? void 0 : paginatorOptions.pageSize) !== null && _paginatorOptions$pag2 !== void 0 ? _paginatorOptions$pag2 : undefined).build();
|
|
8890
9194
|
_context2.next = 3;
|
|
8891
9195
|
return this._services.commandExecutor.fetchResource(url);
|
|
8892
9196
|
|
|
@@ -9218,7 +9522,47 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
9218
9522
|
*/
|
|
9219
9523
|
|
|
9220
9524
|
/**
|
|
9221
|
-
*
|
|
9525
|
+
* Promise that resolves on successful initialization.
|
|
9526
|
+
*/
|
|
9527
|
+
|
|
9528
|
+
/**
|
|
9529
|
+
* Options passed to the client.
|
|
9530
|
+
*/
|
|
9531
|
+
|
|
9532
|
+
/**
|
|
9533
|
+
* Client service objects.
|
|
9534
|
+
*/
|
|
9535
|
+
|
|
9536
|
+
/**
|
|
9537
|
+
* The user of the client.
|
|
9538
|
+
*/
|
|
9539
|
+
|
|
9540
|
+
/**
|
|
9541
|
+
* Resolves the {@link Client._ensureReady} promise.
|
|
9542
|
+
*/
|
|
9543
|
+
|
|
9544
|
+
/**
|
|
9545
|
+
* Rejects the {@link Client._ensureReady} promise.
|
|
9546
|
+
*/
|
|
9547
|
+
|
|
9548
|
+
/**
|
|
9549
|
+
* The current token of the client.
|
|
9550
|
+
*/
|
|
9551
|
+
|
|
9552
|
+
/**
|
|
9553
|
+
* The constructed configuration object.
|
|
9554
|
+
*/
|
|
9555
|
+
|
|
9556
|
+
/**
|
|
9557
|
+
* The Conversations entity.
|
|
9558
|
+
*/
|
|
9559
|
+
|
|
9560
|
+
/**
|
|
9561
|
+
* Promise that resolves when initial conversations are fetched.
|
|
9562
|
+
*/
|
|
9563
|
+
|
|
9564
|
+
/**
|
|
9565
|
+
* Returned Conversations Client instance is not yet fully initialized. Calling any
|
|
9222
9566
|
* operations will block until it is. Use connection events to monitor when
|
|
9223
9567
|
* client becomes fully available (connectionStateChanged with state
|
|
9224
9568
|
* 'connected') or not available (connectionStateChange with state 'denied',
|
|
@@ -9308,16 +9652,16 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
9308
9652
|
|
|
9309
9653
|
_this._services.twilsockClient = _this._options.twilsockClient = (_this$_options$twilso = _this._options.twilsockClient) !== null && _this$_options$twilso !== void 0 ? _this$_options$twilso : new twilsock.TwilsockClient(fpaToken, productId, _this._options);
|
|
9310
9654
|
|
|
9311
|
-
_this._services.twilsockClient.on(
|
|
9312
|
-
return _this.emit(
|
|
9655
|
+
_this._services.twilsockClient.on(Client_1.tokenAboutToExpire, function () {
|
|
9656
|
+
return _this.emit(Client_1.tokenAboutToExpire);
|
|
9313
9657
|
});
|
|
9314
9658
|
|
|
9315
|
-
_this._services.twilsockClient.on(
|
|
9316
|
-
return _this.emit(
|
|
9659
|
+
_this._services.twilsockClient.on(Client_1.tokenExpired, function () {
|
|
9660
|
+
return _this.emit(Client_1.tokenExpired);
|
|
9317
9661
|
});
|
|
9318
9662
|
|
|
9319
|
-
_this._services.twilsockClient.on(
|
|
9320
|
-
return _this.emit(
|
|
9663
|
+
_this._services.twilsockClient.on(Client_1.connectionError, function (error) {
|
|
9664
|
+
return _this.emit(Client_1.connectionError, error);
|
|
9321
9665
|
});
|
|
9322
9666
|
|
|
9323
9667
|
_this._services.twilsockClient.on("stateChanged", function (state) {
|
|
@@ -9326,7 +9670,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
9326
9670
|
if (state !== _this.connectionState) {
|
|
9327
9671
|
_this.connectionState = state;
|
|
9328
9672
|
|
|
9329
|
-
_this.emit(
|
|
9673
|
+
_this.emit(Client_1.connectionStateChanged, _this.connectionState);
|
|
9330
9674
|
}
|
|
9331
9675
|
});
|
|
9332
9676
|
|
|
@@ -9344,9 +9688,9 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
9344
9688
|
var emitFailed = function emitFailed(error) {
|
|
9345
9689
|
_this._rejectEnsureReady(error);
|
|
9346
9690
|
|
|
9347
|
-
_this.emit(
|
|
9691
|
+
_this.emit(Client_1.stateChanged, "failed");
|
|
9348
9692
|
|
|
9349
|
-
_this.emit(
|
|
9693
|
+
_this.emit(Client_1.initFailed, {
|
|
9350
9694
|
error: error
|
|
9351
9695
|
});
|
|
9352
9696
|
};
|
|
@@ -9356,6 +9700,8 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
9356
9700
|
terminal: true,
|
|
9357
9701
|
message: "Twilsock has disconnected."
|
|
9358
9702
|
});
|
|
9703
|
+
|
|
9704
|
+
_this._initializeEnsureReady((options === null || options === void 0 ? void 0 : options.throwErrorsAlways) || false);
|
|
9359
9705
|
};
|
|
9360
9706
|
|
|
9361
9707
|
_this._services.twilsockClient.once("connectionError", emitFailed);
|
|
@@ -9399,9 +9745,9 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
9399
9745
|
|
|
9400
9746
|
_this._rejectEnsureReady(connectionError);
|
|
9401
9747
|
|
|
9402
|
-
_this.emit(
|
|
9748
|
+
_this.emit(Client_1.stateChanged, "failed");
|
|
9403
9749
|
|
|
9404
|
-
_this.emit(
|
|
9750
|
+
_this.emit(Client_1.initFailed, {
|
|
9405
9751
|
error: connectionError
|
|
9406
9752
|
});
|
|
9407
9753
|
|
|
@@ -9413,12 +9759,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
9413
9759
|
}, _callee, null, [[3, 11]]);
|
|
9414
9760
|
})));
|
|
9415
9761
|
|
|
9416
|
-
_this.
|
|
9417
|
-
_this._resolveEnsureReady = resolve;
|
|
9418
|
-
_this._rejectEnsureReady = reject;
|
|
9419
|
-
}).catch(function () {
|
|
9420
|
-
return void 0;
|
|
9421
|
-
}); // @todo How to process unhandled rejection here?
|
|
9762
|
+
_this._initializeEnsureReady((options === null || options === void 0 ? void 0 : options.throwErrorsAlways) || false);
|
|
9422
9763
|
|
|
9423
9764
|
if (startTwilsock) {
|
|
9424
9765
|
_this._services.twilsockClient.connect();
|
|
@@ -9643,7 +9984,6 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
9643
9984
|
/**
|
|
9644
9985
|
* Peek a conversation by its SID.
|
|
9645
9986
|
* @param conversationSid Conversation sid
|
|
9646
|
-
* @internal
|
|
9647
9987
|
*/
|
|
9648
9988
|
|
|
9649
9989
|
}, {
|
|
@@ -9929,7 +10269,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
9929
10269
|
return removePushRegistrations;
|
|
9930
10270
|
}()
|
|
9931
10271
|
/**
|
|
9932
|
-
*
|
|
10272
|
+
* Parse a push notification payload.
|
|
9933
10273
|
*/
|
|
9934
10274
|
|
|
9935
10275
|
}, {
|
|
@@ -10248,6 +10588,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
10248
10588
|
this._conversationsPromise = this._conversationsEntity.fetchConversations().then(function () {
|
|
10249
10589
|
return _this3._conversationsEntity;
|
|
10250
10590
|
}).catch(function (error) {
|
|
10591
|
+
console.error("Failed to fetch conversations _conversationsPromise -> client.ts", error);
|
|
10251
10592
|
throw error;
|
|
10252
10593
|
});
|
|
10253
10594
|
_context17.next = 30;
|
|
@@ -10266,8 +10607,8 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
10266
10607
|
|
|
10267
10608
|
this._resolveEnsureReady();
|
|
10268
10609
|
|
|
10269
|
-
this.emit(
|
|
10270
|
-
this.emit(
|
|
10610
|
+
this.emit(Client_1.stateChanged, "initialized");
|
|
10611
|
+
this.emit(Client_1.initialized);
|
|
10271
10612
|
|
|
10272
10613
|
case 36:
|
|
10273
10614
|
case "end":
|
|
@@ -10311,6 +10652,26 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
10311
10652
|
_this5._services.notificationClient.unsubscribe(channelType, messageType);
|
|
10312
10653
|
});
|
|
10313
10654
|
}
|
|
10655
|
+
/**
|
|
10656
|
+
* Initialize the ensureReady promise.
|
|
10657
|
+
*/
|
|
10658
|
+
|
|
10659
|
+
}, {
|
|
10660
|
+
key: "_initializeEnsureReady",
|
|
10661
|
+
value: function _initializeEnsureReady(throwErrorsAlways) {
|
|
10662
|
+
var _this6 = this;
|
|
10663
|
+
|
|
10664
|
+
this._ensureReady = new Promise(function (resolve, reject) {
|
|
10665
|
+
_this6._resolveEnsureReady = resolve;
|
|
10666
|
+
_this6._rejectEnsureReady = reject;
|
|
10667
|
+
}).catch(function (error) {
|
|
10668
|
+
if (throwErrorsAlways) {
|
|
10669
|
+
throw error;
|
|
10670
|
+
} else {
|
|
10671
|
+
return void 0;
|
|
10672
|
+
}
|
|
10673
|
+
});
|
|
10674
|
+
}
|
|
10314
10675
|
}], [{
|
|
10315
10676
|
key: "create",
|
|
10316
10677
|
value: function () {
|