@twilio/conversations 2.0.1 → 2.1.0-rc.6
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/CHANGELOG.md +74 -0
- package/NOTICE.txt +679 -0
- package/builds/browser.js +889 -619
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +384 -129
- package/builds/lib.js +889 -619
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +1065 -939
- package/builds/twilio-conversations.min.js +2 -14
- package/dist/aggregated-delivery-receipt.js +6 -1
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/client.js +165 -142
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +16 -14
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +14 -10
- package/dist/configuration.js.map +1 -1
- package/dist/conversation.js +232 -159
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +82 -78
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +43 -39
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +100 -78
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +24 -22
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js +1 -1
- package/dist/detailed-delivery-receipt.js.map +1 -1
- package/dist/interfaces/attributes.js +147 -0
- package/dist/interfaces/attributes.js.map +1 -0
- package/dist/interfaces/notification-types.js +5 -5
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/logger.js +36 -15
- package/dist/logger.js.map +1 -1
- package/dist/media.js +21 -9
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +56 -3
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +157 -78
- package/dist/message.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/participant.js +101 -50
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js +16 -6
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +18 -14
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +20 -17
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +87 -60
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js +3 -1
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js +6 -6
- package/dist/util/index.js.map +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/classes/AggregatedDeliveryReceipt.html +0 -102
- package/docs/classes/Client.html +24 -132
- package/docs/classes/Conversation.html +37 -132
- package/docs/classes/DetailedDeliveryReceipt.html +1 -103
- package/docs/classes/Media.html +0 -102
- package/docs/classes/Message.html +73 -109
- package/docs/classes/MessageBuilder.html +78 -104
- package/docs/classes/Participant.html +37 -110
- package/docs/classes/PushNotification.html +0 -102
- package/docs/classes/RestPaginator.html +0 -102
- package/docs/classes/UnsentMessage.html +0 -102
- package/docs/classes/User.html +7 -109
- package/docs/index.html +93 -3
- package/docs/interfaces/ClientOptions.html +0 -102
- package/docs/interfaces/ConversationBindings.html +3001 -0
- package/docs/interfaces/ConversationEmailBinding.html +3001 -0
- package/docs/interfaces/ConversationState.html +0 -102
- package/docs/interfaces/CreateConversationOptions.html +1 -103
- package/docs/interfaces/LastMessage.html +0 -102
- package/docs/interfaces/Paginator.html +0 -102
- package/docs/interfaces/ParticipantBindings.html +3001 -0
- package/docs/interfaces/ParticipantEmailBinding.html +3001 -0
- package/docs/interfaces/PushNotificationData.html +0 -102
- package/docs/interfaces/SendEmailOptions.html +0 -102
- package/docs/interfaces/SendMediaOptions.html +0 -102
- package/docs/modules.html +93 -3
- package/package.json +23 -17
package/builds/lib.js
CHANGED
@@ -163,6 +163,7 @@ require('core-js/modules/es.regexp.exec.js');
|
|
163
163
|
require('core-js/modules/es.string.replace.js');
|
164
164
|
require('core-js/modules/es.array.join.js');
|
165
165
|
var declarativeTypeValidator = require('@twilio/declarative-type-validator');
|
166
|
+
require('core-js/modules/es.array.includes.js');
|
166
167
|
var replayEventEmitter = require('@twilio/replay-event-emitter');
|
167
168
|
var isEqual = require('lodash.isequal');
|
168
169
|
require('core-js/modules/es.array.slice.js');
|
@@ -178,7 +179,6 @@ var twilioSync = require('twilio-sync');
|
|
178
179
|
var mcsClient = require('@twilio/mcs-client');
|
179
180
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
180
181
|
require('core-js/modules/es.set.js');
|
181
|
-
require('core-js/modules/es.array.includes.js');
|
182
182
|
require('core-js/modules/es.number.is-integer.js');
|
183
183
|
require('core-js/modules/es.typed-array.uint8-array.js');
|
184
184
|
require('core-js/modules/es.typed-array.copy-within.js');
|
@@ -266,15 +266,15 @@ function prepareLine(prefix, args) {
|
|
266
266
|
return ["".concat(new Date().toISOString(), " Conversations ").concat(prefix, ":")].concat(Array.from(args));
|
267
267
|
}
|
268
268
|
|
269
|
-
var log$9 = loglevelLog__namespace.getLogger(
|
269
|
+
var log$9 = loglevelLog__namespace.getLogger("twilio-conversations"); // twilio-conversations is used by Flex SDK. Please DO NOT change
|
270
270
|
|
271
271
|
var Logger = /*#__PURE__*/function () {
|
272
272
|
function Logger(prefix) {
|
273
273
|
_classCallCheck__default['default'](this, Logger);
|
274
274
|
|
275
|
-
_defineProperty__default['default'](this, "prefix",
|
275
|
+
_defineProperty__default['default'](this, "prefix", "");
|
276
276
|
|
277
|
-
this.prefix = prefix !== null && prefix !== undefined && prefix.length > 0 ? prefix +
|
277
|
+
this.prefix = prefix !== null && prefix !== undefined && prefix.length > 0 ? prefix + " " : "";
|
278
278
|
}
|
279
279
|
|
280
280
|
_createClass__default['default'](Logger, [{
|
@@ -289,7 +289,7 @@ var Logger = /*#__PURE__*/function () {
|
|
289
289
|
args[_key] = arguments[_key];
|
290
290
|
}
|
291
291
|
|
292
|
-
log$9.trace.apply(null, prepareLine(this.prefix +
|
292
|
+
log$9.trace.apply(null, prepareLine(this.prefix + "T", args));
|
293
293
|
}
|
294
294
|
}, {
|
295
295
|
key: "debug",
|
@@ -298,7 +298,7 @@ var Logger = /*#__PURE__*/function () {
|
|
298
298
|
args[_key2] = arguments[_key2];
|
299
299
|
}
|
300
300
|
|
301
|
-
log$9.debug.apply(null, prepareLine(this.prefix +
|
301
|
+
log$9.debug.apply(null, prepareLine(this.prefix + "D", args));
|
302
302
|
}
|
303
303
|
}, {
|
304
304
|
key: "info",
|
@@ -307,7 +307,7 @@ var Logger = /*#__PURE__*/function () {
|
|
307
307
|
args[_key3] = arguments[_key3];
|
308
308
|
}
|
309
309
|
|
310
|
-
log$9.info.apply(null, prepareLine(this.prefix +
|
310
|
+
log$9.info.apply(null, prepareLine(this.prefix + "I", args));
|
311
311
|
}
|
312
312
|
}, {
|
313
313
|
key: "warn",
|
@@ -316,7 +316,7 @@ var Logger = /*#__PURE__*/function () {
|
|
316
316
|
args[_key4] = arguments[_key4];
|
317
317
|
}
|
318
318
|
|
319
|
-
log$9.warn.apply(null, prepareLine(this.prefix +
|
319
|
+
log$9.warn.apply(null, prepareLine(this.prefix + "W", args));
|
320
320
|
}
|
321
321
|
}, {
|
322
322
|
key: "error",
|
@@ -325,7 +325,7 @@ var Logger = /*#__PURE__*/function () {
|
|
325
325
|
args[_key5] = arguments[_key5];
|
326
326
|
}
|
327
327
|
|
328
|
-
log$9.error.apply(null, prepareLine(this.prefix +
|
328
|
+
log$9.error.apply(null, prepareLine(this.prefix + "E", args));
|
329
329
|
}
|
330
330
|
}], [{
|
331
331
|
key: "scope",
|
@@ -344,7 +344,7 @@ var Logger = /*#__PURE__*/function () {
|
|
344
344
|
args[_key6] = arguments[_key6];
|
345
345
|
}
|
346
346
|
|
347
|
-
log$9.trace.apply(null, prepareLine(
|
347
|
+
log$9.trace.apply(null, prepareLine("T", args));
|
348
348
|
}
|
349
349
|
}, {
|
350
350
|
key: "debug",
|
@@ -353,7 +353,7 @@ var Logger = /*#__PURE__*/function () {
|
|
353
353
|
args[_key7] = arguments[_key7];
|
354
354
|
}
|
355
355
|
|
356
|
-
log$9.debug.apply(null, prepareLine(
|
356
|
+
log$9.debug.apply(null, prepareLine("D", args));
|
357
357
|
}
|
358
358
|
}, {
|
359
359
|
key: "info",
|
@@ -362,7 +362,7 @@ var Logger = /*#__PURE__*/function () {
|
|
362
362
|
args[_key8] = arguments[_key8];
|
363
363
|
}
|
364
364
|
|
365
|
-
log$9.info.apply(null, prepareLine(
|
365
|
+
log$9.info.apply(null, prepareLine("I", args));
|
366
366
|
}
|
367
367
|
}, {
|
368
368
|
key: "warn",
|
@@ -371,7 +371,7 @@ var Logger = /*#__PURE__*/function () {
|
|
371
371
|
args[_key9] = arguments[_key9];
|
372
372
|
}
|
373
373
|
|
374
|
-
log$9.warn.apply(null, prepareLine(
|
374
|
+
log$9.warn.apply(null, prepareLine("W", args));
|
375
375
|
}
|
376
376
|
}, {
|
377
377
|
key: "error",
|
@@ -380,7 +380,7 @@ var Logger = /*#__PURE__*/function () {
|
|
380
380
|
args[_key10] = arguments[_key10];
|
381
381
|
}
|
382
382
|
|
383
|
-
log$9.error.apply(null, prepareLine(
|
383
|
+
log$9.error.apply(null, prepareLine("E", args));
|
384
384
|
}
|
385
385
|
}]);
|
386
386
|
|
@@ -391,8 +391,8 @@ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if
|
|
391
391
|
|
392
392
|
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
393
393
|
var TYPING_TIMEOUT = 5;
|
394
|
-
var HTTP_CACHE_LIFETIME =
|
395
|
-
var CONSUMPTION_HORIZON_SENDING_INTERVAL =
|
394
|
+
var HTTP_CACHE_LIFETIME = "PT5S";
|
395
|
+
var CONSUMPTION_HORIZON_SENDING_INTERVAL = "PT5S";
|
396
396
|
var USER_INFOS_TO_SUBSCRIBE = 100;
|
397
397
|
var MINIMUM_RETRY_DELAY = 1000;
|
398
398
|
var MAXIMUM_RETRY_DELAY = 4000;
|
@@ -471,7 +471,7 @@ function deepClone(obj) {
|
|
471
471
|
}
|
472
472
|
|
473
473
|
function parseToNumber(value) {
|
474
|
-
if (typeof value !==
|
474
|
+
if (typeof value !== "undefined" && !isNaN(Number(value))) {
|
475
475
|
return Number(value);
|
476
476
|
}
|
477
477
|
|
@@ -510,7 +510,7 @@ var UriBuilder = /*#__PURE__*/function () {
|
|
510
510
|
function UriBuilder(base) {
|
511
511
|
_classCallCheck__default['default'](this, UriBuilder);
|
512
512
|
|
513
|
-
this.base = base.replace(/\/$/,
|
513
|
+
this.base = base.replace(/\/$/, "");
|
514
514
|
this.args = [];
|
515
515
|
this.paths = [];
|
516
516
|
}
|
@@ -518,8 +518,8 @@ var UriBuilder = /*#__PURE__*/function () {
|
|
518
518
|
_createClass__default['default'](UriBuilder, [{
|
519
519
|
key: "arg",
|
520
520
|
value: function arg(name, value) {
|
521
|
-
if (typeof value !==
|
522
|
-
this.args.push(encodeURIComponent(name) +
|
521
|
+
if (typeof value !== "undefined") {
|
522
|
+
this.args.push(encodeURIComponent(name) + "=" + encodeURIComponent(value));
|
523
523
|
}
|
524
524
|
|
525
525
|
return this;
|
@@ -536,11 +536,11 @@ var UriBuilder = /*#__PURE__*/function () {
|
|
536
536
|
var result = this.base;
|
537
537
|
|
538
538
|
if (this.paths.length) {
|
539
|
-
result +=
|
539
|
+
result += "/" + this.paths.join("/");
|
540
540
|
}
|
541
541
|
|
542
542
|
if (this.args.length) {
|
543
|
-
result +=
|
543
|
+
result += "?" + this.args.join("&");
|
544
544
|
}
|
545
545
|
|
546
546
|
return result;
|
@@ -550,10 +550,17 @@ var UriBuilder = /*#__PURE__*/function () {
|
|
550
550
|
return UriBuilder;
|
551
551
|
}();
|
552
552
|
|
553
|
+
var attributesValidator = declarativeTypeValidator.custom(function (value) {
|
554
|
+
return [["string", "number", "boolean", "object"].includes(_typeof__default['default'](value)), "a JSON type"];
|
555
|
+
});
|
556
|
+
var optionalAttributesValidator = declarativeTypeValidator.custom(function (value) {
|
557
|
+
return [["undefined", "string", "number", "boolean", "object"].includes(_typeof__default['default'](value)), "an optional JSON type"];
|
558
|
+
});
|
559
|
+
|
553
560
|
function _createSuper$8(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$8(); 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); }; }
|
554
561
|
|
555
562
|
function _isNativeReflectConstruct$8() { 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; } }
|
556
|
-
var log$8 = Logger.scope(
|
563
|
+
var log$8 = Logger.scope("User");
|
557
564
|
/**
|
558
565
|
* Extended user information.
|
559
566
|
* Note that `isOnline` and `isNotifiable` properties are eligible
|
@@ -578,14 +585,14 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
578
585
|
|
579
586
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "promiseToFetch", null);
|
580
587
|
|
581
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "updated",
|
588
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "updated", "updated");
|
582
589
|
|
583
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userSubscribed",
|
590
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userSubscribed", "userSubscribed");
|
584
591
|
|
585
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userUnsubscribed",
|
592
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userUnsubscribed", "userUnsubscribed");
|
586
593
|
|
587
594
|
_this.services = services;
|
588
|
-
_this.subscribed =
|
595
|
+
_this.subscribed = "initializing";
|
589
596
|
|
590
597
|
_this.setMaxListeners(0);
|
591
598
|
|
@@ -678,7 +685,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
678
685
|
}, {
|
679
686
|
key: "isSubscribed",
|
680
687
|
get: function get() {
|
681
|
-
return this.subscribed ==
|
688
|
+
return this.subscribed == "subscribed";
|
682
689
|
} // Handles service updates
|
683
690
|
|
684
691
|
}, {
|
@@ -695,14 +702,14 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
695
702
|
|
696
703
|
case 2:
|
697
704
|
updateReasons = [];
|
698
|
-
log$8.debug(
|
705
|
+
log$8.debug("User for", this.state.identity, "updated:", key, value);
|
699
706
|
_context.t0 = key;
|
700
|
-
_context.next = _context.t0 ===
|
707
|
+
_context.next = _context.t0 === "friendlyName" ? 7 : _context.t0 === "attributes" ? 9 : _context.t0 === "reachability" ? 12 : 15;
|
701
708
|
break;
|
702
709
|
|
703
710
|
case 7:
|
704
711
|
if (this.state.friendlyName !== value.value) {
|
705
|
-
updateReasons.push(
|
712
|
+
updateReasons.push("friendlyName");
|
706
713
|
this.state.friendlyName = value.value;
|
707
714
|
}
|
708
715
|
|
@@ -713,7 +720,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
713
720
|
|
714
721
|
if (!isEqual__default['default'](this.state.attributes, updateAttributes)) {
|
715
722
|
this.state.attributes = updateAttributes;
|
716
|
-
updateReasons.push(
|
723
|
+
updateReasons.push("attributes");
|
717
724
|
}
|
718
725
|
|
719
726
|
return _context.abrupt("break", 16);
|
@@ -721,12 +728,12 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
721
728
|
case 12:
|
722
729
|
if (this.state.online !== value.online) {
|
723
730
|
this.state.online = value.online;
|
724
|
-
updateReasons.push(
|
731
|
+
updateReasons.push("reachabilityOnline");
|
725
732
|
}
|
726
733
|
|
727
734
|
if (this.state.notifiable !== value.notifiable) {
|
728
735
|
this.state.notifiable = value.notifiable;
|
729
|
-
updateReasons.push(
|
736
|
+
updateReasons.push("reachabilityNotifiable");
|
730
737
|
}
|
731
738
|
|
732
739
|
return _context.abrupt("break", 16);
|
@@ -736,7 +743,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
736
743
|
|
737
744
|
case 16:
|
738
745
|
if (updateReasons.length > 0) {
|
739
|
-
this.emit(
|
746
|
+
this.emit("updated", {
|
740
747
|
user: this,
|
741
748
|
updateReasons: updateReasons
|
742
749
|
});
|
@@ -779,8 +786,8 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
779
786
|
return _context2.abrupt("return", Promise.resolve());
|
780
787
|
|
781
788
|
case 4:
|
782
|
-
return _context2.abrupt("return", map.get(
|
783
|
-
log$8.warn(
|
789
|
+
return _context2.abrupt("return", map.get("reachability").then(update).catch(function (err) {
|
790
|
+
log$8.warn("Failed to get reachability info for ", _this2.state.identity, err);
|
784
791
|
}));
|
785
792
|
|
786
793
|
case 5:
|
@@ -822,26 +829,26 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
822
829
|
case 4:
|
823
830
|
this.promiseToFetch = this.services.syncClient.map({
|
824
831
|
id: this.state.entityName,
|
825
|
-
mode:
|
832
|
+
mode: "open_existing",
|
826
833
|
includeItems: true
|
827
834
|
}).then(function (map) {
|
828
835
|
_this3.entity = map;
|
829
|
-
map.on(
|
830
|
-
log$8.debug(_this3.state.entityName +
|
836
|
+
map.on("itemUpdated", function (args) {
|
837
|
+
log$8.debug(_this3.state.entityName + " (" + _this3.state.identity + ") itemUpdated: " + args.item.key);
|
831
838
|
return _this3._update(args.item.key, args.item.data);
|
832
839
|
});
|
833
|
-
return Promise.all([map.get(
|
840
|
+
return Promise.all([map.get("friendlyName").then(function (item) {
|
834
841
|
return _this3._update(item.key, item.data);
|
835
|
-
}), map.get(
|
842
|
+
}), map.get("attributes").then(function (item) {
|
836
843
|
return _this3._update(item.key, item.data);
|
837
844
|
}), _this3._updateReachabilityInfo(map, function (item) {
|
838
845
|
return _this3._update(item.key, item.data);
|
839
846
|
})]);
|
840
847
|
}).then(function () {
|
841
|
-
log$8.debug(
|
842
|
-
_this3.subscribed =
|
848
|
+
log$8.debug("Fetched for", _this3.identity);
|
849
|
+
_this3.subscribed = "subscribed";
|
843
850
|
|
844
|
-
_this3.emit(
|
851
|
+
_this3.emit("userSubscribed", _this3);
|
845
852
|
|
846
853
|
return _this3;
|
847
854
|
}).catch(function (err) {
|
@@ -909,16 +916,16 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
909
916
|
return this._initializationPromise;
|
910
917
|
|
911
918
|
case 2:
|
912
|
-
if (!(this.subscribed ==
|
919
|
+
if (!(this.subscribed == "unsubscribed")) {
|
913
920
|
_context5.next = 4;
|
914
921
|
break;
|
915
922
|
}
|
916
923
|
|
917
|
-
throw new Error(
|
924
|
+
throw new Error("Can't modify unsubscribed object");
|
918
925
|
|
919
926
|
case 4:
|
920
927
|
_context5.next = 6;
|
921
|
-
return this.services.commandExecutor.mutateResource(
|
928
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
922
929
|
attributes: JSON.stringify(attributes)
|
923
930
|
});
|
924
931
|
|
@@ -956,16 +963,16 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
956
963
|
return this._initializationPromise;
|
957
964
|
|
958
965
|
case 2:
|
959
|
-
if (!(this.subscribed ==
|
966
|
+
if (!(this.subscribed == "unsubscribed")) {
|
960
967
|
_context6.next = 4;
|
961
968
|
break;
|
962
969
|
}
|
963
970
|
|
964
|
-
throw new Error(
|
971
|
+
throw new Error("Can't modify unsubscribed object");
|
965
972
|
|
966
973
|
case 4:
|
967
974
|
_context6.next = 6;
|
968
|
-
return this.services.commandExecutor.mutateResource(
|
975
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
969
976
|
friendly_name: friendlyName
|
970
977
|
});
|
971
978
|
|
@@ -1014,8 +1021,8 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1014
1021
|
case 5:
|
1015
1022
|
this.entity.close();
|
1016
1023
|
this.promiseToFetch = null;
|
1017
|
-
this.subscribed =
|
1018
|
-
this.emit(
|
1024
|
+
this.subscribed = "unsubscribed";
|
1025
|
+
this.emit("userUnsubscribed", this);
|
1019
1026
|
|
1020
1027
|
case 9:
|
1021
1028
|
case "end":
|
@@ -1044,9 +1051,9 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1044
1051
|
this._resolveInitializationPromise();
|
1045
1052
|
|
1046
1053
|
if (emitUpdated) {
|
1047
|
-
this.emit(
|
1054
|
+
this.emit("updated", {
|
1048
1055
|
user: this,
|
1049
|
-
updateReasons: [
|
1056
|
+
updateReasons: ["friendlyName", "attributes", "reachabilityOnline", "reachabilityNotifiable"]
|
1050
1057
|
});
|
1051
1058
|
}
|
1052
1059
|
}
|
@@ -1055,9 +1062,9 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1055
1062
|
return User;
|
1056
1063
|
}(replayEventEmitter.ReplayEventEmitter);
|
1057
1064
|
|
1058
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
1065
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], User.prototype, "updateAttributes", null);
|
1059
1066
|
|
1060
|
-
__decorate([declarativeTypeValidator.validateTypesAsync([
|
1067
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], User.prototype, "updateFriendlyName", null);
|
1061
1068
|
|
1062
1069
|
function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
1063
1070
|
|
@@ -1130,13 +1137,13 @@ var Network = /*#__PURE__*/function () {
|
|
1130
1137
|
}
|
1131
1138
|
|
1132
1139
|
var retrier = new operationRetrier.Retrier(_this2.configuration.backoffConfiguration);
|
1133
|
-
retrier.on(
|
1140
|
+
retrier.on("attempt", function () {
|
1134
1141
|
request().then(function (result) {
|
1135
1142
|
return retrier.succeeded(result);
|
1136
1143
|
}).catch(function (err) {
|
1137
1144
|
if (codesToRetryOn.indexOf(err.status) > -1) {
|
1138
1145
|
retrier.failed(err);
|
1139
|
-
} else if (err.message ===
|
1146
|
+
} else if (err.message === "Twilsock disconnected") {
|
1140
1147
|
// Ugly hack. We must make a proper exceptions for twilsock
|
1141
1148
|
retrier.failed(err);
|
1142
1149
|
} else {
|
@@ -1147,13 +1154,13 @@ var Network = /*#__PURE__*/function () {
|
|
1147
1154
|
}
|
1148
1155
|
});
|
1149
1156
|
});
|
1150
|
-
retrier.on(
|
1157
|
+
retrier.on("succeeded", function (result) {
|
1151
1158
|
resolve(result);
|
1152
1159
|
});
|
1153
|
-
retrier.on(
|
1160
|
+
retrier.on("cancelled", function (err) {
|
1154
1161
|
return reject(err);
|
1155
1162
|
});
|
1156
|
-
retrier.on(
|
1163
|
+
retrier.on("failed", function (err) {
|
1157
1164
|
return reject(err);
|
1158
1165
|
});
|
1159
1166
|
retrier.start();
|
@@ -1218,20 +1225,20 @@ var NotificationTypes = function NotificationTypes() {
|
|
1218
1225
|
_classCallCheck__default['default'](this, NotificationTypes);
|
1219
1226
|
};
|
1220
1227
|
|
1221
|
-
_defineProperty__default['default'](NotificationTypes, "TYPING_INDICATOR",
|
1228
|
+
_defineProperty__default['default'](NotificationTypes, "TYPING_INDICATOR", "twilio.ipmsg.typing_indicator");
|
1222
1229
|
|
1223
|
-
_defineProperty__default['default'](NotificationTypes, "NEW_MESSAGE",
|
1230
|
+
_defineProperty__default['default'](NotificationTypes, "NEW_MESSAGE", "twilio.conversations.new_message");
|
1224
1231
|
|
1225
|
-
_defineProperty__default['default'](NotificationTypes, "ADDED_TO_CONVERSATION",
|
1232
|
+
_defineProperty__default['default'](NotificationTypes, "ADDED_TO_CONVERSATION", "twilio.conversations.added_to_conversation");
|
1226
1233
|
|
1227
|
-
_defineProperty__default['default'](NotificationTypes, "REMOVED_FROM_CONVERSATION",
|
1234
|
+
_defineProperty__default['default'](NotificationTypes, "REMOVED_FROM_CONVERSATION", "twilio.conversations.removed_from_conversation");
|
1228
1235
|
|
1229
|
-
_defineProperty__default['default'](NotificationTypes, "CONSUMPTION_UPDATE",
|
1236
|
+
_defineProperty__default['default'](NotificationTypes, "CONSUMPTION_UPDATE", "twilio.channel.consumption_update");
|
1230
1237
|
|
1231
1238
|
function _createSuper$7(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$7(); 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); }; }
|
1232
1239
|
|
1233
1240
|
function _isNativeReflectConstruct$7() { 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; } }
|
1234
|
-
var log$7 = Logger.scope(
|
1241
|
+
var log$7 = Logger.scope("Participant");
|
1235
1242
|
/**
|
1236
1243
|
* A participant represents a remote client in a conversation.
|
1237
1244
|
*/
|
@@ -1245,6 +1252,8 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1245
1252
|
* @internal
|
1246
1253
|
*/
|
1247
1254
|
function Participant(data, sid, conversation, links, services) {
|
1255
|
+
var _data$roleSid, _data$bindings;
|
1256
|
+
|
1248
1257
|
var _this;
|
1249
1258
|
|
1250
1259
|
_classCallCheck__default['default'](this, Participant);
|
@@ -1254,22 +1263,23 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1254
1263
|
_this.links = links;
|
1255
1264
|
_this.services = services;
|
1256
1265
|
_this.state = {
|
1257
|
-
attributes: parseAttributes(data.attributes,
|
1266
|
+
attributes: parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + sid, log$7),
|
1258
1267
|
dateCreated: data.dateCreated ? parseTime$1(data.dateCreated) : null,
|
1259
1268
|
dateUpdated: data.dateCreated ? parseTime$1(data.dateUpdated) : null,
|
1260
1269
|
sid: sid,
|
1261
1270
|
typingTimeout: null,
|
1262
1271
|
isTyping: false,
|
1263
|
-
identity: data.identity
|
1264
|
-
roleSid: data.roleSid
|
1272
|
+
identity: data.identity,
|
1273
|
+
roleSid: (_data$roleSid = data.roleSid) !== null && _data$roleSid !== void 0 ? _data$roleSid : "",
|
1265
1274
|
lastReadMessageIndex: Number.isInteger(data.lastConsumedMessageIndex) ? data.lastConsumedMessageIndex : null,
|
1266
1275
|
lastReadTimestamp: data.lastConsumptionTimestamp ? parseTime$1(data.lastConsumptionTimestamp) : null,
|
1267
|
-
type: data.type ||
|
1268
|
-
userInfo: data.userInfo
|
1276
|
+
type: data.type || "chat",
|
1277
|
+
userInfo: data.userInfo,
|
1278
|
+
bindings: (_data$bindings = data.bindings) !== null && _data$bindings !== void 0 ? _data$bindings : {}
|
1269
1279
|
};
|
1270
1280
|
|
1271
1281
|
if (!data.identity && !data.type) {
|
1272
|
-
throw new Error(
|
1282
|
+
throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");
|
1273
1283
|
}
|
1274
1284
|
|
1275
1285
|
return _this;
|
@@ -1368,7 +1378,7 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1368
1378
|
return this.state.roleSid;
|
1369
1379
|
}
|
1370
1380
|
/**
|
1371
|
-
*
|
1381
|
+
* Type of the participant.
|
1372
1382
|
*/
|
1373
1383
|
|
1374
1384
|
}, {
|
@@ -1376,6 +1386,23 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1376
1386
|
get: function get() {
|
1377
1387
|
return this.state.type;
|
1378
1388
|
}
|
1389
|
+
/**
|
1390
|
+
* Get the bindings mapping for the current participant.
|
1391
|
+
* Available binding depends on the participant type.
|
1392
|
+
* You could access it as `participant.bindings.sms?.address` or
|
1393
|
+
* using the type dynamically `participant.bindings[participant.type]`
|
1394
|
+
* just be aware that the binding information has different structure for
|
1395
|
+
* each participant type.
|
1396
|
+
* See also {ParticipantEmailBinding}, the only available currently binding descriptor.
|
1397
|
+
*/
|
1398
|
+
|
1399
|
+
}, {
|
1400
|
+
key: "bindings",
|
1401
|
+
get: function get() {
|
1402
|
+
var _this$state$bindings;
|
1403
|
+
|
1404
|
+
return (_this$state$bindings = this.state.bindings) !== null && _this$state$bindings !== void 0 ? _this$state$bindings : {};
|
1405
|
+
}
|
1379
1406
|
}, {
|
1380
1407
|
key: "_startTyping",
|
1381
1408
|
value:
|
@@ -1386,13 +1413,16 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1386
1413
|
function _startTyping(timeout) {
|
1387
1414
|
var _this2 = this;
|
1388
1415
|
|
1389
|
-
|
1416
|
+
if (this.state.typingTimeout) {
|
1417
|
+
clearTimeout(this.state.typingTimeout);
|
1418
|
+
}
|
1419
|
+
|
1390
1420
|
this.state.isTyping = true;
|
1391
|
-
this.emit(
|
1392
|
-
this.conversation.emit(
|
1393
|
-
this.state.typingTimeout = setTimeout(function () {
|
1421
|
+
this.emit("typingStarted", this);
|
1422
|
+
this.conversation.emit("typingStarted", this);
|
1423
|
+
this.state.typingTimeout = Number(setTimeout(function () {
|
1394
1424
|
return _this2._endTyping();
|
1395
|
-
}, timeout);
|
1425
|
+
}, timeout));
|
1396
1426
|
return this;
|
1397
1427
|
}
|
1398
1428
|
/**
|
@@ -1408,8 +1438,8 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1408
1438
|
}
|
1409
1439
|
|
1410
1440
|
this.state.isTyping = false;
|
1411
|
-
this.emit(
|
1412
|
-
this.conversation.emit(
|
1441
|
+
this.emit("typingEnded", this);
|
1442
|
+
this.conversation.emit("typingEnded", this);
|
1413
1443
|
clearInterval(this.state.typingTimeout);
|
1414
1444
|
this.state.typingTimeout = null;
|
1415
1445
|
}
|
@@ -1422,35 +1452,35 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1422
1452
|
key: "_update",
|
1423
1453
|
value: function _update(data) {
|
1424
1454
|
var updateReasons = [];
|
1425
|
-
var updateAttributes = parseAttributes(data.attributes,
|
1455
|
+
var updateAttributes = parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + this.state.sid, log$7);
|
1426
1456
|
|
1427
1457
|
if (data.attributes && !isEqual__default['default'](this.state.attributes, updateAttributes)) {
|
1428
1458
|
this.state.attributes = updateAttributes;
|
1429
|
-
updateReasons.push(
|
1459
|
+
updateReasons.push("attributes");
|
1430
1460
|
}
|
1431
1461
|
|
1432
1462
|
var updatedDateUpdated = parseTime$1(data.dateUpdated);
|
1433
1463
|
|
1434
|
-
if (data.dateUpdated && updatedDateUpdated.getTime() !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
|
1464
|
+
if (data.dateUpdated && (updatedDateUpdated === null || updatedDateUpdated === void 0 ? void 0 : updatedDateUpdated.getTime()) !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
|
1435
1465
|
this.state.dateUpdated = updatedDateUpdated;
|
1436
|
-
updateReasons.push(
|
1466
|
+
updateReasons.push("dateUpdated");
|
1437
1467
|
}
|
1438
1468
|
|
1439
1469
|
var updatedDateCreated = parseTime$1(data.dateCreated);
|
1440
1470
|
|
1441
|
-
if (data.dateCreated && updatedDateCreated.getTime() !== (this.state.dateCreated && this.state.dateCreated.getTime())) {
|
1471
|
+
if (data.dateCreated && (updatedDateCreated === null || updatedDateCreated === void 0 ? void 0 : updatedDateCreated.getTime()) !== (this.state.dateCreated && this.state.dateCreated.getTime())) {
|
1442
1472
|
this.state.dateCreated = updatedDateCreated;
|
1443
|
-
updateReasons.push(
|
1473
|
+
updateReasons.push("dateCreated");
|
1444
1474
|
}
|
1445
1475
|
|
1446
1476
|
if (data.roleSid && this.state.roleSid !== data.roleSid) {
|
1447
1477
|
this.state.roleSid = data.roleSid;
|
1448
|
-
updateReasons.push(
|
1478
|
+
updateReasons.push("roleSid");
|
1449
1479
|
}
|
1450
1480
|
|
1451
1481
|
if ((Number.isInteger(data.lastConsumedMessageIndex) || data.lastConsumedMessageIndex === null) && this.state.lastReadMessageIndex !== data.lastConsumedMessageIndex) {
|
1452
1482
|
this.state.lastReadMessageIndex = data.lastConsumedMessageIndex;
|
1453
|
-
updateReasons.push(
|
1483
|
+
updateReasons.push("lastReadMessageIndex");
|
1454
1484
|
}
|
1455
1485
|
|
1456
1486
|
if (data.lastConsumptionTimestamp) {
|
@@ -1458,12 +1488,17 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1458
1488
|
|
1459
1489
|
if (!this.state.lastReadTimestamp || this.state.lastReadTimestamp.getTime() !== lastReadTimestamp.getTime()) {
|
1460
1490
|
this.state.lastReadTimestamp = lastReadTimestamp;
|
1461
|
-
updateReasons.push(
|
1491
|
+
updateReasons.push("lastReadTimestamp");
|
1462
1492
|
}
|
1463
1493
|
}
|
1464
1494
|
|
1495
|
+
if (data.bindings && !isEqual__default['default'](this.state.bindings, data.bindings)) {
|
1496
|
+
this.state.bindings = data.bindings;
|
1497
|
+
updateReasons.push("bindings");
|
1498
|
+
}
|
1499
|
+
|
1465
1500
|
if (updateReasons.length > 0) {
|
1466
|
-
this.emit(
|
1501
|
+
this.emit("updated", {
|
1467
1502
|
participant: this,
|
1468
1503
|
updateReasons: updateReasons
|
1469
1504
|
});
|
@@ -1483,12 +1518,12 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1483
1518
|
while (1) {
|
1484
1519
|
switch (_context.prev = _context.next) {
|
1485
1520
|
case 0:
|
1486
|
-
if (!(this.type !=
|
1521
|
+
if (!(this.type != "chat")) {
|
1487
1522
|
_context.next = 2;
|
1488
1523
|
break;
|
1489
1524
|
}
|
1490
1525
|
|
1491
|
-
throw new Error(
|
1526
|
+
throw new Error("Getting User is not supported for this Participant type: " + this.type);
|
1492
1527
|
|
1493
1528
|
case 2:
|
1494
1529
|
return _context.abrupt("return", this.services.users.getUser(this.state.identity, this.state.userInfo));
|
@@ -1549,7 +1584,7 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1549
1584
|
switch (_context3.prev = _context3.next) {
|
1550
1585
|
case 0:
|
1551
1586
|
_context3.next = 2;
|
1552
|
-
return this.services.commandExecutor.mutateResource(
|
1587
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
1553
1588
|
attributes: JSON.stringify(attributes)
|
1554
1589
|
});
|
1555
1590
|
|
@@ -1575,18 +1610,18 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1575
1610
|
return Participant;
|
1576
1611
|
}(replayEventEmitter.ReplayEventEmitter);
|
1577
1612
|
|
1578
|
-
_defineProperty__default['default'](Participant, "typingStarted",
|
1613
|
+
_defineProperty__default['default'](Participant, "typingStarted", "typingStarted");
|
1579
1614
|
|
1580
|
-
_defineProperty__default['default'](Participant, "typingEnded",
|
1615
|
+
_defineProperty__default['default'](Participant, "typingEnded", "typingEnded");
|
1581
1616
|
|
1582
|
-
_defineProperty__default['default'](Participant, "updated",
|
1617
|
+
_defineProperty__default['default'](Participant, "updated", "updated");
|
1583
1618
|
|
1584
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
1619
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Participant.prototype, "updateAttributes", null);
|
1585
1620
|
|
1586
1621
|
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); }; }
|
1587
1622
|
|
1588
1623
|
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; } }
|
1589
|
-
var log$6 = Logger.scope(
|
1624
|
+
var log$6 = Logger.scope("Participants");
|
1590
1625
|
/**
|
1591
1626
|
* @classdesc Represents the collection of participants for the conversation
|
1592
1627
|
* @fires Participants#participantJoined
|
@@ -1605,6 +1640,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1605
1640
|
_classCallCheck__default['default'](this, Participants);
|
1606
1641
|
|
1607
1642
|
_this = _super.call(this);
|
1643
|
+
|
1644
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "rosterEntityPromise", null);
|
1645
|
+
|
1608
1646
|
_this.conversation = conversation;
|
1609
1647
|
_this.participants = participants;
|
1610
1648
|
_this.links = links;
|
@@ -1656,17 +1694,17 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1656
1694
|
|
1657
1695
|
return this.rosterEntityPromise = this.rosterEntityPromise || this.services.syncClient.map({
|
1658
1696
|
id: rosterObjectName,
|
1659
|
-
mode:
|
1697
|
+
mode: "open_existing"
|
1660
1698
|
}).then(function (rosterMap) {
|
1661
|
-
rosterMap.on(
|
1662
|
-
log$6.debug(_this2.conversation.sid +
|
1699
|
+
rosterMap.on("itemAdded", function (args) {
|
1700
|
+
log$6.debug(_this2.conversation.sid + " itemAdded: " + args.item.key);
|
1663
1701
|
|
1664
1702
|
_this2.upsertParticipant(args.item.key, args.item.data).then(function (participant) {
|
1665
|
-
_this2.emit(
|
1703
|
+
_this2.emit("participantJoined", participant);
|
1666
1704
|
});
|
1667
1705
|
});
|
1668
|
-
rosterMap.on(
|
1669
|
-
log$6.debug(_this2.conversation.sid +
|
1706
|
+
rosterMap.on("itemRemoved", function (args) {
|
1707
|
+
log$6.debug(_this2.conversation.sid + " itemRemoved: " + args.key);
|
1670
1708
|
var participantSid = args.key;
|
1671
1709
|
|
1672
1710
|
if (!_this2.participants.has(participantSid)) {
|
@@ -1677,19 +1715,22 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1677
1715
|
|
1678
1716
|
_this2.participants.delete(participantSid);
|
1679
1717
|
|
1680
|
-
|
1718
|
+
if (!leftParticipant) {
|
1719
|
+
return;
|
1720
|
+
}
|
1721
|
+
|
1722
|
+
_this2.emit("participantLeft", leftParticipant);
|
1681
1723
|
});
|
1682
|
-
rosterMap.on(
|
1683
|
-
log$6.debug(_this2.conversation.sid +
|
1724
|
+
rosterMap.on("itemUpdated", function (args) {
|
1725
|
+
log$6.debug(_this2.conversation.sid + " itemUpdated: " + args.item.key);
|
1684
1726
|
|
1685
1727
|
_this2.upsertParticipant(args.item.key, args.item.data);
|
1686
1728
|
});
|
1687
1729
|
var participantsPromises = [];
|
1688
|
-
var that = _this2;
|
1689
1730
|
|
1690
1731
|
var rosterMapHandler = function rosterMapHandler(paginator) {
|
1691
1732
|
paginator.items.forEach(function (item) {
|
1692
|
-
participantsPromises.push(
|
1733
|
+
participantsPromises.push(_this2.upsertParticipant(item.key, item.data));
|
1693
1734
|
});
|
1694
1735
|
return paginator.hasNextPage ? paginator.nextPage().then(rosterMapHandler) : null;
|
1695
1736
|
};
|
@@ -1702,11 +1743,11 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1702
1743
|
}).catch(function (err) {
|
1703
1744
|
_this2.rosterEntityPromise = null;
|
1704
1745
|
|
1705
|
-
if (_this2.services.syncClient.connectionState !=
|
1706
|
-
log$6.error(
|
1746
|
+
if (_this2.services.syncClient.connectionState != "disconnected") {
|
1747
|
+
log$6.error("Failed to get roster object for conversation", _this2.conversation.sid, err);
|
1707
1748
|
}
|
1708
1749
|
|
1709
|
-
log$6.debug(
|
1750
|
+
log$6.debug("ERROR: Failed to get roster object for conversation", _this2.conversation.sid, err);
|
1710
1751
|
throw err;
|
1711
1752
|
});
|
1712
1753
|
}
|
@@ -1736,8 +1777,8 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1736
1777
|
};
|
1737
1778
|
participant = new Participant(data, participantSid, this.conversation, links, this.services);
|
1738
1779
|
this.participants.set(participantSid, participant);
|
1739
|
-
participant.on(
|
1740
|
-
return _this3.emit(
|
1780
|
+
participant.on("updated", function (args) {
|
1781
|
+
return _this3.emit("participantUpdated", args);
|
1741
1782
|
});
|
1742
1783
|
return _context2.abrupt("return", participant);
|
1743
1784
|
|
@@ -1761,19 +1802,38 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1761
1802
|
|
1762
1803
|
}, {
|
1763
1804
|
key: "getParticipants",
|
1764
|
-
value: function
|
1765
|
-
var
|
1805
|
+
value: function () {
|
1806
|
+
var _getParticipants = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
1807
|
+
var _this4 = this;
|
1766
1808
|
|
1767
|
-
|
1768
|
-
|
1809
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
1810
|
+
while (1) {
|
1811
|
+
switch (_context3.prev = _context3.next) {
|
1812
|
+
case 0:
|
1813
|
+
return _context3.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
|
1814
|
+
var participants = [];
|
1769
1815
|
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1816
|
+
_this4.participants.forEach(function (participant) {
|
1817
|
+
return participants.push(participant);
|
1818
|
+
});
|
1773
1819
|
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1820
|
+
return participants;
|
1821
|
+
}) : []);
|
1822
|
+
|
1823
|
+
case 1:
|
1824
|
+
case "end":
|
1825
|
+
return _context3.stop();
|
1826
|
+
}
|
1827
|
+
}
|
1828
|
+
}, _callee3, this);
|
1829
|
+
}));
|
1830
|
+
|
1831
|
+
function getParticipants() {
|
1832
|
+
return _getParticipants.apply(this, arguments);
|
1833
|
+
}
|
1834
|
+
|
1835
|
+
return getParticipants;
|
1836
|
+
}()
|
1777
1837
|
/**
|
1778
1838
|
* Get participant by SID from conversation
|
1779
1839
|
* @returns {Promise<Participant>}
|
@@ -1782,29 +1842,29 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1782
1842
|
}, {
|
1783
1843
|
key: "getParticipantBySid",
|
1784
1844
|
value: function () {
|
1785
|
-
var _getParticipantBySid = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
1845
|
+
var _getParticipantBySid = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(participantSid) {
|
1786
1846
|
var _this5 = this;
|
1787
1847
|
|
1788
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
1848
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
1789
1849
|
while (1) {
|
1790
|
-
switch (
|
1850
|
+
switch (_context4.prev = _context4.next) {
|
1791
1851
|
case 0:
|
1792
|
-
return
|
1852
|
+
return _context4.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
|
1793
1853
|
var participant = _this5.participants.get(participantSid);
|
1794
1854
|
|
1795
1855
|
if (!participant) {
|
1796
|
-
throw new Error(
|
1856
|
+
throw new Error("Participant with SID " + participantSid + " was not found");
|
1797
1857
|
}
|
1798
1858
|
|
1799
1859
|
return participant;
|
1800
|
-
}));
|
1860
|
+
}) : null);
|
1801
1861
|
|
1802
1862
|
case 1:
|
1803
1863
|
case "end":
|
1804
|
-
return
|
1864
|
+
return _context4.stop();
|
1805
1865
|
}
|
1806
1866
|
}
|
1807
|
-
},
|
1867
|
+
}, _callee4, this);
|
1808
1868
|
}));
|
1809
1869
|
|
1810
1870
|
function getParticipantBySid(_x3) {
|
@@ -1821,16 +1881,16 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1821
1881
|
}, {
|
1822
1882
|
key: "getParticipantByIdentity",
|
1823
1883
|
value: function () {
|
1824
|
-
var _getParticipantByIdentity = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
1884
|
+
var _getParticipantByIdentity = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(identity) {
|
1825
1885
|
var _this6 = this;
|
1826
1886
|
|
1827
1887
|
var foundParticipant;
|
1828
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
1888
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
1829
1889
|
while (1) {
|
1830
|
-
switch (
|
1890
|
+
switch (_context5.prev = _context5.next) {
|
1831
1891
|
case 0:
|
1832
1892
|
foundParticipant = null;
|
1833
|
-
return
|
1893
|
+
return _context5.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
|
1834
1894
|
_this6.participants.forEach(function (participant) {
|
1835
1895
|
if (participant.identity === identity) {
|
1836
1896
|
foundParticipant = participant;
|
@@ -1838,18 +1898,18 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1838
1898
|
});
|
1839
1899
|
|
1840
1900
|
if (!foundParticipant) {
|
1841
|
-
throw new Error(
|
1901
|
+
throw new Error("Participant with identity " + identity + " was not found");
|
1842
1902
|
}
|
1843
1903
|
|
1844
1904
|
return foundParticipant;
|
1845
|
-
}));
|
1905
|
+
}) : null);
|
1846
1906
|
|
1847
1907
|
case 2:
|
1848
1908
|
case "end":
|
1849
|
-
return
|
1909
|
+
return _context5.stop();
|
1850
1910
|
}
|
1851
1911
|
}
|
1852
|
-
},
|
1912
|
+
}, _callee5, this);
|
1853
1913
|
}));
|
1854
1914
|
|
1855
1915
|
function getParticipantByIdentity(_x4) {
|
@@ -1860,32 +1920,32 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1860
1920
|
}()
|
1861
1921
|
/**
|
1862
1922
|
* Add a chat participant to the conversation
|
1863
|
-
* @returns {Promise<
|
1923
|
+
* @returns {Promise<ParticipantResponse>}
|
1864
1924
|
*/
|
1865
1925
|
|
1866
1926
|
}, {
|
1867
1927
|
key: "add",
|
1868
1928
|
value: function () {
|
1869
|
-
var _add = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
1870
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
1929
|
+
var _add = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6(identity, attributes) {
|
1930
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
1871
1931
|
while (1) {
|
1872
|
-
switch (
|
1932
|
+
switch (_context6.prev = _context6.next) {
|
1873
1933
|
case 0:
|
1874
|
-
|
1875
|
-
return this.services.commandExecutor.mutateResource(
|
1934
|
+
_context6.next = 2;
|
1935
|
+
return this.services.commandExecutor.mutateResource("post", this.links.participants, {
|
1876
1936
|
identity: identity,
|
1877
|
-
attributes: typeof attributes !==
|
1937
|
+
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
|
1878
1938
|
});
|
1879
1939
|
|
1880
1940
|
case 2:
|
1881
|
-
return
|
1941
|
+
return _context6.abrupt("return", _context6.sent);
|
1882
1942
|
|
1883
1943
|
case 3:
|
1884
1944
|
case "end":
|
1885
|
-
return
|
1945
|
+
return _context6.stop();
|
1886
1946
|
}
|
1887
1947
|
}
|
1888
|
-
},
|
1948
|
+
}, _callee6, this);
|
1889
1949
|
}));
|
1890
1950
|
|
1891
1951
|
function add(_x5, _x6) {
|
@@ -1900,17 +1960,24 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1900
1960
|
* @param proxyAddress
|
1901
1961
|
* @param address
|
1902
1962
|
* @param attributes
|
1963
|
+
* @param bindingOptions
|
1903
1964
|
* @returns {Promise<any>}
|
1904
1965
|
*/
|
1905
1966
|
|
1906
1967
|
}, {
|
1907
1968
|
key: "addNonChatParticipant",
|
1908
|
-
value: function addNonChatParticipant(proxyAddress, address
|
1909
|
-
|
1910
|
-
|
1969
|
+
value: function addNonChatParticipant(proxyAddress, address) {
|
1970
|
+
var _bindingOptions$email, _bindingOptions$email2;
|
1971
|
+
|
1972
|
+
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
1973
|
+
var bindingOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
1974
|
+
return this.services.commandExecutor.mutateResource("post", this.links.participants, {
|
1975
|
+
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined,
|
1911
1976
|
messaging_binding: {
|
1912
1977
|
address: address,
|
1913
|
-
proxy_address: proxyAddress
|
1978
|
+
proxy_address: proxyAddress,
|
1979
|
+
name: bindingOptions === null || bindingOptions === void 0 ? void 0 : (_bindingOptions$email = bindingOptions.email) === null || _bindingOptions$email === void 0 ? void 0 : _bindingOptions$email.name,
|
1980
|
+
level: bindingOptions === null || bindingOptions === void 0 ? void 0 : (_bindingOptions$email2 = bindingOptions.email) === null || _bindingOptions$email2 === void 0 ? void 0 : _bindingOptions$email2.level
|
1914
1981
|
}
|
1915
1982
|
});
|
1916
1983
|
}
|
@@ -1921,7 +1988,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1921
1988
|
}, {
|
1922
1989
|
key: "remove",
|
1923
1990
|
value: function remove(identity) {
|
1924
|
-
return this.services.commandExecutor.mutateResource(
|
1991
|
+
return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(identity));
|
1925
1992
|
}
|
1926
1993
|
}]);
|
1927
1994
|
|
@@ -2032,6 +2099,8 @@ var Media = /*#__PURE__*/function () {
|
|
2032
2099
|
key: "getContentTemporaryUrl",
|
2033
2100
|
value: function () {
|
2034
2101
|
var _getContentTemporaryUrl = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
2102
|
+
var _this$mcsMedia$getCon, _this$mcsMedia;
|
2103
|
+
|
2035
2104
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
2036
2105
|
while (1) {
|
2037
2106
|
switch (_context.prev = _context.next) {
|
@@ -2040,7 +2109,7 @@ var Media = /*#__PURE__*/function () {
|
|
2040
2109
|
return this._fetchMcsMedia();
|
2041
2110
|
|
2042
2111
|
case 2:
|
2043
|
-
return _context.abrupt("return", this.mcsMedia.getContentUrl());
|
2112
|
+
return _context.abrupt("return", (_this$mcsMedia$getCon = (_this$mcsMedia = this.mcsMedia) === null || _this$mcsMedia === void 0 ? void 0 : _this$mcsMedia.getContentUrl()) !== null && _this$mcsMedia$getCon !== void 0 ? _this$mcsMedia$getCon : null);
|
2044
2113
|
|
2045
2114
|
case 3:
|
2046
2115
|
case "end":
|
@@ -2070,6 +2139,8 @@ var Media = /*#__PURE__*/function () {
|
|
2070
2139
|
key: "getCachedTemporaryUrl",
|
2071
2140
|
value: function () {
|
2072
2141
|
var _getCachedTemporaryUrl = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
2142
|
+
var _this$mcsMedia$getCac, _this$mcsMedia2;
|
2143
|
+
|
2073
2144
|
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
2074
2145
|
while (1) {
|
2075
2146
|
switch (_context2.prev = _context2.next) {
|
@@ -2078,7 +2149,7 @@ var Media = /*#__PURE__*/function () {
|
|
2078
2149
|
return this._fetchMcsMedia();
|
2079
2150
|
|
2080
2151
|
case 2:
|
2081
|
-
return _context2.abrupt("return", this.mcsMedia.getCachedContentUrl());
|
2152
|
+
return _context2.abrupt("return", (_this$mcsMedia$getCac = (_this$mcsMedia2 = this.mcsMedia) === null || _this$mcsMedia2 === void 0 ? void 0 : _this$mcsMedia2.getCachedContentUrl()) !== null && _this$mcsMedia$getCac !== void 0 ? _this$mcsMedia$getCac : null);
|
2082
2153
|
|
2083
2154
|
case 3:
|
2084
2155
|
case "end":
|
@@ -2121,7 +2192,7 @@ var Media = /*#__PURE__*/function () {
|
|
2121
2192
|
break;
|
2122
2193
|
|
2123
2194
|
case 7:
|
2124
|
-
throw new Error(
|
2195
|
+
throw new Error("Media Content Service is unavailable");
|
2125
2196
|
|
2126
2197
|
case 8:
|
2127
2198
|
case "end":
|
@@ -2315,7 +2386,7 @@ var RestPaginator = /*#__PURE__*/function () {
|
|
2315
2386
|
}, {
|
2316
2387
|
key: "nextPage",
|
2317
2388
|
value: function nextPage() {
|
2318
|
-
return this.hasNextPage ? this.state.source(this.state.nextToken) : Promise.reject(new Error(
|
2389
|
+
return this.hasNextPage ? this.state.source(this.state.nextToken) : Promise.reject(new Error("No next page"));
|
2319
2390
|
}
|
2320
2391
|
/**
|
2321
2392
|
* Request the previous page. Does not modify the existing object.
|
@@ -2324,7 +2395,7 @@ var RestPaginator = /*#__PURE__*/function () {
|
|
2324
2395
|
}, {
|
2325
2396
|
key: "prevPage",
|
2326
2397
|
value: function prevPage() {
|
2327
|
-
return this.hasPrevPage ? this.state.source(this.state.prevToken) : Promise.reject(new Error(
|
2398
|
+
return this.hasPrevPage ? this.state.source(this.state.prevToken) : Promise.reject(new Error("No previous page"));
|
2328
2399
|
}
|
2329
2400
|
}]);
|
2330
2401
|
|
@@ -2383,7 +2454,7 @@ function DetailedDeliveryReceipt(descriptor) {
|
|
2383
2454
|
this.conversationSid = descriptor.conversation_sid;
|
2384
2455
|
this.channelMessageSid = descriptor.channel_message_sid;
|
2385
2456
|
this.participantSid = descriptor.participant_sid;
|
2386
|
-
this.status = descriptor.status ||
|
2457
|
+
this.status = descriptor.status || "queued";
|
2387
2458
|
this.errorCode = descriptor.error_code || 0;
|
2388
2459
|
this.dateCreated = descriptor.date_created;
|
2389
2460
|
this.dateUpdated = descriptor.date_updated;
|
@@ -2392,7 +2463,7 @@ function DetailedDeliveryReceipt(descriptor) {
|
|
2392
2463
|
function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); 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); }; }
|
2393
2464
|
|
2394
2465
|
function _isNativeReflectConstruct$5() { 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; } }
|
2395
|
-
var log$5 = Logger.scope(
|
2466
|
+
var log$5 = Logger.scope("Message");
|
2396
2467
|
/**
|
2397
2468
|
* A message in a conversation.
|
2398
2469
|
*/
|
@@ -2410,7 +2481,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2410
2481
|
* @internal
|
2411
2482
|
*/
|
2412
2483
|
function Message(index, data, conversation, links, configuration, services) {
|
2413
|
-
var _data$
|
2484
|
+
var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid;
|
2414
2485
|
|
2415
2486
|
var _this;
|
2416
2487
|
|
@@ -2424,16 +2495,16 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2424
2495
|
_this.state = {
|
2425
2496
|
sid: data.sid,
|
2426
2497
|
index: index,
|
2427
|
-
author:
|
2428
|
-
subject:
|
2429
|
-
body: data.text,
|
2498
|
+
author: data.author,
|
2499
|
+
subject: data.subject,
|
2500
|
+
body: (_data$text = data.text) !== null && _data$text !== void 0 ? _data$text : null,
|
2430
2501
|
timestamp: data.timestamp ? new Date(data.timestamp) : null,
|
2431
2502
|
dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,
|
2432
2503
|
lastUpdatedBy: (_data$lastUpdatedBy = data.lastUpdatedBy) !== null && _data$lastUpdatedBy !== void 0 ? _data$lastUpdatedBy : null,
|
2433
2504
|
attributes: parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(data.sid), log$5),
|
2434
|
-
type: (_data$type = data.type) !== null && _data$type !== void 0 ? _data$type :
|
2435
|
-
media: data.type && data.type ===
|
2436
|
-
medias: data.type && data.type ===
|
2505
|
+
type: (_data$type = data.type) !== null && _data$type !== void 0 ? _data$type : "text",
|
2506
|
+
media: data.type && data.type === "media" && data.media ? new Media(data.media, _this.services) : null,
|
2507
|
+
medias: data.type && data.type === "media" && data.medias ? data.medias.map(function (m) {
|
2437
2508
|
return new Media(m, _this.services);
|
2438
2509
|
}) : null,
|
2439
2510
|
participantSid: (_data$memberSid = data.memberSid) !== null && _data$memberSid !== void 0 ? _data$memberSid : null,
|
@@ -2541,7 +2612,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2541
2612
|
return this.state.attributes;
|
2542
2613
|
}
|
2543
2614
|
/**
|
2544
|
-
*
|
2615
|
+
* Type of the message.
|
2545
2616
|
*/
|
2546
2617
|
|
2547
2618
|
}, {
|
@@ -2550,7 +2621,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2550
2621
|
return this.state.type;
|
2551
2622
|
}
|
2552
2623
|
/**
|
2553
|
-
* One of the attached media.
|
2624
|
+
* One of the attached media (if present).
|
2554
2625
|
* @deprecated Use attachedMedia instead. Note that the latter is now an array.
|
2555
2626
|
*/
|
2556
2627
|
|
@@ -2566,7 +2637,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2566
2637
|
}, {
|
2567
2638
|
key: "attachedMedia",
|
2568
2639
|
get: function get() {
|
2569
|
-
return this.getMediaByCategory([
|
2640
|
+
return this.getMediaByCategory(["media"]);
|
2570
2641
|
}
|
2571
2642
|
/**
|
2572
2643
|
* The server-assigned unique identifier of the authoring participant.
|
@@ -2598,50 +2669,82 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2598
2669
|
value: function getMediaByCategory(categories) {
|
2599
2670
|
var _this$state$medias;
|
2600
2671
|
|
2601
|
-
return (_this$state$medias = this.state.medias)
|
2672
|
+
return ((_this$state$medias = this.state.medias) !== null && _this$state$medias !== void 0 ? _this$state$medias : []).filter(function (m) {
|
2602
2673
|
return categories.includes(m.category);
|
2603
2674
|
});
|
2604
2675
|
}
|
2676
|
+
/**
|
2677
|
+
* Get a media descriptor for an email body attachment of a provided type.
|
2678
|
+
* Allowed body types are returned in the Conversation.limits().emailBodiesAllowedMimeTypes array.
|
2679
|
+
* @param type Type of email body to request, defaults to `text/plain`.
|
2680
|
+
*/
|
2681
|
+
|
2682
|
+
}, {
|
2683
|
+
key: "getEmailBody",
|
2684
|
+
value: function getEmailBody() {
|
2685
|
+
var _this$getMediaByCateg, _this$getMediaByCateg2;
|
2686
|
+
|
2687
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "text/plain";
|
2688
|
+
return (_this$getMediaByCateg = (_this$getMediaByCateg2 = this.getMediaByCategory(["body"])) === null || _this$getMediaByCateg2 === void 0 ? void 0 : _this$getMediaByCateg2.filter(function (m) {
|
2689
|
+
return m.contentType == type;
|
2690
|
+
}).shift()) !== null && _this$getMediaByCateg !== void 0 ? _this$getMediaByCateg : null;
|
2691
|
+
}
|
2692
|
+
/**
|
2693
|
+
* Get a media descriptor for an email history attachment of a provided type.
|
2694
|
+
* Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedMimeTypes array.
|
2695
|
+
* @param type Type of email history to request, defaults to `text/plain`.
|
2696
|
+
*/
|
2697
|
+
|
2698
|
+
}, {
|
2699
|
+
key: "getEmailHistory",
|
2700
|
+
value: function getEmailHistory() {
|
2701
|
+
var _this$getMediaByCateg3, _this$getMediaByCateg4;
|
2702
|
+
|
2703
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "text/plain";
|
2704
|
+
return (_this$getMediaByCateg3 = (_this$getMediaByCateg4 = this.getMediaByCategory(["history"])) === null || _this$getMediaByCateg4 === void 0 ? void 0 : _this$getMediaByCateg4.filter(function (m) {
|
2705
|
+
return m.contentType == type;
|
2706
|
+
}).shift()) !== null && _this$getMediaByCateg3 !== void 0 ? _this$getMediaByCateg3 : null;
|
2707
|
+
}
|
2605
2708
|
}, {
|
2606
2709
|
key: "_update",
|
2607
2710
|
value: function _update(data) {
|
2608
2711
|
var updateReasons = [];
|
2609
2712
|
|
2610
|
-
if ((data.text || typeof data.text ===
|
2713
|
+
if ((data.text || typeof data.text === "string") && data.text !== this.state.body) {
|
2611
2714
|
this.state.body = data.text;
|
2612
|
-
updateReasons.push(
|
2715
|
+
updateReasons.push("body");
|
2613
2716
|
}
|
2614
2717
|
|
2615
2718
|
if (data.subject && data.subject !== this.state.subject) {
|
2616
2719
|
this.state.subject = data.subject;
|
2617
|
-
updateReasons.push(
|
2720
|
+
updateReasons.push("subject");
|
2618
2721
|
}
|
2619
2722
|
|
2620
2723
|
if (data.lastUpdatedBy && data.lastUpdatedBy !== this.state.lastUpdatedBy) {
|
2621
2724
|
this.state.lastUpdatedBy = data.lastUpdatedBy;
|
2622
|
-
updateReasons.push(
|
2725
|
+
updateReasons.push("lastUpdatedBy");
|
2623
2726
|
}
|
2624
2727
|
|
2625
2728
|
if (data.author && data.author !== this.state.author) {
|
2626
2729
|
this.state.author = data.author;
|
2627
|
-
updateReasons.push(
|
2730
|
+
updateReasons.push("author");
|
2628
2731
|
}
|
2629
2732
|
|
2630
2733
|
if (data.dateUpdated && new Date(data.dateUpdated).getTime() !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
|
2631
2734
|
this.state.dateUpdated = new Date(data.dateUpdated);
|
2632
|
-
updateReasons.push(
|
2735
|
+
updateReasons.push("dateUpdated");
|
2633
2736
|
}
|
2634
2737
|
|
2635
2738
|
if (data.timestamp && new Date(data.timestamp).getTime() !== (this.state.timestamp && this.state.timestamp.getTime())) {
|
2636
2739
|
this.state.timestamp = new Date(data.timestamp);
|
2637
|
-
updateReasons.push(
|
2740
|
+
updateReasons.push("dateCreated");
|
2638
2741
|
}
|
2639
2742
|
|
2640
2743
|
var updatedAttributes = parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(this.sid), log$5);
|
2641
2744
|
|
2642
2745
|
if (!isEqual__default['default'](this.state.attributes, updatedAttributes)) {
|
2643
2746
|
this.state.attributes = updatedAttributes;
|
2644
|
-
updateReasons.push(
|
2747
|
+
updateReasons.push("attributes");
|
2645
2748
|
}
|
2646
2749
|
|
2647
2750
|
var updatedAggregatedDelivery = data.delivery;
|
@@ -2651,16 +2754,16 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2651
2754
|
if (isUpdatedAggregateDeliveryValid) {
|
2652
2755
|
if (!currentAggregatedDelivery) {
|
2653
2756
|
this.state.aggregatedDeliveryReceipt = new AggregatedDeliveryReceipt(updatedAggregatedDelivery);
|
2654
|
-
updateReasons.push(
|
2757
|
+
updateReasons.push("deliveryReceipt");
|
2655
2758
|
} else if (!currentAggregatedDelivery._isEquals(updatedAggregatedDelivery)) {
|
2656
2759
|
currentAggregatedDelivery._update(updatedAggregatedDelivery);
|
2657
2760
|
|
2658
|
-
updateReasons.push(
|
2761
|
+
updateReasons.push("deliveryReceipt");
|
2659
2762
|
}
|
2660
2763
|
}
|
2661
2764
|
|
2662
2765
|
if (updateReasons.length > 0) {
|
2663
|
-
this.emit(
|
2766
|
+
this.emit("updated", {
|
2664
2767
|
message: this,
|
2665
2768
|
updateReasons: updateReasons
|
2666
2769
|
});
|
@@ -2689,7 +2792,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2689
2792
|
}
|
2690
2793
|
|
2691
2794
|
_context.next = 4;
|
2692
|
-
return this.conversation.getParticipantBySid(this.participantSid).catch(function () {
|
2795
|
+
return this.conversation.getParticipantBySid(this.state.participantSid).catch(function () {
|
2693
2796
|
log$5.debug("Participant with sid \"".concat(_this2.participantSid, "\" not found for message ").concat(_this2.sid));
|
2694
2797
|
return null;
|
2695
2798
|
});
|
@@ -2721,25 +2824,25 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2721
2824
|
return _context.abrupt("return", participant);
|
2722
2825
|
|
2723
2826
|
case 11:
|
2724
|
-
errorMesage =
|
2827
|
+
errorMesage = "Participant with ";
|
2725
2828
|
|
2726
2829
|
if (this.state.participantSid) {
|
2727
|
-
errorMesage +=
|
2830
|
+
errorMesage += "SID '" + this.state.participantSid + "' ";
|
2728
2831
|
}
|
2729
2832
|
|
2730
2833
|
if (this.state.author) {
|
2731
2834
|
if (this.state.participantSid) {
|
2732
|
-
errorMesage +=
|
2835
|
+
errorMesage += "or ";
|
2733
2836
|
}
|
2734
2837
|
|
2735
|
-
errorMesage +=
|
2838
|
+
errorMesage += "identity '" + this.state.author + "' ";
|
2736
2839
|
}
|
2737
2840
|
|
2738
|
-
if (errorMesage ===
|
2739
|
-
errorMesage =
|
2841
|
+
if (errorMesage === "Participant with ") {
|
2842
|
+
errorMesage = "Participant ";
|
2740
2843
|
}
|
2741
2844
|
|
2742
|
-
errorMesage +=
|
2845
|
+
errorMesage += "was not found";
|
2743
2846
|
throw new Error(errorMesage);
|
2744
2847
|
|
2745
2848
|
case 17:
|
@@ -2826,7 +2929,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2826
2929
|
switch (_context3.prev = _context3.next) {
|
2827
2930
|
case 0:
|
2828
2931
|
_context3.next = 2;
|
2829
|
-
return this.services.commandExecutor.mutateResource(
|
2932
|
+
return this.services.commandExecutor.mutateResource("delete", this.links.self);
|
2830
2933
|
|
2831
2934
|
case 2:
|
2832
2935
|
return _context3.abrupt("return", this);
|
@@ -2859,7 +2962,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2859
2962
|
switch (_context4.prev = _context4.next) {
|
2860
2963
|
case 0:
|
2861
2964
|
_context4.next = 2;
|
2862
|
-
return this.services.commandExecutor.mutateResource(
|
2965
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
2863
2966
|
body: body
|
2864
2967
|
});
|
2865
2968
|
|
@@ -2894,8 +2997,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2894
2997
|
switch (_context5.prev = _context5.next) {
|
2895
2998
|
case 0:
|
2896
2999
|
_context5.next = 2;
|
2897
|
-
return this.services.commandExecutor.mutateResource(
|
2898
|
-
attributes: typeof attributes !==
|
3000
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
3001
|
+
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
|
2899
3002
|
});
|
2900
3003
|
|
2901
3004
|
case 2:
|
@@ -2933,11 +3036,11 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2933
3036
|
case 0:
|
2934
3037
|
// We ignore existing mcsMedia members of each of the media entries.
|
2935
3038
|
// Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.
|
2936
|
-
sids = contentSet.map(function (m) {
|
3039
|
+
sids = contentSet === null || contentSet === void 0 ? void 0 : contentSet.map(function (m) {
|
2937
3040
|
return m.sid;
|
2938
3041
|
});
|
2939
3042
|
|
2940
|
-
if (!this.services.mcsClient) {
|
3043
|
+
if (!(this.services.mcsClient && sids)) {
|
2941
3044
|
_context6.next = 7;
|
2942
3045
|
break;
|
2943
3046
|
}
|
@@ -2951,7 +3054,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2951
3054
|
}));
|
2952
3055
|
|
2953
3056
|
case 7:
|
2954
|
-
throw new Error(
|
3057
|
+
throw new Error("Media Content Service is unavailable");
|
2955
3058
|
|
2956
3059
|
case 8:
|
2957
3060
|
case "end":
|
@@ -2978,8 +3081,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2978
3081
|
while (1) {
|
2979
3082
|
switch (_context7.prev = _context7.next) {
|
2980
3083
|
case 0:
|
2981
|
-
messagesReceiptsUrl = this.configuration.links.messagesReceipts.replace(
|
2982
|
-
url = new UriBuilder(messagesReceiptsUrl).arg(
|
3084
|
+
messagesReceiptsUrl = this.configuration.links.messagesReceipts.replace("%s", this.conversation.sid).replace("%s", this.sid);
|
3085
|
+
url = new UriBuilder(messagesReceiptsUrl).arg("PageToken", options === null || options === void 0 ? void 0 : options.pageToken).arg("PageSize", options === null || options === void 0 ? void 0 : options.pageSize).build();
|
2983
3086
|
_context7.next = 4;
|
2984
3087
|
return this.services.network.get(url);
|
2985
3088
|
|
@@ -3013,16 +3116,20 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3013
3116
|
return Message;
|
3014
3117
|
}(replayEventEmitter.ReplayEventEmitter);
|
3015
3118
|
|
3016
|
-
_defineProperty__default['default'](Message, "updated",
|
3119
|
+
_defineProperty__default['default'](Message, "updated", "updated");
|
3120
|
+
|
3121
|
+
__decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailBody", null);
|
3017
3122
|
|
3018
|
-
__decorate([declarativeTypeValidator.
|
3123
|
+
__decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailHistory", null);
|
3019
3124
|
|
3020
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
3125
|
+
__decorate([declarativeTypeValidator.validateTypesAsync("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Message.prototype, "updateBody", null);
|
3126
|
+
|
3127
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Message.prototype, "updateAttributes", null);
|
3021
3128
|
|
3022
3129
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.custom(function (value) {
|
3023
3130
|
return [value instanceof Array && value.length > 0 && value.reduce(function (a, c) {
|
3024
3131
|
return a && c instanceof Media;
|
3025
|
-
}),
|
3132
|
+
}, true), "a non-empty array of Media"];
|
3026
3133
|
})), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", Promise)], Message.prototype, "attachTemporaryUrlsFor", null);
|
3027
3134
|
|
3028
3135
|
function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
@@ -3034,7 +3141,7 @@ function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) le
|
|
3034
3141
|
function _createSuper$4(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$4(); 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); }; }
|
3035
3142
|
|
3036
3143
|
function _isNativeReflectConstruct$4() { 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; } }
|
3037
|
-
var log$4 = Logger.scope(
|
3144
|
+
var log$4 = Logger.scope("Messages");
|
3038
3145
|
/**
|
3039
3146
|
* Represents the collection of messages in a conversation
|
3040
3147
|
*/
|
@@ -3084,7 +3191,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3084
3191
|
case 2:
|
3085
3192
|
this.messagesListPromise = this.services.syncClient.list({
|
3086
3193
|
id: name,
|
3087
|
-
mode:
|
3194
|
+
mode: "open_existing"
|
3088
3195
|
});
|
3089
3196
|
_context.prev = 3;
|
3090
3197
|
_context.next = 6;
|
@@ -3092,7 +3199,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3092
3199
|
|
3093
3200
|
case 6:
|
3094
3201
|
list = _context.sent;
|
3095
|
-
list.on(
|
3202
|
+
list.on("itemAdded", function (args) {
|
3096
3203
|
log$4.debug("".concat(_this2.conversation.sid, " itemAdded: ").concat(args.item.index));
|
3097
3204
|
var links = {
|
3098
3205
|
self: "".concat(_this2.conversation.links.messages, "/").concat(args.item.data.sid),
|
@@ -3102,33 +3209,37 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3102
3209
|
var message = new Message(args.item.index, args.item.data, _this2.conversation, links, _this2.configuration, _this2.services);
|
3103
3210
|
|
3104
3211
|
if (_this2.messagesByIndex.has(message.index)) {
|
3105
|
-
log$4.debug(
|
3212
|
+
log$4.debug("Message arrived, but is already known and ignored", _this2.conversation.sid, message.index);
|
3106
3213
|
return;
|
3107
3214
|
}
|
3108
3215
|
|
3109
3216
|
_this2.messagesByIndex.set(message.index, message);
|
3110
3217
|
|
3111
|
-
message.on(
|
3112
|
-
return _this2.emit(
|
3218
|
+
message.on("updated", function (args) {
|
3219
|
+
return _this2.emit("messageUpdated", args);
|
3113
3220
|
});
|
3114
3221
|
|
3115
|
-
_this2.emit(
|
3222
|
+
_this2.emit("messageAdded", message);
|
3116
3223
|
});
|
3117
|
-
list.on(
|
3224
|
+
list.on("itemRemoved", function (args) {
|
3118
3225
|
log$4.debug("#{this.conversation.sid} itemRemoved: ".concat(args.index));
|
3119
3226
|
var index = args.index;
|
3120
3227
|
|
3121
3228
|
if (_this2.messagesByIndex.has(index)) {
|
3122
3229
|
var message = _this2.messagesByIndex.get(index);
|
3123
3230
|
|
3231
|
+
if (!message) {
|
3232
|
+
return;
|
3233
|
+
}
|
3234
|
+
|
3124
3235
|
_this2.messagesByIndex.delete(message.index);
|
3125
3236
|
|
3126
|
-
message.removeAllListeners(
|
3237
|
+
message.removeAllListeners("updated");
|
3127
3238
|
|
3128
|
-
_this2.emit(
|
3239
|
+
_this2.emit("messageRemoved", message);
|
3129
3240
|
}
|
3130
3241
|
});
|
3131
|
-
list.on(
|
3242
|
+
list.on("itemUpdated", function (args) {
|
3132
3243
|
log$4.debug("".concat(_this2.conversation.sid, " itemUpdated: ").concat(args.item.index));
|
3133
3244
|
|
3134
3245
|
var message = _this2.messagesByIndex.get(args.item.index);
|
@@ -3144,11 +3255,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3144
3255
|
_context.t0 = _context["catch"](3);
|
3145
3256
|
this.messagesListPromise = null;
|
3146
3257
|
|
3147
|
-
if (this.services.syncClient.connectionState !==
|
3148
|
-
log$4.error(
|
3258
|
+
if (this.services.syncClient.connectionState !== "disconnected") {
|
3259
|
+
log$4.error("Failed to get messages object for conversation", this.conversation.sid, _context.t0);
|
3149
3260
|
}
|
3150
3261
|
|
3151
|
-
log$4.debug(
|
3262
|
+
log$4.debug("ERROR: Failed to get messages object for conversation", this.conversation.sid, _context.t0);
|
3152
3263
|
throw _context.t0;
|
3153
3264
|
|
3154
3265
|
case 19:
|
@@ -3207,7 +3318,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3207
3318
|
/**
|
3208
3319
|
* Send Message to the conversation, message could include both text and multiple media attachments.
|
3209
3320
|
* @param message Message to post
|
3210
|
-
* @returns Returns promise which can fail
|
3321
|
+
* @returns Returns a promise which can fail
|
3211
3322
|
*/
|
3212
3323
|
|
3213
3324
|
}, {
|
@@ -3216,13 +3327,13 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3216
3327
|
var _sendV = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(message) {
|
3217
3328
|
var _message$emailOptions;
|
3218
3329
|
|
3219
|
-
var media, _iterator, _step, _step$value, category, mediaContent;
|
3330
|
+
var media, _iterator, _step, _mediaContent$content, _mediaContent$media, _step$value, category, mediaContent;
|
3220
3331
|
|
3221
3332
|
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
3222
3333
|
while (1) {
|
3223
3334
|
switch (_context3.prev = _context3.next) {
|
3224
3335
|
case 0:
|
3225
|
-
log$4.debug(
|
3336
|
+
log$4.debug("Sending message V2", message.mediaContent, message.attributes, message.emailOptions);
|
3226
3337
|
media = [];
|
3227
3338
|
_iterator = _createForOfIteratorHelper$2(message.mediaContent);
|
3228
3339
|
_context3.prev = 3;
|
@@ -3236,7 +3347,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3236
3347
|
}
|
3237
3348
|
|
3238
3349
|
_step$value = _slicedToArray__default['default'](_step.value, 2), category = _step$value[0], mediaContent = _step$value[1];
|
3239
|
-
log$4.debug("Adding media to a message as ".concat(mediaContent instanceof FormData ?
|
3350
|
+
log$4.debug("Adding media to a message as ".concat(mediaContent instanceof FormData ? "FormData" : "SendMediaOptions"), mediaContent);
|
3240
3351
|
_context3.t0 = media;
|
3241
3352
|
|
3242
3353
|
if (!(mediaContent instanceof FormData)) {
|
@@ -3254,7 +3365,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3254
3365
|
|
3255
3366
|
case 15:
|
3256
3367
|
_context3.next = 17;
|
3257
|
-
return this.services.mcsClient.post(mediaContent.contentType, mediaContent.media, category, mediaContent.filename);
|
3368
|
+
return this.services.mcsClient.post((_mediaContent$content = mediaContent.contentType) !== null && _mediaContent$content !== void 0 ? _mediaContent$content : "", (_mediaContent$media = mediaContent.media) !== null && _mediaContent$media !== void 0 ? _mediaContent$media : "", category, mediaContent.filename);
|
3258
3369
|
|
3259
3370
|
case 17:
|
3260
3371
|
_context3.t1 = _context3.sent;
|
@@ -3287,13 +3398,13 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3287
3398
|
|
3288
3399
|
case 30:
|
3289
3400
|
_context3.next = 32;
|
3290
|
-
return this.services.commandExecutor.mutateResource(
|
3401
|
+
return this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
|
3291
3402
|
body: message.text,
|
3292
3403
|
subject: (_message$emailOptions = message.emailOptions) === null || _message$emailOptions === void 0 ? void 0 : _message$emailOptions.subject,
|
3293
3404
|
media_sids: media.map(function (m) {
|
3294
3405
|
return m.sid;
|
3295
3406
|
}),
|
3296
|
-
attributes: typeof message.attributes !==
|
3407
|
+
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined
|
3297
3408
|
});
|
3298
3409
|
|
3299
3410
|
case 32:
|
@@ -3334,11 +3445,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3334
3445
|
case 0:
|
3335
3446
|
attributes = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
3336
3447
|
emailOptions = _args4.length > 2 ? _args4[2] : undefined;
|
3337
|
-
log$4.debug(
|
3448
|
+
log$4.debug("Sending text message", message, attributes, emailOptions);
|
3338
3449
|
_context4.next = 5;
|
3339
|
-
return this.services.commandExecutor.mutateResource(
|
3340
|
-
body: message !== null && message !== void 0 ? message :
|
3341
|
-
attributes: typeof attributes !==
|
3450
|
+
return this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
|
3451
|
+
body: message !== null && message !== void 0 ? message : "",
|
3452
|
+
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined,
|
3342
3453
|
subject: emailOptions === null || emailOptions === void 0 ? void 0 : emailOptions.subject
|
3343
3454
|
});
|
3344
3455
|
|
@@ -3371,6 +3482,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3371
3482
|
key: "sendMedia",
|
3372
3483
|
value: function () {
|
3373
3484
|
var _sendMedia = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(mediaContent) {
|
3485
|
+
var _mediaContent$content2, _mediaContent$media2;
|
3486
|
+
|
3374
3487
|
var attributes,
|
3375
3488
|
emailOptions,
|
3376
3489
|
media,
|
@@ -3381,8 +3494,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3381
3494
|
case 0:
|
3382
3495
|
attributes = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
3383
3496
|
emailOptions = _args5.length > 2 ? _args5[2] : undefined;
|
3384
|
-
log$4.debug(
|
3385
|
-
log$4.debug("Sending media message as ".concat(mediaContent instanceof FormData ?
|
3497
|
+
log$4.debug("Sending media message", mediaContent, attributes, emailOptions);
|
3498
|
+
log$4.debug("Sending media message as ".concat(mediaContent instanceof FormData ? "FormData" : "SendMediaOptions"), mediaContent, attributes);
|
3386
3499
|
|
3387
3500
|
if (!(mediaContent instanceof FormData)) {
|
3388
3501
|
_context5.next = 10;
|
@@ -3399,7 +3512,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3399
3512
|
|
3400
3513
|
case 10:
|
3401
3514
|
_context5.next = 12;
|
3402
|
-
return this.services.mcsClient.post(mediaContent.contentType, mediaContent.media,
|
3515
|
+
return this.services.mcsClient.post((_mediaContent$content2 = mediaContent.contentType) !== null && _mediaContent$content2 !== void 0 ? _mediaContent$content2 : "", (_mediaContent$media2 = mediaContent.media) !== null && _mediaContent$media2 !== void 0 ? _mediaContent$media2 : "", "media", mediaContent.filename);
|
3403
3516
|
|
3404
3517
|
case 12:
|
3405
3518
|
_context5.t0 = _context5.sent;
|
@@ -3407,9 +3520,9 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3407
3520
|
case 13:
|
3408
3521
|
media = _context5.t0;
|
3409
3522
|
_context5.next = 16;
|
3410
|
-
return this.services.commandExecutor.mutateResource(
|
3523
|
+
return this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
|
3411
3524
|
media_sids: [media.sid],
|
3412
|
-
attributes: typeof attributes !==
|
3525
|
+
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
|
3413
3526
|
});
|
3414
3527
|
|
3415
3528
|
case 16:
|
@@ -3447,7 +3560,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3447
3560
|
while (1) {
|
3448
3561
|
switch (_context6.prev = _context6.next) {
|
3449
3562
|
case 0:
|
3450
|
-
direction = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] :
|
3563
|
+
direction = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : "backwards";
|
3451
3564
|
return _context6.abrupt("return", this._getMessages(pageSize, anchor, direction));
|
3452
3565
|
|
3453
3566
|
case 2:
|
@@ -3471,7 +3584,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3471
3584
|
|
3472
3585
|
// Due to an inconsistency between Sync and Chat conventions, next and
|
3473
3586
|
// previous pages should be swapped.
|
3474
|
-
var shouldReverse = order ===
|
3587
|
+
var shouldReverse = order === "desc";
|
3475
3588
|
|
3476
3589
|
var nextPage = function nextPage() {
|
3477
3590
|
return page.nextPage().then(function (page) {
|
@@ -3515,8 +3628,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3515
3628
|
};
|
3516
3629
|
var message = new Message(index, value, this.conversation, links, this.configuration, this.services);
|
3517
3630
|
this.messagesByIndex.set(message.index, message);
|
3518
|
-
message.on(
|
3519
|
-
return _this4.emit(
|
3631
|
+
message.on("updated", function (args) {
|
3632
|
+
return _this4.emit("messageUpdated", args);
|
3520
3633
|
});
|
3521
3634
|
return message;
|
3522
3635
|
}
|
@@ -3547,17 +3660,17 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3547
3660
|
switch (_context7.prev = _context7.next) {
|
3548
3661
|
case 0:
|
3549
3662
|
pageSize = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : 30;
|
3550
|
-
anchor = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] :
|
3551
|
-
direction = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] :
|
3552
|
-
order = direction ===
|
3663
|
+
anchor = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : "end";
|
3664
|
+
direction = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : "forward";
|
3665
|
+
order = direction === "backwards" ? "desc" : "asc";
|
3553
3666
|
_context7.next = 6;
|
3554
3667
|
return this.messagesListPromise;
|
3555
3668
|
|
3556
3669
|
case 6:
|
3557
3670
|
list = _context7.sent;
|
3558
3671
|
_context7.next = 9;
|
3559
|
-
return list.getItems({
|
3560
|
-
from: anchor !==
|
3672
|
+
return list === null || list === void 0 ? void 0 : list.getItems({
|
3673
|
+
from: anchor !== "end" ? anchor : void 0,
|
3561
3674
|
pageSize: pageSize,
|
3562
3675
|
order: order,
|
3563
3676
|
limit: pageSize // @todo Limit equals pageSize by default in Sync. This is probably not ideal.
|
@@ -3680,6 +3793,8 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
3680
3793
|
|
3681
3794
|
this.limits = limits;
|
3682
3795
|
this.message = new UnsentMessage(messagesEntity);
|
3796
|
+
this.emailBodies = new Map();
|
3797
|
+
this.emailHistories = new Map();
|
3683
3798
|
}
|
3684
3799
|
/**
|
3685
3800
|
* Sets the message body.
|
@@ -3715,6 +3830,30 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
3715
3830
|
this.message.attributes = attributes;
|
3716
3831
|
return this;
|
3717
3832
|
}
|
3833
|
+
/**
|
3834
|
+
* Set email body with given MIME-type.
|
3835
|
+
* @param mimeType Format of the body to set (text/plain or text/html).
|
3836
|
+
* @param body Body payload in selected format.
|
3837
|
+
*/
|
3838
|
+
|
3839
|
+
}, {
|
3840
|
+
key: "setEmailBody",
|
3841
|
+
value: function setEmailBody(mimeType, body) {
|
3842
|
+
this.emailBodies.set(mimeType, body);
|
3843
|
+
return this;
|
3844
|
+
}
|
3845
|
+
/**
|
3846
|
+
* Set email history with given MIME-type.
|
3847
|
+
* @param mimeType Format of the history to set (text/plain or text/html).
|
3848
|
+
* @param history History payload in selected format.
|
3849
|
+
*/
|
3850
|
+
|
3851
|
+
}, {
|
3852
|
+
key: "setEmailHistory",
|
3853
|
+
value: function setEmailHistory(mimeType, history) {
|
3854
|
+
this.emailHistories.set(mimeType, history);
|
3855
|
+
return this;
|
3856
|
+
}
|
3718
3857
|
/**
|
3719
3858
|
* Adds media to the message.
|
3720
3859
|
* @param payload Media to add.
|
@@ -3723,7 +3862,19 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
3723
3862
|
}, {
|
3724
3863
|
key: "addMedia",
|
3725
3864
|
value: function addMedia(payload) {
|
3726
|
-
|
3865
|
+
if (typeof FormData === "undefined" && payload instanceof FormData) {
|
3866
|
+
throw new Error("Could not add FormData content whilst not in a browser");
|
3867
|
+
}
|
3868
|
+
|
3869
|
+
if (!(payload instanceof FormData)) {
|
3870
|
+
var mediaOptions = payload;
|
3871
|
+
|
3872
|
+
if (!mediaOptions.contentType || !mediaOptions.media) {
|
3873
|
+
throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media");
|
3874
|
+
}
|
3875
|
+
}
|
3876
|
+
|
3877
|
+
this.message.mediaContent.push(["media", payload]);
|
3727
3878
|
return this;
|
3728
3879
|
}
|
3729
3880
|
/**
|
@@ -3733,18 +3884,46 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
3733
3884
|
}, {
|
3734
3885
|
key: "build",
|
3735
3886
|
value: function build() {
|
3887
|
+
var _this = this;
|
3888
|
+
|
3889
|
+
this.emailBodies.forEach(function (_, key) {
|
3890
|
+
if (!_this.limits.emailBodiesAllowedMimeTypes.includes(key)) {
|
3891
|
+
throw new Error("Unsupported email body MIME type ".concat(key));
|
3892
|
+
}
|
3893
|
+
});
|
3894
|
+
this.emailHistories.forEach(function (_, key) {
|
3895
|
+
if (!_this.limits.emailHistoriesAllowedMimeTypes.includes(key)) {
|
3896
|
+
throw new Error("Unsupported email history MIME type ".concat(key));
|
3897
|
+
}
|
3898
|
+
});
|
3899
|
+
|
3900
|
+
if (this.emailBodies.size > this.limits.emailBodiesAllowedMimeTypes.length) {
|
3901
|
+
throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size, " > ").concat(this.limits.emailBodiesAllowedMimeTypes.length, ")"));
|
3902
|
+
}
|
3903
|
+
|
3904
|
+
if (this.emailHistories.size > this.limits.emailHistoriesAllowedMimeTypes.length) {
|
3905
|
+
throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size, " > ").concat(this.limits.emailHistoriesAllowedMimeTypes.length, ")"));
|
3906
|
+
}
|
3907
|
+
|
3736
3908
|
if (this.message.mediaContent.length > this.limits.mediaAttachmentsCountLimit) {
|
3737
3909
|
throw new Error("Too many media attachments in the message (".concat(this.message.mediaContent.length, " > ").concat(this.limits.mediaAttachmentsCountLimit, ")"));
|
3738
3910
|
} // @todo we don't know the sizes of the attachments in FormData
|
3911
|
+
// @todo insertion below makes build() method non-repeatable - probably move to UnsentMessage.send() or even sendV2()?
|
3739
3912
|
|
3740
3913
|
|
3914
|
+
this.emailBodies.forEach(function (body) {
|
3915
|
+
_this.message.mediaContent.push(["body", body]);
|
3916
|
+
});
|
3917
|
+
this.emailHistories.forEach(function (history) {
|
3918
|
+
_this.message.mediaContent.push(["history", history]);
|
3919
|
+
});
|
3741
3920
|
return this.message;
|
3742
3921
|
}
|
3743
3922
|
}, {
|
3744
3923
|
key: "getPayloadContentType",
|
3745
3924
|
value: function getPayloadContentType(payload) {
|
3746
|
-
if (typeof FormData !==
|
3747
|
-
return payload.get(
|
3925
|
+
if (typeof FormData !== "undefined" && payload instanceof FormData) {
|
3926
|
+
return payload.get("Content-Type");
|
3748
3927
|
}
|
3749
3928
|
|
3750
3929
|
return payload.contentType;
|
@@ -3763,20 +3942,21 @@ function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) le
|
|
3763
3942
|
function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); 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); }; }
|
3764
3943
|
|
3765
3944
|
function _isNativeReflectConstruct$3() { 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; } }
|
3766
|
-
var log$3 = Logger.scope(
|
3945
|
+
var log$3 = Logger.scope("Conversation");
|
3767
3946
|
var fieldMappings = {
|
3768
|
-
lastMessage:
|
3769
|
-
attributes:
|
3770
|
-
createdBy:
|
3771
|
-
dateCreated:
|
3772
|
-
dateUpdated:
|
3773
|
-
friendlyName:
|
3774
|
-
lastConsumedMessageIndex:
|
3775
|
-
notificationLevel:
|
3776
|
-
sid:
|
3777
|
-
status:
|
3778
|
-
uniqueName:
|
3779
|
-
state:
|
3947
|
+
lastMessage: "lastMessage",
|
3948
|
+
attributes: "attributes",
|
3949
|
+
createdBy: "createdBy",
|
3950
|
+
dateCreated: "dateCreated",
|
3951
|
+
dateUpdated: "dateUpdated",
|
3952
|
+
friendlyName: "friendlyName",
|
3953
|
+
lastConsumedMessageIndex: "lastConsumedMessageIndex",
|
3954
|
+
notificationLevel: "notificationLevel",
|
3955
|
+
sid: "sid",
|
3956
|
+
status: "status",
|
3957
|
+
uniqueName: "uniqueName",
|
3958
|
+
state: "state",
|
3959
|
+
bindings: "bindings"
|
3780
3960
|
};
|
3781
3961
|
|
3782
3962
|
function parseTime(timeString) {
|
@@ -3804,6 +3984,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3804
3984
|
* @internal
|
3805
3985
|
*/
|
3806
3986
|
function Conversation(descriptor, sid, links, configuration, services) {
|
3987
|
+
var _descriptor$bindings;
|
3988
|
+
|
3807
3989
|
var _this;
|
3808
3990
|
|
3809
3991
|
_classCallCheck__default['default'](this, Conversation);
|
@@ -3824,19 +4006,20 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3824
4006
|
try {
|
3825
4007
|
JSON.stringify(attributes);
|
3826
4008
|
} catch (e) {
|
3827
|
-
throw new Error(
|
4009
|
+
throw new Error("Attributes must be a valid JSON object.");
|
3828
4010
|
}
|
3829
4011
|
|
3830
4012
|
_this.entityName = descriptor.channel;
|
3831
4013
|
_this.channelState = {
|
3832
4014
|
uniqueName: uniqueName,
|
3833
|
-
status:
|
4015
|
+
status: "notParticipating",
|
3834
4016
|
attributes: attributes,
|
3835
4017
|
createdBy: createdBy,
|
3836
4018
|
dateCreated: dateCreated,
|
3837
4019
|
dateUpdated: dateUpdated,
|
3838
4020
|
friendlyName: friendlyName,
|
3839
|
-
lastReadMessageIndex: lastReadMessageIndex
|
4021
|
+
lastReadMessageIndex: lastReadMessageIndex,
|
4022
|
+
bindings: (_descriptor$bindings = descriptor.bindings) !== null && _descriptor$bindings !== void 0 ? _descriptor$bindings : {}
|
3840
4023
|
};
|
3841
4024
|
|
3842
4025
|
if (descriptor.notificationLevel) {
|
@@ -3849,25 +4032,31 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3849
4032
|
_this.participants = new Map();
|
3850
4033
|
_this.participantsEntity = new Participants(_assertThisInitialized__default['default'](_this), _this.participants, participantsLinks, _this.configuration, _this.services);
|
3851
4034
|
|
3852
|
-
_this.participantsEntity.on(
|
4035
|
+
_this.participantsEntity.on("participantJoined", function (participant) {
|
4036
|
+
return _this.emit("participantJoined", participant);
|
4037
|
+
});
|
3853
4038
|
|
3854
|
-
_this.participantsEntity.on(
|
4039
|
+
_this.participantsEntity.on("participantLeft", function (participant) {
|
4040
|
+
return _this.emit("participantLeft", participant);
|
4041
|
+
});
|
3855
4042
|
|
3856
|
-
_this.participantsEntity.on(
|
3857
|
-
return _this.emit(
|
4043
|
+
_this.participantsEntity.on("participantUpdated", function (args) {
|
4044
|
+
return _this.emit("participantUpdated", args);
|
3858
4045
|
});
|
3859
4046
|
|
3860
4047
|
_this.messagesEntity = new Messages(_assertThisInitialized__default['default'](_this), configuration, services);
|
3861
4048
|
|
3862
|
-
_this.messagesEntity.on(
|
4049
|
+
_this.messagesEntity.on("messageAdded", function (message) {
|
3863
4050
|
return _this._onMessageAdded(message);
|
3864
4051
|
});
|
3865
4052
|
|
3866
|
-
_this.messagesEntity.on(
|
3867
|
-
return _this.emit(
|
4053
|
+
_this.messagesEntity.on("messageUpdated", function (args) {
|
4054
|
+
return _this.emit("messageUpdated", args);
|
3868
4055
|
});
|
3869
4056
|
|
3870
|
-
_this.messagesEntity.on(
|
4057
|
+
_this.messagesEntity.on("messageRemoved", function (message) {
|
4058
|
+
return _this.emit("messageRemoved", message);
|
4059
|
+
});
|
3871
4060
|
|
3872
4061
|
return _this;
|
3873
4062
|
}
|
@@ -3932,7 +4121,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3932
4121
|
}, {
|
3933
4122
|
key: "createdBy",
|
3934
4123
|
get: function get() {
|
3935
|
-
|
4124
|
+
var _this$channelState$cr;
|
4125
|
+
|
4126
|
+
return (_this$channelState$cr = this.channelState.createdBy) !== null && _this$channelState$cr !== void 0 ? _this$channelState$cr : "";
|
3936
4127
|
}
|
3937
4128
|
/**
|
3938
4129
|
* Custom attributes of the conversation.
|
@@ -3959,7 +4150,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3959
4150
|
}, {
|
3960
4151
|
key: "lastMessage",
|
3961
4152
|
get: function get() {
|
3962
|
-
|
4153
|
+
var _this$channelState$la;
|
4154
|
+
|
4155
|
+
return (_this$channelState$la = this.channelState.lastMessage) !== null && _this$channelState$la !== void 0 ? _this$channelState$la : undefined;
|
3963
4156
|
}
|
3964
4157
|
/**
|
3965
4158
|
* User notification level for this conversation.
|
@@ -3968,7 +4161,14 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3968
4161
|
}, {
|
3969
4162
|
key: "notificationLevel",
|
3970
4163
|
get: function get() {
|
3971
|
-
|
4164
|
+
var _this$channelState$no;
|
4165
|
+
|
4166
|
+
return (_this$channelState$no = this.channelState.notificationLevel) !== null && _this$channelState$no !== void 0 ? _this$channelState$no : "default";
|
4167
|
+
}
|
4168
|
+
}, {
|
4169
|
+
key: "bindings",
|
4170
|
+
get: function get() {
|
4171
|
+
return this.channelState.bindings;
|
3972
4172
|
}
|
3973
4173
|
}, {
|
3974
4174
|
key: "limits",
|
@@ -3998,16 +4198,16 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3998
4198
|
|
3999
4199
|
return this.entityPromise = (_this$entityPromise = this.entityPromise) !== null && _this$entityPromise !== void 0 ? _this$entityPromise : this.services.syncClient.document({
|
4000
4200
|
id: this.entityName,
|
4001
|
-
mode:
|
4201
|
+
mode: "open_existing"
|
4002
4202
|
}).then(function (entity) {
|
4003
4203
|
_this2.entity = entity;
|
4004
4204
|
|
4005
|
-
_this2.entity.on(
|
4205
|
+
_this2.entity.on("updated", function (args) {
|
4006
4206
|
_this2._update(args.data);
|
4007
4207
|
});
|
4008
4208
|
|
4009
|
-
_this2.entity.on(
|
4010
|
-
return _this2.emit(
|
4209
|
+
_this2.entity.on("removed", function () {
|
4210
|
+
return _this2.emit("removed", _this2);
|
4011
4211
|
});
|
4012
4212
|
|
4013
4213
|
_this2._update(_this2.entity.data);
|
@@ -4017,11 +4217,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4017
4217
|
_this2.entity = null;
|
4018
4218
|
_this2.entityPromise = null;
|
4019
4219
|
|
4020
|
-
if (_this2.services.syncClient.connectionState !=
|
4021
|
-
log$3.error(
|
4220
|
+
if (_this2.services.syncClient.connectionState != "disconnected") {
|
4221
|
+
log$3.error("Failed to get conversation object", err);
|
4022
4222
|
}
|
4023
4223
|
|
4024
|
-
log$3.debug(
|
4224
|
+
log$3.debug("ERROR: Failed to get conversation object", err);
|
4025
4225
|
throw err;
|
4026
4226
|
});
|
4027
4227
|
}
|
@@ -4036,7 +4236,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4036
4236
|
key: "_subscribeStreams",
|
4037
4237
|
value: function () {
|
4038
4238
|
var _subscribeStreams2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
4039
|
-
var messagesObjectName, rosterObjectName;
|
4239
|
+
var _this$entity, _this$entity2, _this$entity3, messagesObjectName, rosterObjectName;
|
4240
|
+
|
4040
4241
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
4041
4242
|
while (1) {
|
4042
4243
|
switch (_context.prev = _context.next) {
|
@@ -4046,9 +4247,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4046
4247
|
return this._subscribe();
|
4047
4248
|
|
4048
4249
|
case 3:
|
4049
|
-
log$3.trace(
|
4050
|
-
messagesObjectName = this.entity.data.messages;
|
4051
|
-
rosterObjectName = this.entity.data.roster;
|
4250
|
+
log$3.trace("_subscribeStreams, this.entity.data=", (_this$entity = this.entity) === null || _this$entity === void 0 ? void 0 : _this$entity.data);
|
4251
|
+
messagesObjectName = (_this$entity2 = this.entity) === null || _this$entity2 === void 0 ? void 0 : _this$entity2.data.messages;
|
4252
|
+
rosterObjectName = (_this$entity3 = this.entity) === null || _this$entity3 === void 0 ? void 0 : _this$entity3.data.roster;
|
4052
4253
|
_context.next = 8;
|
4053
4254
|
return Promise.all([this.messagesEntity.subscribe(messagesObjectName), this.participantsEntity.subscribe(rosterObjectName)]);
|
4054
4255
|
|
@@ -4060,11 +4261,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4060
4261
|
_context.prev = 10;
|
4061
4262
|
_context.t0 = _context["catch"](0);
|
4062
4263
|
|
4063
|
-
if (this.services.syncClient.connectionState !==
|
4064
|
-
log$3.error(
|
4264
|
+
if (this.services.syncClient.connectionState !== "disconnected") {
|
4265
|
+
log$3.error("Failed to subscribe on conversation objects", this.sid, _context.t0);
|
4065
4266
|
}
|
4066
4267
|
|
4067
|
-
log$3.debug(
|
4268
|
+
log$3.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context.t0);
|
4068
4269
|
throw _context.t0;
|
4069
4270
|
|
4070
4271
|
case 15:
|
@@ -4141,19 +4342,19 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4141
4342
|
|
4142
4343
|
this.channelState.status = status;
|
4143
4344
|
|
4144
|
-
if (status ===
|
4345
|
+
if (status === "joined") {
|
4145
4346
|
this._subscribeStreams().catch(function (err) {
|
4146
|
-
log$3.debug(
|
4347
|
+
log$3.debug("ERROR while setting conversation status " + status, err);
|
4147
4348
|
|
4148
|
-
if (_this3.services.syncClient.connectionState !==
|
4349
|
+
if (_this3.services.syncClient.connectionState !== "disconnected") {
|
4149
4350
|
throw err;
|
4150
4351
|
}
|
4151
4352
|
});
|
4152
4353
|
} else if (this.entityPromise) {
|
4153
4354
|
this._unsubscribe().catch(function (err) {
|
4154
|
-
log$3.debug(
|
4355
|
+
log$3.debug("ERROR while setting conversation status " + status, err);
|
4155
4356
|
|
4156
|
-
if (_this3.services.syncClient.connectionState !==
|
4357
|
+
if (_this3.services.syncClient.connectionState !== "disconnected") {
|
4157
4358
|
throw err;
|
4158
4359
|
}
|
4159
4360
|
});
|
@@ -4177,9 +4378,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4177
4378
|
* @internal
|
4178
4379
|
*/
|
4179
4380
|
function _update(update) {
|
4180
|
-
var _update$lastMessage, _update$lastMessage2, _this$channelState$
|
4381
|
+
var _update$lastMessage, _update$lastMessage2, _this$channelState$la2, _this$channelState$la3, _this$channelState$lo;
|
4181
4382
|
|
4182
|
-
log$3.trace(
|
4383
|
+
log$3.trace("_update", update);
|
4183
4384
|
Conversation.preprocessUpdate(update, this.sid);
|
4184
4385
|
var updateReasons = new Set();
|
4185
4386
|
|
@@ -4193,7 +4394,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4193
4394
|
|
4194
4395
|
switch (localKey) {
|
4195
4396
|
case fieldMappings.status:
|
4196
|
-
if (!update.status || update.status ===
|
4397
|
+
if (!update.status || update.status === "unknown" || this.channelState.status === update.status) {
|
4197
4398
|
break;
|
4198
4399
|
}
|
4199
4400
|
|
@@ -4216,7 +4417,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4216
4417
|
}
|
4217
4418
|
|
4218
4419
|
this.channelState.lastReadMessageIndex = update.lastConsumedMessageIndex;
|
4219
|
-
updateReasons.add(
|
4420
|
+
updateReasons.add("lastReadMessageIndex");
|
4220
4421
|
break;
|
4221
4422
|
|
4222
4423
|
case fieldMappings.lastMessage:
|
@@ -4233,7 +4434,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4233
4434
|
updateReasons.add(localKey);
|
4234
4435
|
}
|
4235
4436
|
|
4236
|
-
if (((_update$lastMessage2 = update.lastMessage) === null || _update$lastMessage2 === void 0 ? void 0 : _update$lastMessage2.timestamp) !== undefined && ((_this$channelState$
|
4437
|
+
if (((_update$lastMessage2 = update.lastMessage) === null || _update$lastMessage2 === void 0 ? void 0 : _update$lastMessage2.timestamp) !== undefined && ((_this$channelState$la2 = this.channelState.lastMessage) === null || _this$channelState$la2 === void 0 ? void 0 : (_this$channelState$la3 = _this$channelState$la2.dateCreated) === null || _this$channelState$la3 === void 0 ? void 0 : _this$channelState$la3.getTime()) !== update.lastMessage.timestamp.getTime()) {
|
4237
4438
|
this.channelState.lastMessage.dateCreated = update.lastMessage.timestamp;
|
4238
4439
|
updateReasons.add(localKey);
|
4239
4440
|
}
|
@@ -4259,6 +4460,15 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4259
4460
|
updateReasons.add(localKey);
|
4260
4461
|
break;
|
4261
4462
|
|
4463
|
+
case fieldMappings.bindings:
|
4464
|
+
if (isEqual__default['default'](this.channelState.bindings, update.bindings)) {
|
4465
|
+
break;
|
4466
|
+
}
|
4467
|
+
|
4468
|
+
this.channelState.bindings = update.bindings;
|
4469
|
+
updateReasons.add(localKey);
|
4470
|
+
break;
|
4471
|
+
|
4262
4472
|
default:
|
4263
4473
|
var isDate = update[key] instanceof Date;
|
4264
4474
|
var keysMatchAsDates = isDate && ((_this$channelState$lo = this.channelState[localKey]) === null || _this$channelState$lo === void 0 ? void 0 : _this$channelState$lo.getTime()) === update[key].getTime();
|
@@ -4274,7 +4484,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4274
4484
|
}
|
4275
4485
|
|
4276
4486
|
if (updateReasons.size > 0) {
|
4277
|
-
this.emit(
|
4487
|
+
this.emit("updated", {
|
4278
4488
|
conversation: this,
|
4279
4489
|
updateReasons: _toConsumableArray__default['default'](updateReasons)
|
4280
4490
|
});
|
@@ -4306,7 +4516,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4306
4516
|
_iterator.f();
|
4307
4517
|
}
|
4308
4518
|
|
4309
|
-
this.emit(
|
4519
|
+
this.emit("messageAdded", message);
|
4310
4520
|
}
|
4311
4521
|
}, {
|
4312
4522
|
key: "_setLastReadMessageIndex",
|
@@ -4318,7 +4528,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4318
4528
|
switch (_context3.prev = _context3.next) {
|
4319
4529
|
case 0:
|
4320
4530
|
_context3.next = 2;
|
4321
|
-
return this.services.commandExecutor.mutateResource(
|
4531
|
+
return this.services.commandExecutor.mutateResource("post", "".concat(this.configuration.links.myConversations, "/").concat(this.sid), {
|
4322
4532
|
last_read_message_index: index
|
4323
4533
|
});
|
4324
4534
|
|
@@ -4354,7 +4564,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4354
4564
|
while (1) {
|
4355
4565
|
switch (_context4.prev = _context4.next) {
|
4356
4566
|
case 0:
|
4357
|
-
return _context4.abrupt("return", this.participantsEntity.add(identity, attributes));
|
4567
|
+
return _context4.abrupt("return", this.participantsEntity.add(identity, attributes !== null && attributes !== void 0 ? attributes : {}));
|
4358
4568
|
|
4359
4569
|
case 1:
|
4360
4570
|
case "end":
|
@@ -4375,19 +4585,25 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4375
4585
|
* @param proxyAddress Proxy (Twilio) address of the participant.
|
4376
4586
|
* @param address User address of the participant.
|
4377
4587
|
* @param attributes Attributes to be attached to the participant.
|
4588
|
+
* @param bindingOptions Options for adding email participants - name and CC/To level.
|
4378
4589
|
*/
|
4379
4590
|
|
4380
4591
|
}, {
|
4381
4592
|
key: "addNonChatParticipant",
|
4382
4593
|
value: function () {
|
4383
|
-
var _addNonChatParticipant = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(proxyAddress, address
|
4594
|
+
var _addNonChatParticipant = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(proxyAddress, address) {
|
4595
|
+
var attributes,
|
4596
|
+
bindingOptions,
|
4597
|
+
_args5 = arguments;
|
4384
4598
|
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
4385
4599
|
while (1) {
|
4386
4600
|
switch (_context5.prev = _context5.next) {
|
4387
4601
|
case 0:
|
4388
|
-
|
4602
|
+
attributes = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
|
4603
|
+
bindingOptions = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
|
4604
|
+
return _context5.abrupt("return", this.participantsEntity.addNonChatParticipant(proxyAddress, address, attributes !== null && attributes !== void 0 ? attributes : {}, bindingOptions !== null && bindingOptions !== void 0 ? bindingOptions : {}));
|
4389
4605
|
|
4390
|
-
case
|
4606
|
+
case 3:
|
4391
4607
|
case "end":
|
4392
4608
|
return _context5.stop();
|
4393
4609
|
}
|
@@ -4395,7 +4611,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4395
4611
|
}, _callee5, this);
|
4396
4612
|
}));
|
4397
4613
|
|
4398
|
-
function addNonChatParticipant(_x4, _x5
|
4614
|
+
function addNonChatParticipant(_x4, _x5) {
|
4399
4615
|
return _addNonChatParticipant.apply(this, arguments);
|
4400
4616
|
}
|
4401
4617
|
|
@@ -4421,7 +4637,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4421
4637
|
return this._subscribeStreams();
|
4422
4638
|
|
4423
4639
|
case 2:
|
4424
|
-
if (!(index < this.lastReadMessageIndex)) {
|
4640
|
+
if (!(index < (this.lastReadMessageIndex || 0))) {
|
4425
4641
|
_context6.next = 6;
|
4426
4642
|
break;
|
4427
4643
|
}
|
@@ -4447,7 +4663,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4447
4663
|
}, _callee6, this);
|
4448
4664
|
}));
|
4449
4665
|
|
4450
|
-
function advanceLastReadMessageIndex(
|
4666
|
+
function advanceLastReadMessageIndex(_x6) {
|
4451
4667
|
return _advanceLastReadMessageIndex.apply(this, arguments);
|
4452
4668
|
}
|
4453
4669
|
|
@@ -4466,7 +4682,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4466
4682
|
switch (_context7.prev = _context7.next) {
|
4467
4683
|
case 0:
|
4468
4684
|
_context7.next = 2;
|
4469
|
-
return this.services.commandExecutor.mutateResource(
|
4685
|
+
return this.services.commandExecutor.mutateResource("delete", this.links.self);
|
4470
4686
|
|
4471
4687
|
case 2:
|
4472
4688
|
return _context7.abrupt("return", this);
|
@@ -4548,7 +4764,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4548
4764
|
}, _callee9, this);
|
4549
4765
|
}));
|
4550
4766
|
|
4551
|
-
function getMessages(_x8, _x9
|
4767
|
+
function getMessages(_x7, _x8, _x9) {
|
4552
4768
|
return _getMessages.apply(this, arguments);
|
4553
4769
|
}
|
4554
4770
|
|
@@ -4601,6 +4817,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4601
4817
|
key: "getParticipantsCount",
|
4602
4818
|
value: function () {
|
4603
4819
|
var _getParticipantsCount = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee11() {
|
4820
|
+
var _response$body$partic;
|
4821
|
+
|
4604
4822
|
var url, response;
|
4605
4823
|
return _regeneratorRuntime__default['default'].wrap(function _callee11$(_context11) {
|
4606
4824
|
while (1) {
|
@@ -4612,7 +4830,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4612
4830
|
|
4613
4831
|
case 3:
|
4614
4832
|
response = _context11.sent;
|
4615
|
-
return _context11.abrupt("return", response.body.participants_count);
|
4833
|
+
return _context11.abrupt("return", (_response$body$partic = response.body.participants_count) !== null && _response$body$partic !== void 0 ? _response$body$partic : 0);
|
4616
4834
|
|
4617
4835
|
case 5:
|
4618
4836
|
case "end":
|
@@ -4651,7 +4869,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4651
4869
|
}, _callee12, this);
|
4652
4870
|
}));
|
4653
4871
|
|
4654
|
-
function getParticipantBySid(
|
4872
|
+
function getParticipantBySid(_x10) {
|
4655
4873
|
return _getParticipantBySid.apply(this, arguments);
|
4656
4874
|
}
|
4657
4875
|
|
@@ -4665,14 +4883,17 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4665
4883
|
}, {
|
4666
4884
|
key: "getParticipantByIdentity",
|
4667
4885
|
value: function () {
|
4668
|
-
var _getParticipantByIdentity = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee13(
|
4886
|
+
var _getParticipantByIdentity = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee13() {
|
4887
|
+
var identity,
|
4888
|
+
_args13 = arguments;
|
4669
4889
|
return _regeneratorRuntime__default['default'].wrap(function _callee13$(_context13) {
|
4670
4890
|
while (1) {
|
4671
4891
|
switch (_context13.prev = _context13.next) {
|
4672
4892
|
case 0:
|
4673
|
-
|
4893
|
+
identity = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : "";
|
4894
|
+
return _context13.abrupt("return", this.participantsEntity.getParticipantByIdentity(identity !== null && identity !== void 0 ? identity : ""));
|
4674
4895
|
|
4675
|
-
case
|
4896
|
+
case 2:
|
4676
4897
|
case "end":
|
4677
4898
|
return _context13.stop();
|
4678
4899
|
}
|
@@ -4680,7 +4901,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4680
4901
|
}, _callee13, this);
|
4681
4902
|
}));
|
4682
4903
|
|
4683
|
-
function getParticipantByIdentity(
|
4904
|
+
function getParticipantByIdentity() {
|
4684
4905
|
return _getParticipantByIdentity.apply(this, arguments);
|
4685
4906
|
}
|
4686
4907
|
|
@@ -4701,6 +4922,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4701
4922
|
key: "getMessagesCount",
|
4702
4923
|
value: function () {
|
4703
4924
|
var _getMessagesCount = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee14() {
|
4925
|
+
var _response$body$messag;
|
4926
|
+
|
4704
4927
|
var url, response;
|
4705
4928
|
return _regeneratorRuntime__default['default'].wrap(function _callee14$(_context14) {
|
4706
4929
|
while (1) {
|
@@ -4712,7 +4935,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4712
4935
|
|
4713
4936
|
case 3:
|
4714
4937
|
response = _context14.sent;
|
4715
|
-
return _context14.abrupt("return", response.body.messages_count);
|
4938
|
+
return _context14.abrupt("return", (_response$body$messag = response.body.messages_count) !== null && _response$body$messag !== void 0 ? _response$body$messag : 0);
|
4716
4939
|
|
4717
4940
|
case 5:
|
4718
4941
|
case "end":
|
@@ -4765,12 +4988,12 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4765
4988
|
break;
|
4766
4989
|
}
|
4767
4990
|
|
4768
|
-
throw new Error(
|
4991
|
+
throw new Error("Conversation was not found in the user conversations list");
|
4769
4992
|
|
4770
4993
|
case 6:
|
4771
4994
|
unreadMessageCount = response.body.unread_messages_count;
|
4772
4995
|
|
4773
|
-
if (!(typeof unreadMessageCount ===
|
4996
|
+
if (!(typeof unreadMessageCount === "number")) {
|
4774
4997
|
_context15.next = 9;
|
4775
4998
|
break;
|
4776
4999
|
}
|
@@ -4807,7 +5030,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4807
5030
|
switch (_context16.prev = _context16.next) {
|
4808
5031
|
case 0:
|
4809
5032
|
_context16.next = 2;
|
4810
|
-
return this.services.commandExecutor.mutateResource(
|
5033
|
+
return this.services.commandExecutor.mutateResource("post", this.links.participants, {
|
4811
5034
|
identity: this.configuration.userIdentity
|
4812
5035
|
});
|
4813
5036
|
|
@@ -4840,13 +5063,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4840
5063
|
while (1) {
|
4841
5064
|
switch (_context17.prev = _context17.next) {
|
4842
5065
|
case 0:
|
4843
|
-
if (!(this.channelState.status ===
|
5066
|
+
if (!(this.channelState.status === "joined")) {
|
4844
5067
|
_context17.next = 3;
|
4845
5068
|
break;
|
4846
5069
|
}
|
4847
5070
|
|
4848
5071
|
_context17.next = 3;
|
4849
|
-
return this.services.commandExecutor.mutateResource(
|
5072
|
+
return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(this.configuration.userIdentity));
|
4850
5073
|
|
4851
5074
|
case 3:
|
4852
5075
|
return _context17.abrupt("return", this);
|
@@ -4871,6 +5094,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4871
5094
|
* @param participant Identity, SID or the participant object to remove.
|
4872
5095
|
*/
|
4873
5096
|
|
5097
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
5098
|
+
// @ts-ignore TODO: fix validateTypesAsync typing
|
5099
|
+
|
4874
5100
|
}, {
|
4875
5101
|
key: "removeParticipant",
|
4876
5102
|
value: function () {
|
@@ -4880,7 +5106,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4880
5106
|
switch (_context18.prev = _context18.next) {
|
4881
5107
|
case 0:
|
4882
5108
|
_context18.next = 2;
|
4883
|
-
return this.participantsEntity.remove(typeof participant ===
|
5109
|
+
return this.participantsEntity.remove(typeof participant === "string" ? participant : participant.sid);
|
4884
5110
|
|
4885
5111
|
case 2:
|
4886
5112
|
case "end":
|
@@ -4890,7 +5116,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4890
5116
|
}, _callee18, this);
|
4891
5117
|
}));
|
4892
5118
|
|
4893
|
-
function removeParticipant(
|
5119
|
+
function removeParticipant(_x11) {
|
4894
5120
|
return _removeParticipant.apply(this, arguments);
|
4895
5121
|
}
|
4896
5122
|
|
@@ -4909,13 +5135,15 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4909
5135
|
key: "sendMessage",
|
4910
5136
|
value: function () {
|
4911
5137
|
var _sendMessage = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee19(message, messageAttributes, emailOptions) {
|
4912
|
-
var
|
5138
|
+
var _parseToNumber2;
|
5139
|
+
|
5140
|
+
var _parseToNumber, _response, response;
|
4913
5141
|
|
4914
5142
|
return _regeneratorRuntime__default['default'].wrap(function _callee19$(_context19) {
|
4915
5143
|
while (1) {
|
4916
5144
|
switch (_context19.prev = _context19.next) {
|
4917
5145
|
case 0:
|
4918
|
-
if (!(typeof message ===
|
5146
|
+
if (!(typeof message === "string" || message === null)) {
|
4919
5147
|
_context19.next = 5;
|
4920
5148
|
break;
|
4921
5149
|
}
|
@@ -4925,7 +5153,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4925
5153
|
|
4926
5154
|
case 3:
|
4927
5155
|
_response = _context19.sent;
|
4928
|
-
return _context19.abrupt("return", parseToNumber(_response.index));
|
5156
|
+
return _context19.abrupt("return", (_parseToNumber = parseToNumber(_response.index)) !== null && _parseToNumber !== void 0 ? _parseToNumber : 0);
|
4929
5157
|
|
4930
5158
|
case 5:
|
4931
5159
|
_context19.next = 7;
|
@@ -4933,7 +5161,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4933
5161
|
|
4934
5162
|
case 7:
|
4935
5163
|
response = _context19.sent;
|
4936
|
-
return _context19.abrupt("return", parseToNumber(response.index));
|
5164
|
+
return _context19.abrupt("return", (_parseToNumber2 = parseToNumber(response.index)) !== null && _parseToNumber2 !== void 0 ? _parseToNumber2 : 0);
|
4937
5165
|
|
4938
5166
|
case 9:
|
4939
5167
|
case "end":
|
@@ -4943,7 +5171,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4943
5171
|
}, _callee19, this);
|
4944
5172
|
}));
|
4945
5173
|
|
4946
|
-
function sendMessage(
|
5174
|
+
function sendMessage(_x12, _x13, _x14) {
|
4947
5175
|
return _sendMessage.apply(this, arguments);
|
4948
5176
|
}
|
4949
5177
|
|
@@ -4952,6 +5180,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4952
5180
|
/**
|
4953
5181
|
* New interface to prepare for sending a message.
|
4954
5182
|
* Use instead of `sendMessage`.
|
5183
|
+
* @return A MessageBuilder to help set all message sending options.
|
4955
5184
|
*/
|
4956
5185
|
|
4957
5186
|
}, {
|
@@ -5058,7 +5287,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5058
5287
|
switch (_context22.prev = _context22.next) {
|
5059
5288
|
case 0:
|
5060
5289
|
_context22.next = 2;
|
5061
|
-
return this.services.commandExecutor.mutateResource(
|
5290
|
+
return this.services.commandExecutor.mutateResource("post", "".concat(this.configuration.links.myConversations, "/").concat(this.sid), {
|
5062
5291
|
notification_level: notificationLevel
|
5063
5292
|
});
|
5064
5293
|
|
@@ -5070,7 +5299,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5070
5299
|
}, _callee22, this);
|
5071
5300
|
}));
|
5072
5301
|
|
5073
|
-
function setUserNotificationLevel(
|
5302
|
+
function setUserNotificationLevel(_x15) {
|
5074
5303
|
return _setUserNotificationLevel.apply(this, arguments);
|
5075
5304
|
}
|
5076
5305
|
|
@@ -5100,7 +5329,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5100
5329
|
switch (_context23.prev = _context23.next) {
|
5101
5330
|
case 0:
|
5102
5331
|
_context23.next = 2;
|
5103
|
-
return this.services.commandExecutor.mutateResource(
|
5332
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
5104
5333
|
attributes: attributes !== undefined ? JSON.stringify(attributes) : undefined
|
5105
5334
|
});
|
5106
5335
|
|
@@ -5115,7 +5344,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5115
5344
|
}, _callee23, this);
|
5116
5345
|
}));
|
5117
5346
|
|
5118
|
-
function updateAttributes(
|
5347
|
+
function updateAttributes(_x16) {
|
5119
5348
|
return _updateAttributes.apply(this, arguments);
|
5120
5349
|
}
|
5121
5350
|
|
@@ -5140,7 +5369,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5140
5369
|
}
|
5141
5370
|
|
5142
5371
|
_context24.next = 3;
|
5143
|
-
return this.services.commandExecutor.mutateResource(
|
5372
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
5144
5373
|
friendly_name: friendlyName
|
5145
5374
|
});
|
5146
5375
|
|
@@ -5155,7 +5384,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5155
5384
|
}, _callee24, this);
|
5156
5385
|
}));
|
5157
5386
|
|
5158
|
-
function updateFriendlyName(
|
5387
|
+
function updateFriendlyName(_x17) {
|
5159
5388
|
return _updateFriendlyName.apply(this, arguments);
|
5160
5389
|
}
|
5161
5390
|
|
@@ -5190,7 +5419,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5190
5419
|
}, _callee25, this);
|
5191
5420
|
}));
|
5192
5421
|
|
5193
|
-
function updateLastReadMessageIndex(
|
5422
|
+
function updateLastReadMessageIndex(_x18) {
|
5194
5423
|
return _updateLastReadMessageIndex.apply(this, arguments);
|
5195
5424
|
}
|
5196
5425
|
|
@@ -5215,11 +5444,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5215
5444
|
}
|
5216
5445
|
|
5217
5446
|
if (!uniqueName) {
|
5218
|
-
uniqueName =
|
5447
|
+
uniqueName = "";
|
5219
5448
|
}
|
5220
5449
|
|
5221
5450
|
_context26.next = 4;
|
5222
|
-
return this.services.commandExecutor.mutateResource(
|
5451
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
5223
5452
|
unique_name: uniqueName
|
5224
5453
|
});
|
5225
5454
|
|
@@ -5234,7 +5463,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5234
5463
|
}, _callee26, this);
|
5235
5464
|
}));
|
5236
5465
|
|
5237
|
-
function updateUniqueName(
|
5466
|
+
function updateUniqueName(_x19) {
|
5238
5467
|
return _updateUniqueName.apply(this, arguments);
|
5239
5468
|
}
|
5240
5469
|
|
@@ -5244,13 +5473,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5244
5473
|
key: "preprocessUpdate",
|
5245
5474
|
value: function preprocessUpdate(update, conversationSid) {
|
5246
5475
|
try {
|
5247
|
-
if (typeof update.attributes ===
|
5476
|
+
if (typeof update.attributes === "string") {
|
5248
5477
|
update.attributes = JSON.parse(update.attributes);
|
5249
5478
|
} else if (update.attributes) {
|
5250
5479
|
JSON.stringify(update.attributes);
|
5251
5480
|
}
|
5252
5481
|
} catch (e) {
|
5253
|
-
log$3.warn(
|
5482
|
+
log$3.warn("Retrieved malformed attributes from the server for conversation: " + conversationSid);
|
5254
5483
|
update.attributes = {};
|
5255
5484
|
}
|
5256
5485
|
|
@@ -5259,7 +5488,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5259
5488
|
update.dateCreated = new Date(update.dateCreated);
|
5260
5489
|
}
|
5261
5490
|
} catch (e) {
|
5262
|
-
log$3.warn(
|
5491
|
+
log$3.warn("Retrieved malformed dateCreated from the server for conversation: " + conversationSid);
|
5263
5492
|
delete update.dateCreated;
|
5264
5493
|
}
|
5265
5494
|
|
@@ -5268,7 +5497,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5268
5497
|
update.dateUpdated = new Date(update.dateUpdated);
|
5269
5498
|
}
|
5270
5499
|
} catch (e) {
|
5271
|
-
log$3.warn(
|
5500
|
+
log$3.warn("Retrieved malformed dateUpdated from the server for conversation: " + conversationSid);
|
5272
5501
|
delete update.dateUpdated;
|
5273
5502
|
}
|
5274
5503
|
|
@@ -5277,7 +5506,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5277
5506
|
update.lastMessage.timestamp = new Date(update.lastMessage.timestamp);
|
5278
5507
|
}
|
5279
5508
|
} catch (e) {
|
5280
|
-
log$3.warn(
|
5509
|
+
log$3.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: " + conversationSid);
|
5281
5510
|
delete update.lastMessage.timestamp;
|
5282
5511
|
}
|
5283
5512
|
}
|
@@ -5286,33 +5515,33 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5286
5515
|
return Conversation;
|
5287
5516
|
}(replayEventEmitter.ReplayEventEmitter);
|
5288
5517
|
|
5289
|
-
_defineProperty__default['default'](Conversation, "participantJoined",
|
5518
|
+
_defineProperty__default['default'](Conversation, "participantJoined", "participantJoined");
|
5290
5519
|
|
5291
|
-
_defineProperty__default['default'](Conversation, "participantLeft",
|
5520
|
+
_defineProperty__default['default'](Conversation, "participantLeft", "participantLeft");
|
5292
5521
|
|
5293
|
-
_defineProperty__default['default'](Conversation, "participantUpdated",
|
5522
|
+
_defineProperty__default['default'](Conversation, "participantUpdated", "participantUpdated");
|
5294
5523
|
|
5295
|
-
_defineProperty__default['default'](Conversation, "messageAdded",
|
5524
|
+
_defineProperty__default['default'](Conversation, "messageAdded", "messageAdded");
|
5296
5525
|
|
5297
|
-
_defineProperty__default['default'](Conversation, "messageRemoved",
|
5526
|
+
_defineProperty__default['default'](Conversation, "messageRemoved", "messageRemoved");
|
5298
5527
|
|
5299
|
-
_defineProperty__default['default'](Conversation, "messageUpdated",
|
5528
|
+
_defineProperty__default['default'](Conversation, "messageUpdated", "messageUpdated");
|
5300
5529
|
|
5301
|
-
_defineProperty__default['default'](Conversation, "typingEnded",
|
5530
|
+
_defineProperty__default['default'](Conversation, "typingEnded", "typingEnded");
|
5302
5531
|
|
5303
|
-
_defineProperty__default['default'](Conversation, "typingStarted",
|
5532
|
+
_defineProperty__default['default'](Conversation, "typingStarted", "typingStarted");
|
5304
5533
|
|
5305
|
-
_defineProperty__default['default'](Conversation, "updated",
|
5534
|
+
_defineProperty__default['default'](Conversation, "updated", "updated");
|
5306
5535
|
|
5307
|
-
_defineProperty__default['default'](Conversation, "removed",
|
5536
|
+
_defineProperty__default['default'](Conversation, "removed", "removed");
|
5308
5537
|
|
5309
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString,
|
5538
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, optionalAttributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "add", null);
|
5310
5539
|
|
5311
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString,
|
5540
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString, optionalAttributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "addNonChatParticipant", null);
|
5312
5541
|
|
5313
5542
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonNegativeInteger), __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", Promise)], Conversation.prototype, "advanceLastReadMessageIndex", null);
|
5314
5543
|
|
5315
|
-
__decorate([declarativeTypeValidator.validateTypesAsync([
|
5544
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(["undefined", declarativeTypeValidator.nonNegativeInteger], ["undefined", declarativeTypeValidator.nonNegativeInteger], ["undefined", declarativeTypeValidator.literal("backwards", "forward")]), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, Number, String]), __metadata("design:returntype", Promise)], Conversation.prototype, "getMessages", null);
|
5316
5545
|
|
5317
5546
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "getParticipantBySid", null);
|
5318
5547
|
|
@@ -5320,33 +5549,33 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
|
|
5320
5549
|
|
5321
5550
|
__decorate([declarativeTypeValidator.validateTypesAsync([declarativeTypeValidator.nonEmptyString, Participant]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "removeParticipant", null);
|
5322
5551
|
|
5323
|
-
__decorate([declarativeTypeValidator.validateTypesAsync([
|
5552
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(["string", declarativeTypeValidator.literal(null), // Wrapping it into a custom rule is necessary because the FormData class is not available on initialization.
|
5324
5553
|
declarativeTypeValidator.custom(function (value) {
|
5325
|
-
return [value instanceof FormData,
|
5326
|
-
}), declarativeTypeValidator.objectSchema(
|
5554
|
+
return [value instanceof FormData, "an instance of FormData"];
|
5555
|
+
}), declarativeTypeValidator.objectSchema("media options", {
|
5327
5556
|
contentType: declarativeTypeValidator.nonEmptyString,
|
5328
5557
|
media: declarativeTypeValidator.custom(function (value) {
|
5329
|
-
var isValid = typeof value ===
|
5558
|
+
var isValid = typeof value === "string" && value.length > 0 || value instanceof Uint8Array || value instanceof ArrayBuffer;
|
5330
5559
|
|
5331
|
-
if (typeof Blob ===
|
5560
|
+
if (typeof Blob === "function") {
|
5332
5561
|
isValid = isValid || value instanceof Blob;
|
5333
5562
|
}
|
5334
5563
|
|
5335
|
-
return [isValid,
|
5564
|
+
return [isValid, "a non-empty string, an instance of Buffer or an instance of Blob"];
|
5336
5565
|
})
|
5337
|
-
})],
|
5338
|
-
subject: [declarativeTypeValidator.nonEmptyString,
|
5566
|
+
})], optionalAttributesValidator, ["undefined", declarativeTypeValidator.literal(null), declarativeTypeValidator.objectSchema("email attributes", {
|
5567
|
+
subject: [declarativeTypeValidator.nonEmptyString, "undefined"]
|
5339
5568
|
})]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "sendMessage", null);
|
5340
5569
|
|
5341
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal(
|
5570
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("default", "muted")), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "setUserNotificationLevel", null);
|
5342
5571
|
|
5343
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
5572
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateAttributes", null);
|
5344
5573
|
|
5345
|
-
__decorate([declarativeTypeValidator.validateTypesAsync([
|
5574
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateFriendlyName", null);
|
5346
5575
|
|
5347
5576
|
__decorate([declarativeTypeValidator.validateTypesAsync([declarativeTypeValidator.literal(null), declarativeTypeValidator.nonNegativeInteger]), __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateLastReadMessageIndex", null);
|
5348
5577
|
|
5349
|
-
__decorate([declarativeTypeValidator.validateTypesAsync([
|
5578
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(["string", declarativeTypeValidator.literal(null)]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateUniqueName", null);
|
5350
5579
|
|
5351
5580
|
var Deferred = /*#__PURE__*/function () {
|
5352
5581
|
function Deferred() {
|
@@ -5400,7 +5629,7 @@ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) {
|
|
5400
5629
|
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); 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); }; }
|
5401
5630
|
|
5402
5631
|
function _isNativeReflectConstruct$2() { 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; } }
|
5403
|
-
var log$2 = Logger.scope(
|
5632
|
+
var log$2 = Logger.scope("Conversations");
|
5404
5633
|
/**
|
5405
5634
|
* Represents conversations collection
|
5406
5635
|
* {@see Conversation}
|
@@ -5442,12 +5671,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5442
5671
|
while (1) {
|
5443
5672
|
switch (_context.prev = _context.next) {
|
5444
5673
|
case 0:
|
5445
|
-
attributes = typeof (options === null || options === void 0 ? void 0 : options.attributes) !==
|
5674
|
+
attributes = typeof (options === null || options === void 0 ? void 0 : options.attributes) !== "undefined" ? options.attributes : {};
|
5446
5675
|
_context.next = 3;
|
5447
|
-
return this.services.commandExecutor.mutateResource(
|
5676
|
+
return this.services.commandExecutor.mutateResource("post", this.configuration.links.conversations, {
|
5448
5677
|
friendly_name: options.friendlyName,
|
5449
5678
|
unique_name: options.uniqueName,
|
5450
|
-
attributes: typeof attributes !==
|
5679
|
+
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
|
5451
5680
|
});
|
5452
5681
|
|
5453
5682
|
case 3:
|
@@ -5473,12 +5702,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5473
5702
|
case 12:
|
5474
5703
|
conversation = new Conversation({
|
5475
5704
|
channel: conversationDocument,
|
5476
|
-
entityName:
|
5477
|
-
uniqueName:
|
5705
|
+
entityName: "",
|
5706
|
+
uniqueName: "",
|
5478
5707
|
attributes: null,
|
5479
|
-
createdBy:
|
5480
|
-
friendlyName:
|
5481
|
-
lastConsumedMessageIndex:
|
5708
|
+
createdBy: "",
|
5709
|
+
friendlyName: "",
|
5710
|
+
lastConsumedMessageIndex: 0,
|
5482
5711
|
dateCreated: null,
|
5483
5712
|
dateUpdated: null
|
5484
5713
|
}, conversationSid, links, this.configuration, this.services);
|
@@ -5490,7 +5719,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5490
5719
|
return conversation._subscribe();
|
5491
5720
|
|
5492
5721
|
case 17:
|
5493
|
-
this.emit(
|
5722
|
+
this.emit("conversationAdded", conversation);
|
5494
5723
|
return _context.abrupt("return", conversation);
|
5495
5724
|
|
5496
5725
|
case 19:
|
@@ -5529,12 +5758,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5529
5758
|
|
5530
5759
|
case 3:
|
5531
5760
|
map = _context2.sent;
|
5532
|
-
map.on(
|
5761
|
+
map.on("itemAdded", function (args) {
|
5533
5762
|
log$2.debug("itemAdded: ".concat(args.item.key));
|
5534
5763
|
|
5535
|
-
_this2._upsertConversation(
|
5764
|
+
_this2._upsertConversation("sync", args.item.key, args.item.data);
|
5536
5765
|
});
|
5537
|
-
map.on(
|
5766
|
+
map.on("itemRemoved", function (args) {
|
5538
5767
|
log$2.debug("itemRemoved: ".concat(args.key));
|
5539
5768
|
var sid = args.key;
|
5540
5769
|
|
@@ -5548,22 +5777,22 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5548
5777
|
return;
|
5549
5778
|
}
|
5550
5779
|
|
5551
|
-
if (conversation.status ===
|
5552
|
-
conversation._setStatus(
|
5780
|
+
if (conversation.status === "joined") {
|
5781
|
+
conversation._setStatus("notParticipating", "sync");
|
5553
5782
|
|
5554
|
-
_this2.emit(
|
5783
|
+
_this2.emit("conversationLeft", conversation);
|
5555
5784
|
}
|
5556
5785
|
|
5557
5786
|
_this2.conversations.delete(sid);
|
5558
5787
|
|
5559
|
-
_this2.emit(
|
5788
|
+
_this2.emit("conversationRemoved", conversation);
|
5560
5789
|
|
5561
|
-
conversation.emit(
|
5790
|
+
conversation.emit("removed", conversation);
|
5562
5791
|
});
|
5563
|
-
map.on(
|
5792
|
+
map.on("itemUpdated", function (args) {
|
5564
5793
|
log$2.debug("itemUpdated: ".concat(args.item.key));
|
5565
5794
|
|
5566
|
-
_this2._upsertConversation(
|
5795
|
+
_this2._upsertConversation("sync", args.item.key, args.item.data);
|
5567
5796
|
});
|
5568
5797
|
_context2.next = 9;
|
5569
5798
|
return this._fetchMyConversations();
|
@@ -5576,7 +5805,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5576
5805
|
try {
|
5577
5806
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
5578
5807
|
conversation = _step.value;
|
5579
|
-
upserts.push(this._upsertConversation(
|
5808
|
+
upserts.push(this._upsertConversation("rest", conversation["channel_sid"], conversation));
|
5580
5809
|
}
|
5581
5810
|
} catch (err) {
|
5582
5811
|
_iterator.e(err);
|
@@ -5591,15 +5820,15 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5591
5820
|
case 16:
|
5592
5821
|
this.myConversationsFetched = true;
|
5593
5822
|
this.tombstones.clear();
|
5594
|
-
log$2.debug(
|
5823
|
+
log$2.debug("The conversations list has been successfully fetched");
|
5595
5824
|
return _context2.abrupt("return", this);
|
5596
5825
|
|
5597
5826
|
case 22:
|
5598
5827
|
_context2.prev = 22;
|
5599
5828
|
_context2.t0 = _context2["catch"](0);
|
5600
|
-
errorMessage =
|
5829
|
+
errorMessage = "Failed to fetch the conversations list";
|
5601
5830
|
|
5602
|
-
if (this.services.syncClient.connectionState !==
|
5831
|
+
if (this.services.syncClient.connectionState !== "disconnected") {
|
5603
5832
|
log$2.error(errorMessage, _context2.t0);
|
5604
5833
|
}
|
5605
5834
|
|
@@ -5623,7 +5852,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5623
5852
|
}, {
|
5624
5853
|
key: "getConversations",
|
5625
5854
|
value: function () {
|
5626
|
-
var _getConversations = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(
|
5855
|
+
var _getConversations = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
5627
5856
|
var _this3 = this;
|
5628
5857
|
|
5629
5858
|
var conversationsMap, page;
|
@@ -5643,7 +5872,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5643
5872
|
page = _context3.sent;
|
5644
5873
|
return _context3.abrupt("return", this._wrapPaginator(page, function (items) {
|
5645
5874
|
return Promise.all(items.map(function (item) {
|
5646
|
-
return _this3._upsertConversation(
|
5875
|
+
return _this3._upsertConversation("sync", item.key, item.data);
|
5647
5876
|
}));
|
5648
5877
|
}));
|
5649
5878
|
|
@@ -5655,7 +5884,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5655
5884
|
}, _callee3, this);
|
5656
5885
|
}));
|
5657
5886
|
|
5658
|
-
function getConversations(
|
5887
|
+
function getConversations() {
|
5659
5888
|
return _getConversations.apply(this, arguments);
|
5660
5889
|
}
|
5661
5890
|
|
@@ -5685,7 +5914,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5685
5914
|
case 5:
|
5686
5915
|
page = _context4.sent;
|
5687
5916
|
items = page.items.map(function (item) {
|
5688
|
-
return _this4._upsertConversation(
|
5917
|
+
return _this4._upsertConversation("sync", item.key, item.data);
|
5689
5918
|
});
|
5690
5919
|
return _context4.abrupt("return", items.length > 0 ? items[0] : null);
|
5691
5920
|
|
@@ -5697,7 +5926,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5697
5926
|
}, _callee4, this);
|
5698
5927
|
}));
|
5699
5928
|
|
5700
|
-
function getConversation(
|
5929
|
+
function getConversation(_x2) {
|
5701
5930
|
return _getConversation.apply(this, arguments);
|
5702
5931
|
}
|
5703
5932
|
|
@@ -5723,7 +5952,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5723
5952
|
data = {
|
5724
5953
|
entityName: null,
|
5725
5954
|
lastConsumedMessageIndex: body.last_read_message_index,
|
5726
|
-
status: (body === null || body === void 0 ? void 0 : body.status) ||
|
5955
|
+
status: (body === null || body === void 0 ? void 0 : body.status) || "unknown",
|
5727
5956
|
friendlyName: body.friendly_name,
|
5728
5957
|
dateUpdated: body.date_updated,
|
5729
5958
|
dateCreated: body.date_created,
|
@@ -5734,7 +5963,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5734
5963
|
notificationLevel: body === null || body === void 0 ? void 0 : body.notification_level,
|
5735
5964
|
sid: sid
|
5736
5965
|
};
|
5737
|
-
return _context5.abrupt("return", this._upsertConversation(
|
5966
|
+
return _context5.abrupt("return", sid ? this._upsertConversation("sync", sid, data) : null);
|
5738
5967
|
|
5739
5968
|
case 8:
|
5740
5969
|
case "end":
|
@@ -5744,7 +5973,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5744
5973
|
}, _callee5, this);
|
5745
5974
|
}));
|
5746
5975
|
|
5747
|
-
function getConversationByUniqueName(
|
5976
|
+
function getConversationByUniqueName(_x3) {
|
5748
5977
|
return _getConversationByUniqueName.apply(this, arguments);
|
5749
5978
|
}
|
5750
5979
|
|
@@ -5769,7 +5998,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5769
5998
|
data = {
|
5770
5999
|
entityName: null,
|
5771
6000
|
// lastConsumedMessageIndex: body.last_read_message_index,
|
5772
|
-
status: (body === null || body === void 0 ? void 0 : body.status) ||
|
6001
|
+
status: (body === null || body === void 0 ? void 0 : body.status) || "unknown",
|
5773
6002
|
friendlyName: body.friendly_name,
|
5774
6003
|
dateUpdated: body.date_updated,
|
5775
6004
|
dateCreated: body.date_created,
|
@@ -5780,7 +6009,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5780
6009
|
// notificationLevel: body?.notification_level,
|
5781
6010
|
sid: sid
|
5782
6011
|
};
|
5783
|
-
return _context6.abrupt("return", this._upsertConversation(
|
6012
|
+
return _context6.abrupt("return", this._upsertConversation("sync", sid, data));
|
5784
6013
|
|
5785
6014
|
case 7:
|
5786
6015
|
case "end":
|
@@ -5790,7 +6019,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5790
6019
|
}, _callee6, this);
|
5791
6020
|
}));
|
5792
6021
|
|
5793
|
-
function peekConversation(
|
6022
|
+
function peekConversation(_x4) {
|
5794
6023
|
return _peekConversation.apply(this, arguments);
|
5795
6024
|
}
|
5796
6025
|
|
@@ -5807,7 +6036,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5807
6036
|
_context7.next = 2;
|
5808
6037
|
return this.services.syncClient.map({
|
5809
6038
|
id: this.configuration.myConversations,
|
5810
|
-
mode:
|
6039
|
+
mode: "open_existing"
|
5811
6040
|
});
|
5812
6041
|
|
5813
6042
|
case 2:
|
@@ -5867,7 +6096,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5867
6096
|
}, _callee8);
|
5868
6097
|
}));
|
5869
6098
|
|
5870
|
-
function _wrapPaginator(
|
6099
|
+
function _wrapPaginator(_x5, _x6) {
|
5871
6100
|
return _wrapPaginator2.apply(this, arguments);
|
5872
6101
|
}
|
5873
6102
|
|
@@ -5885,14 +6114,14 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5885
6114
|
switch (_context9.prev = _context9.next) {
|
5886
6115
|
case 0:
|
5887
6116
|
areSourcesDifferent = conversation._statusSource() !== undefined && source !== conversation._statusSource();
|
5888
|
-
isChannelSourceSync = source !==
|
6117
|
+
isChannelSourceSync = source !== "rest" || conversation._statusSource() === "sync";
|
5889
6118
|
|
5890
|
-
if (!(areSourcesDifferent && isChannelSourceSync && source !==
|
6119
|
+
if (!(areSourcesDifferent && isChannelSourceSync && source !== "sync")) {
|
5891
6120
|
_context9.next = 5;
|
5892
6121
|
break;
|
5893
6122
|
}
|
5894
6123
|
|
5895
|
-
log$2.trace(
|
6124
|
+
log$2.trace("upsertConversation: conversation is known from sync and came from chat, ignoring", {
|
5896
6125
|
sid: conversation.sid,
|
5897
6126
|
data: data.status,
|
5898
6127
|
conversation: conversation.status
|
@@ -5900,20 +6129,20 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5900
6129
|
return _context9.abrupt("return");
|
5901
6130
|
|
5902
6131
|
case 5:
|
5903
|
-
if (!(data.status ===
|
6132
|
+
if (!(data.status === "joined" && conversation.status !== "joined")) {
|
5904
6133
|
_context9.next = 13;
|
5905
6134
|
break;
|
5906
6135
|
}
|
5907
6136
|
|
5908
|
-
conversation._setStatus(
|
6137
|
+
conversation._setStatus("joined", source);
|
5909
6138
|
|
5910
6139
|
updateData = {};
|
5911
6140
|
|
5912
|
-
if (typeof data.notificationLevel !==
|
6141
|
+
if (typeof data.notificationLevel !== "undefined") {
|
5913
6142
|
updateData.notificationLevel = data.notificationLevel;
|
5914
6143
|
}
|
5915
6144
|
|
5916
|
-
if (typeof data.lastConsumedMessageIndex !==
|
6145
|
+
if (typeof data.lastConsumedMessageIndex !== "undefined") {
|
5917
6146
|
updateData.lastConsumedMessageIndex = data.lastConsumedMessageIndex;
|
5918
6147
|
}
|
5919
6148
|
|
@@ -5922,18 +6151,18 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5922
6151
|
}
|
5923
6152
|
|
5924
6153
|
conversation._subscribe().then(function () {
|
5925
|
-
_this6.emit(
|
6154
|
+
_this6.emit("conversationJoined", conversation);
|
5926
6155
|
});
|
5927
6156
|
|
5928
6157
|
return _context9.abrupt("return");
|
5929
6158
|
|
5930
6159
|
case 13:
|
5931
|
-
if (!(data.status ===
|
6160
|
+
if (!(data.status === "notParticipating" && conversation.status === "joined")) {
|
5932
6161
|
_context9.next = 20;
|
5933
6162
|
break;
|
5934
6163
|
}
|
5935
6164
|
|
5936
|
-
conversation._setStatus(
|
6165
|
+
conversation._setStatus("notParticipating", source);
|
5937
6166
|
|
5938
6167
|
conversation._update(data);
|
5939
6168
|
|
@@ -5941,11 +6170,11 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5941
6170
|
return conversation._subscribe();
|
5942
6171
|
|
5943
6172
|
case 18:
|
5944
|
-
this.emit(
|
6173
|
+
this.emit("conversationLeft", conversation);
|
5945
6174
|
return _context9.abrupt("return");
|
5946
6175
|
|
5947
6176
|
case 20:
|
5948
|
-
if (!(data.status ===
|
6177
|
+
if (!(data.status === "notParticipating")) {
|
5949
6178
|
_context9.next = 24;
|
5950
6179
|
break;
|
5951
6180
|
}
|
@@ -5967,7 +6196,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5967
6196
|
}, _callee9, this);
|
5968
6197
|
}));
|
5969
6198
|
|
5970
|
-
function _updateConversation(_x8, _x9
|
6199
|
+
function _updateConversation(_x7, _x8, _x9) {
|
5971
6200
|
return _updateConversation2.apply(this, arguments);
|
5972
6201
|
}
|
5973
6202
|
|
@@ -6002,17 +6231,17 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6002
6231
|
return _context10.abrupt("return", conversation);
|
6003
6232
|
|
6004
6233
|
case 9:
|
6005
|
-
if (!([
|
6234
|
+
if (!(["chat", "rest"].includes(source) && this.tombstones.has(sid))) {
|
6006
6235
|
_context10.next = 12;
|
6007
6236
|
break;
|
6008
6237
|
}
|
6009
6238
|
|
6010
|
-
log$2.trace(
|
6011
|
-
return _context10.abrupt("return");
|
6239
|
+
log$2.trace("upsertChannel: the channel is deleted but reappeared again from chat, ignoring", sid);
|
6240
|
+
return _context10.abrupt("return", null);
|
6012
6241
|
|
6013
6242
|
case 12:
|
6014
6243
|
// If the conversation is unknown, fetch it
|
6015
|
-
log$2.trace(
|
6244
|
+
log$2.trace("upsertConversation: creating a local conversation object with sid " + sid, data);
|
6016
6245
|
baseLink = "".concat(this.configuration.links.conversations, "/").concat(sid);
|
6017
6246
|
links = {
|
6018
6247
|
self: baseLink,
|
@@ -6027,12 +6256,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6027
6256
|
case 19:
|
6028
6257
|
this._registerForEvents(newConversation);
|
6029
6258
|
|
6030
|
-
this.emit(
|
6259
|
+
this.emit("conversationAdded", newConversation);
|
6031
6260
|
|
6032
|
-
if (data.status ===
|
6033
|
-
newConversation._setStatus(
|
6261
|
+
if (data.status === "joined") {
|
6262
|
+
newConversation._setStatus("joined", source);
|
6034
6263
|
|
6035
|
-
this.emit(
|
6264
|
+
this.emit("conversationJoined", newConversation);
|
6036
6265
|
}
|
6037
6266
|
|
6038
6267
|
return _context10.abrupt("return", newConversation);
|
@@ -6045,7 +6274,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6045
6274
|
}, _callee10, this);
|
6046
6275
|
}));
|
6047
6276
|
|
6048
|
-
function _upsertConversation(_x11, _x12
|
6277
|
+
function _upsertConversation(_x10, _x11, _x12) {
|
6049
6278
|
return _upsertConversation2.apply(this, arguments);
|
6050
6279
|
}
|
6051
6280
|
|
@@ -6055,7 +6284,8 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6055
6284
|
key: "_fetchMyConversations",
|
6056
6285
|
value: function () {
|
6057
6286
|
var _fetchMyConversations2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee11() {
|
6058
|
-
var conversations, pageToken, url, response, receivedConversations;
|
6287
|
+
var conversations, pageToken, _response$body, url, response, receivedConversations;
|
6288
|
+
|
6059
6289
|
return _regeneratorRuntime__default['default'].wrap(function _callee11$(_context11) {
|
6060
6290
|
while (1) {
|
6061
6291
|
switch (_context11.prev = _context11.next) {
|
@@ -6067,7 +6297,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6067
6297
|
url = new UriBuilder(this.configuration.links.myConversations);
|
6068
6298
|
|
6069
6299
|
if (pageToken) {
|
6070
|
-
url.arg(
|
6300
|
+
url.arg("PageToken", pageToken);
|
6071
6301
|
}
|
6072
6302
|
|
6073
6303
|
_context11.next = 6;
|
@@ -6075,7 +6305,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6075
6305
|
|
6076
6306
|
case 6:
|
6077
6307
|
response = _context11.sent;
|
6078
|
-
receivedConversations = response.body.conversations.map(function (conversationDescriptor) {
|
6308
|
+
receivedConversations = (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.conversations.map(function (conversationDescriptor) {
|
6079
6309
|
return {
|
6080
6310
|
descriptor: conversationDescriptor,
|
6081
6311
|
channel_sid: conversationDescriptor.conversation_sid,
|
@@ -6083,7 +6313,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6083
6313
|
channel: conversationDescriptor.sync_objects.conversation,
|
6084
6314
|
messages: conversationDescriptor.sync_objects.messages,
|
6085
6315
|
roster: "".concat(conversationDescriptor.conversation_sid, ".roster"),
|
6086
|
-
lastConsumedMessageIndex: conversationDescriptor.
|
6316
|
+
lastConsumedMessageIndex: conversationDescriptor.last_read_message_index,
|
6087
6317
|
notificationLevel: conversationDescriptor.notification_level
|
6088
6318
|
};
|
6089
6319
|
});
|
@@ -6120,7 +6350,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6120
6350
|
|
6121
6351
|
if (conversation) {
|
6122
6352
|
this.conversations.delete(sid);
|
6123
|
-
this.emit(
|
6353
|
+
this.emit("conversationRemoved", conversation);
|
6124
6354
|
}
|
6125
6355
|
}
|
6126
6356
|
}, {
|
@@ -6128,24 +6358,36 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6128
6358
|
value: function _registerForEvents(conversation) {
|
6129
6359
|
var _this7 = this;
|
6130
6360
|
|
6131
|
-
conversation.on(
|
6361
|
+
conversation.on("removed", function () {
|
6132
6362
|
return _this7._onConversationRemoved(conversation.sid);
|
6133
6363
|
});
|
6134
|
-
conversation.on(
|
6135
|
-
return _this7.emit(
|
6364
|
+
conversation.on("updated", function (args) {
|
6365
|
+
return _this7.emit("conversationUpdated", args);
|
6366
|
+
});
|
6367
|
+
conversation.on("participantJoined", function (participant) {
|
6368
|
+
return _this7.emit("participantJoined", participant);
|
6369
|
+
});
|
6370
|
+
conversation.on("participantLeft", function (participant) {
|
6371
|
+
return _this7.emit("participantLeft", participant);
|
6372
|
+
});
|
6373
|
+
conversation.on("participantUpdated", function (args) {
|
6374
|
+
return _this7.emit("participantUpdated", args);
|
6375
|
+
});
|
6376
|
+
conversation.on("messageAdded", function (message) {
|
6377
|
+
return _this7.emit("messageAdded", message);
|
6136
6378
|
});
|
6137
|
-
conversation.on(
|
6138
|
-
|
6139
|
-
conversation.on('participantUpdated', function (args) {
|
6140
|
-
return _this7.emit('participantUpdated', args);
|
6379
|
+
conversation.on("messageUpdated", function (args) {
|
6380
|
+
return _this7.emit("messageUpdated", args);
|
6141
6381
|
});
|
6142
|
-
conversation.on(
|
6143
|
-
|
6144
|
-
|
6382
|
+
conversation.on("messageRemoved", function (message) {
|
6383
|
+
return _this7.emit("messageRemoved", message);
|
6384
|
+
});
|
6385
|
+
conversation.on("typingStarted", function (participant) {
|
6386
|
+
return _this7.emit("typingStarted", participant);
|
6387
|
+
});
|
6388
|
+
conversation.on("typingEnded", function (participant) {
|
6389
|
+
return _this7.emit("typingEnded", participant);
|
6145
6390
|
});
|
6146
|
-
conversation.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));
|
6147
|
-
conversation.on('typingStarted', this.emit.bind(this, 'typingStarted'));
|
6148
|
-
conversation.on('typingEnded', this.emit.bind(this, 'typingEnded'));
|
6149
6391
|
}
|
6150
6392
|
}]);
|
6151
6393
|
|
@@ -6175,16 +6417,16 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6175
6417
|
_this.fifoStack = [];
|
6176
6418
|
_this.myself = myself;
|
6177
6419
|
|
6178
|
-
_this.myself.on(
|
6179
|
-
return _this.emit(
|
6420
|
+
_this.myself.on("updated", function (args) {
|
6421
|
+
return _this.emit("userUpdated", args);
|
6180
6422
|
});
|
6181
6423
|
|
6182
|
-
_this.myself.on(
|
6183
|
-
return _this.emit(
|
6424
|
+
_this.myself.on("userSubscribed", function () {
|
6425
|
+
return _this.emit("userSubscribed", _this.myself);
|
6184
6426
|
});
|
6185
6427
|
|
6186
|
-
_this.myself.on(
|
6187
|
-
_this.emit(
|
6428
|
+
_this.myself.on("userUnsubscribed", function () {
|
6429
|
+
_this.emit("userUnsubscribed", _this.myself);
|
6188
6430
|
|
6189
6431
|
_this.myself._ensureFetched();
|
6190
6432
|
});
|
@@ -6200,7 +6442,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6200
6442
|
this.subscribedUsers.delete(user.identity);
|
6201
6443
|
}
|
6202
6444
|
|
6203
|
-
var foundItemIndex =
|
6445
|
+
var foundItemIndex = 0;
|
6204
6446
|
var foundItem = this.fifoStack.find(function (item, index) {
|
6205
6447
|
if (item == user.identity) {
|
6206
6448
|
foundItemIndex = index;
|
@@ -6214,7 +6456,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6214
6456
|
this.fifoStack.splice(foundItemIndex, 1);
|
6215
6457
|
}
|
6216
6458
|
|
6217
|
-
this.emit(
|
6459
|
+
this.emit("userUnsubscribed", user);
|
6218
6460
|
}
|
6219
6461
|
}, {
|
6220
6462
|
key: "handleSubscribeUser",
|
@@ -6224,12 +6466,15 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6224
6466
|
}
|
6225
6467
|
|
6226
6468
|
if (this.fifoStack.length >= this.configuration.userInfosToSubscribe) {
|
6227
|
-
|
6469
|
+
var _this$subscribedUsers, _this$subscribedUsers2;
|
6470
|
+
|
6471
|
+
var item = this.fifoStack.shift();
|
6472
|
+
(_this$subscribedUsers = this.subscribedUsers) === null || _this$subscribedUsers === void 0 ? void 0 : (_this$subscribedUsers2 = _this$subscribedUsers.get(item)) === null || _this$subscribedUsers2 === void 0 ? void 0 : _this$subscribedUsers2.unsubscribe();
|
6228
6473
|
}
|
6229
6474
|
|
6230
6475
|
this.fifoStack.push(user.identity);
|
6231
6476
|
this.subscribedUsers.set(user.identity, user);
|
6232
|
-
this.emit(
|
6477
|
+
this.emit("userSubscribed", user);
|
6233
6478
|
}
|
6234
6479
|
/**
|
6235
6480
|
* Gets user, if it's in subscribed list - then return the user object from it,
|
@@ -6240,65 +6485,74 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6240
6485
|
}, {
|
6241
6486
|
key: "getUser",
|
6242
6487
|
value: function () {
|
6243
|
-
var _getUser = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(
|
6488
|
+
var _getUser = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
6244
6489
|
var _this2 = this;
|
6245
6490
|
|
6246
|
-
var
|
6491
|
+
var identity,
|
6492
|
+
entityName,
|
6247
6493
|
user,
|
6494
|
+
newUser,
|
6248
6495
|
_args = arguments;
|
6249
6496
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
6250
6497
|
while (1) {
|
6251
6498
|
switch (_context.prev = _context.next) {
|
6252
6499
|
case 0:
|
6253
|
-
|
6254
|
-
|
6500
|
+
identity = _args.length > 0 && _args[0] !== undefined ? _args[0] : "";
|
6501
|
+
entityName = _args.length > 1 && _args[1] !== undefined ? _args[1] : "";
|
6502
|
+
_context.next = 4;
|
6255
6503
|
return this.myself._ensureFetched();
|
6256
6504
|
|
6257
|
-
case
|
6505
|
+
case 4:
|
6258
6506
|
if (!(identity == this.myself.identity)) {
|
6259
|
-
_context.next =
|
6507
|
+
_context.next = 6;
|
6260
6508
|
break;
|
6261
6509
|
}
|
6262
6510
|
|
6263
6511
|
return _context.abrupt("return", this.myself);
|
6264
6512
|
|
6265
|
-
case
|
6513
|
+
case 6:
|
6266
6514
|
user = this.subscribedUsers.get(identity);
|
6267
6515
|
|
6268
|
-
if (user) {
|
6269
|
-
_context.next =
|
6516
|
+
if (!user) {
|
6517
|
+
_context.next = 9;
|
6270
6518
|
break;
|
6271
6519
|
}
|
6272
6520
|
|
6273
|
-
|
6274
|
-
|
6521
|
+
return _context.abrupt("return", user);
|
6522
|
+
|
6523
|
+
case 9:
|
6524
|
+
_context.t0 = entityName;
|
6525
|
+
|
6526
|
+
if (_context.t0) {
|
6527
|
+
_context.next = 14;
|
6275
6528
|
break;
|
6276
6529
|
}
|
6277
6530
|
|
6278
|
-
_context.next =
|
6531
|
+
_context.next = 13;
|
6279
6532
|
return this.getSyncUniqueName(identity);
|
6280
6533
|
|
6281
|
-
case
|
6282
|
-
|
6534
|
+
case 13:
|
6535
|
+
_context.t0 = _context.sent;
|
6283
6536
|
|
6284
|
-
case
|
6285
|
-
|
6286
|
-
|
6287
|
-
|
6537
|
+
case 14:
|
6538
|
+
entityName = _context.t0;
|
6539
|
+
newUser = new User(identity, entityName, this.configuration, this.services);
|
6540
|
+
newUser.on("updated", function (args) {
|
6541
|
+
return _this2.emit("userUpdated", args);
|
6288
6542
|
});
|
6289
|
-
|
6290
|
-
return _this2.handleSubscribeUser(
|
6543
|
+
newUser.on("userSubscribed", function () {
|
6544
|
+
return _this2.handleSubscribeUser(newUser);
|
6291
6545
|
});
|
6292
|
-
|
6293
|
-
return _this2.handleUnsubscribeUser(
|
6546
|
+
newUser.on("userUnsubscribed", function () {
|
6547
|
+
return _this2.handleUnsubscribeUser(newUser);
|
6294
6548
|
});
|
6295
|
-
_context.next =
|
6296
|
-
return
|
6549
|
+
_context.next = 21;
|
6550
|
+
return newUser._ensureFetched();
|
6297
6551
|
|
6298
|
-
case
|
6299
|
-
return _context.abrupt("return",
|
6552
|
+
case 21:
|
6553
|
+
return _context.abrupt("return", newUser);
|
6300
6554
|
|
6301
|
-
case
|
6555
|
+
case 22:
|
6302
6556
|
case "end":
|
6303
6557
|
return _context.stop();
|
6304
6558
|
}
|
@@ -6306,7 +6560,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6306
6560
|
}, _callee, this);
|
6307
6561
|
}));
|
6308
6562
|
|
6309
|
-
function getUser(
|
6563
|
+
function getUser() {
|
6310
6564
|
return _getUser.apply(this, arguments);
|
6311
6565
|
}
|
6312
6566
|
|
@@ -6357,6 +6611,8 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6357
6611
|
key: "getSyncUniqueName",
|
6358
6612
|
value: function () {
|
6359
6613
|
var _getSyncUniqueName = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(identity) {
|
6614
|
+
var _response$body$sync_o, _response$body;
|
6615
|
+
|
6360
6616
|
var url, response;
|
6361
6617
|
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
6362
6618
|
while (1) {
|
@@ -6368,7 +6624,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6368
6624
|
|
6369
6625
|
case 3:
|
6370
6626
|
response = _context3.sent;
|
6371
|
-
return _context3.abrupt("return", response.body.sync_objects.user_info_map);
|
6627
|
+
return _context3.abrupt("return", (_response$body$sync_o = (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.sync_objects.user_info_map) !== null && _response$body$sync_o !== void 0 ? _response$body$sync_o : "");
|
6372
6628
|
|
6373
6629
|
case 5:
|
6374
6630
|
case "end":
|
@@ -6378,7 +6634,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6378
6634
|
}, _callee3, this);
|
6379
6635
|
}));
|
6380
6636
|
|
6381
|
-
function getSyncUniqueName(
|
6637
|
+
function getSyncUniqueName(_x) {
|
6382
6638
|
return _getSyncUniqueName.apply(this, arguments);
|
6383
6639
|
}
|
6384
6640
|
|
@@ -6389,7 +6645,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6389
6645
|
return Users;
|
6390
6646
|
}(replayEventEmitter.ReplayEventEmitter);
|
6391
6647
|
|
6392
|
-
var log$1 = Logger.scope(
|
6648
|
+
var log$1 = Logger.scope("TypingIndicator");
|
6393
6649
|
/**
|
6394
6650
|
* An important note in regards to typing timeout timers. There are two places that the SDK can get the "typing_timeout" attribute from. The first
|
6395
6651
|
* place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the
|
@@ -6436,7 +6692,7 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6436
6692
|
var _this = this;
|
6437
6693
|
|
6438
6694
|
// this.services.notificationClient.subscribe(NotificationTypes.TYPING_INDICATOR, 'twilsock');
|
6439
|
-
this.services.notificationClient.on(
|
6695
|
+
this.services.notificationClient.on("message", /*#__PURE__*/function () {
|
6440
6696
|
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(type, message) {
|
6441
6697
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
6442
6698
|
while (1) {
|
@@ -6477,7 +6733,7 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6477
6733
|
while (1) {
|
6478
6734
|
switch (_context2.prev = _context2.next) {
|
6479
6735
|
case 0:
|
6480
|
-
log$1.trace(
|
6736
|
+
log$1.trace("Got new typing indicator ", message);
|
6481
6737
|
this.getConversation(message.channel_sid).then(function (conversation) {
|
6482
6738
|
if (!conversation) {
|
6483
6739
|
return;
|
@@ -6488,7 +6744,7 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6488
6744
|
return;
|
6489
6745
|
}
|
6490
6746
|
|
6491
|
-
var timeout = _this2.configuration.typingIndicatorTimeoutOverride + 1000
|
6747
|
+
var timeout = _this2.configuration.typingIndicatorTimeoutOverride ? _this2.configuration.typingIndicatorTimeoutOverride + 1000 : message.typing_timeout * 1000;
|
6492
6748
|
|
6493
6749
|
participant._startTyping(timeout);
|
6494
6750
|
});
|
@@ -6533,18 +6789,18 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6533
6789
|
value: function _send(conversationSid) {
|
6534
6790
|
var _this3 = this;
|
6535
6791
|
|
6536
|
-
log$1.trace(
|
6792
|
+
log$1.trace("Sending typing indicator");
|
6537
6793
|
var url = this.configuration.links.typing;
|
6538
6794
|
var headers = {
|
6539
|
-
|
6795
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
6540
6796
|
};
|
6541
6797
|
var body = "ChannelSid=".concat(conversationSid);
|
6542
6798
|
return this.services.twilsockClient.post(url, headers, body, this.configuration.productId).then(function (response) {
|
6543
|
-
if (response.body.hasOwnProperty(
|
6799
|
+
if (response.body.hasOwnProperty("typing_timeout")) {
|
6544
6800
|
_this3.serviceTypingTimeout = response.body.typing_timeout * 1000;
|
6545
6801
|
}
|
6546
6802
|
}).catch(function (err) {
|
6547
|
-
log$1.error(
|
6803
|
+
log$1.error("Failed to send typing indicator:", err);
|
6548
6804
|
throw err;
|
6549
6805
|
});
|
6550
6806
|
}
|
@@ -6600,14 +6856,14 @@ function PushNotification(data) {
|
|
6600
6856
|
this.data = data.data || {};
|
6601
6857
|
};
|
6602
6858
|
|
6603
|
-
var version = "2.0.
|
6859
|
+
var version = "2.1.0-rc.6";
|
6604
6860
|
|
6605
6861
|
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
6606
6862
|
|
6607
6863
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
6608
6864
|
|
6609
6865
|
var trimSlashes = function trimSlashes(url) {
|
6610
|
-
return url.replace(/(^\/+|\/+$)/g,
|
6866
|
+
return url.replace(/(^\/+|\/+$)/g, "");
|
6611
6867
|
};
|
6612
6868
|
|
6613
6869
|
var isMutationConflictResponse = function isMutationConflictResponse(response) {
|
@@ -6645,19 +6901,19 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
6645
6901
|
case 0:
|
6646
6902
|
preProcessedUrl = this._preProcessUrl(url);
|
6647
6903
|
finalHeaders = _objectSpread$1({
|
6648
|
-
|
6904
|
+
"Content-Type": "application/json; charset=utf-8"
|
6649
6905
|
}, headers || {});
|
6650
6906
|
_context.t0 = method;
|
6651
|
-
_context.next = _context.t0 ===
|
6907
|
+
_context.next = _context.t0 === "get" ? 5 : _context.t0 === "post" ? 11 : _context.t0 === "delete" ? 15 : 19;
|
6652
6908
|
break;
|
6653
6909
|
|
6654
6910
|
case 5:
|
6655
6911
|
getUrl = preProcessedUrl;
|
6656
6912
|
|
6657
6913
|
if (requestBody) {
|
6658
|
-
getUrl +=
|
6659
|
-
return entry.map(encodeURIComponent).join(
|
6660
|
-
}).join(
|
6914
|
+
getUrl += "?" + Object.entries(requestBody).map(function (entry) {
|
6915
|
+
return entry.map(encodeURIComponent).join("=");
|
6916
|
+
}).join("&");
|
6661
6917
|
}
|
6662
6918
|
|
6663
6919
|
_context.next = 9;
|
@@ -6677,7 +6933,7 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
6677
6933
|
|
6678
6934
|
case 15:
|
6679
6935
|
_context.next = 17;
|
6680
|
-
return this._services.transport.delete(preProcessedUrl, finalHeaders,
|
6936
|
+
return this._services.transport.delete(preProcessedUrl, finalHeaders, {}, this._productId);
|
6681
6937
|
|
6682
6938
|
case 17:
|
6683
6939
|
response = _context.sent;
|
@@ -6727,28 +6983,24 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
6727
6983
|
max: 1600,
|
6728
6984
|
maxAttemptsCount: maxAttemptsCount
|
6729
6985
|
}).run(function () {
|
6730
|
-
return _this._makeRequest(
|
6986
|
+
return _this._makeRequest("get", url, requestBody);
|
6731
6987
|
});
|
6732
6988
|
|
6733
6989
|
case 4:
|
6734
6990
|
result = _context2.sent;
|
6735
|
-
_context2.
|
6736
|
-
break;
|
6991
|
+
return _context2.abrupt("return", result.body);
|
6737
6992
|
|
6738
|
-
case
|
6739
|
-
_context2.prev =
|
6993
|
+
case 8:
|
6994
|
+
_context2.prev = 8;
|
6740
6995
|
_context2.t0 = _context2["catch"](1);
|
6741
6996
|
throw new Error("Fetch resource from \"".concat(url, "\" failed."));
|
6742
6997
|
|
6743
|
-
case 10:
|
6744
|
-
return _context2.abrupt("return", result.body);
|
6745
|
-
|
6746
6998
|
case 11:
|
6747
6999
|
case "end":
|
6748
7000
|
return _context2.stop();
|
6749
7001
|
}
|
6750
7002
|
}
|
6751
|
-
}, _callee2, null, [[1,
|
7003
|
+
}, _callee2, null, [[1, 8]]);
|
6752
7004
|
}));
|
6753
7005
|
|
6754
7006
|
function fetchResource(_x5, _x6) {
|
@@ -6768,7 +7020,7 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
6768
7020
|
case 0:
|
6769
7021
|
_context3.next = 2;
|
6770
7022
|
return this._makeRequest(method, url, requestBody, {
|
6771
|
-
|
7023
|
+
"X-Twilio-Mutation-Id": uuid.v4()
|
6772
7024
|
});
|
6773
7025
|
|
6774
7026
|
case 2:
|
@@ -6818,7 +7070,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
6818
7070
|
function _isNativeReflectConstruct() { 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; } }
|
6819
7071
|
|
6820
7072
|
var Client_1;
|
6821
|
-
var log = Logger.scope(
|
7073
|
+
var log = Logger.scope("Client");
|
6822
7074
|
var SDK_VERSION = version;
|
6823
7075
|
|
6824
7076
|
var ClientServices = function ClientServices() {
|
@@ -6866,22 +7118,14 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
6866
7118
|
|
6867
7119
|
_this = _super.call(this);
|
6868
7120
|
|
6869
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "connectionState",
|
6870
|
-
|
6871
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "conversationsPromise", null);
|
6872
|
-
|
6873
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_ensureReady", null);
|
6874
|
-
|
6875
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_resolveEnsureReady", null);
|
6876
|
-
|
6877
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_rejectEnsureReady", null);
|
7121
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "connectionState", "unknown");
|
6878
7122
|
|
6879
7123
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "version", SDK_VERSION);
|
6880
7124
|
|
6881
7125
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "parsePushNotification", Client_1.parsePushNotification);
|
6882
7126
|
|
6883
|
-
_this.fpaToken = fpaToken;
|
6884
|
-
_this.options = options;
|
7127
|
+
_this.fpaToken = fpaToken !== null && fpaToken !== void 0 ? fpaToken : "";
|
7128
|
+
_this.options = options !== null && options !== void 0 ? options : {};
|
6885
7129
|
|
6886
7130
|
if (!_this.options.disableDeepClone) {
|
6887
7131
|
var _options = _objectSpread(_objectSpread({}, _this.options), {}, {
|
@@ -6895,25 +7139,25 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
6895
7139
|
_this.options = _options;
|
6896
7140
|
}
|
6897
7141
|
|
6898
|
-
_this.options.logLevel = (_this$options$logLeve = _this.options.logLevel) !== null && _this$options$logLeve !== void 0 ? _this$options$logLeve :
|
7142
|
+
_this.options.logLevel = (_this$options$logLeve = _this.options.logLevel) !== null && _this$options$logLeve !== void 0 ? _this$options$logLeve : "silent";
|
6899
7143
|
log.setLevel(_this.options.logLevel);
|
6900
|
-
var productId = _this.options.productId =
|
7144
|
+
var productId = _this.options.productId = "ip_messaging"; // Filling ClientMetadata
|
6901
7145
|
|
6902
7146
|
_this.options.clientMetadata = _this.options.clientMetadata || {};
|
6903
7147
|
|
6904
|
-
if (!_this.options.clientMetadata.hasOwnProperty(
|
6905
|
-
_this.options.clientMetadata.type =
|
7148
|
+
if (!_this.options.clientMetadata.hasOwnProperty("type")) {
|
7149
|
+
_this.options.clientMetadata.type = "conversations";
|
6906
7150
|
}
|
6907
7151
|
|
6908
|
-
if (!_this.options.clientMetadata.hasOwnProperty(
|
6909
|
-
_this.options.clientMetadata.sdk =
|
7152
|
+
if (!_this.options.clientMetadata.hasOwnProperty("sdk")) {
|
7153
|
+
_this.options.clientMetadata.sdk = "JS";
|
6910
7154
|
_this.options.clientMetadata.sdkv = SDK_VERSION;
|
6911
7155
|
} // Enable session local storage for Sync
|
6912
7156
|
|
6913
7157
|
|
6914
7158
|
_this.options.Sync = _this.options.Sync || {};
|
6915
7159
|
|
6916
|
-
if (typeof _this.options.Sync.enableSessionStorage ===
|
7160
|
+
if (typeof _this.options.Sync.enableSessionStorage === "undefined") {
|
6917
7161
|
_this.options.Sync.enableSessionStorage = true;
|
6918
7162
|
}
|
6919
7163
|
|
@@ -6922,11 +7166,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
6922
7166
|
}
|
6923
7167
|
|
6924
7168
|
if (!fpaToken) {
|
6925
|
-
throw new Error(
|
7169
|
+
throw new Error("A valid Twilio token should be provided");
|
6926
7170
|
}
|
6927
7171
|
|
6928
7172
|
_this.services = new ClientServices();
|
6929
|
-
_this._myself = new User(
|
7173
|
+
_this._myself = new User("", "", null, _this.services);
|
6930
7174
|
var startTwilsock = !_this.options.twilsockClient; // Create default init registrations if none were provided.
|
6931
7175
|
// Otherwise, the outside party have to list all the init registrations they
|
6932
7176
|
// need.
|
@@ -6941,34 +7185,34 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
6941
7185
|
|
6942
7186
|
_this.services.twilsockClient = _this.options.twilsockClient = (_this$options$twilsoc = _this.options.twilsockClient) !== null && _this$options$twilsoc !== void 0 ? _this$options$twilsoc : new twilsock.TwilsockClient(fpaToken, productId, _this.options);
|
6943
7187
|
|
6944
|
-
_this.services.twilsockClient.on(
|
6945
|
-
return _this.emit(
|
7188
|
+
_this.services.twilsockClient.on("tokenAboutToExpire", function (ttl) {
|
7189
|
+
return _this.emit("tokenAboutToExpire", ttl);
|
6946
7190
|
});
|
6947
7191
|
|
6948
|
-
_this.services.twilsockClient.on(
|
6949
|
-
return _this.emit(
|
7192
|
+
_this.services.twilsockClient.on("tokenExpired", function () {
|
7193
|
+
return _this.emit("tokenExpired");
|
6950
7194
|
});
|
6951
7195
|
|
6952
|
-
_this.services.twilsockClient.on(
|
6953
|
-
return _this.emit(
|
7196
|
+
_this.services.twilsockClient.on("connectionError", function (error) {
|
7197
|
+
return _this.emit("connectionError", error);
|
6954
7198
|
});
|
6955
7199
|
|
6956
|
-
_this.services.twilsockClient.on(
|
7200
|
+
_this.services.twilsockClient.on("stateChanged", function (state) {
|
6957
7201
|
log.debug("Handling stateChanged for ConversationsClient: new state ".concat(state));
|
6958
7202
|
|
6959
7203
|
if (state !== _this.connectionState) {
|
6960
7204
|
_this.connectionState = state;
|
6961
7205
|
|
6962
|
-
_this.emit(
|
7206
|
+
_this.emit("connectionStateChanged", _this.connectionState);
|
6963
7207
|
}
|
6964
7208
|
});
|
6965
7209
|
|
6966
7210
|
_this.services.transport = _this.options.transport = (_this$options$transpo = _this.options.transport) !== null && _this$options$transpo !== void 0 ? _this$options$transpo : _this.options.twilsockClient;
|
6967
7211
|
_this.services.notificationClient = _this.options.notificationsClient = (_this$options$notific = _this.options.notificationsClient) !== null && _this$options$notific !== void 0 ? _this$options$notific : new notifications.Notifications(fpaToken, _this.options);
|
6968
7212
|
_this.services.syncClient = _this.options.syncClient = (_this$options$syncCli = _this.options.syncClient) !== null && _this$options$syncCli !== void 0 ? _this$options$syncCli : new twilioSync.SyncClient(fpaToken, _this.options);
|
6969
|
-
var configurationOptions = options.Chat || options.IPMessaging || options || {};
|
6970
|
-
var region = configurationOptions.region || options.region;
|
6971
|
-
var baseUrl = configurationOptions.apiUri || configurationOptions.typingUri || "https://aim.".concat(region ||
|
7213
|
+
var configurationOptions = (options === null || options === void 0 ? void 0 : options.Chat) || (options === null || options === void 0 ? void 0 : options.IPMessaging) || options || {};
|
7214
|
+
var region = configurationOptions.region || (options === null || options === void 0 ? void 0 : options.region);
|
7215
|
+
var baseUrl = configurationOptions.apiUri || configurationOptions.typingUri || "https://aim.".concat(region || "us1", ".twilio.com");
|
6972
7216
|
_this.services.commandExecutor = new CommandExecutor(baseUrl, {
|
6973
7217
|
transport: _this.options.transport
|
6974
7218
|
}, productId);
|
@@ -6976,15 +7220,15 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
6976
7220
|
var emitFailed = function emitFailed(err) {
|
6977
7221
|
_this._rejectEnsureReady(err);
|
6978
7222
|
|
6979
|
-
_this.emit(
|
7223
|
+
_this.emit("stateChanged", "failed");
|
6980
7224
|
};
|
6981
7225
|
|
6982
|
-
_this.services.twilsockClient.once(
|
7226
|
+
_this.services.twilsockClient.once("connectionError", emitFailed);
|
6983
7227
|
|
6984
|
-
_this.services.twilsockClient.once(
|
7228
|
+
_this.services.twilsockClient.once("disconnected", emitFailed); // ConversationsClient will be able to initialize only after twilsock is connected
|
6985
7229
|
|
6986
7230
|
|
6987
|
-
_this.services.twilsockClient.once(
|
7231
|
+
_this.services.twilsockClient.once("connected", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
6988
7232
|
var startupEvent;
|
6989
7233
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
6990
7234
|
while (1) {
|
@@ -6992,20 +7236,20 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
6992
7236
|
case 0:
|
6993
7237
|
log.debug("ConversationsClient started INITIALIZING");
|
6994
7238
|
|
6995
|
-
_this.services.twilsockClient.off(
|
7239
|
+
_this.services.twilsockClient.off("connectionError", emitFailed);
|
6996
7240
|
|
6997
|
-
_this.services.twilsockClient.off(
|
7241
|
+
_this.services.twilsockClient.off("disconnected", emitFailed);
|
6998
7242
|
|
6999
7243
|
_context.prev = 3;
|
7000
|
-
startupEvent =
|
7244
|
+
startupEvent = "conversations.client.startup";
|
7001
7245
|
|
7002
|
-
_this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription(startupEvent,
|
7246
|
+
_this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription(startupEvent, "Conversations client startup", new Date()), startupEvent, twilsock.TelemetryPoint.Start);
|
7003
7247
|
|
7004
7248
|
_context.next = 8;
|
7005
7249
|
return _this._initialize();
|
7006
7250
|
|
7007
7251
|
case 8:
|
7008
|
-
_this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription(
|
7252
|
+
_this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription("", "", new Date()), startupEvent, twilsock.TelemetryPoint.End);
|
7009
7253
|
|
7010
7254
|
_context.next = 15;
|
7011
7255
|
break;
|
@@ -7017,7 +7261,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7017
7261
|
// Fail ChatClient if initialization is incomplete
|
7018
7262
|
_this._rejectEnsureReady(_context.t0);
|
7019
7263
|
|
7020
|
-
_this.emit(
|
7264
|
+
_this.emit("stateChanged", "failed");
|
7021
7265
|
|
7022
7266
|
case 15:
|
7023
7267
|
case "end":
|
@@ -7030,7 +7274,9 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7030
7274
|
_this._ensureReady = new Promise(function (resolve, reject) {
|
7031
7275
|
_this._resolveEnsureReady = resolve;
|
7032
7276
|
_this._rejectEnsureReady = reject;
|
7033
|
-
}).catch(function (
|
7277
|
+
}).catch(function () {
|
7278
|
+
return void 0;
|
7279
|
+
}); // @todo How to process unhandled rejection here?
|
7034
7280
|
|
7035
7281
|
if (startTwilsock) {
|
7036
7282
|
_this.services.twilsockClient.connect();
|
@@ -7059,7 +7305,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7059
7305
|
key: "reachabilityEnabled",
|
7060
7306
|
get: function get() {
|
7061
7307
|
if (!this.configuration) {
|
7062
|
-
throw new Error(
|
7308
|
+
throw new Error("Reachability information could not yet be accessed as the client " + "has not yet been initialized. Subscribe to the 'stateChanged' event " + "to properly react to the client initialization.");
|
7063
7309
|
}
|
7064
7310
|
|
7065
7311
|
return this.configuration.reachabilityEnabled;
|
@@ -7099,7 +7345,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7099
7345
|
switch (_context2.prev = _context2.next) {
|
7100
7346
|
case 0:
|
7101
7347
|
_context2.next = 2;
|
7102
|
-
return this.services.commandExecutor.fetchResource(
|
7348
|
+
return this.services.commandExecutor.fetchResource("Client/v2/Configuration");
|
7103
7349
|
|
7104
7350
|
case 2:
|
7105
7351
|
configurationResponse = _context2.sent;
|
@@ -7110,31 +7356,55 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7110
7356
|
this.services.typingIndicator = new TypingIndicator(this.getConversationBySid.bind(this), this.configuration, this.services);
|
7111
7357
|
this.services.network = new Network(this.configuration, this.services);
|
7112
7358
|
this.services.users = new Users(this._myself, this.configuration, this.services);
|
7113
|
-
this.services.users.on(
|
7114
|
-
|
7115
|
-
|
7359
|
+
this.services.users.on("userSubscribed", function (user) {
|
7360
|
+
_this4.emit("userSubscribed", user);
|
7361
|
+
});
|
7362
|
+
this.services.users.on("userUpdated", function (args) {
|
7363
|
+
return _this4.emit("userUpdated", args);
|
7364
|
+
});
|
7365
|
+
this.services.users.on("userUnsubscribed", function (user) {
|
7366
|
+
_this4.emit("userUnsubscribed", user);
|
7116
7367
|
});
|
7117
|
-
this.services.users.on('userUnsubscribed', this.emit.bind(this, 'userUnsubscribed'));
|
7118
7368
|
this.conversations = new Conversations(this.configuration, this.services);
|
7119
|
-
this.conversations.on(
|
7120
|
-
|
7121
|
-
|
7122
|
-
this.conversations.on(
|
7123
|
-
|
7124
|
-
|
7369
|
+
this.conversations.on("conversationAdded", function (conversation) {
|
7370
|
+
_this4.emit("conversationAdded", conversation);
|
7371
|
+
});
|
7372
|
+
this.conversations.on("conversationRemoved", function (conversation) {
|
7373
|
+
_this4.emit("conversationRemoved", conversation);
|
7374
|
+
});
|
7375
|
+
this.conversations.on("conversationJoined", function (conversation) {
|
7376
|
+
_this4.emit("conversationJoined", conversation);
|
7377
|
+
});
|
7378
|
+
this.conversations.on("conversationLeft", function (conversation) {
|
7379
|
+
_this4.emit("conversationLeft", conversation);
|
7380
|
+
});
|
7381
|
+
this.conversations.on("conversationUpdated", function (args) {
|
7382
|
+
return _this4.emit("conversationUpdated", args);
|
7383
|
+
});
|
7384
|
+
this.conversations.on("participantJoined", function (participant) {
|
7385
|
+
_this4.emit("participantJoined", participant);
|
7386
|
+
});
|
7387
|
+
this.conversations.on("participantLeft", function (participant) {
|
7388
|
+
_this4.emit("participantLeft", participant);
|
7389
|
+
});
|
7390
|
+
this.conversations.on("participantUpdated", function (args) {
|
7391
|
+
return _this4.emit("participantUpdated", args);
|
7392
|
+
});
|
7393
|
+
this.conversations.on("messageAdded", function (message) {
|
7394
|
+
return _this4.emit("messageAdded", message);
|
7395
|
+
});
|
7396
|
+
this.conversations.on("messageUpdated", function (args) {
|
7397
|
+
return _this4.emit("messageUpdated", args);
|
7398
|
+
});
|
7399
|
+
this.conversations.on("messageRemoved", function (message) {
|
7400
|
+
return _this4.emit("messageRemoved", message);
|
7125
7401
|
});
|
7126
|
-
this.conversations.on(
|
7127
|
-
|
7128
|
-
this.conversations.on('participantUpdated', function (args) {
|
7129
|
-
return _this4.emit('participantUpdated', args);
|
7402
|
+
this.conversations.on("typingStarted", function (participant) {
|
7403
|
+
return _this4.emit("typingStarted", participant);
|
7130
7404
|
});
|
7131
|
-
this.conversations.on(
|
7132
|
-
|
7133
|
-
return _this4.emit('messageUpdated', args);
|
7405
|
+
this.conversations.on("typingEnded", function (participant) {
|
7406
|
+
return _this4.emit("typingEnded", participant);
|
7134
7407
|
});
|
7135
|
-
this.conversations.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));
|
7136
|
-
this.conversations.on('typingStarted', this.emit.bind(this, 'typingStarted'));
|
7137
|
-
this.conversations.on('typingEnded', this.emit.bind(this, 'typingEnded'));
|
7138
7408
|
this.conversationsPromise = this.conversations.fetchConversations().then(function () {
|
7139
7409
|
return _this4.conversations;
|
7140
7410
|
}).catch(function (error) {
|
@@ -7149,12 +7419,12 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7149
7419
|
});
|
7150
7420
|
this.services.typingIndicator.initialize();
|
7151
7421
|
this.services.mcsClient = new mcsClient.McsClient(this.fpaToken, this.configuration.links.mediaService, this.configuration.links.mediaSetService, _objectSpread(_objectSpread({}, this.options), {}, {
|
7152
|
-
transport:
|
7422
|
+
transport: undefined
|
7153
7423
|
}));
|
7154
7424
|
|
7155
7425
|
this._resolveEnsureReady();
|
7156
7426
|
|
7157
|
-
this.emit(
|
7427
|
+
this.emit("stateChanged", "initialized");
|
7158
7428
|
|
7159
7429
|
case 33:
|
7160
7430
|
case "end":
|
@@ -7220,7 +7490,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7220
7490
|
return this._ensureReady;
|
7221
7491
|
|
7222
7492
|
case 2:
|
7223
|
-
log.info(
|
7493
|
+
log.info("updateToken");
|
7224
7494
|
|
7225
7495
|
if (!(this.fpaToken === token)) {
|
7226
7496
|
_context4.next = 5;
|
@@ -7382,7 +7652,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7382
7652
|
}, {
|
7383
7653
|
key: "getSubscribedConversations",
|
7384
7654
|
value: function () {
|
7385
|
-
var _getSubscribedConversations = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee7(
|
7655
|
+
var _getSubscribedConversations = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee7() {
|
7386
7656
|
return _regeneratorRuntime__default['default'].wrap(function _callee7$(_context7) {
|
7387
7657
|
while (1) {
|
7388
7658
|
switch (_context7.prev = _context7.next) {
|
@@ -7392,7 +7662,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7392
7662
|
|
7393
7663
|
case 2:
|
7394
7664
|
return _context7.abrupt("return", this.conversationsPromise.then(function (conversations) {
|
7395
|
-
return conversations.getConversations(
|
7665
|
+
return conversations.getConversations();
|
7396
7666
|
}));
|
7397
7667
|
|
7398
7668
|
case 3:
|
@@ -7403,7 +7673,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7403
7673
|
}, _callee7, this);
|
7404
7674
|
}));
|
7405
7675
|
|
7406
|
-
function getSubscribedConversations(
|
7676
|
+
function getSubscribedConversations() {
|
7407
7677
|
return _getSubscribedConversations.apply(this, arguments);
|
7408
7678
|
}
|
7409
7679
|
|
@@ -7440,7 +7710,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7440
7710
|
}, _callee8, this);
|
7441
7711
|
}));
|
7442
7712
|
|
7443
|
-
function createConversation(
|
7713
|
+
function createConversation(_x4) {
|
7444
7714
|
return _createConversation.apply(this, arguments);
|
7445
7715
|
}
|
7446
7716
|
|
@@ -7478,7 +7748,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7478
7748
|
}, _callee9, this);
|
7479
7749
|
}));
|
7480
7750
|
|
7481
|
-
function setPushRegistrationId(
|
7751
|
+
function setPushRegistrationId(_x5, _x6) {
|
7482
7752
|
return _setPushRegistrationId.apply(this, arguments);
|
7483
7753
|
}
|
7484
7754
|
|
@@ -7515,7 +7785,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7515
7785
|
}, _callee10, this);
|
7516
7786
|
}));
|
7517
7787
|
|
7518
|
-
function unsetPushRegistrationId(
|
7788
|
+
function unsetPushRegistrationId(_x7) {
|
7519
7789
|
return _unsetPushRegistrationId.apply(this, arguments);
|
7520
7790
|
}
|
7521
7791
|
|
@@ -7551,7 +7821,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7551
7821
|
}, _callee11, this);
|
7552
7822
|
}));
|
7553
7823
|
|
7554
|
-
function removePushRegistrations(
|
7824
|
+
function removePushRegistrations(_x8, _x9) {
|
7555
7825
|
return _removePushRegistrations.apply(this, arguments);
|
7556
7826
|
}
|
7557
7827
|
|
@@ -7574,8 +7844,8 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7574
7844
|
return this._ensureReady;
|
7575
7845
|
|
7576
7846
|
case 2:
|
7577
|
-
log.debug(
|
7578
|
-
this.emit(
|
7847
|
+
log.debug("handlePushNotification, notificationPayload=", notificationPayload);
|
7848
|
+
this.emit("pushNotification", Client_1.parsePushNotification(notificationPayload));
|
7579
7849
|
|
7580
7850
|
case 4:
|
7581
7851
|
case "end":
|
@@ -7585,7 +7855,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7585
7855
|
}, _callee12, this);
|
7586
7856
|
}));
|
7587
7857
|
|
7588
|
-
function handlePushNotification(
|
7858
|
+
function handlePushNotification(_x10) {
|
7589
7859
|
return _handlePushNotification.apply(this, arguments);
|
7590
7860
|
}
|
7591
7861
|
|
@@ -7620,7 +7890,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7620
7890
|
}, _callee13, this);
|
7621
7891
|
}));
|
7622
7892
|
|
7623
|
-
function getUser(
|
7893
|
+
function getUser(_x11) {
|
7624
7894
|
return _getUser.apply(this, arguments);
|
7625
7895
|
}
|
7626
7896
|
|
@@ -7707,7 +7977,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7707
7977
|
break;
|
7708
7978
|
}
|
7709
7979
|
|
7710
|
-
throw new Error(
|
7980
|
+
throw new Error("Obsolete usage of ConversationsClient.create() " + "factory method: if you pass twilsock from the outside then you must " + "use ConversationsClient constructor and be prepared to work with " + "uninitialized client.");
|
7711
7981
|
|
7712
7982
|
case 2:
|
7713
7983
|
client = new Client_1(token, options);
|
@@ -7725,7 +7995,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7725
7995
|
}, _callee15);
|
7726
7996
|
}));
|
7727
7997
|
|
7728
|
-
function create(
|
7998
|
+
function create(_x12, _x13) {
|
7729
7999
|
return _create.apply(this, arguments);
|
7730
8000
|
}
|
7731
8001
|
|
@@ -7737,11 +8007,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7737
8007
|
var result = {};
|
7738
8008
|
|
7739
8009
|
for (var key in Client_1.supportedPushDataFields) {
|
7740
|
-
if (typeof data[key] ===
|
8010
|
+
if (typeof data[key] === "undefined" || data[key] === null) {
|
7741
8011
|
continue;
|
7742
8012
|
}
|
7743
8013
|
|
7744
|
-
if (key !==
|
8014
|
+
if (key !== "message_index") {
|
7745
8015
|
result[Client_1.supportedPushDataFields[key]] = data[key];
|
7746
8016
|
continue;
|
7747
8017
|
}
|
@@ -7761,19 +8031,19 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7761
8031
|
}, {
|
7762
8032
|
key: "parsePushNotification",
|
7763
8033
|
value: function parsePushNotification(notificationPayload) {
|
7764
|
-
log.debug(
|
8034
|
+
log.debug("parsePushNotification, notificationPayload=", notificationPayload); // APNS specifics
|
7765
8035
|
|
7766
|
-
if (typeof notificationPayload.aps !==
|
8036
|
+
if (typeof notificationPayload.aps !== "undefined") {
|
7767
8037
|
if (!notificationPayload.twi_message_type) {
|
7768
|
-
throw new Error(
|
8038
|
+
throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
|
7769
8039
|
}
|
7770
8040
|
|
7771
8041
|
var data = Client_1.parsePushNotificationChatData(notificationPayload);
|
7772
8042
|
var apsPayload = notificationPayload.aps;
|
7773
|
-
var body
|
8043
|
+
var body;
|
7774
8044
|
var title = null;
|
7775
8045
|
|
7776
|
-
if (typeof apsPayload.alert ===
|
8046
|
+
if (typeof apsPayload.alert === "string") {
|
7777
8047
|
body = apsPayload.alert || null;
|
7778
8048
|
} else {
|
7779
8049
|
body = apsPayload.alert.body || null;
|
@@ -7792,11 +8062,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7792
8062
|
} // FCM specifics
|
7793
8063
|
|
7794
8064
|
|
7795
|
-
if (typeof notificationPayload.data !==
|
8065
|
+
if (typeof notificationPayload.data !== "undefined") {
|
7796
8066
|
var dataPayload = notificationPayload.data;
|
7797
8067
|
|
7798
8068
|
if (!dataPayload.twi_message_type) {
|
7799
|
-
throw new Error(
|
8069
|
+
throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
|
7800
8070
|
}
|
7801
8071
|
|
7802
8072
|
var _data = Client_1.parsePushNotificationChatData(notificationPayload.data);
|
@@ -7812,16 +8082,16 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7812
8082
|
});
|
7813
8083
|
}
|
7814
8084
|
|
7815
|
-
throw new Error(
|
8085
|
+
throw new Error("Provided push notification payload is not Programmable Chat notification");
|
7816
8086
|
}
|
7817
8087
|
}]);
|
7818
8088
|
|
7819
8089
|
return Client;
|
7820
|
-
}(replayEventEmitter.ReplayEventEmitter), _defineProperty__default['default'](_class, "version", SDK_VERSION), _defineProperty__default['default'](_class, "supportedPushChannels", [
|
7821
|
-
|
7822
|
-
|
7823
|
-
|
7824
|
-
}), _defineProperty__default['default'](_class, "conversationAdded",
|
8090
|
+
}(replayEventEmitter.ReplayEventEmitter), _defineProperty__default['default'](_class, "version", SDK_VERSION), _defineProperty__default['default'](_class, "supportedPushChannels", ["fcm", "apn"]), _defineProperty__default['default'](_class, "supportedPushDataFields", {
|
8091
|
+
conversation_sid: "conversationSid",
|
8092
|
+
message_sid: "messageSid",
|
8093
|
+
message_index: "messageIndex"
|
8094
|
+
}), _defineProperty__default['default'](_class, "conversationAdded", "conversationAdded"), _defineProperty__default['default'](_class, "conversationJoined", "conversationJoined"), _defineProperty__default['default'](_class, "conversationLeft", "conversationLeft"), _defineProperty__default['default'](_class, "conversationRemoved", "conversationRemoved"), _defineProperty__default['default'](_class, "conversationUpdated", "conversationUpdated"), _defineProperty__default['default'](_class, "participantJoined", "participantJoined"), _defineProperty__default['default'](_class, "participantLeft", "participantLeft"), _defineProperty__default['default'](_class, "participantUpdated", "participantUpdated"), _defineProperty__default['default'](_class, "messageAdded", "messageAdded"), _defineProperty__default['default'](_class, "messageRemoved", "messageRemoved"), _defineProperty__default['default'](_class, "messageUpdated", "messageUpdated"), _defineProperty__default['default'](_class, "tokenAboutToExpire", "tokenAboutToExpire"), _defineProperty__default['default'](_class, "tokenExpired", "tokenExpired"), _defineProperty__default['default'](_class, "typingEnded", "typingEnded"), _defineProperty__default['default'](_class, "typingStarted", "typingStarted"), _defineProperty__default['default'](_class, "pushNotification", "pushNotification"), _defineProperty__default['default'](_class, "userSubscribed", "userSubscribed"), _defineProperty__default['default'](_class, "userUnsubscribed", "userUnsubscribed"), _defineProperty__default['default'](_class, "userUpdated", "userUpdated"), _defineProperty__default['default'](_class, "stateChanged", "stateChanged"), _defineProperty__default['default'](_class, "connectionStateChanged", "connectionStateChanged"), _defineProperty__default['default'](_class, "connectionError", "connectionError"), _temp);
|
7825
8095
|
|
7826
8096
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "updateToken", null);
|
7827
8097
|
|
@@ -7829,27 +8099,27 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
|
|
7829
8099
|
|
7830
8100
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "getConversationByUniqueName", null);
|
7831
8101
|
|
7832
|
-
__decorate([declarativeTypeValidator.validateTypesAsync([
|
7833
|
-
friendlyName: [
|
7834
|
-
isPrivate: [
|
7835
|
-
uniqueName: [
|
8102
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(["undefined", declarativeTypeValidator.objectSchema("conversation options", {
|
8103
|
+
friendlyName: ["string", "undefined"],
|
8104
|
+
isPrivate: ["boolean", "undefined"],
|
8105
|
+
uniqueName: ["string", "undefined"]
|
7836
8106
|
})]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], exports.Client.prototype, "createConversation", null);
|
7837
8107
|
|
7838
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal(
|
8108
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("fcm", "apn"), "string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "setPushRegistrationId", null);
|
7839
8109
|
|
7840
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal(
|
8110
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("fcm", "apn")), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "unsetPushRegistrationId", null);
|
7841
8111
|
|
7842
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal(
|
8112
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("fcm", "apn"), declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "removePushRegistrations", null);
|
7843
8113
|
|
7844
8114
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.pureObject), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], exports.Client.prototype, "handlePushNotification", null);
|
7845
8115
|
|
7846
8116
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "getUser", null);
|
7847
8117
|
|
7848
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
8118
|
+
__decorate([declarativeTypeValidator.validateTypesAsync("string", ["undefined", declarativeTypeValidator.pureObject]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], exports.Client, "create", null);
|
7849
8119
|
|
7850
8120
|
__decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.pureObject), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", PushNotification)], exports.Client, "parsePushNotification", null);
|
7851
8121
|
|
7852
|
-
exports.Client = Client_1 = __decorate([declarativeTypeValidator.validateConstructorTypes(declarativeTypeValidator.nonEmptyString, [declarativeTypeValidator.pureObject,
|
8122
|
+
exports.Client = Client_1 = __decorate([declarativeTypeValidator.validateConstructorTypes(declarativeTypeValidator.nonEmptyString, [declarativeTypeValidator.pureObject, "undefined"]), __metadata("design:paramtypes", [String, Object])], exports.Client);
|
7853
8123
|
|
7854
8124
|
exports.AggregatedDeliveryReceipt = AggregatedDeliveryReceipt;
|
7855
8125
|
exports.Conversation = Conversation;
|