@twilio/conversations 2.1.0-rc.0 → 2.1.0-rc.7
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 +61 -0
- package/NOTICE.txt +679 -0
- package/builds/browser.js +675 -588
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +301 -122
- package/builds/lib.js +675 -588
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +853 -910
- 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 +212 -153
- 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 +42 -38
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +93 -75
- 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 +4 -4
- package/dist/interfaces/attributes.js.map +1 -1
- 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 +10 -9
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +131 -83
- package/dist/message.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/participant.js +85 -51
- 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 +85 -59
- 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 -117
- package/docs/classes/Client.html +24 -147
- package/docs/classes/Conversation.html +30 -147
- package/docs/classes/DetailedDeliveryReceipt.html +1 -118
- package/docs/classes/Media.html +0 -117
- package/docs/classes/Message.html +7 -124
- package/docs/classes/MessageBuilder.html +2 -119
- package/docs/classes/Participant.html +7 -124
- package/docs/classes/PushNotification.html +0 -117
- package/docs/classes/RestPaginator.html +0 -117
- package/docs/classes/UnsentMessage.html +0 -117
- package/docs/classes/User.html +7 -124
- package/docs/index.html +56 -0
- package/docs/interfaces/ClientOptions.html +0 -117
- package/docs/interfaces/ConversationBindings.html +0 -117
- package/docs/interfaces/ConversationEmailBinding.html +0 -117
- package/docs/interfaces/ConversationState.html +0 -117
- package/docs/interfaces/CreateConversationOptions.html +1 -118
- package/docs/interfaces/LastMessage.html +0 -117
- package/docs/interfaces/Paginator.html +0 -117
- package/docs/interfaces/ParticipantBindings.html +0 -117
- package/docs/interfaces/ParticipantEmailBinding.html +0 -117
- package/docs/interfaces/PushNotificationData.html +0 -117
- package/docs/interfaces/SendEmailOptions.html +0 -117
- package/docs/interfaces/SendMediaOptions.html +0 -117
- package/docs/modules.html +56 -0
- package/package.json +23 -17
package/builds/browser.js
CHANGED
@@ -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;
|
@@ -551,16 +551,16 @@ var UriBuilder = /*#__PURE__*/function () {
|
|
551
551
|
}();
|
552
552
|
|
553
553
|
var attributesValidator = declarativeTypeValidator.custom(function (value) {
|
554
|
-
return [[
|
554
|
+
return [["string", "number", "boolean", "object"].includes(_typeof__default['default'](value)), "a JSON type"];
|
555
555
|
});
|
556
556
|
var optionalAttributesValidator = declarativeTypeValidator.custom(function (value) {
|
557
|
-
return [[
|
557
|
+
return [["undefined", "string", "number", "boolean", "object"].includes(_typeof__default['default'](value)), "an optional JSON type"];
|
558
558
|
});
|
559
559
|
|
560
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); }; }
|
561
561
|
|
562
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; } }
|
563
|
-
var log$8 = Logger.scope(
|
563
|
+
var log$8 = Logger.scope("User");
|
564
564
|
/**
|
565
565
|
* Extended user information.
|
566
566
|
* Note that `isOnline` and `isNotifiable` properties are eligible
|
@@ -585,14 +585,14 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
585
585
|
|
586
586
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "promiseToFetch", null);
|
587
587
|
|
588
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "updated",
|
588
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "updated", "updated");
|
589
589
|
|
590
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userSubscribed",
|
590
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userSubscribed", "userSubscribed");
|
591
591
|
|
592
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userUnsubscribed",
|
592
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "userUnsubscribed", "userUnsubscribed");
|
593
593
|
|
594
594
|
_this.services = services;
|
595
|
-
_this.subscribed =
|
595
|
+
_this.subscribed = "initializing";
|
596
596
|
|
597
597
|
_this.setMaxListeners(0);
|
598
598
|
|
@@ -685,7 +685,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
685
685
|
}, {
|
686
686
|
key: "isSubscribed",
|
687
687
|
get: function get() {
|
688
|
-
return this.subscribed ==
|
688
|
+
return this.subscribed == "subscribed";
|
689
689
|
} // Handles service updates
|
690
690
|
|
691
691
|
}, {
|
@@ -702,14 +702,14 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
702
702
|
|
703
703
|
case 2:
|
704
704
|
updateReasons = [];
|
705
|
-
log$8.debug(
|
705
|
+
log$8.debug("User for", this.state.identity, "updated:", key, value);
|
706
706
|
_context.t0 = key;
|
707
|
-
_context.next = _context.t0 ===
|
707
|
+
_context.next = _context.t0 === "friendlyName" ? 7 : _context.t0 === "attributes" ? 9 : _context.t0 === "reachability" ? 12 : 15;
|
708
708
|
break;
|
709
709
|
|
710
710
|
case 7:
|
711
711
|
if (this.state.friendlyName !== value.value) {
|
712
|
-
updateReasons.push(
|
712
|
+
updateReasons.push("friendlyName");
|
713
713
|
this.state.friendlyName = value.value;
|
714
714
|
}
|
715
715
|
|
@@ -720,7 +720,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
720
720
|
|
721
721
|
if (!isEqual__default['default'](this.state.attributes, updateAttributes)) {
|
722
722
|
this.state.attributes = updateAttributes;
|
723
|
-
updateReasons.push(
|
723
|
+
updateReasons.push("attributes");
|
724
724
|
}
|
725
725
|
|
726
726
|
return _context.abrupt("break", 16);
|
@@ -728,12 +728,12 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
728
728
|
case 12:
|
729
729
|
if (this.state.online !== value.online) {
|
730
730
|
this.state.online = value.online;
|
731
|
-
updateReasons.push(
|
731
|
+
updateReasons.push("reachabilityOnline");
|
732
732
|
}
|
733
733
|
|
734
734
|
if (this.state.notifiable !== value.notifiable) {
|
735
735
|
this.state.notifiable = value.notifiable;
|
736
|
-
updateReasons.push(
|
736
|
+
updateReasons.push("reachabilityNotifiable");
|
737
737
|
}
|
738
738
|
|
739
739
|
return _context.abrupt("break", 16);
|
@@ -743,7 +743,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
743
743
|
|
744
744
|
case 16:
|
745
745
|
if (updateReasons.length > 0) {
|
746
|
-
this.emit(
|
746
|
+
this.emit("updated", {
|
747
747
|
user: this,
|
748
748
|
updateReasons: updateReasons
|
749
749
|
});
|
@@ -786,8 +786,8 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
786
786
|
return _context2.abrupt("return", Promise.resolve());
|
787
787
|
|
788
788
|
case 4:
|
789
|
-
return _context2.abrupt("return", map.get(
|
790
|
-
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);
|
791
791
|
}));
|
792
792
|
|
793
793
|
case 5:
|
@@ -829,26 +829,26 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
829
829
|
case 4:
|
830
830
|
this.promiseToFetch = this.services.syncClient.map({
|
831
831
|
id: this.state.entityName,
|
832
|
-
mode:
|
832
|
+
mode: "open_existing",
|
833
833
|
includeItems: true
|
834
834
|
}).then(function (map) {
|
835
835
|
_this3.entity = map;
|
836
|
-
map.on(
|
837
|
-
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);
|
838
838
|
return _this3._update(args.item.key, args.item.data);
|
839
839
|
});
|
840
|
-
return Promise.all([map.get(
|
840
|
+
return Promise.all([map.get("friendlyName").then(function (item) {
|
841
841
|
return _this3._update(item.key, item.data);
|
842
|
-
}), map.get(
|
842
|
+
}), map.get("attributes").then(function (item) {
|
843
843
|
return _this3._update(item.key, item.data);
|
844
844
|
}), _this3._updateReachabilityInfo(map, function (item) {
|
845
845
|
return _this3._update(item.key, item.data);
|
846
846
|
})]);
|
847
847
|
}).then(function () {
|
848
|
-
log$8.debug(
|
849
|
-
_this3.subscribed =
|
848
|
+
log$8.debug("Fetched for", _this3.identity);
|
849
|
+
_this3.subscribed = "subscribed";
|
850
850
|
|
851
|
-
_this3.emit(
|
851
|
+
_this3.emit("userSubscribed", _this3);
|
852
852
|
|
853
853
|
return _this3;
|
854
854
|
}).catch(function (err) {
|
@@ -916,16 +916,16 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
916
916
|
return this._initializationPromise;
|
917
917
|
|
918
918
|
case 2:
|
919
|
-
if (!(this.subscribed ==
|
919
|
+
if (!(this.subscribed == "unsubscribed")) {
|
920
920
|
_context5.next = 4;
|
921
921
|
break;
|
922
922
|
}
|
923
923
|
|
924
|
-
throw new Error(
|
924
|
+
throw new Error("Can't modify unsubscribed object");
|
925
925
|
|
926
926
|
case 4:
|
927
927
|
_context5.next = 6;
|
928
|
-
return this.services.commandExecutor.mutateResource(
|
928
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
929
929
|
attributes: JSON.stringify(attributes)
|
930
930
|
});
|
931
931
|
|
@@ -963,16 +963,16 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
963
963
|
return this._initializationPromise;
|
964
964
|
|
965
965
|
case 2:
|
966
|
-
if (!(this.subscribed ==
|
966
|
+
if (!(this.subscribed == "unsubscribed")) {
|
967
967
|
_context6.next = 4;
|
968
968
|
break;
|
969
969
|
}
|
970
970
|
|
971
|
-
throw new Error(
|
971
|
+
throw new Error("Can't modify unsubscribed object");
|
972
972
|
|
973
973
|
case 4:
|
974
974
|
_context6.next = 6;
|
975
|
-
return this.services.commandExecutor.mutateResource(
|
975
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
976
976
|
friendly_name: friendlyName
|
977
977
|
});
|
978
978
|
|
@@ -1021,8 +1021,8 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1021
1021
|
case 5:
|
1022
1022
|
this.entity.close();
|
1023
1023
|
this.promiseToFetch = null;
|
1024
|
-
this.subscribed =
|
1025
|
-
this.emit(
|
1024
|
+
this.subscribed = "unsubscribed";
|
1025
|
+
this.emit("userUnsubscribed", this);
|
1026
1026
|
|
1027
1027
|
case 9:
|
1028
1028
|
case "end":
|
@@ -1051,9 +1051,9 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1051
1051
|
this._resolveInitializationPromise();
|
1052
1052
|
|
1053
1053
|
if (emitUpdated) {
|
1054
|
-
this.emit(
|
1054
|
+
this.emit("updated", {
|
1055
1055
|
user: this,
|
1056
|
-
updateReasons: [
|
1056
|
+
updateReasons: ["friendlyName", "attributes", "reachabilityOnline", "reachabilityNotifiable"]
|
1057
1057
|
});
|
1058
1058
|
}
|
1059
1059
|
}
|
@@ -1064,7 +1064,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1064
1064
|
|
1065
1065
|
__decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], User.prototype, "updateAttributes", null);
|
1066
1066
|
|
1067
|
-
__decorate([declarativeTypeValidator.validateTypesAsync([
|
1067
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], User.prototype, "updateFriendlyName", null);
|
1068
1068
|
|
1069
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; } } }; }
|
1070
1070
|
|
@@ -1137,13 +1137,13 @@ var Network = /*#__PURE__*/function () {
|
|
1137
1137
|
}
|
1138
1138
|
|
1139
1139
|
var retrier = new operationRetrier.Retrier(_this2.configuration.backoffConfiguration);
|
1140
|
-
retrier.on(
|
1140
|
+
retrier.on("attempt", function () {
|
1141
1141
|
request().then(function (result) {
|
1142
1142
|
return retrier.succeeded(result);
|
1143
1143
|
}).catch(function (err) {
|
1144
1144
|
if (codesToRetryOn.indexOf(err.status) > -1) {
|
1145
1145
|
retrier.failed(err);
|
1146
|
-
} else if (err.message ===
|
1146
|
+
} else if (err.message === "Twilsock disconnected") {
|
1147
1147
|
// Ugly hack. We must make a proper exceptions for twilsock
|
1148
1148
|
retrier.failed(err);
|
1149
1149
|
} else {
|
@@ -1154,13 +1154,13 @@ var Network = /*#__PURE__*/function () {
|
|
1154
1154
|
}
|
1155
1155
|
});
|
1156
1156
|
});
|
1157
|
-
retrier.on(
|
1157
|
+
retrier.on("succeeded", function (result) {
|
1158
1158
|
resolve(result);
|
1159
1159
|
});
|
1160
|
-
retrier.on(
|
1160
|
+
retrier.on("cancelled", function (err) {
|
1161
1161
|
return reject(err);
|
1162
1162
|
});
|
1163
|
-
retrier.on(
|
1163
|
+
retrier.on("failed", function (err) {
|
1164
1164
|
return reject(err);
|
1165
1165
|
});
|
1166
1166
|
retrier.start();
|
@@ -1225,20 +1225,20 @@ var NotificationTypes = function NotificationTypes() {
|
|
1225
1225
|
_classCallCheck__default['default'](this, NotificationTypes);
|
1226
1226
|
};
|
1227
1227
|
|
1228
|
-
_defineProperty__default['default'](NotificationTypes, "TYPING_INDICATOR",
|
1228
|
+
_defineProperty__default['default'](NotificationTypes, "TYPING_INDICATOR", "twilio.ipmsg.typing_indicator");
|
1229
1229
|
|
1230
|
-
_defineProperty__default['default'](NotificationTypes, "NEW_MESSAGE",
|
1230
|
+
_defineProperty__default['default'](NotificationTypes, "NEW_MESSAGE", "twilio.conversations.new_message");
|
1231
1231
|
|
1232
|
-
_defineProperty__default['default'](NotificationTypes, "ADDED_TO_CONVERSATION",
|
1232
|
+
_defineProperty__default['default'](NotificationTypes, "ADDED_TO_CONVERSATION", "twilio.conversations.added_to_conversation");
|
1233
1233
|
|
1234
|
-
_defineProperty__default['default'](NotificationTypes, "REMOVED_FROM_CONVERSATION",
|
1234
|
+
_defineProperty__default['default'](NotificationTypes, "REMOVED_FROM_CONVERSATION", "twilio.conversations.removed_from_conversation");
|
1235
1235
|
|
1236
|
-
_defineProperty__default['default'](NotificationTypes, "CONSUMPTION_UPDATE",
|
1236
|
+
_defineProperty__default['default'](NotificationTypes, "CONSUMPTION_UPDATE", "twilio.channel.consumption_update");
|
1237
1237
|
|
1238
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); }; }
|
1239
1239
|
|
1240
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; } }
|
1241
|
-
var log$7 = Logger.scope(
|
1241
|
+
var log$7 = Logger.scope("Participant");
|
1242
1242
|
/**
|
1243
1243
|
* A participant represents a remote client in a conversation.
|
1244
1244
|
*/
|
@@ -1252,7 +1252,7 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1252
1252
|
* @internal
|
1253
1253
|
*/
|
1254
1254
|
function Participant(data, sid, conversation, links, services) {
|
1255
|
-
var _data$bindings;
|
1255
|
+
var _data$roleSid, _data$bindings;
|
1256
1256
|
|
1257
1257
|
var _this;
|
1258
1258
|
|
@@ -1263,23 +1263,23 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1263
1263
|
_this.links = links;
|
1264
1264
|
_this.services = services;
|
1265
1265
|
_this.state = {
|
1266
|
-
attributes: parseAttributes(data.attributes,
|
1266
|
+
attributes: parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + sid, log$7),
|
1267
1267
|
dateCreated: data.dateCreated ? parseTime$1(data.dateCreated) : null,
|
1268
1268
|
dateUpdated: data.dateCreated ? parseTime$1(data.dateUpdated) : null,
|
1269
1269
|
sid: sid,
|
1270
1270
|
typingTimeout: null,
|
1271
1271
|
isTyping: false,
|
1272
|
-
identity: data.identity
|
1273
|
-
roleSid: data.roleSid
|
1272
|
+
identity: data.identity,
|
1273
|
+
roleSid: (_data$roleSid = data.roleSid) !== null && _data$roleSid !== void 0 ? _data$roleSid : "",
|
1274
1274
|
lastReadMessageIndex: Number.isInteger(data.lastConsumedMessageIndex) ? data.lastConsumedMessageIndex : null,
|
1275
1275
|
lastReadTimestamp: data.lastConsumptionTimestamp ? parseTime$1(data.lastConsumptionTimestamp) : null,
|
1276
|
-
type: data.type ||
|
1276
|
+
type: data.type || "chat",
|
1277
1277
|
userInfo: data.userInfo,
|
1278
1278
|
bindings: (_data$bindings = data.bindings) !== null && _data$bindings !== void 0 ? _data$bindings : {}
|
1279
1279
|
};
|
1280
1280
|
|
1281
1281
|
if (!data.identity && !data.type) {
|
1282
|
-
throw new Error(
|
1282
|
+
throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");
|
1283
1283
|
}
|
1284
1284
|
|
1285
1285
|
return _this;
|
@@ -1399,7 +1399,9 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1399
1399
|
}, {
|
1400
1400
|
key: "bindings",
|
1401
1401
|
get: function get() {
|
1402
|
-
|
1402
|
+
var _this$state$bindings;
|
1403
|
+
|
1404
|
+
return (_this$state$bindings = this.state.bindings) !== null && _this$state$bindings !== void 0 ? _this$state$bindings : {};
|
1403
1405
|
}
|
1404
1406
|
}, {
|
1405
1407
|
key: "_startTyping",
|
@@ -1411,13 +1413,16 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1411
1413
|
function _startTyping(timeout) {
|
1412
1414
|
var _this2 = this;
|
1413
1415
|
|
1414
|
-
|
1416
|
+
if (this.state.typingTimeout) {
|
1417
|
+
clearTimeout(this.state.typingTimeout);
|
1418
|
+
}
|
1419
|
+
|
1415
1420
|
this.state.isTyping = true;
|
1416
|
-
this.emit(
|
1417
|
-
this.conversation.emit(
|
1418
|
-
this.state.typingTimeout = setTimeout(function () {
|
1421
|
+
this.emit("typingStarted", this);
|
1422
|
+
this.conversation.emit("typingStarted", this);
|
1423
|
+
this.state.typingTimeout = Number(setTimeout(function () {
|
1419
1424
|
return _this2._endTyping();
|
1420
|
-
}, timeout);
|
1425
|
+
}, timeout));
|
1421
1426
|
return this;
|
1422
1427
|
}
|
1423
1428
|
/**
|
@@ -1433,8 +1438,8 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1433
1438
|
}
|
1434
1439
|
|
1435
1440
|
this.state.isTyping = false;
|
1436
|
-
this.emit(
|
1437
|
-
this.conversation.emit(
|
1441
|
+
this.emit("typingEnded", this);
|
1442
|
+
this.conversation.emit("typingEnded", this);
|
1438
1443
|
clearInterval(this.state.typingTimeout);
|
1439
1444
|
this.state.typingTimeout = null;
|
1440
1445
|
}
|
@@ -1447,35 +1452,35 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1447
1452
|
key: "_update",
|
1448
1453
|
value: function _update(data) {
|
1449
1454
|
var updateReasons = [];
|
1450
|
-
var updateAttributes = parseAttributes(data.attributes,
|
1455
|
+
var updateAttributes = parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + this.state.sid, log$7);
|
1451
1456
|
|
1452
1457
|
if (data.attributes && !isEqual__default['default'](this.state.attributes, updateAttributes)) {
|
1453
1458
|
this.state.attributes = updateAttributes;
|
1454
|
-
updateReasons.push(
|
1459
|
+
updateReasons.push("attributes");
|
1455
1460
|
}
|
1456
1461
|
|
1457
1462
|
var updatedDateUpdated = parseTime$1(data.dateUpdated);
|
1458
1463
|
|
1459
|
-
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())) {
|
1460
1465
|
this.state.dateUpdated = updatedDateUpdated;
|
1461
|
-
updateReasons.push(
|
1466
|
+
updateReasons.push("dateUpdated");
|
1462
1467
|
}
|
1463
1468
|
|
1464
1469
|
var updatedDateCreated = parseTime$1(data.dateCreated);
|
1465
1470
|
|
1466
|
-
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())) {
|
1467
1472
|
this.state.dateCreated = updatedDateCreated;
|
1468
|
-
updateReasons.push(
|
1473
|
+
updateReasons.push("dateCreated");
|
1469
1474
|
}
|
1470
1475
|
|
1471
1476
|
if (data.roleSid && this.state.roleSid !== data.roleSid) {
|
1472
1477
|
this.state.roleSid = data.roleSid;
|
1473
|
-
updateReasons.push(
|
1478
|
+
updateReasons.push("roleSid");
|
1474
1479
|
}
|
1475
1480
|
|
1476
1481
|
if ((Number.isInteger(data.lastConsumedMessageIndex) || data.lastConsumedMessageIndex === null) && this.state.lastReadMessageIndex !== data.lastConsumedMessageIndex) {
|
1477
1482
|
this.state.lastReadMessageIndex = data.lastConsumedMessageIndex;
|
1478
|
-
updateReasons.push(
|
1483
|
+
updateReasons.push("lastReadMessageIndex");
|
1479
1484
|
}
|
1480
1485
|
|
1481
1486
|
if (data.lastConsumptionTimestamp) {
|
@@ -1483,17 +1488,17 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1483
1488
|
|
1484
1489
|
if (!this.state.lastReadTimestamp || this.state.lastReadTimestamp.getTime() !== lastReadTimestamp.getTime()) {
|
1485
1490
|
this.state.lastReadTimestamp = lastReadTimestamp;
|
1486
|
-
updateReasons.push(
|
1491
|
+
updateReasons.push("lastReadTimestamp");
|
1487
1492
|
}
|
1488
1493
|
}
|
1489
1494
|
|
1490
1495
|
if (data.bindings && !isEqual__default['default'](this.state.bindings, data.bindings)) {
|
1491
1496
|
this.state.bindings = data.bindings;
|
1492
|
-
updateReasons.push(
|
1497
|
+
updateReasons.push("bindings");
|
1493
1498
|
}
|
1494
1499
|
|
1495
1500
|
if (updateReasons.length > 0) {
|
1496
|
-
this.emit(
|
1501
|
+
this.emit("updated", {
|
1497
1502
|
participant: this,
|
1498
1503
|
updateReasons: updateReasons
|
1499
1504
|
});
|
@@ -1513,12 +1518,12 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1513
1518
|
while (1) {
|
1514
1519
|
switch (_context.prev = _context.next) {
|
1515
1520
|
case 0:
|
1516
|
-
if (!(this.type !=
|
1521
|
+
if (!(this.type != "chat")) {
|
1517
1522
|
_context.next = 2;
|
1518
1523
|
break;
|
1519
1524
|
}
|
1520
1525
|
|
1521
|
-
throw new Error(
|
1526
|
+
throw new Error("Getting User is not supported for this Participant type: " + this.type);
|
1522
1527
|
|
1523
1528
|
case 2:
|
1524
1529
|
return _context.abrupt("return", this.services.users.getUser(this.state.identity, this.state.userInfo));
|
@@ -1579,7 +1584,7 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1579
1584
|
switch (_context3.prev = _context3.next) {
|
1580
1585
|
case 0:
|
1581
1586
|
_context3.next = 2;
|
1582
|
-
return this.services.commandExecutor.mutateResource(
|
1587
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
1583
1588
|
attributes: JSON.stringify(attributes)
|
1584
1589
|
});
|
1585
1590
|
|
@@ -1605,18 +1610,18 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1605
1610
|
return Participant;
|
1606
1611
|
}(replayEventEmitter.ReplayEventEmitter);
|
1607
1612
|
|
1608
|
-
_defineProperty__default['default'](Participant, "typingStarted",
|
1613
|
+
_defineProperty__default['default'](Participant, "typingStarted", "typingStarted");
|
1609
1614
|
|
1610
|
-
_defineProperty__default['default'](Participant, "typingEnded",
|
1615
|
+
_defineProperty__default['default'](Participant, "typingEnded", "typingEnded");
|
1611
1616
|
|
1612
|
-
_defineProperty__default['default'](Participant, "updated",
|
1617
|
+
_defineProperty__default['default'](Participant, "updated", "updated");
|
1613
1618
|
|
1614
1619
|
__decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Participant.prototype, "updateAttributes", null);
|
1615
1620
|
|
1616
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); }; }
|
1617
1622
|
|
1618
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; } }
|
1619
|
-
var log$6 = Logger.scope(
|
1624
|
+
var log$6 = Logger.scope("Participants");
|
1620
1625
|
/**
|
1621
1626
|
* @classdesc Represents the collection of participants for the conversation
|
1622
1627
|
* @fires Participants#participantJoined
|
@@ -1635,6 +1640,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1635
1640
|
_classCallCheck__default['default'](this, Participants);
|
1636
1641
|
|
1637
1642
|
_this = _super.call(this);
|
1643
|
+
|
1644
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "rosterEntityPromise", null);
|
1645
|
+
|
1638
1646
|
_this.conversation = conversation;
|
1639
1647
|
_this.participants = participants;
|
1640
1648
|
_this.links = links;
|
@@ -1686,17 +1694,17 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1686
1694
|
|
1687
1695
|
return this.rosterEntityPromise = this.rosterEntityPromise || this.services.syncClient.map({
|
1688
1696
|
id: rosterObjectName,
|
1689
|
-
mode:
|
1697
|
+
mode: "open_existing"
|
1690
1698
|
}).then(function (rosterMap) {
|
1691
|
-
rosterMap.on(
|
1692
|
-
log$6.debug(_this2.conversation.sid +
|
1699
|
+
rosterMap.on("itemAdded", function (args) {
|
1700
|
+
log$6.debug(_this2.conversation.sid + " itemAdded: " + args.item.key);
|
1693
1701
|
|
1694
1702
|
_this2.upsertParticipant(args.item.key, args.item.data).then(function (participant) {
|
1695
|
-
_this2.emit(
|
1703
|
+
_this2.emit("participantJoined", participant);
|
1696
1704
|
});
|
1697
1705
|
});
|
1698
|
-
rosterMap.on(
|
1699
|
-
log$6.debug(_this2.conversation.sid +
|
1706
|
+
rosterMap.on("itemRemoved", function (args) {
|
1707
|
+
log$6.debug(_this2.conversation.sid + " itemRemoved: " + args.key);
|
1700
1708
|
var participantSid = args.key;
|
1701
1709
|
|
1702
1710
|
if (!_this2.participants.has(participantSid)) {
|
@@ -1707,19 +1715,22 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1707
1715
|
|
1708
1716
|
_this2.participants.delete(participantSid);
|
1709
1717
|
|
1710
|
-
|
1718
|
+
if (!leftParticipant) {
|
1719
|
+
return;
|
1720
|
+
}
|
1721
|
+
|
1722
|
+
_this2.emit("participantLeft", leftParticipant);
|
1711
1723
|
});
|
1712
|
-
rosterMap.on(
|
1713
|
-
log$6.debug(_this2.conversation.sid +
|
1724
|
+
rosterMap.on("itemUpdated", function (args) {
|
1725
|
+
log$6.debug(_this2.conversation.sid + " itemUpdated: " + args.item.key);
|
1714
1726
|
|
1715
1727
|
_this2.upsertParticipant(args.item.key, args.item.data);
|
1716
1728
|
});
|
1717
1729
|
var participantsPromises = [];
|
1718
|
-
var that = _this2;
|
1719
1730
|
|
1720
1731
|
var rosterMapHandler = function rosterMapHandler(paginator) {
|
1721
1732
|
paginator.items.forEach(function (item) {
|
1722
|
-
participantsPromises.push(
|
1733
|
+
participantsPromises.push(_this2.upsertParticipant(item.key, item.data));
|
1723
1734
|
});
|
1724
1735
|
return paginator.hasNextPage ? paginator.nextPage().then(rosterMapHandler) : null;
|
1725
1736
|
};
|
@@ -1732,11 +1743,11 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1732
1743
|
}).catch(function (err) {
|
1733
1744
|
_this2.rosterEntityPromise = null;
|
1734
1745
|
|
1735
|
-
if (_this2.services.syncClient.connectionState !=
|
1736
|
-
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);
|
1737
1748
|
}
|
1738
1749
|
|
1739
|
-
log$6.debug(
|
1750
|
+
log$6.debug("ERROR: Failed to get roster object for conversation", _this2.conversation.sid, err);
|
1740
1751
|
throw err;
|
1741
1752
|
});
|
1742
1753
|
}
|
@@ -1766,8 +1777,8 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1766
1777
|
};
|
1767
1778
|
participant = new Participant(data, participantSid, this.conversation, links, this.services);
|
1768
1779
|
this.participants.set(participantSid, participant);
|
1769
|
-
participant.on(
|
1770
|
-
return _this3.emit(
|
1780
|
+
participant.on("updated", function (args) {
|
1781
|
+
return _this3.emit("participantUpdated", args);
|
1771
1782
|
});
|
1772
1783
|
return _context2.abrupt("return", participant);
|
1773
1784
|
|
@@ -1799,7 +1810,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1799
1810
|
while (1) {
|
1800
1811
|
switch (_context3.prev = _context3.next) {
|
1801
1812
|
case 0:
|
1802
|
-
return _context3.abrupt("return", this.rosterEntityPromise.then(function () {
|
1813
|
+
return _context3.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
|
1803
1814
|
var participants = [];
|
1804
1815
|
|
1805
1816
|
_this4.participants.forEach(function (participant) {
|
@@ -1807,7 +1818,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1807
1818
|
});
|
1808
1819
|
|
1809
1820
|
return participants;
|
1810
|
-
}));
|
1821
|
+
}) : []);
|
1811
1822
|
|
1812
1823
|
case 1:
|
1813
1824
|
case "end":
|
@@ -1838,15 +1849,15 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1838
1849
|
while (1) {
|
1839
1850
|
switch (_context4.prev = _context4.next) {
|
1840
1851
|
case 0:
|
1841
|
-
return _context4.abrupt("return", this.rosterEntityPromise.then(function () {
|
1852
|
+
return _context4.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
|
1842
1853
|
var participant = _this5.participants.get(participantSid);
|
1843
1854
|
|
1844
1855
|
if (!participant) {
|
1845
|
-
throw new Error(
|
1856
|
+
throw new Error("Participant with SID " + participantSid + " was not found");
|
1846
1857
|
}
|
1847
1858
|
|
1848
1859
|
return participant;
|
1849
|
-
}));
|
1860
|
+
}) : null);
|
1850
1861
|
|
1851
1862
|
case 1:
|
1852
1863
|
case "end":
|
@@ -1879,7 +1890,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1879
1890
|
switch (_context5.prev = _context5.next) {
|
1880
1891
|
case 0:
|
1881
1892
|
foundParticipant = null;
|
1882
|
-
return _context5.abrupt("return", this.rosterEntityPromise.then(function () {
|
1893
|
+
return _context5.abrupt("return", this.rosterEntityPromise ? this.rosterEntityPromise.then(function () {
|
1883
1894
|
_this6.participants.forEach(function (participant) {
|
1884
1895
|
if (participant.identity === identity) {
|
1885
1896
|
foundParticipant = participant;
|
@@ -1887,11 +1898,11 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1887
1898
|
});
|
1888
1899
|
|
1889
1900
|
if (!foundParticipant) {
|
1890
|
-
throw new Error(
|
1901
|
+
throw new Error("Participant with identity " + identity + " was not found");
|
1891
1902
|
}
|
1892
1903
|
|
1893
1904
|
return foundParticipant;
|
1894
|
-
}));
|
1905
|
+
}) : null);
|
1895
1906
|
|
1896
1907
|
case 2:
|
1897
1908
|
case "end":
|
@@ -1909,7 +1920,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1909
1920
|
}()
|
1910
1921
|
/**
|
1911
1922
|
* Add a chat participant to the conversation
|
1912
|
-
* @returns {Promise<
|
1923
|
+
* @returns {Promise<ParticipantResponse>}
|
1913
1924
|
*/
|
1914
1925
|
|
1915
1926
|
}, {
|
@@ -1921,9 +1932,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1921
1932
|
switch (_context6.prev = _context6.next) {
|
1922
1933
|
case 0:
|
1923
1934
|
_context6.next = 2;
|
1924
|
-
return this.services.commandExecutor.mutateResource(
|
1935
|
+
return this.services.commandExecutor.mutateResource("post", this.links.participants, {
|
1925
1936
|
identity: identity,
|
1926
|
-
attributes: typeof attributes !==
|
1937
|
+
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
|
1927
1938
|
});
|
1928
1939
|
|
1929
1940
|
case 2:
|
@@ -1960,8 +1971,8 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1960
1971
|
|
1961
1972
|
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
1962
1973
|
var bindingOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
1963
|
-
return this.services.commandExecutor.mutateResource(
|
1964
|
-
attributes: typeof attributes !==
|
1974
|
+
return this.services.commandExecutor.mutateResource("post", this.links.participants, {
|
1975
|
+
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined,
|
1965
1976
|
messaging_binding: {
|
1966
1977
|
address: address,
|
1967
1978
|
proxy_address: proxyAddress,
|
@@ -1977,7 +1988,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1977
1988
|
}, {
|
1978
1989
|
key: "remove",
|
1979
1990
|
value: function remove(identity) {
|
1980
|
-
return this.services.commandExecutor.mutateResource(
|
1991
|
+
return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(identity));
|
1981
1992
|
}
|
1982
1993
|
}]);
|
1983
1994
|
|
@@ -2088,6 +2099,8 @@ var Media = /*#__PURE__*/function () {
|
|
2088
2099
|
key: "getContentTemporaryUrl",
|
2089
2100
|
value: function () {
|
2090
2101
|
var _getContentTemporaryUrl = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
2102
|
+
var _this$mcsMedia$getCon, _this$mcsMedia;
|
2103
|
+
|
2091
2104
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
2092
2105
|
while (1) {
|
2093
2106
|
switch (_context.prev = _context.next) {
|
@@ -2096,7 +2109,7 @@ var Media = /*#__PURE__*/function () {
|
|
2096
2109
|
return this._fetchMcsMedia();
|
2097
2110
|
|
2098
2111
|
case 2:
|
2099
|
-
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);
|
2100
2113
|
|
2101
2114
|
case 3:
|
2102
2115
|
case "end":
|
@@ -2126,6 +2139,8 @@ var Media = /*#__PURE__*/function () {
|
|
2126
2139
|
key: "getCachedTemporaryUrl",
|
2127
2140
|
value: function () {
|
2128
2141
|
var _getCachedTemporaryUrl = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
2142
|
+
var _this$mcsMedia$getCac, _this$mcsMedia2;
|
2143
|
+
|
2129
2144
|
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
2130
2145
|
while (1) {
|
2131
2146
|
switch (_context2.prev = _context2.next) {
|
@@ -2134,7 +2149,7 @@ var Media = /*#__PURE__*/function () {
|
|
2134
2149
|
return this._fetchMcsMedia();
|
2135
2150
|
|
2136
2151
|
case 2:
|
2137
|
-
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);
|
2138
2153
|
|
2139
2154
|
case 3:
|
2140
2155
|
case "end":
|
@@ -2177,7 +2192,7 @@ var Media = /*#__PURE__*/function () {
|
|
2177
2192
|
break;
|
2178
2193
|
|
2179
2194
|
case 7:
|
2180
|
-
throw new Error(
|
2195
|
+
throw new Error("Media Content Service is unavailable");
|
2181
2196
|
|
2182
2197
|
case 8:
|
2183
2198
|
case "end":
|
@@ -2371,7 +2386,7 @@ var RestPaginator = /*#__PURE__*/function () {
|
|
2371
2386
|
}, {
|
2372
2387
|
key: "nextPage",
|
2373
2388
|
value: function nextPage() {
|
2374
|
-
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"));
|
2375
2390
|
}
|
2376
2391
|
/**
|
2377
2392
|
* Request the previous page. Does not modify the existing object.
|
@@ -2380,7 +2395,7 @@ var RestPaginator = /*#__PURE__*/function () {
|
|
2380
2395
|
}, {
|
2381
2396
|
key: "prevPage",
|
2382
2397
|
value: function prevPage() {
|
2383
|
-
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"));
|
2384
2399
|
}
|
2385
2400
|
}]);
|
2386
2401
|
|
@@ -2439,7 +2454,7 @@ function DetailedDeliveryReceipt(descriptor) {
|
|
2439
2454
|
this.conversationSid = descriptor.conversation_sid;
|
2440
2455
|
this.channelMessageSid = descriptor.channel_message_sid;
|
2441
2456
|
this.participantSid = descriptor.participant_sid;
|
2442
|
-
this.status = descriptor.status ||
|
2457
|
+
this.status = descriptor.status || "queued";
|
2443
2458
|
this.errorCode = descriptor.error_code || 0;
|
2444
2459
|
this.dateCreated = descriptor.date_created;
|
2445
2460
|
this.dateUpdated = descriptor.date_updated;
|
@@ -2448,7 +2463,7 @@ function DetailedDeliveryReceipt(descriptor) {
|
|
2448
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); }; }
|
2449
2464
|
|
2450
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; } }
|
2451
|
-
var log$5 = Logger.scope(
|
2466
|
+
var log$5 = Logger.scope("Message");
|
2452
2467
|
/**
|
2453
2468
|
* A message in a conversation.
|
2454
2469
|
*/
|
@@ -2466,7 +2481,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2466
2481
|
* @internal
|
2467
2482
|
*/
|
2468
2483
|
function Message(index, data, conversation, links, configuration, services) {
|
2469
|
-
var _data$
|
2484
|
+
var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid;
|
2470
2485
|
|
2471
2486
|
var _this;
|
2472
2487
|
|
@@ -2480,16 +2495,16 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2480
2495
|
_this.state = {
|
2481
2496
|
sid: data.sid,
|
2482
2497
|
index: index,
|
2483
|
-
author:
|
2484
|
-
subject:
|
2485
|
-
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,
|
2486
2501
|
timestamp: data.timestamp ? new Date(data.timestamp) : null,
|
2487
2502
|
dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,
|
2488
2503
|
lastUpdatedBy: (_data$lastUpdatedBy = data.lastUpdatedBy) !== null && _data$lastUpdatedBy !== void 0 ? _data$lastUpdatedBy : null,
|
2489
2504
|
attributes: parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(data.sid), log$5),
|
2490
|
-
type: (_data$type = data.type) !== null && _data$type !== void 0 ? _data$type :
|
2491
|
-
media: data.type && data.type ===
|
2492
|
-
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) {
|
2493
2508
|
return new Media(m, _this.services);
|
2494
2509
|
}) : null,
|
2495
2510
|
participantSid: (_data$memberSid = data.memberSid) !== null && _data$memberSid !== void 0 ? _data$memberSid : null,
|
@@ -2622,7 +2637,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2622
2637
|
}, {
|
2623
2638
|
key: "attachedMedia",
|
2624
2639
|
get: function get() {
|
2625
|
-
return this.getMediaByCategory([
|
2640
|
+
return this.getMediaByCategory(["media"]);
|
2626
2641
|
}
|
2627
2642
|
/**
|
2628
2643
|
* The server-assigned unique identifier of the authoring participant.
|
@@ -2654,7 +2669,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2654
2669
|
value: function getMediaByCategory(categories) {
|
2655
2670
|
var _this$state$medias;
|
2656
2671
|
|
2657
|
-
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) {
|
2658
2673
|
return categories.includes(m.category);
|
2659
2674
|
});
|
2660
2675
|
}
|
@@ -2669,8 +2684,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2669
2684
|
value: function getEmailBody() {
|
2670
2685
|
var _this$getMediaByCateg, _this$getMediaByCateg2;
|
2671
2686
|
|
2672
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
2673
|
-
return (_this$getMediaByCateg = (_this$getMediaByCateg2 = this.getMediaByCategory([
|
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) {
|
2674
2689
|
return m.contentType == type;
|
2675
2690
|
}).shift()) !== null && _this$getMediaByCateg !== void 0 ? _this$getMediaByCateg : null;
|
2676
2691
|
}
|
@@ -2685,8 +2700,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2685
2700
|
value: function getEmailHistory() {
|
2686
2701
|
var _this$getMediaByCateg3, _this$getMediaByCateg4;
|
2687
2702
|
|
2688
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
2689
|
-
return (_this$getMediaByCateg3 = (_this$getMediaByCateg4 = this.getMediaByCategory([
|
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) {
|
2690
2705
|
return m.contentType == type;
|
2691
2706
|
}).shift()) !== null && _this$getMediaByCateg3 !== void 0 ? _this$getMediaByCateg3 : null;
|
2692
2707
|
}
|
@@ -2695,41 +2710,41 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2695
2710
|
value: function _update(data) {
|
2696
2711
|
var updateReasons = [];
|
2697
2712
|
|
2698
|
-
if ((data.text || typeof data.text ===
|
2713
|
+
if ((data.text || typeof data.text === "string") && data.text !== this.state.body) {
|
2699
2714
|
this.state.body = data.text;
|
2700
|
-
updateReasons.push(
|
2715
|
+
updateReasons.push("body");
|
2701
2716
|
}
|
2702
2717
|
|
2703
2718
|
if (data.subject && data.subject !== this.state.subject) {
|
2704
2719
|
this.state.subject = data.subject;
|
2705
|
-
updateReasons.push(
|
2720
|
+
updateReasons.push("subject");
|
2706
2721
|
}
|
2707
2722
|
|
2708
2723
|
if (data.lastUpdatedBy && data.lastUpdatedBy !== this.state.lastUpdatedBy) {
|
2709
2724
|
this.state.lastUpdatedBy = data.lastUpdatedBy;
|
2710
|
-
updateReasons.push(
|
2725
|
+
updateReasons.push("lastUpdatedBy");
|
2711
2726
|
}
|
2712
2727
|
|
2713
2728
|
if (data.author && data.author !== this.state.author) {
|
2714
2729
|
this.state.author = data.author;
|
2715
|
-
updateReasons.push(
|
2730
|
+
updateReasons.push("author");
|
2716
2731
|
}
|
2717
2732
|
|
2718
2733
|
if (data.dateUpdated && new Date(data.dateUpdated).getTime() !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
|
2719
2734
|
this.state.dateUpdated = new Date(data.dateUpdated);
|
2720
|
-
updateReasons.push(
|
2735
|
+
updateReasons.push("dateUpdated");
|
2721
2736
|
}
|
2722
2737
|
|
2723
2738
|
if (data.timestamp && new Date(data.timestamp).getTime() !== (this.state.timestamp && this.state.timestamp.getTime())) {
|
2724
2739
|
this.state.timestamp = new Date(data.timestamp);
|
2725
|
-
updateReasons.push(
|
2740
|
+
updateReasons.push("dateCreated");
|
2726
2741
|
}
|
2727
2742
|
|
2728
2743
|
var updatedAttributes = parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(this.sid), log$5);
|
2729
2744
|
|
2730
2745
|
if (!isEqual__default['default'](this.state.attributes, updatedAttributes)) {
|
2731
2746
|
this.state.attributes = updatedAttributes;
|
2732
|
-
updateReasons.push(
|
2747
|
+
updateReasons.push("attributes");
|
2733
2748
|
}
|
2734
2749
|
|
2735
2750
|
var updatedAggregatedDelivery = data.delivery;
|
@@ -2739,16 +2754,16 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2739
2754
|
if (isUpdatedAggregateDeliveryValid) {
|
2740
2755
|
if (!currentAggregatedDelivery) {
|
2741
2756
|
this.state.aggregatedDeliveryReceipt = new AggregatedDeliveryReceipt(updatedAggregatedDelivery);
|
2742
|
-
updateReasons.push(
|
2757
|
+
updateReasons.push("deliveryReceipt");
|
2743
2758
|
} else if (!currentAggregatedDelivery._isEquals(updatedAggregatedDelivery)) {
|
2744
2759
|
currentAggregatedDelivery._update(updatedAggregatedDelivery);
|
2745
2760
|
|
2746
|
-
updateReasons.push(
|
2761
|
+
updateReasons.push("deliveryReceipt");
|
2747
2762
|
}
|
2748
2763
|
}
|
2749
2764
|
|
2750
2765
|
if (updateReasons.length > 0) {
|
2751
|
-
this.emit(
|
2766
|
+
this.emit("updated", {
|
2752
2767
|
message: this,
|
2753
2768
|
updateReasons: updateReasons
|
2754
2769
|
});
|
@@ -2777,7 +2792,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2777
2792
|
}
|
2778
2793
|
|
2779
2794
|
_context.next = 4;
|
2780
|
-
return this.conversation.getParticipantBySid(this.participantSid).catch(function () {
|
2795
|
+
return this.conversation.getParticipantBySid(this.state.participantSid).catch(function () {
|
2781
2796
|
log$5.debug("Participant with sid \"".concat(_this2.participantSid, "\" not found for message ").concat(_this2.sid));
|
2782
2797
|
return null;
|
2783
2798
|
});
|
@@ -2809,25 +2824,25 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2809
2824
|
return _context.abrupt("return", participant);
|
2810
2825
|
|
2811
2826
|
case 11:
|
2812
|
-
errorMesage =
|
2827
|
+
errorMesage = "Participant with ";
|
2813
2828
|
|
2814
2829
|
if (this.state.participantSid) {
|
2815
|
-
errorMesage +=
|
2830
|
+
errorMesage += "SID '" + this.state.participantSid + "' ";
|
2816
2831
|
}
|
2817
2832
|
|
2818
2833
|
if (this.state.author) {
|
2819
2834
|
if (this.state.participantSid) {
|
2820
|
-
errorMesage +=
|
2835
|
+
errorMesage += "or ";
|
2821
2836
|
}
|
2822
2837
|
|
2823
|
-
errorMesage +=
|
2838
|
+
errorMesage += "identity '" + this.state.author + "' ";
|
2824
2839
|
}
|
2825
2840
|
|
2826
|
-
if (errorMesage ===
|
2827
|
-
errorMesage =
|
2841
|
+
if (errorMesage === "Participant with ") {
|
2842
|
+
errorMesage = "Participant ";
|
2828
2843
|
}
|
2829
2844
|
|
2830
|
-
errorMesage +=
|
2845
|
+
errorMesage += "was not found";
|
2831
2846
|
throw new Error(errorMesage);
|
2832
2847
|
|
2833
2848
|
case 17:
|
@@ -2914,7 +2929,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2914
2929
|
switch (_context3.prev = _context3.next) {
|
2915
2930
|
case 0:
|
2916
2931
|
_context3.next = 2;
|
2917
|
-
return this.services.commandExecutor.mutateResource(
|
2932
|
+
return this.services.commandExecutor.mutateResource("delete", this.links.self);
|
2918
2933
|
|
2919
2934
|
case 2:
|
2920
2935
|
return _context3.abrupt("return", this);
|
@@ -2947,7 +2962,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2947
2962
|
switch (_context4.prev = _context4.next) {
|
2948
2963
|
case 0:
|
2949
2964
|
_context4.next = 2;
|
2950
|
-
return this.services.commandExecutor.mutateResource(
|
2965
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
2951
2966
|
body: body
|
2952
2967
|
});
|
2953
2968
|
|
@@ -2982,8 +2997,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2982
2997
|
switch (_context5.prev = _context5.next) {
|
2983
2998
|
case 0:
|
2984
2999
|
_context5.next = 2;
|
2985
|
-
return this.services.commandExecutor.mutateResource(
|
2986
|
-
attributes: typeof attributes !==
|
3000
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
3001
|
+
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
|
2987
3002
|
});
|
2988
3003
|
|
2989
3004
|
case 2:
|
@@ -3021,11 +3036,11 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3021
3036
|
case 0:
|
3022
3037
|
// We ignore existing mcsMedia members of each of the media entries.
|
3023
3038
|
// Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.
|
3024
|
-
sids = contentSet.map(function (m) {
|
3039
|
+
sids = contentSet === null || contentSet === void 0 ? void 0 : contentSet.map(function (m) {
|
3025
3040
|
return m.sid;
|
3026
3041
|
});
|
3027
3042
|
|
3028
|
-
if (!this.services.mcsClient) {
|
3043
|
+
if (!(this.services.mcsClient && sids)) {
|
3029
3044
|
_context6.next = 7;
|
3030
3045
|
break;
|
3031
3046
|
}
|
@@ -3039,7 +3054,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3039
3054
|
}));
|
3040
3055
|
|
3041
3056
|
case 7:
|
3042
|
-
throw new Error(
|
3057
|
+
throw new Error("Media Content Service is unavailable");
|
3043
3058
|
|
3044
3059
|
case 8:
|
3045
3060
|
case "end":
|
@@ -3066,8 +3081,8 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3066
3081
|
while (1) {
|
3067
3082
|
switch (_context7.prev = _context7.next) {
|
3068
3083
|
case 0:
|
3069
|
-
messagesReceiptsUrl = this.configuration.links.messagesReceipts.replace(
|
3070
|
-
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();
|
3071
3086
|
_context7.next = 4;
|
3072
3087
|
return this.services.network.get(url);
|
3073
3088
|
|
@@ -3101,20 +3116,20 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3101
3116
|
return Message;
|
3102
3117
|
}(replayEventEmitter.ReplayEventEmitter);
|
3103
3118
|
|
3104
|
-
_defineProperty__default['default'](Message, "updated",
|
3119
|
+
_defineProperty__default['default'](Message, "updated", "updated");
|
3105
3120
|
|
3106
|
-
__decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [
|
3121
|
+
__decorate([declarativeTypeValidator.validateTypes([declarativeTypeValidator.nonEmptyString, "undefined"]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailBody", null);
|
3107
3122
|
|
3108
|
-
__decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [
|
3123
|
+
__decorate([declarativeTypeValidator.validateTypes([declarativeTypeValidator.nonEmptyString, "undefined"]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailHistory", null);
|
3109
3124
|
|
3110
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
3125
|
+
__decorate([declarativeTypeValidator.validateTypesAsync("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Message.prototype, "updateBody", null);
|
3111
3126
|
|
3112
3127
|
__decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Message.prototype, "updateAttributes", null);
|
3113
3128
|
|
3114
3129
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.custom(function (value) {
|
3115
3130
|
return [value instanceof Array && value.length > 0 && value.reduce(function (a, c) {
|
3116
3131
|
return a && c instanceof Media;
|
3117
|
-
}, true),
|
3132
|
+
}, true), "a non-empty array of Media"];
|
3118
3133
|
})), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", Promise)], Message.prototype, "attachTemporaryUrlsFor", null);
|
3119
3134
|
|
3120
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; } } }; }
|
@@ -3126,7 +3141,7 @@ function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) le
|
|
3126
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); }; }
|
3127
3142
|
|
3128
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; } }
|
3129
|
-
var log$4 = Logger.scope(
|
3144
|
+
var log$4 = Logger.scope("Messages");
|
3130
3145
|
/**
|
3131
3146
|
* Represents the collection of messages in a conversation
|
3132
3147
|
*/
|
@@ -3176,7 +3191,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3176
3191
|
case 2:
|
3177
3192
|
this.messagesListPromise = this.services.syncClient.list({
|
3178
3193
|
id: name,
|
3179
|
-
mode:
|
3194
|
+
mode: "open_existing"
|
3180
3195
|
});
|
3181
3196
|
_context.prev = 3;
|
3182
3197
|
_context.next = 6;
|
@@ -3184,7 +3199,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3184
3199
|
|
3185
3200
|
case 6:
|
3186
3201
|
list = _context.sent;
|
3187
|
-
list.on(
|
3202
|
+
list.on("itemAdded", function (args) {
|
3188
3203
|
log$4.debug("".concat(_this2.conversation.sid, " itemAdded: ").concat(args.item.index));
|
3189
3204
|
var links = {
|
3190
3205
|
self: "".concat(_this2.conversation.links.messages, "/").concat(args.item.data.sid),
|
@@ -3194,33 +3209,37 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3194
3209
|
var message = new Message(args.item.index, args.item.data, _this2.conversation, links, _this2.configuration, _this2.services);
|
3195
3210
|
|
3196
3211
|
if (_this2.messagesByIndex.has(message.index)) {
|
3197
|
-
log$4.debug(
|
3212
|
+
log$4.debug("Message arrived, but is already known and ignored", _this2.conversation.sid, message.index);
|
3198
3213
|
return;
|
3199
3214
|
}
|
3200
3215
|
|
3201
3216
|
_this2.messagesByIndex.set(message.index, message);
|
3202
3217
|
|
3203
|
-
message.on(
|
3204
|
-
return _this2.emit(
|
3218
|
+
message.on("updated", function (args) {
|
3219
|
+
return _this2.emit("messageUpdated", args);
|
3205
3220
|
});
|
3206
3221
|
|
3207
|
-
_this2.emit(
|
3222
|
+
_this2.emit("messageAdded", message);
|
3208
3223
|
});
|
3209
|
-
list.on(
|
3224
|
+
list.on("itemRemoved", function (args) {
|
3210
3225
|
log$4.debug("#{this.conversation.sid} itemRemoved: ".concat(args.index));
|
3211
3226
|
var index = args.index;
|
3212
3227
|
|
3213
3228
|
if (_this2.messagesByIndex.has(index)) {
|
3214
3229
|
var message = _this2.messagesByIndex.get(index);
|
3215
3230
|
|
3231
|
+
if (!message) {
|
3232
|
+
return;
|
3233
|
+
}
|
3234
|
+
|
3216
3235
|
_this2.messagesByIndex.delete(message.index);
|
3217
3236
|
|
3218
|
-
message.removeAllListeners(
|
3237
|
+
message.removeAllListeners("updated");
|
3219
3238
|
|
3220
|
-
_this2.emit(
|
3239
|
+
_this2.emit("messageRemoved", message);
|
3221
3240
|
}
|
3222
3241
|
});
|
3223
|
-
list.on(
|
3242
|
+
list.on("itemUpdated", function (args) {
|
3224
3243
|
log$4.debug("".concat(_this2.conversation.sid, " itemUpdated: ").concat(args.item.index));
|
3225
3244
|
|
3226
3245
|
var message = _this2.messagesByIndex.get(args.item.index);
|
@@ -3236,11 +3255,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3236
3255
|
_context.t0 = _context["catch"](3);
|
3237
3256
|
this.messagesListPromise = null;
|
3238
3257
|
|
3239
|
-
if (this.services.syncClient.connectionState !==
|
3240
|
-
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);
|
3241
3260
|
}
|
3242
3261
|
|
3243
|
-
log$4.debug(
|
3262
|
+
log$4.debug("ERROR: Failed to get messages object for conversation", this.conversation.sid, _context.t0);
|
3244
3263
|
throw _context.t0;
|
3245
3264
|
|
3246
3265
|
case 19:
|
@@ -3308,13 +3327,13 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3308
3327
|
var _sendV = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(message) {
|
3309
3328
|
var _message$emailOptions;
|
3310
3329
|
|
3311
|
-
var media, _iterator, _step, _step$value, category, mediaContent;
|
3330
|
+
var media, _iterator, _step, _mediaContent$content, _mediaContent$media, _step$value, category, mediaContent;
|
3312
3331
|
|
3313
3332
|
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
3314
3333
|
while (1) {
|
3315
3334
|
switch (_context3.prev = _context3.next) {
|
3316
3335
|
case 0:
|
3317
|
-
log$4.debug(
|
3336
|
+
log$4.debug("Sending message V2", message.mediaContent, message.attributes, message.emailOptions);
|
3318
3337
|
media = [];
|
3319
3338
|
_iterator = _createForOfIteratorHelper$2(message.mediaContent);
|
3320
3339
|
_context3.prev = 3;
|
@@ -3328,7 +3347,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3328
3347
|
}
|
3329
3348
|
|
3330
3349
|
_step$value = _slicedToArray__default['default'](_step.value, 2), category = _step$value[0], mediaContent = _step$value[1];
|
3331
|
-
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);
|
3332
3351
|
_context3.t0 = media;
|
3333
3352
|
|
3334
3353
|
if (!(mediaContent instanceof FormData)) {
|
@@ -3346,7 +3365,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3346
3365
|
|
3347
3366
|
case 15:
|
3348
3367
|
_context3.next = 17;
|
3349
|
-
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);
|
3350
3369
|
|
3351
3370
|
case 17:
|
3352
3371
|
_context3.t1 = _context3.sent;
|
@@ -3379,13 +3398,13 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3379
3398
|
|
3380
3399
|
case 30:
|
3381
3400
|
_context3.next = 32;
|
3382
|
-
return this.services.commandExecutor.mutateResource(
|
3401
|
+
return this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
|
3383
3402
|
body: message.text,
|
3384
3403
|
subject: (_message$emailOptions = message.emailOptions) === null || _message$emailOptions === void 0 ? void 0 : _message$emailOptions.subject,
|
3385
3404
|
media_sids: media.map(function (m) {
|
3386
3405
|
return m.sid;
|
3387
3406
|
}),
|
3388
|
-
attributes: typeof message.attributes !==
|
3407
|
+
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined
|
3389
3408
|
});
|
3390
3409
|
|
3391
3410
|
case 32:
|
@@ -3426,11 +3445,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3426
3445
|
case 0:
|
3427
3446
|
attributes = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
3428
3447
|
emailOptions = _args4.length > 2 ? _args4[2] : undefined;
|
3429
|
-
log$4.debug(
|
3448
|
+
log$4.debug("Sending text message", message, attributes, emailOptions);
|
3430
3449
|
_context4.next = 5;
|
3431
|
-
return this.services.commandExecutor.mutateResource(
|
3432
|
-
body: message !== null && message !== void 0 ? message :
|
3433
|
-
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,
|
3434
3453
|
subject: emailOptions === null || emailOptions === void 0 ? void 0 : emailOptions.subject
|
3435
3454
|
});
|
3436
3455
|
|
@@ -3463,6 +3482,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3463
3482
|
key: "sendMedia",
|
3464
3483
|
value: function () {
|
3465
3484
|
var _sendMedia = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(mediaContent) {
|
3485
|
+
var _mediaContent$content2, _mediaContent$media2;
|
3486
|
+
|
3466
3487
|
var attributes,
|
3467
3488
|
emailOptions,
|
3468
3489
|
media,
|
@@ -3473,8 +3494,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3473
3494
|
case 0:
|
3474
3495
|
attributes = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
3475
3496
|
emailOptions = _args5.length > 2 ? _args5[2] : undefined;
|
3476
|
-
log$4.debug(
|
3477
|
-
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);
|
3478
3499
|
|
3479
3500
|
if (!(mediaContent instanceof FormData)) {
|
3480
3501
|
_context5.next = 10;
|
@@ -3491,7 +3512,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3491
3512
|
|
3492
3513
|
case 10:
|
3493
3514
|
_context5.next = 12;
|
3494
|
-
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);
|
3495
3516
|
|
3496
3517
|
case 12:
|
3497
3518
|
_context5.t0 = _context5.sent;
|
@@ -3499,9 +3520,9 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3499
3520
|
case 13:
|
3500
3521
|
media = _context5.t0;
|
3501
3522
|
_context5.next = 16;
|
3502
|
-
return this.services.commandExecutor.mutateResource(
|
3523
|
+
return this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
|
3503
3524
|
media_sids: [media.sid],
|
3504
|
-
attributes: typeof attributes !==
|
3525
|
+
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
|
3505
3526
|
});
|
3506
3527
|
|
3507
3528
|
case 16:
|
@@ -3539,7 +3560,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3539
3560
|
while (1) {
|
3540
3561
|
switch (_context6.prev = _context6.next) {
|
3541
3562
|
case 0:
|
3542
|
-
direction = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] :
|
3563
|
+
direction = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : "backwards";
|
3543
3564
|
return _context6.abrupt("return", this._getMessages(pageSize, anchor, direction));
|
3544
3565
|
|
3545
3566
|
case 2:
|
@@ -3563,7 +3584,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3563
3584
|
|
3564
3585
|
// Due to an inconsistency between Sync and Chat conventions, next and
|
3565
3586
|
// previous pages should be swapped.
|
3566
|
-
var shouldReverse = order ===
|
3587
|
+
var shouldReverse = order === "desc";
|
3567
3588
|
|
3568
3589
|
var nextPage = function nextPage() {
|
3569
3590
|
return page.nextPage().then(function (page) {
|
@@ -3607,8 +3628,8 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3607
3628
|
};
|
3608
3629
|
var message = new Message(index, value, this.conversation, links, this.configuration, this.services);
|
3609
3630
|
this.messagesByIndex.set(message.index, message);
|
3610
|
-
message.on(
|
3611
|
-
return _this4.emit(
|
3631
|
+
message.on("updated", function (args) {
|
3632
|
+
return _this4.emit("messageUpdated", args);
|
3612
3633
|
});
|
3613
3634
|
return message;
|
3614
3635
|
}
|
@@ -3639,17 +3660,17 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3639
3660
|
switch (_context7.prev = _context7.next) {
|
3640
3661
|
case 0:
|
3641
3662
|
pageSize = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : 30;
|
3642
|
-
anchor = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] :
|
3643
|
-
direction = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] :
|
3644
|
-
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";
|
3645
3666
|
_context7.next = 6;
|
3646
3667
|
return this.messagesListPromise;
|
3647
3668
|
|
3648
3669
|
case 6:
|
3649
3670
|
list = _context7.sent;
|
3650
3671
|
_context7.next = 9;
|
3651
|
-
return list.getItems({
|
3652
|
-
from: anchor !==
|
3672
|
+
return list === null || list === void 0 ? void 0 : list.getItems({
|
3673
|
+
from: anchor !== "end" ? anchor : void 0,
|
3653
3674
|
pageSize: pageSize,
|
3654
3675
|
order: order,
|
3655
3676
|
limit: pageSize // @todo Limit equals pageSize by default in Sync. This is probably not ideal.
|
@@ -3841,19 +3862,19 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
3841
3862
|
}, {
|
3842
3863
|
key: "addMedia",
|
3843
3864
|
value: function addMedia(payload) {
|
3844
|
-
if (typeof FormData ===
|
3845
|
-
throw new Error(
|
3865
|
+
if (typeof FormData === "undefined" && payload instanceof FormData) {
|
3866
|
+
throw new Error("Could not add FormData content whilst not in a browser");
|
3846
3867
|
}
|
3847
3868
|
|
3848
3869
|
if (!(payload instanceof FormData)) {
|
3849
3870
|
var mediaOptions = payload;
|
3850
3871
|
|
3851
3872
|
if (!mediaOptions.contentType || !mediaOptions.media) {
|
3852
|
-
throw new Error(
|
3873
|
+
throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media");
|
3853
3874
|
}
|
3854
3875
|
}
|
3855
3876
|
|
3856
|
-
this.message.mediaContent.push([
|
3877
|
+
this.message.mediaContent.push(["media", payload]);
|
3857
3878
|
return this;
|
3858
3879
|
}
|
3859
3880
|
/**
|
@@ -3891,18 +3912,18 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
3891
3912
|
|
3892
3913
|
|
3893
3914
|
this.emailBodies.forEach(function (body) {
|
3894
|
-
_this.message.mediaContent.push([
|
3915
|
+
_this.message.mediaContent.push(["body", body]);
|
3895
3916
|
});
|
3896
3917
|
this.emailHistories.forEach(function (history) {
|
3897
|
-
_this.message.mediaContent.push([
|
3918
|
+
_this.message.mediaContent.push(["history", history]);
|
3898
3919
|
});
|
3899
3920
|
return this.message;
|
3900
3921
|
}
|
3901
3922
|
}, {
|
3902
3923
|
key: "getPayloadContentType",
|
3903
3924
|
value: function getPayloadContentType(payload) {
|
3904
|
-
if (typeof FormData !==
|
3905
|
-
return payload.get(
|
3925
|
+
if (typeof FormData !== "undefined" && payload instanceof FormData) {
|
3926
|
+
return payload.get("Content-Type");
|
3906
3927
|
}
|
3907
3928
|
|
3908
3929
|
return payload.contentType;
|
@@ -3921,21 +3942,21 @@ function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) le
|
|
3921
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); }; }
|
3922
3943
|
|
3923
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; } }
|
3924
|
-
var log$3 = Logger.scope(
|
3945
|
+
var log$3 = Logger.scope("Conversation");
|
3925
3946
|
var fieldMappings = {
|
3926
|
-
lastMessage:
|
3927
|
-
attributes:
|
3928
|
-
createdBy:
|
3929
|
-
dateCreated:
|
3930
|
-
dateUpdated:
|
3931
|
-
friendlyName:
|
3932
|
-
lastConsumedMessageIndex:
|
3933
|
-
notificationLevel:
|
3934
|
-
sid:
|
3935
|
-
status:
|
3936
|
-
uniqueName:
|
3937
|
-
state:
|
3938
|
-
bindings:
|
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"
|
3939
3960
|
};
|
3940
3961
|
|
3941
3962
|
function parseTime(timeString) {
|
@@ -3985,13 +4006,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3985
4006
|
try {
|
3986
4007
|
JSON.stringify(attributes);
|
3987
4008
|
} catch (e) {
|
3988
|
-
throw new Error(
|
4009
|
+
throw new Error("Attributes must be a valid JSON object.");
|
3989
4010
|
}
|
3990
4011
|
|
3991
4012
|
_this.entityName = descriptor.channel;
|
3992
4013
|
_this.channelState = {
|
3993
4014
|
uniqueName: uniqueName,
|
3994
|
-
status:
|
4015
|
+
status: "notParticipating",
|
3995
4016
|
attributes: attributes,
|
3996
4017
|
createdBy: createdBy,
|
3997
4018
|
dateCreated: dateCreated,
|
@@ -4011,25 +4032,31 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4011
4032
|
_this.participants = new Map();
|
4012
4033
|
_this.participantsEntity = new Participants(_assertThisInitialized__default['default'](_this), _this.participants, participantsLinks, _this.configuration, _this.services);
|
4013
4034
|
|
4014
|
-
_this.participantsEntity.on(
|
4035
|
+
_this.participantsEntity.on("participantJoined", function (participant) {
|
4036
|
+
return _this.emit("participantJoined", participant);
|
4037
|
+
});
|
4015
4038
|
|
4016
|
-
_this.participantsEntity.on(
|
4039
|
+
_this.participantsEntity.on("participantLeft", function (participant) {
|
4040
|
+
return _this.emit("participantLeft", participant);
|
4041
|
+
});
|
4017
4042
|
|
4018
|
-
_this.participantsEntity.on(
|
4019
|
-
return _this.emit(
|
4043
|
+
_this.participantsEntity.on("participantUpdated", function (args) {
|
4044
|
+
return _this.emit("participantUpdated", args);
|
4020
4045
|
});
|
4021
4046
|
|
4022
4047
|
_this.messagesEntity = new Messages(_assertThisInitialized__default['default'](_this), configuration, services);
|
4023
4048
|
|
4024
|
-
_this.messagesEntity.on(
|
4049
|
+
_this.messagesEntity.on("messageAdded", function (message) {
|
4025
4050
|
return _this._onMessageAdded(message);
|
4026
4051
|
});
|
4027
4052
|
|
4028
|
-
_this.messagesEntity.on(
|
4029
|
-
return _this.emit(
|
4053
|
+
_this.messagesEntity.on("messageUpdated", function (args) {
|
4054
|
+
return _this.emit("messageUpdated", args);
|
4030
4055
|
});
|
4031
4056
|
|
4032
|
-
_this.messagesEntity.on(
|
4057
|
+
_this.messagesEntity.on("messageRemoved", function (message) {
|
4058
|
+
return _this.emit("messageRemoved", message);
|
4059
|
+
});
|
4033
4060
|
|
4034
4061
|
return _this;
|
4035
4062
|
}
|
@@ -4094,7 +4121,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4094
4121
|
}, {
|
4095
4122
|
key: "createdBy",
|
4096
4123
|
get: function get() {
|
4097
|
-
|
4124
|
+
var _this$channelState$cr;
|
4125
|
+
|
4126
|
+
return (_this$channelState$cr = this.channelState.createdBy) !== null && _this$channelState$cr !== void 0 ? _this$channelState$cr : "";
|
4098
4127
|
}
|
4099
4128
|
/**
|
4100
4129
|
* Custom attributes of the conversation.
|
@@ -4121,7 +4150,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4121
4150
|
}, {
|
4122
4151
|
key: "lastMessage",
|
4123
4152
|
get: function get() {
|
4124
|
-
|
4153
|
+
var _this$channelState$la;
|
4154
|
+
|
4155
|
+
return (_this$channelState$la = this.channelState.lastMessage) !== null && _this$channelState$la !== void 0 ? _this$channelState$la : undefined;
|
4125
4156
|
}
|
4126
4157
|
/**
|
4127
4158
|
* User notification level for this conversation.
|
@@ -4130,7 +4161,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4130
4161
|
}, {
|
4131
4162
|
key: "notificationLevel",
|
4132
4163
|
get: function get() {
|
4133
|
-
|
4164
|
+
var _this$channelState$no;
|
4165
|
+
|
4166
|
+
return (_this$channelState$no = this.channelState.notificationLevel) !== null && _this$channelState$no !== void 0 ? _this$channelState$no : "default";
|
4134
4167
|
}
|
4135
4168
|
}, {
|
4136
4169
|
key: "bindings",
|
@@ -4165,16 +4198,16 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4165
4198
|
|
4166
4199
|
return this.entityPromise = (_this$entityPromise = this.entityPromise) !== null && _this$entityPromise !== void 0 ? _this$entityPromise : this.services.syncClient.document({
|
4167
4200
|
id: this.entityName,
|
4168
|
-
mode:
|
4201
|
+
mode: "open_existing"
|
4169
4202
|
}).then(function (entity) {
|
4170
4203
|
_this2.entity = entity;
|
4171
4204
|
|
4172
|
-
_this2.entity.on(
|
4205
|
+
_this2.entity.on("updated", function (args) {
|
4173
4206
|
_this2._update(args.data);
|
4174
4207
|
});
|
4175
4208
|
|
4176
|
-
_this2.entity.on(
|
4177
|
-
return _this2.emit(
|
4209
|
+
_this2.entity.on("removed", function () {
|
4210
|
+
return _this2.emit("removed", _this2);
|
4178
4211
|
});
|
4179
4212
|
|
4180
4213
|
_this2._update(_this2.entity.data);
|
@@ -4184,11 +4217,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4184
4217
|
_this2.entity = null;
|
4185
4218
|
_this2.entityPromise = null;
|
4186
4219
|
|
4187
|
-
if (_this2.services.syncClient.connectionState !=
|
4188
|
-
log$3.error(
|
4220
|
+
if (_this2.services.syncClient.connectionState != "disconnected") {
|
4221
|
+
log$3.error("Failed to get conversation object", err);
|
4189
4222
|
}
|
4190
4223
|
|
4191
|
-
log$3.debug(
|
4224
|
+
log$3.debug("ERROR: Failed to get conversation object", err);
|
4192
4225
|
throw err;
|
4193
4226
|
});
|
4194
4227
|
}
|
@@ -4203,7 +4236,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4203
4236
|
key: "_subscribeStreams",
|
4204
4237
|
value: function () {
|
4205
4238
|
var _subscribeStreams2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
4206
|
-
var messagesObjectName, rosterObjectName;
|
4239
|
+
var _this$entity, _this$entity2, _this$entity3, messagesObjectName, rosterObjectName;
|
4240
|
+
|
4207
4241
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
4208
4242
|
while (1) {
|
4209
4243
|
switch (_context.prev = _context.next) {
|
@@ -4213,9 +4247,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4213
4247
|
return this._subscribe();
|
4214
4248
|
|
4215
4249
|
case 3:
|
4216
|
-
log$3.trace(
|
4217
|
-
messagesObjectName = this.entity.data.messages;
|
4218
|
-
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;
|
4219
4253
|
_context.next = 8;
|
4220
4254
|
return Promise.all([this.messagesEntity.subscribe(messagesObjectName), this.participantsEntity.subscribe(rosterObjectName)]);
|
4221
4255
|
|
@@ -4227,11 +4261,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4227
4261
|
_context.prev = 10;
|
4228
4262
|
_context.t0 = _context["catch"](0);
|
4229
4263
|
|
4230
|
-
if (this.services.syncClient.connectionState !==
|
4231
|
-
log$3.error(
|
4264
|
+
if (this.services.syncClient.connectionState !== "disconnected") {
|
4265
|
+
log$3.error("Failed to subscribe on conversation objects", this.sid, _context.t0);
|
4232
4266
|
}
|
4233
4267
|
|
4234
|
-
log$3.debug(
|
4268
|
+
log$3.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context.t0);
|
4235
4269
|
throw _context.t0;
|
4236
4270
|
|
4237
4271
|
case 15:
|
@@ -4308,19 +4342,19 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4308
4342
|
|
4309
4343
|
this.channelState.status = status;
|
4310
4344
|
|
4311
|
-
if (status ===
|
4345
|
+
if (status === "joined") {
|
4312
4346
|
this._subscribeStreams().catch(function (err) {
|
4313
|
-
log$3.debug(
|
4347
|
+
log$3.debug("ERROR while setting conversation status " + status, err);
|
4314
4348
|
|
4315
|
-
if (_this3.services.syncClient.connectionState !==
|
4349
|
+
if (_this3.services.syncClient.connectionState !== "disconnected") {
|
4316
4350
|
throw err;
|
4317
4351
|
}
|
4318
4352
|
});
|
4319
4353
|
} else if (this.entityPromise) {
|
4320
4354
|
this._unsubscribe().catch(function (err) {
|
4321
|
-
log$3.debug(
|
4355
|
+
log$3.debug("ERROR while setting conversation status " + status, err);
|
4322
4356
|
|
4323
|
-
if (_this3.services.syncClient.connectionState !==
|
4357
|
+
if (_this3.services.syncClient.connectionState !== "disconnected") {
|
4324
4358
|
throw err;
|
4325
4359
|
}
|
4326
4360
|
});
|
@@ -4344,9 +4378,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4344
4378
|
* @internal
|
4345
4379
|
*/
|
4346
4380
|
function _update(update) {
|
4347
|
-
var _update$lastMessage, _update$lastMessage2, _this$channelState$
|
4381
|
+
var _update$lastMessage, _update$lastMessage2, _this$channelState$la2, _this$channelState$la3, _this$channelState$lo;
|
4348
4382
|
|
4349
|
-
log$3.trace(
|
4383
|
+
log$3.trace("_update", update);
|
4350
4384
|
Conversation.preprocessUpdate(update, this.sid);
|
4351
4385
|
var updateReasons = new Set();
|
4352
4386
|
|
@@ -4360,7 +4394,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4360
4394
|
|
4361
4395
|
switch (localKey) {
|
4362
4396
|
case fieldMappings.status:
|
4363
|
-
if (!update.status || update.status ===
|
4397
|
+
if (!update.status || update.status === "unknown" || this.channelState.status === update.status) {
|
4364
4398
|
break;
|
4365
4399
|
}
|
4366
4400
|
|
@@ -4383,7 +4417,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4383
4417
|
}
|
4384
4418
|
|
4385
4419
|
this.channelState.lastReadMessageIndex = update.lastConsumedMessageIndex;
|
4386
|
-
updateReasons.add(
|
4420
|
+
updateReasons.add("lastReadMessageIndex");
|
4387
4421
|
break;
|
4388
4422
|
|
4389
4423
|
case fieldMappings.lastMessage:
|
@@ -4400,7 +4434,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4400
4434
|
updateReasons.add(localKey);
|
4401
4435
|
}
|
4402
4436
|
|
4403
|
-
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()) {
|
4404
4438
|
this.channelState.lastMessage.dateCreated = update.lastMessage.timestamp;
|
4405
4439
|
updateReasons.add(localKey);
|
4406
4440
|
}
|
@@ -4450,7 +4484,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4450
4484
|
}
|
4451
4485
|
|
4452
4486
|
if (updateReasons.size > 0) {
|
4453
|
-
this.emit(
|
4487
|
+
this.emit("updated", {
|
4454
4488
|
conversation: this,
|
4455
4489
|
updateReasons: _toConsumableArray__default['default'](updateReasons)
|
4456
4490
|
});
|
@@ -4482,7 +4516,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4482
4516
|
_iterator.f();
|
4483
4517
|
}
|
4484
4518
|
|
4485
|
-
this.emit(
|
4519
|
+
this.emit("messageAdded", message);
|
4486
4520
|
}
|
4487
4521
|
}, {
|
4488
4522
|
key: "_setLastReadMessageIndex",
|
@@ -4494,7 +4528,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4494
4528
|
switch (_context3.prev = _context3.next) {
|
4495
4529
|
case 0:
|
4496
4530
|
_context3.next = 2;
|
4497
|
-
return this.services.commandExecutor.mutateResource(
|
4531
|
+
return this.services.commandExecutor.mutateResource("post", "".concat(this.configuration.links.myConversations, "/").concat(this.sid), {
|
4498
4532
|
last_read_message_index: index
|
4499
4533
|
});
|
4500
4534
|
|
@@ -4603,7 +4637,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4603
4637
|
return this._subscribeStreams();
|
4604
4638
|
|
4605
4639
|
case 2:
|
4606
|
-
if (!(index < this.lastReadMessageIndex)) {
|
4640
|
+
if (!(index < (this.lastReadMessageIndex || 0))) {
|
4607
4641
|
_context6.next = 6;
|
4608
4642
|
break;
|
4609
4643
|
}
|
@@ -4648,7 +4682,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4648
4682
|
switch (_context7.prev = _context7.next) {
|
4649
4683
|
case 0:
|
4650
4684
|
_context7.next = 2;
|
4651
|
-
return this.services.commandExecutor.mutateResource(
|
4685
|
+
return this.services.commandExecutor.mutateResource("delete", this.links.self);
|
4652
4686
|
|
4653
4687
|
case 2:
|
4654
4688
|
return _context7.abrupt("return", this);
|
@@ -4783,6 +4817,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4783
4817
|
key: "getParticipantsCount",
|
4784
4818
|
value: function () {
|
4785
4819
|
var _getParticipantsCount = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee11() {
|
4820
|
+
var _response$body$partic;
|
4821
|
+
|
4786
4822
|
var url, response;
|
4787
4823
|
return _regeneratorRuntime__default['default'].wrap(function _callee11$(_context11) {
|
4788
4824
|
while (1) {
|
@@ -4794,7 +4830,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4794
4830
|
|
4795
4831
|
case 3:
|
4796
4832
|
response = _context11.sent;
|
4797
|
-
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);
|
4798
4834
|
|
4799
4835
|
case 5:
|
4800
4836
|
case "end":
|
@@ -4847,14 +4883,17 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4847
4883
|
}, {
|
4848
4884
|
key: "getParticipantByIdentity",
|
4849
4885
|
value: function () {
|
4850
|
-
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;
|
4851
4889
|
return _regeneratorRuntime__default['default'].wrap(function _callee13$(_context13) {
|
4852
4890
|
while (1) {
|
4853
4891
|
switch (_context13.prev = _context13.next) {
|
4854
4892
|
case 0:
|
4855
|
-
|
4893
|
+
identity = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : "";
|
4894
|
+
return _context13.abrupt("return", this.participantsEntity.getParticipantByIdentity(identity !== null && identity !== void 0 ? identity : ""));
|
4856
4895
|
|
4857
|
-
case
|
4896
|
+
case 2:
|
4858
4897
|
case "end":
|
4859
4898
|
return _context13.stop();
|
4860
4899
|
}
|
@@ -4862,7 +4901,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4862
4901
|
}, _callee13, this);
|
4863
4902
|
}));
|
4864
4903
|
|
4865
|
-
function getParticipantByIdentity(
|
4904
|
+
function getParticipantByIdentity() {
|
4866
4905
|
return _getParticipantByIdentity.apply(this, arguments);
|
4867
4906
|
}
|
4868
4907
|
|
@@ -4883,6 +4922,8 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4883
4922
|
key: "getMessagesCount",
|
4884
4923
|
value: function () {
|
4885
4924
|
var _getMessagesCount = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee14() {
|
4925
|
+
var _response$body$messag;
|
4926
|
+
|
4886
4927
|
var url, response;
|
4887
4928
|
return _regeneratorRuntime__default['default'].wrap(function _callee14$(_context14) {
|
4888
4929
|
while (1) {
|
@@ -4894,7 +4935,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4894
4935
|
|
4895
4936
|
case 3:
|
4896
4937
|
response = _context14.sent;
|
4897
|
-
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);
|
4898
4939
|
|
4899
4940
|
case 5:
|
4900
4941
|
case "end":
|
@@ -4947,12 +4988,12 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4947
4988
|
break;
|
4948
4989
|
}
|
4949
4990
|
|
4950
|
-
throw new Error(
|
4991
|
+
throw new Error("Conversation was not found in the user conversations list");
|
4951
4992
|
|
4952
4993
|
case 6:
|
4953
4994
|
unreadMessageCount = response.body.unread_messages_count;
|
4954
4995
|
|
4955
|
-
if (!(typeof unreadMessageCount ===
|
4996
|
+
if (!(typeof unreadMessageCount === "number")) {
|
4956
4997
|
_context15.next = 9;
|
4957
4998
|
break;
|
4958
4999
|
}
|
@@ -4989,7 +5030,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4989
5030
|
switch (_context16.prev = _context16.next) {
|
4990
5031
|
case 0:
|
4991
5032
|
_context16.next = 2;
|
4992
|
-
return this.services.commandExecutor.mutateResource(
|
5033
|
+
return this.services.commandExecutor.mutateResource("post", this.links.participants, {
|
4993
5034
|
identity: this.configuration.userIdentity
|
4994
5035
|
});
|
4995
5036
|
|
@@ -5022,13 +5063,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5022
5063
|
while (1) {
|
5023
5064
|
switch (_context17.prev = _context17.next) {
|
5024
5065
|
case 0:
|
5025
|
-
if (!(this.channelState.status ===
|
5066
|
+
if (!(this.channelState.status === "joined")) {
|
5026
5067
|
_context17.next = 3;
|
5027
5068
|
break;
|
5028
5069
|
}
|
5029
5070
|
|
5030
5071
|
_context17.next = 3;
|
5031
|
-
return this.services.commandExecutor.mutateResource(
|
5072
|
+
return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(this.configuration.userIdentity));
|
5032
5073
|
|
5033
5074
|
case 3:
|
5034
5075
|
return _context17.abrupt("return", this);
|
@@ -5053,6 +5094,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5053
5094
|
* @param participant Identity, SID or the participant object to remove.
|
5054
5095
|
*/
|
5055
5096
|
|
5097
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
5098
|
+
// @ts-ignore TODO: fix validateTypesAsync typing
|
5099
|
+
|
5056
5100
|
}, {
|
5057
5101
|
key: "removeParticipant",
|
5058
5102
|
value: function () {
|
@@ -5062,7 +5106,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5062
5106
|
switch (_context18.prev = _context18.next) {
|
5063
5107
|
case 0:
|
5064
5108
|
_context18.next = 2;
|
5065
|
-
return this.participantsEntity.remove(typeof participant ===
|
5109
|
+
return this.participantsEntity.remove(typeof participant === "string" ? participant : participant.sid);
|
5066
5110
|
|
5067
5111
|
case 2:
|
5068
5112
|
case "end":
|
@@ -5072,7 +5116,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5072
5116
|
}, _callee18, this);
|
5073
5117
|
}));
|
5074
5118
|
|
5075
|
-
function removeParticipant(
|
5119
|
+
function removeParticipant(_x11) {
|
5076
5120
|
return _removeParticipant.apply(this, arguments);
|
5077
5121
|
}
|
5078
5122
|
|
@@ -5091,13 +5135,15 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5091
5135
|
key: "sendMessage",
|
5092
5136
|
value: function () {
|
5093
5137
|
var _sendMessage = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee19(message, messageAttributes, emailOptions) {
|
5094
|
-
var
|
5138
|
+
var _parseToNumber2;
|
5139
|
+
|
5140
|
+
var _parseToNumber, _response, response;
|
5095
5141
|
|
5096
5142
|
return _regeneratorRuntime__default['default'].wrap(function _callee19$(_context19) {
|
5097
5143
|
while (1) {
|
5098
5144
|
switch (_context19.prev = _context19.next) {
|
5099
5145
|
case 0:
|
5100
|
-
if (!(typeof message ===
|
5146
|
+
if (!(typeof message === "string" || message === null)) {
|
5101
5147
|
_context19.next = 5;
|
5102
5148
|
break;
|
5103
5149
|
}
|
@@ -5107,7 +5153,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5107
5153
|
|
5108
5154
|
case 3:
|
5109
5155
|
_response = _context19.sent;
|
5110
|
-
return _context19.abrupt("return", parseToNumber(_response.index));
|
5156
|
+
return _context19.abrupt("return", (_parseToNumber = parseToNumber(_response.index)) !== null && _parseToNumber !== void 0 ? _parseToNumber : 0);
|
5111
5157
|
|
5112
5158
|
case 5:
|
5113
5159
|
_context19.next = 7;
|
@@ -5115,7 +5161,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5115
5161
|
|
5116
5162
|
case 7:
|
5117
5163
|
response = _context19.sent;
|
5118
|
-
return _context19.abrupt("return", parseToNumber(response.index));
|
5164
|
+
return _context19.abrupt("return", (_parseToNumber2 = parseToNumber(response.index)) !== null && _parseToNumber2 !== void 0 ? _parseToNumber2 : 0);
|
5119
5165
|
|
5120
5166
|
case 9:
|
5121
5167
|
case "end":
|
@@ -5125,7 +5171,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5125
5171
|
}, _callee19, this);
|
5126
5172
|
}));
|
5127
5173
|
|
5128
|
-
function sendMessage(_x13, _x14
|
5174
|
+
function sendMessage(_x12, _x13, _x14) {
|
5129
5175
|
return _sendMessage.apply(this, arguments);
|
5130
5176
|
}
|
5131
5177
|
|
@@ -5241,7 +5287,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5241
5287
|
switch (_context22.prev = _context22.next) {
|
5242
5288
|
case 0:
|
5243
5289
|
_context22.next = 2;
|
5244
|
-
return this.services.commandExecutor.mutateResource(
|
5290
|
+
return this.services.commandExecutor.mutateResource("post", "".concat(this.configuration.links.myConversations, "/").concat(this.sid), {
|
5245
5291
|
notification_level: notificationLevel
|
5246
5292
|
});
|
5247
5293
|
|
@@ -5253,7 +5299,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5253
5299
|
}, _callee22, this);
|
5254
5300
|
}));
|
5255
5301
|
|
5256
|
-
function setUserNotificationLevel(
|
5302
|
+
function setUserNotificationLevel(_x15) {
|
5257
5303
|
return _setUserNotificationLevel.apply(this, arguments);
|
5258
5304
|
}
|
5259
5305
|
|
@@ -5283,7 +5329,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5283
5329
|
switch (_context23.prev = _context23.next) {
|
5284
5330
|
case 0:
|
5285
5331
|
_context23.next = 2;
|
5286
|
-
return this.services.commandExecutor.mutateResource(
|
5332
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
5287
5333
|
attributes: attributes !== undefined ? JSON.stringify(attributes) : undefined
|
5288
5334
|
});
|
5289
5335
|
|
@@ -5298,7 +5344,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5298
5344
|
}, _callee23, this);
|
5299
5345
|
}));
|
5300
5346
|
|
5301
|
-
function updateAttributes(
|
5347
|
+
function updateAttributes(_x16) {
|
5302
5348
|
return _updateAttributes.apply(this, arguments);
|
5303
5349
|
}
|
5304
5350
|
|
@@ -5323,7 +5369,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5323
5369
|
}
|
5324
5370
|
|
5325
5371
|
_context24.next = 3;
|
5326
|
-
return this.services.commandExecutor.mutateResource(
|
5372
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
5327
5373
|
friendly_name: friendlyName
|
5328
5374
|
});
|
5329
5375
|
|
@@ -5338,7 +5384,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5338
5384
|
}, _callee24, this);
|
5339
5385
|
}));
|
5340
5386
|
|
5341
|
-
function updateFriendlyName(
|
5387
|
+
function updateFriendlyName(_x17) {
|
5342
5388
|
return _updateFriendlyName.apply(this, arguments);
|
5343
5389
|
}
|
5344
5390
|
|
@@ -5373,7 +5419,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5373
5419
|
}, _callee25, this);
|
5374
5420
|
}));
|
5375
5421
|
|
5376
|
-
function updateLastReadMessageIndex(
|
5422
|
+
function updateLastReadMessageIndex(_x18) {
|
5377
5423
|
return _updateLastReadMessageIndex.apply(this, arguments);
|
5378
5424
|
}
|
5379
5425
|
|
@@ -5398,11 +5444,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5398
5444
|
}
|
5399
5445
|
|
5400
5446
|
if (!uniqueName) {
|
5401
|
-
uniqueName =
|
5447
|
+
uniqueName = "";
|
5402
5448
|
}
|
5403
5449
|
|
5404
5450
|
_context26.next = 4;
|
5405
|
-
return this.services.commandExecutor.mutateResource(
|
5451
|
+
return this.services.commandExecutor.mutateResource("post", this.links.self, {
|
5406
5452
|
unique_name: uniqueName
|
5407
5453
|
});
|
5408
5454
|
|
@@ -5417,7 +5463,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5417
5463
|
}, _callee26, this);
|
5418
5464
|
}));
|
5419
5465
|
|
5420
|
-
function updateUniqueName(
|
5466
|
+
function updateUniqueName(_x19) {
|
5421
5467
|
return _updateUniqueName.apply(this, arguments);
|
5422
5468
|
}
|
5423
5469
|
|
@@ -5427,13 +5473,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5427
5473
|
key: "preprocessUpdate",
|
5428
5474
|
value: function preprocessUpdate(update, conversationSid) {
|
5429
5475
|
try {
|
5430
|
-
if (typeof update.attributes ===
|
5476
|
+
if (typeof update.attributes === "string") {
|
5431
5477
|
update.attributes = JSON.parse(update.attributes);
|
5432
5478
|
} else if (update.attributes) {
|
5433
5479
|
JSON.stringify(update.attributes);
|
5434
5480
|
}
|
5435
5481
|
} catch (e) {
|
5436
|
-
log$3.warn(
|
5482
|
+
log$3.warn("Retrieved malformed attributes from the server for conversation: " + conversationSid);
|
5437
5483
|
update.attributes = {};
|
5438
5484
|
}
|
5439
5485
|
|
@@ -5442,7 +5488,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5442
5488
|
update.dateCreated = new Date(update.dateCreated);
|
5443
5489
|
}
|
5444
5490
|
} catch (e) {
|
5445
|
-
log$3.warn(
|
5491
|
+
log$3.warn("Retrieved malformed dateCreated from the server for conversation: " + conversationSid);
|
5446
5492
|
delete update.dateCreated;
|
5447
5493
|
}
|
5448
5494
|
|
@@ -5451,7 +5497,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5451
5497
|
update.dateUpdated = new Date(update.dateUpdated);
|
5452
5498
|
}
|
5453
5499
|
} catch (e) {
|
5454
|
-
log$3.warn(
|
5500
|
+
log$3.warn("Retrieved malformed dateUpdated from the server for conversation: " + conversationSid);
|
5455
5501
|
delete update.dateUpdated;
|
5456
5502
|
}
|
5457
5503
|
|
@@ -5460,7 +5506,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5460
5506
|
update.lastMessage.timestamp = new Date(update.lastMessage.timestamp);
|
5461
5507
|
}
|
5462
5508
|
} catch (e) {
|
5463
|
-
log$3.warn(
|
5509
|
+
log$3.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: " + conversationSid);
|
5464
5510
|
delete update.lastMessage.timestamp;
|
5465
5511
|
}
|
5466
5512
|
}
|
@@ -5469,25 +5515,25 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5469
5515
|
return Conversation;
|
5470
5516
|
}(replayEventEmitter.ReplayEventEmitter);
|
5471
5517
|
|
5472
|
-
_defineProperty__default['default'](Conversation, "participantJoined",
|
5518
|
+
_defineProperty__default['default'](Conversation, "participantJoined", "participantJoined");
|
5473
5519
|
|
5474
|
-
_defineProperty__default['default'](Conversation, "participantLeft",
|
5520
|
+
_defineProperty__default['default'](Conversation, "participantLeft", "participantLeft");
|
5475
5521
|
|
5476
|
-
_defineProperty__default['default'](Conversation, "participantUpdated",
|
5522
|
+
_defineProperty__default['default'](Conversation, "participantUpdated", "participantUpdated");
|
5477
5523
|
|
5478
|
-
_defineProperty__default['default'](Conversation, "messageAdded",
|
5524
|
+
_defineProperty__default['default'](Conversation, "messageAdded", "messageAdded");
|
5479
5525
|
|
5480
|
-
_defineProperty__default['default'](Conversation, "messageRemoved",
|
5526
|
+
_defineProperty__default['default'](Conversation, "messageRemoved", "messageRemoved");
|
5481
5527
|
|
5482
|
-
_defineProperty__default['default'](Conversation, "messageUpdated",
|
5528
|
+
_defineProperty__default['default'](Conversation, "messageUpdated", "messageUpdated");
|
5483
5529
|
|
5484
|
-
_defineProperty__default['default'](Conversation, "typingEnded",
|
5530
|
+
_defineProperty__default['default'](Conversation, "typingEnded", "typingEnded");
|
5485
5531
|
|
5486
|
-
_defineProperty__default['default'](Conversation, "typingStarted",
|
5532
|
+
_defineProperty__default['default'](Conversation, "typingStarted", "typingStarted");
|
5487
5533
|
|
5488
|
-
_defineProperty__default['default'](Conversation, "updated",
|
5534
|
+
_defineProperty__default['default'](Conversation, "updated", "updated");
|
5489
5535
|
|
5490
|
-
_defineProperty__default['default'](Conversation, "removed",
|
5536
|
+
_defineProperty__default['default'](Conversation, "removed", "removed");
|
5491
5537
|
|
5492
5538
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, optionalAttributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "add", null);
|
5493
5539
|
|
@@ -5495,7 +5541,7 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
|
|
5495
5541
|
|
5496
5542
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonNegativeInteger), __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", Promise)], Conversation.prototype, "advanceLastReadMessageIndex", null);
|
5497
5543
|
|
5498
|
-
__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);
|
5499
5545
|
|
5500
5546
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "getParticipantBySid", null);
|
5501
5547
|
|
@@ -5503,33 +5549,33 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
|
|
5503
5549
|
|
5504
5550
|
__decorate([declarativeTypeValidator.validateTypesAsync([declarativeTypeValidator.nonEmptyString, Participant]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "removeParticipant", null);
|
5505
5551
|
|
5506
|
-
__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.
|
5507
5553
|
declarativeTypeValidator.custom(function (value) {
|
5508
|
-
return [value instanceof FormData,
|
5509
|
-
}), declarativeTypeValidator.objectSchema(
|
5554
|
+
return [value instanceof FormData, "an instance of FormData"];
|
5555
|
+
}), declarativeTypeValidator.objectSchema("media options", {
|
5510
5556
|
contentType: declarativeTypeValidator.nonEmptyString,
|
5511
5557
|
media: declarativeTypeValidator.custom(function (value) {
|
5512
|
-
var isValid = typeof value ===
|
5558
|
+
var isValid = typeof value === "string" && value.length > 0 || value instanceof Uint8Array || value instanceof ArrayBuffer;
|
5513
5559
|
|
5514
|
-
if (typeof Blob ===
|
5560
|
+
if (typeof Blob === "function") {
|
5515
5561
|
isValid = isValid || value instanceof Blob;
|
5516
5562
|
}
|
5517
5563
|
|
5518
|
-
return [isValid,
|
5564
|
+
return [isValid, "a non-empty string, an instance of Buffer or an instance of Blob"];
|
5519
5565
|
})
|
5520
|
-
})], optionalAttributesValidator, [
|
5521
|
-
subject: [declarativeTypeValidator.nonEmptyString,
|
5566
|
+
})], optionalAttributesValidator, ["undefined", declarativeTypeValidator.literal(null), declarativeTypeValidator.objectSchema("email attributes", {
|
5567
|
+
subject: [declarativeTypeValidator.nonEmptyString, "undefined"]
|
5522
5568
|
})]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "sendMessage", null);
|
5523
5569
|
|
5524
|
-
__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);
|
5525
5571
|
|
5526
5572
|
__decorate([declarativeTypeValidator.validateTypesAsync(attributesValidator), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateAttributes", null);
|
5527
5573
|
|
5528
|
-
__decorate([declarativeTypeValidator.validateTypesAsync([
|
5574
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateFriendlyName", null);
|
5529
5575
|
|
5530
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);
|
5531
5577
|
|
5532
|
-
__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);
|
5533
5579
|
|
5534
5580
|
var Deferred = /*#__PURE__*/function () {
|
5535
5581
|
function Deferred() {
|
@@ -5583,7 +5629,7 @@ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) {
|
|
5583
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); }; }
|
5584
5630
|
|
5585
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; } }
|
5586
|
-
var log$2 = Logger.scope(
|
5632
|
+
var log$2 = Logger.scope("Conversations");
|
5587
5633
|
/**
|
5588
5634
|
* Represents conversations collection
|
5589
5635
|
* {@see Conversation}
|
@@ -5625,12 +5671,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5625
5671
|
while (1) {
|
5626
5672
|
switch (_context.prev = _context.next) {
|
5627
5673
|
case 0:
|
5628
|
-
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 : {};
|
5629
5675
|
_context.next = 3;
|
5630
|
-
return this.services.commandExecutor.mutateResource(
|
5676
|
+
return this.services.commandExecutor.mutateResource("post", this.configuration.links.conversations, {
|
5631
5677
|
friendly_name: options.friendlyName,
|
5632
5678
|
unique_name: options.uniqueName,
|
5633
|
-
attributes: typeof attributes !==
|
5679
|
+
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
|
5634
5680
|
});
|
5635
5681
|
|
5636
5682
|
case 3:
|
@@ -5656,12 +5702,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5656
5702
|
case 12:
|
5657
5703
|
conversation = new Conversation({
|
5658
5704
|
channel: conversationDocument,
|
5659
|
-
entityName:
|
5660
|
-
uniqueName:
|
5705
|
+
entityName: "",
|
5706
|
+
uniqueName: "",
|
5661
5707
|
attributes: null,
|
5662
|
-
createdBy:
|
5663
|
-
friendlyName:
|
5664
|
-
lastConsumedMessageIndex:
|
5708
|
+
createdBy: "",
|
5709
|
+
friendlyName: "",
|
5710
|
+
lastConsumedMessageIndex: 0,
|
5665
5711
|
dateCreated: null,
|
5666
5712
|
dateUpdated: null
|
5667
5713
|
}, conversationSid, links, this.configuration, this.services);
|
@@ -5673,7 +5719,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5673
5719
|
return conversation._subscribe();
|
5674
5720
|
|
5675
5721
|
case 17:
|
5676
|
-
this.emit(
|
5722
|
+
this.emit("conversationAdded", conversation);
|
5677
5723
|
return _context.abrupt("return", conversation);
|
5678
5724
|
|
5679
5725
|
case 19:
|
@@ -5712,12 +5758,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5712
5758
|
|
5713
5759
|
case 3:
|
5714
5760
|
map = _context2.sent;
|
5715
|
-
map.on(
|
5761
|
+
map.on("itemAdded", function (args) {
|
5716
5762
|
log$2.debug("itemAdded: ".concat(args.item.key));
|
5717
5763
|
|
5718
|
-
_this2._upsertConversation(
|
5764
|
+
_this2._upsertConversation("sync", args.item.key, args.item.data);
|
5719
5765
|
});
|
5720
|
-
map.on(
|
5766
|
+
map.on("itemRemoved", function (args) {
|
5721
5767
|
log$2.debug("itemRemoved: ".concat(args.key));
|
5722
5768
|
var sid = args.key;
|
5723
5769
|
|
@@ -5731,22 +5777,22 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5731
5777
|
return;
|
5732
5778
|
}
|
5733
5779
|
|
5734
|
-
if (conversation.status ===
|
5735
|
-
conversation._setStatus(
|
5780
|
+
if (conversation.status === "joined") {
|
5781
|
+
conversation._setStatus("notParticipating", "sync");
|
5736
5782
|
|
5737
|
-
_this2.emit(
|
5783
|
+
_this2.emit("conversationLeft", conversation);
|
5738
5784
|
}
|
5739
5785
|
|
5740
5786
|
_this2.conversations.delete(sid);
|
5741
5787
|
|
5742
|
-
_this2.emit(
|
5788
|
+
_this2.emit("conversationRemoved", conversation);
|
5743
5789
|
|
5744
|
-
conversation.emit(
|
5790
|
+
conversation.emit("removed", conversation);
|
5745
5791
|
});
|
5746
|
-
map.on(
|
5792
|
+
map.on("itemUpdated", function (args) {
|
5747
5793
|
log$2.debug("itemUpdated: ".concat(args.item.key));
|
5748
5794
|
|
5749
|
-
_this2._upsertConversation(
|
5795
|
+
_this2._upsertConversation("sync", args.item.key, args.item.data);
|
5750
5796
|
});
|
5751
5797
|
_context2.next = 9;
|
5752
5798
|
return this._fetchMyConversations();
|
@@ -5759,7 +5805,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5759
5805
|
try {
|
5760
5806
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
5761
5807
|
conversation = _step.value;
|
5762
|
-
upserts.push(this._upsertConversation(
|
5808
|
+
upserts.push(this._upsertConversation("rest", conversation["channel_sid"], conversation));
|
5763
5809
|
}
|
5764
5810
|
} catch (err) {
|
5765
5811
|
_iterator.e(err);
|
@@ -5774,15 +5820,15 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5774
5820
|
case 16:
|
5775
5821
|
this.myConversationsFetched = true;
|
5776
5822
|
this.tombstones.clear();
|
5777
|
-
log$2.debug(
|
5823
|
+
log$2.debug("The conversations list has been successfully fetched");
|
5778
5824
|
return _context2.abrupt("return", this);
|
5779
5825
|
|
5780
5826
|
case 22:
|
5781
5827
|
_context2.prev = 22;
|
5782
5828
|
_context2.t0 = _context2["catch"](0);
|
5783
|
-
errorMessage =
|
5829
|
+
errorMessage = "Failed to fetch the conversations list";
|
5784
5830
|
|
5785
|
-
if (this.services.syncClient.connectionState !==
|
5831
|
+
if (this.services.syncClient.connectionState !== "disconnected") {
|
5786
5832
|
log$2.error(errorMessage, _context2.t0);
|
5787
5833
|
}
|
5788
5834
|
|
@@ -5806,7 +5852,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5806
5852
|
}, {
|
5807
5853
|
key: "getConversations",
|
5808
5854
|
value: function () {
|
5809
|
-
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() {
|
5810
5856
|
var _this3 = this;
|
5811
5857
|
|
5812
5858
|
var conversationsMap, page;
|
@@ -5826,7 +5872,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5826
5872
|
page = _context3.sent;
|
5827
5873
|
return _context3.abrupt("return", this._wrapPaginator(page, function (items) {
|
5828
5874
|
return Promise.all(items.map(function (item) {
|
5829
|
-
return _this3._upsertConversation(
|
5875
|
+
return _this3._upsertConversation("sync", item.key, item.data);
|
5830
5876
|
}));
|
5831
5877
|
}));
|
5832
5878
|
|
@@ -5838,7 +5884,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5838
5884
|
}, _callee3, this);
|
5839
5885
|
}));
|
5840
5886
|
|
5841
|
-
function getConversations(
|
5887
|
+
function getConversations() {
|
5842
5888
|
return _getConversations.apply(this, arguments);
|
5843
5889
|
}
|
5844
5890
|
|
@@ -5868,7 +5914,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5868
5914
|
case 5:
|
5869
5915
|
page = _context4.sent;
|
5870
5916
|
items = page.items.map(function (item) {
|
5871
|
-
return _this4._upsertConversation(
|
5917
|
+
return _this4._upsertConversation("sync", item.key, item.data);
|
5872
5918
|
});
|
5873
5919
|
return _context4.abrupt("return", items.length > 0 ? items[0] : null);
|
5874
5920
|
|
@@ -5880,7 +5926,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5880
5926
|
}, _callee4, this);
|
5881
5927
|
}));
|
5882
5928
|
|
5883
|
-
function getConversation(
|
5929
|
+
function getConversation(_x2) {
|
5884
5930
|
return _getConversation.apply(this, arguments);
|
5885
5931
|
}
|
5886
5932
|
|
@@ -5906,7 +5952,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5906
5952
|
data = {
|
5907
5953
|
entityName: null,
|
5908
5954
|
lastConsumedMessageIndex: body.last_read_message_index,
|
5909
|
-
status: (body === null || body === void 0 ? void 0 : body.status) ||
|
5955
|
+
status: (body === null || body === void 0 ? void 0 : body.status) || "unknown",
|
5910
5956
|
friendlyName: body.friendly_name,
|
5911
5957
|
dateUpdated: body.date_updated,
|
5912
5958
|
dateCreated: body.date_created,
|
@@ -5917,7 +5963,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5917
5963
|
notificationLevel: body === null || body === void 0 ? void 0 : body.notification_level,
|
5918
5964
|
sid: sid
|
5919
5965
|
};
|
5920
|
-
return _context5.abrupt("return", this._upsertConversation(
|
5966
|
+
return _context5.abrupt("return", sid ? this._upsertConversation("sync", sid, data) : null);
|
5921
5967
|
|
5922
5968
|
case 8:
|
5923
5969
|
case "end":
|
@@ -5927,7 +5973,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5927
5973
|
}, _callee5, this);
|
5928
5974
|
}));
|
5929
5975
|
|
5930
|
-
function getConversationByUniqueName(
|
5976
|
+
function getConversationByUniqueName(_x3) {
|
5931
5977
|
return _getConversationByUniqueName.apply(this, arguments);
|
5932
5978
|
}
|
5933
5979
|
|
@@ -5952,7 +5998,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5952
5998
|
data = {
|
5953
5999
|
entityName: null,
|
5954
6000
|
// lastConsumedMessageIndex: body.last_read_message_index,
|
5955
|
-
status: (body === null || body === void 0 ? void 0 : body.status) ||
|
6001
|
+
status: (body === null || body === void 0 ? void 0 : body.status) || "unknown",
|
5956
6002
|
friendlyName: body.friendly_name,
|
5957
6003
|
dateUpdated: body.date_updated,
|
5958
6004
|
dateCreated: body.date_created,
|
@@ -5963,7 +6009,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5963
6009
|
// notificationLevel: body?.notification_level,
|
5964
6010
|
sid: sid
|
5965
6011
|
};
|
5966
|
-
return _context6.abrupt("return", this._upsertConversation(
|
6012
|
+
return _context6.abrupt("return", this._upsertConversation("sync", sid, data));
|
5967
6013
|
|
5968
6014
|
case 7:
|
5969
6015
|
case "end":
|
@@ -5973,7 +6019,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5973
6019
|
}, _callee6, this);
|
5974
6020
|
}));
|
5975
6021
|
|
5976
|
-
function peekConversation(
|
6022
|
+
function peekConversation(_x4) {
|
5977
6023
|
return _peekConversation.apply(this, arguments);
|
5978
6024
|
}
|
5979
6025
|
|
@@ -5990,7 +6036,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5990
6036
|
_context7.next = 2;
|
5991
6037
|
return this.services.syncClient.map({
|
5992
6038
|
id: this.configuration.myConversations,
|
5993
|
-
mode:
|
6039
|
+
mode: "open_existing"
|
5994
6040
|
});
|
5995
6041
|
|
5996
6042
|
case 2:
|
@@ -6050,7 +6096,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6050
6096
|
}, _callee8);
|
6051
6097
|
}));
|
6052
6098
|
|
6053
|
-
function _wrapPaginator(
|
6099
|
+
function _wrapPaginator(_x5, _x6) {
|
6054
6100
|
return _wrapPaginator2.apply(this, arguments);
|
6055
6101
|
}
|
6056
6102
|
|
@@ -6068,14 +6114,14 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6068
6114
|
switch (_context9.prev = _context9.next) {
|
6069
6115
|
case 0:
|
6070
6116
|
areSourcesDifferent = conversation._statusSource() !== undefined && source !== conversation._statusSource();
|
6071
|
-
isChannelSourceSync = source !==
|
6117
|
+
isChannelSourceSync = source !== "rest" || conversation._statusSource() === "sync";
|
6072
6118
|
|
6073
|
-
if (!(areSourcesDifferent && isChannelSourceSync && source !==
|
6119
|
+
if (!(areSourcesDifferent && isChannelSourceSync && source !== "sync")) {
|
6074
6120
|
_context9.next = 5;
|
6075
6121
|
break;
|
6076
6122
|
}
|
6077
6123
|
|
6078
|
-
log$2.trace(
|
6124
|
+
log$2.trace("upsertConversation: conversation is known from sync and came from chat, ignoring", {
|
6079
6125
|
sid: conversation.sid,
|
6080
6126
|
data: data.status,
|
6081
6127
|
conversation: conversation.status
|
@@ -6083,20 +6129,20 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6083
6129
|
return _context9.abrupt("return");
|
6084
6130
|
|
6085
6131
|
case 5:
|
6086
|
-
if (!(data.status ===
|
6132
|
+
if (!(data.status === "joined" && conversation.status !== "joined")) {
|
6087
6133
|
_context9.next = 13;
|
6088
6134
|
break;
|
6089
6135
|
}
|
6090
6136
|
|
6091
|
-
conversation._setStatus(
|
6137
|
+
conversation._setStatus("joined", source);
|
6092
6138
|
|
6093
6139
|
updateData = {};
|
6094
6140
|
|
6095
|
-
if (typeof data.notificationLevel !==
|
6141
|
+
if (typeof data.notificationLevel !== "undefined") {
|
6096
6142
|
updateData.notificationLevel = data.notificationLevel;
|
6097
6143
|
}
|
6098
6144
|
|
6099
|
-
if (typeof data.lastConsumedMessageIndex !==
|
6145
|
+
if (typeof data.lastConsumedMessageIndex !== "undefined") {
|
6100
6146
|
updateData.lastConsumedMessageIndex = data.lastConsumedMessageIndex;
|
6101
6147
|
}
|
6102
6148
|
|
@@ -6105,18 +6151,18 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6105
6151
|
}
|
6106
6152
|
|
6107
6153
|
conversation._subscribe().then(function () {
|
6108
|
-
_this6.emit(
|
6154
|
+
_this6.emit("conversationJoined", conversation);
|
6109
6155
|
});
|
6110
6156
|
|
6111
6157
|
return _context9.abrupt("return");
|
6112
6158
|
|
6113
6159
|
case 13:
|
6114
|
-
if (!(data.status ===
|
6160
|
+
if (!(data.status === "notParticipating" && conversation.status === "joined")) {
|
6115
6161
|
_context9.next = 20;
|
6116
6162
|
break;
|
6117
6163
|
}
|
6118
6164
|
|
6119
|
-
conversation._setStatus(
|
6165
|
+
conversation._setStatus("notParticipating", source);
|
6120
6166
|
|
6121
6167
|
conversation._update(data);
|
6122
6168
|
|
@@ -6124,11 +6170,11 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6124
6170
|
return conversation._subscribe();
|
6125
6171
|
|
6126
6172
|
case 18:
|
6127
|
-
this.emit(
|
6173
|
+
this.emit("conversationLeft", conversation);
|
6128
6174
|
return _context9.abrupt("return");
|
6129
6175
|
|
6130
6176
|
case 20:
|
6131
|
-
if (!(data.status ===
|
6177
|
+
if (!(data.status === "notParticipating")) {
|
6132
6178
|
_context9.next = 24;
|
6133
6179
|
break;
|
6134
6180
|
}
|
@@ -6150,7 +6196,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6150
6196
|
}, _callee9, this);
|
6151
6197
|
}));
|
6152
6198
|
|
6153
|
-
function _updateConversation(_x8, _x9
|
6199
|
+
function _updateConversation(_x7, _x8, _x9) {
|
6154
6200
|
return _updateConversation2.apply(this, arguments);
|
6155
6201
|
}
|
6156
6202
|
|
@@ -6185,17 +6231,17 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6185
6231
|
return _context10.abrupt("return", conversation);
|
6186
6232
|
|
6187
6233
|
case 9:
|
6188
|
-
if (!([
|
6234
|
+
if (!(["chat", "rest"].includes(source) && this.tombstones.has(sid))) {
|
6189
6235
|
_context10.next = 12;
|
6190
6236
|
break;
|
6191
6237
|
}
|
6192
6238
|
|
6193
|
-
log$2.trace(
|
6194
|
-
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);
|
6195
6241
|
|
6196
6242
|
case 12:
|
6197
6243
|
// If the conversation is unknown, fetch it
|
6198
|
-
log$2.trace(
|
6244
|
+
log$2.trace("upsertConversation: creating a local conversation object with sid " + sid, data);
|
6199
6245
|
baseLink = "".concat(this.configuration.links.conversations, "/").concat(sid);
|
6200
6246
|
links = {
|
6201
6247
|
self: baseLink,
|
@@ -6210,12 +6256,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6210
6256
|
case 19:
|
6211
6257
|
this._registerForEvents(newConversation);
|
6212
6258
|
|
6213
|
-
this.emit(
|
6259
|
+
this.emit("conversationAdded", newConversation);
|
6214
6260
|
|
6215
|
-
if (data.status ===
|
6216
|
-
newConversation._setStatus(
|
6261
|
+
if (data.status === "joined") {
|
6262
|
+
newConversation._setStatus("joined", source);
|
6217
6263
|
|
6218
|
-
this.emit(
|
6264
|
+
this.emit("conversationJoined", newConversation);
|
6219
6265
|
}
|
6220
6266
|
|
6221
6267
|
return _context10.abrupt("return", newConversation);
|
@@ -6228,7 +6274,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6228
6274
|
}, _callee10, this);
|
6229
6275
|
}));
|
6230
6276
|
|
6231
|
-
function _upsertConversation(_x11, _x12
|
6277
|
+
function _upsertConversation(_x10, _x11, _x12) {
|
6232
6278
|
return _upsertConversation2.apply(this, arguments);
|
6233
6279
|
}
|
6234
6280
|
|
@@ -6238,7 +6284,8 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6238
6284
|
key: "_fetchMyConversations",
|
6239
6285
|
value: function () {
|
6240
6286
|
var _fetchMyConversations2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee11() {
|
6241
|
-
var conversations, pageToken, url, response, receivedConversations;
|
6287
|
+
var conversations, pageToken, _response$body, url, response, receivedConversations;
|
6288
|
+
|
6242
6289
|
return _regeneratorRuntime__default['default'].wrap(function _callee11$(_context11) {
|
6243
6290
|
while (1) {
|
6244
6291
|
switch (_context11.prev = _context11.next) {
|
@@ -6250,7 +6297,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6250
6297
|
url = new UriBuilder(this.configuration.links.myConversations);
|
6251
6298
|
|
6252
6299
|
if (pageToken) {
|
6253
|
-
url.arg(
|
6300
|
+
url.arg("PageToken", pageToken);
|
6254
6301
|
}
|
6255
6302
|
|
6256
6303
|
_context11.next = 6;
|
@@ -6258,7 +6305,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6258
6305
|
|
6259
6306
|
case 6:
|
6260
6307
|
response = _context11.sent;
|
6261
|
-
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) {
|
6262
6309
|
return {
|
6263
6310
|
descriptor: conversationDescriptor,
|
6264
6311
|
channel_sid: conversationDescriptor.conversation_sid,
|
@@ -6266,7 +6313,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6266
6313
|
channel: conversationDescriptor.sync_objects.conversation,
|
6267
6314
|
messages: conversationDescriptor.sync_objects.messages,
|
6268
6315
|
roster: "".concat(conversationDescriptor.conversation_sid, ".roster"),
|
6269
|
-
lastConsumedMessageIndex: conversationDescriptor.
|
6316
|
+
lastConsumedMessageIndex: conversationDescriptor.last_read_message_index,
|
6270
6317
|
notificationLevel: conversationDescriptor.notification_level
|
6271
6318
|
};
|
6272
6319
|
});
|
@@ -6303,7 +6350,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6303
6350
|
|
6304
6351
|
if (conversation) {
|
6305
6352
|
this.conversations.delete(sid);
|
6306
|
-
this.emit(
|
6353
|
+
this.emit("conversationRemoved", conversation);
|
6307
6354
|
}
|
6308
6355
|
}
|
6309
6356
|
}, {
|
@@ -6311,24 +6358,36 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6311
6358
|
value: function _registerForEvents(conversation) {
|
6312
6359
|
var _this7 = this;
|
6313
6360
|
|
6314
|
-
conversation.on(
|
6361
|
+
conversation.on("removed", function () {
|
6315
6362
|
return _this7._onConversationRemoved(conversation.sid);
|
6316
6363
|
});
|
6317
|
-
conversation.on(
|
6318
|
-
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);
|
6319
6369
|
});
|
6320
|
-
conversation.on(
|
6321
|
-
|
6322
|
-
conversation.on('participantUpdated', function (args) {
|
6323
|
-
return _this7.emit('participantUpdated', args);
|
6370
|
+
conversation.on("participantLeft", function (participant) {
|
6371
|
+
return _this7.emit("participantLeft", participant);
|
6324
6372
|
});
|
6325
|
-
conversation.on(
|
6326
|
-
|
6327
|
-
|
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);
|
6378
|
+
});
|
6379
|
+
conversation.on("messageUpdated", function (args) {
|
6380
|
+
return _this7.emit("messageUpdated", args);
|
6381
|
+
});
|
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);
|
6328
6390
|
});
|
6329
|
-
conversation.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));
|
6330
|
-
conversation.on('typingStarted', this.emit.bind(this, 'typingStarted'));
|
6331
|
-
conversation.on('typingEnded', this.emit.bind(this, 'typingEnded'));
|
6332
6391
|
}
|
6333
6392
|
}]);
|
6334
6393
|
|
@@ -6358,16 +6417,16 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6358
6417
|
_this.fifoStack = [];
|
6359
6418
|
_this.myself = myself;
|
6360
6419
|
|
6361
|
-
_this.myself.on(
|
6362
|
-
return _this.emit(
|
6420
|
+
_this.myself.on("updated", function (args) {
|
6421
|
+
return _this.emit("userUpdated", args);
|
6363
6422
|
});
|
6364
6423
|
|
6365
|
-
_this.myself.on(
|
6366
|
-
return _this.emit(
|
6424
|
+
_this.myself.on("userSubscribed", function () {
|
6425
|
+
return _this.emit("userSubscribed", _this.myself);
|
6367
6426
|
});
|
6368
6427
|
|
6369
|
-
_this.myself.on(
|
6370
|
-
_this.emit(
|
6428
|
+
_this.myself.on("userUnsubscribed", function () {
|
6429
|
+
_this.emit("userUnsubscribed", _this.myself);
|
6371
6430
|
|
6372
6431
|
_this.myself._ensureFetched();
|
6373
6432
|
});
|
@@ -6383,7 +6442,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6383
6442
|
this.subscribedUsers.delete(user.identity);
|
6384
6443
|
}
|
6385
6444
|
|
6386
|
-
var foundItemIndex =
|
6445
|
+
var foundItemIndex = 0;
|
6387
6446
|
var foundItem = this.fifoStack.find(function (item, index) {
|
6388
6447
|
if (item == user.identity) {
|
6389
6448
|
foundItemIndex = index;
|
@@ -6397,7 +6456,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6397
6456
|
this.fifoStack.splice(foundItemIndex, 1);
|
6398
6457
|
}
|
6399
6458
|
|
6400
|
-
this.emit(
|
6459
|
+
this.emit("userUnsubscribed", user);
|
6401
6460
|
}
|
6402
6461
|
}, {
|
6403
6462
|
key: "handleSubscribeUser",
|
@@ -6407,12 +6466,15 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6407
6466
|
}
|
6408
6467
|
|
6409
6468
|
if (this.fifoStack.length >= this.configuration.userInfosToSubscribe) {
|
6410
|
-
|
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();
|
6411
6473
|
}
|
6412
6474
|
|
6413
6475
|
this.fifoStack.push(user.identity);
|
6414
6476
|
this.subscribedUsers.set(user.identity, user);
|
6415
|
-
this.emit(
|
6477
|
+
this.emit("userSubscribed", user);
|
6416
6478
|
}
|
6417
6479
|
/**
|
6418
6480
|
* Gets user, if it's in subscribed list - then return the user object from it,
|
@@ -6423,65 +6485,74 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6423
6485
|
}, {
|
6424
6486
|
key: "getUser",
|
6425
6487
|
value: function () {
|
6426
|
-
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() {
|
6427
6489
|
var _this2 = this;
|
6428
6490
|
|
6429
|
-
var
|
6491
|
+
var identity,
|
6492
|
+
entityName,
|
6430
6493
|
user,
|
6494
|
+
newUser,
|
6431
6495
|
_args = arguments;
|
6432
6496
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
6433
6497
|
while (1) {
|
6434
6498
|
switch (_context.prev = _context.next) {
|
6435
6499
|
case 0:
|
6436
|
-
|
6437
|
-
|
6500
|
+
identity = _args.length > 0 && _args[0] !== undefined ? _args[0] : "";
|
6501
|
+
entityName = _args.length > 1 && _args[1] !== undefined ? _args[1] : "";
|
6502
|
+
_context.next = 4;
|
6438
6503
|
return this.myself._ensureFetched();
|
6439
6504
|
|
6440
|
-
case
|
6505
|
+
case 4:
|
6441
6506
|
if (!(identity == this.myself.identity)) {
|
6442
|
-
_context.next =
|
6507
|
+
_context.next = 6;
|
6443
6508
|
break;
|
6444
6509
|
}
|
6445
6510
|
|
6446
6511
|
return _context.abrupt("return", this.myself);
|
6447
6512
|
|
6448
|
-
case
|
6513
|
+
case 6:
|
6449
6514
|
user = this.subscribedUsers.get(identity);
|
6450
6515
|
|
6451
|
-
if (user) {
|
6452
|
-
_context.next =
|
6516
|
+
if (!user) {
|
6517
|
+
_context.next = 9;
|
6453
6518
|
break;
|
6454
6519
|
}
|
6455
6520
|
|
6456
|
-
|
6457
|
-
|
6521
|
+
return _context.abrupt("return", user);
|
6522
|
+
|
6523
|
+
case 9:
|
6524
|
+
_context.t0 = entityName;
|
6525
|
+
|
6526
|
+
if (_context.t0) {
|
6527
|
+
_context.next = 14;
|
6458
6528
|
break;
|
6459
6529
|
}
|
6460
6530
|
|
6461
|
-
_context.next =
|
6531
|
+
_context.next = 13;
|
6462
6532
|
return this.getSyncUniqueName(identity);
|
6463
6533
|
|
6464
|
-
case
|
6465
|
-
|
6534
|
+
case 13:
|
6535
|
+
_context.t0 = _context.sent;
|
6466
6536
|
|
6467
|
-
case
|
6468
|
-
|
6469
|
-
|
6470
|
-
|
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);
|
6471
6542
|
});
|
6472
|
-
|
6473
|
-
return _this2.handleSubscribeUser(
|
6543
|
+
newUser.on("userSubscribed", function () {
|
6544
|
+
return _this2.handleSubscribeUser(newUser);
|
6474
6545
|
});
|
6475
|
-
|
6476
|
-
return _this2.handleUnsubscribeUser(
|
6546
|
+
newUser.on("userUnsubscribed", function () {
|
6547
|
+
return _this2.handleUnsubscribeUser(newUser);
|
6477
6548
|
});
|
6478
|
-
_context.next =
|
6479
|
-
return
|
6549
|
+
_context.next = 21;
|
6550
|
+
return newUser._ensureFetched();
|
6480
6551
|
|
6481
|
-
case
|
6482
|
-
return _context.abrupt("return",
|
6552
|
+
case 21:
|
6553
|
+
return _context.abrupt("return", newUser);
|
6483
6554
|
|
6484
|
-
case
|
6555
|
+
case 22:
|
6485
6556
|
case "end":
|
6486
6557
|
return _context.stop();
|
6487
6558
|
}
|
@@ -6489,7 +6560,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6489
6560
|
}, _callee, this);
|
6490
6561
|
}));
|
6491
6562
|
|
6492
|
-
function getUser(
|
6563
|
+
function getUser() {
|
6493
6564
|
return _getUser.apply(this, arguments);
|
6494
6565
|
}
|
6495
6566
|
|
@@ -6540,6 +6611,8 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6540
6611
|
key: "getSyncUniqueName",
|
6541
6612
|
value: function () {
|
6542
6613
|
var _getSyncUniqueName = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(identity) {
|
6614
|
+
var _response$body$sync_o, _response$body;
|
6615
|
+
|
6543
6616
|
var url, response;
|
6544
6617
|
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
6545
6618
|
while (1) {
|
@@ -6551,7 +6624,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6551
6624
|
|
6552
6625
|
case 3:
|
6553
6626
|
response = _context3.sent;
|
6554
|
-
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 : "");
|
6555
6628
|
|
6556
6629
|
case 5:
|
6557
6630
|
case "end":
|
@@ -6561,7 +6634,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6561
6634
|
}, _callee3, this);
|
6562
6635
|
}));
|
6563
6636
|
|
6564
|
-
function getSyncUniqueName(
|
6637
|
+
function getSyncUniqueName(_x) {
|
6565
6638
|
return _getSyncUniqueName.apply(this, arguments);
|
6566
6639
|
}
|
6567
6640
|
|
@@ -6572,7 +6645,7 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6572
6645
|
return Users;
|
6573
6646
|
}(replayEventEmitter.ReplayEventEmitter);
|
6574
6647
|
|
6575
|
-
var log$1 = Logger.scope(
|
6648
|
+
var log$1 = Logger.scope("TypingIndicator");
|
6576
6649
|
/**
|
6577
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
|
6578
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
|
@@ -6619,7 +6692,7 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6619
6692
|
var _this = this;
|
6620
6693
|
|
6621
6694
|
// this.services.notificationClient.subscribe(NotificationTypes.TYPING_INDICATOR, 'twilsock');
|
6622
|
-
this.services.notificationClient.on(
|
6695
|
+
this.services.notificationClient.on("message", /*#__PURE__*/function () {
|
6623
6696
|
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(type, message) {
|
6624
6697
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
6625
6698
|
while (1) {
|
@@ -6660,7 +6733,7 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6660
6733
|
while (1) {
|
6661
6734
|
switch (_context2.prev = _context2.next) {
|
6662
6735
|
case 0:
|
6663
|
-
log$1.trace(
|
6736
|
+
log$1.trace("Got new typing indicator ", message);
|
6664
6737
|
this.getConversation(message.channel_sid).then(function (conversation) {
|
6665
6738
|
if (!conversation) {
|
6666
6739
|
return;
|
@@ -6671,7 +6744,7 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6671
6744
|
return;
|
6672
6745
|
}
|
6673
6746
|
|
6674
|
-
var timeout = _this2.configuration.typingIndicatorTimeoutOverride + 1000
|
6747
|
+
var timeout = _this2.configuration.typingIndicatorTimeoutOverride ? _this2.configuration.typingIndicatorTimeoutOverride + 1000 : message.typing_timeout * 1000;
|
6675
6748
|
|
6676
6749
|
participant._startTyping(timeout);
|
6677
6750
|
});
|
@@ -6716,18 +6789,18 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6716
6789
|
value: function _send(conversationSid) {
|
6717
6790
|
var _this3 = this;
|
6718
6791
|
|
6719
|
-
log$1.trace(
|
6792
|
+
log$1.trace("Sending typing indicator");
|
6720
6793
|
var url = this.configuration.links.typing;
|
6721
6794
|
var headers = {
|
6722
|
-
|
6795
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
6723
6796
|
};
|
6724
6797
|
var body = "ChannelSid=".concat(conversationSid);
|
6725
6798
|
return this.services.twilsockClient.post(url, headers, body, this.configuration.productId).then(function (response) {
|
6726
|
-
if (response.body.hasOwnProperty(
|
6799
|
+
if (response.body.hasOwnProperty("typing_timeout")) {
|
6727
6800
|
_this3.serviceTypingTimeout = response.body.typing_timeout * 1000;
|
6728
6801
|
}
|
6729
6802
|
}).catch(function (err) {
|
6730
|
-
log$1.error(
|
6803
|
+
log$1.error("Failed to send typing indicator:", err);
|
6731
6804
|
throw err;
|
6732
6805
|
});
|
6733
6806
|
}
|
@@ -6783,14 +6856,14 @@ function PushNotification(data) {
|
|
6783
6856
|
this.data = data.data || {};
|
6784
6857
|
};
|
6785
6858
|
|
6786
|
-
var version = "2.1.0-rc.
|
6859
|
+
var version = "2.1.0-rc.7";
|
6787
6860
|
|
6788
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; }
|
6789
6862
|
|
6790
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; }
|
6791
6864
|
|
6792
6865
|
var trimSlashes = function trimSlashes(url) {
|
6793
|
-
return url.replace(/(^\/+|\/+$)/g,
|
6866
|
+
return url.replace(/(^\/+|\/+$)/g, "");
|
6794
6867
|
};
|
6795
6868
|
|
6796
6869
|
var isMutationConflictResponse = function isMutationConflictResponse(response) {
|
@@ -6828,19 +6901,19 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
6828
6901
|
case 0:
|
6829
6902
|
preProcessedUrl = this._preProcessUrl(url);
|
6830
6903
|
finalHeaders = _objectSpread$1({
|
6831
|
-
|
6904
|
+
"Content-Type": "application/json; charset=utf-8"
|
6832
6905
|
}, headers || {});
|
6833
6906
|
_context.t0 = method;
|
6834
|
-
_context.next = _context.t0 ===
|
6907
|
+
_context.next = _context.t0 === "get" ? 5 : _context.t0 === "post" ? 11 : _context.t0 === "delete" ? 15 : 19;
|
6835
6908
|
break;
|
6836
6909
|
|
6837
6910
|
case 5:
|
6838
6911
|
getUrl = preProcessedUrl;
|
6839
6912
|
|
6840
6913
|
if (requestBody) {
|
6841
|
-
getUrl +=
|
6842
|
-
return entry.map(encodeURIComponent).join(
|
6843
|
-
}).join(
|
6914
|
+
getUrl += "?" + Object.entries(requestBody).map(function (entry) {
|
6915
|
+
return entry.map(encodeURIComponent).join("=");
|
6916
|
+
}).join("&");
|
6844
6917
|
}
|
6845
6918
|
|
6846
6919
|
_context.next = 9;
|
@@ -6860,7 +6933,7 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
6860
6933
|
|
6861
6934
|
case 15:
|
6862
6935
|
_context.next = 17;
|
6863
|
-
return this._services.transport.delete(preProcessedUrl, finalHeaders,
|
6936
|
+
return this._services.transport.delete(preProcessedUrl, finalHeaders, {}, this._productId);
|
6864
6937
|
|
6865
6938
|
case 17:
|
6866
6939
|
response = _context.sent;
|
@@ -6910,28 +6983,24 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
6910
6983
|
max: 1600,
|
6911
6984
|
maxAttemptsCount: maxAttemptsCount
|
6912
6985
|
}).run(function () {
|
6913
|
-
return _this._makeRequest(
|
6986
|
+
return _this._makeRequest("get", url, requestBody);
|
6914
6987
|
});
|
6915
6988
|
|
6916
6989
|
case 4:
|
6917
6990
|
result = _context2.sent;
|
6918
|
-
_context2.
|
6919
|
-
break;
|
6991
|
+
return _context2.abrupt("return", result.body);
|
6920
6992
|
|
6921
|
-
case
|
6922
|
-
_context2.prev =
|
6993
|
+
case 8:
|
6994
|
+
_context2.prev = 8;
|
6923
6995
|
_context2.t0 = _context2["catch"](1);
|
6924
6996
|
throw new Error("Fetch resource from \"".concat(url, "\" failed."));
|
6925
6997
|
|
6926
|
-
case 10:
|
6927
|
-
return _context2.abrupt("return", result.body);
|
6928
|
-
|
6929
6998
|
case 11:
|
6930
6999
|
case "end":
|
6931
7000
|
return _context2.stop();
|
6932
7001
|
}
|
6933
7002
|
}
|
6934
|
-
}, _callee2, null, [[1,
|
7003
|
+
}, _callee2, null, [[1, 8]]);
|
6935
7004
|
}));
|
6936
7005
|
|
6937
7006
|
function fetchResource(_x5, _x6) {
|
@@ -6951,7 +7020,7 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
6951
7020
|
case 0:
|
6952
7021
|
_context3.next = 2;
|
6953
7022
|
return this._makeRequest(method, url, requestBody, {
|
6954
|
-
|
7023
|
+
"X-Twilio-Mutation-Id": uuid.v4()
|
6955
7024
|
});
|
6956
7025
|
|
6957
7026
|
case 2:
|
@@ -7001,7 +7070,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
7001
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; } }
|
7002
7071
|
|
7003
7072
|
var Client_1;
|
7004
|
-
var log = Logger.scope(
|
7073
|
+
var log = Logger.scope("Client");
|
7005
7074
|
var SDK_VERSION = version;
|
7006
7075
|
|
7007
7076
|
var ClientServices = function ClientServices() {
|
@@ -7049,22 +7118,14 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7049
7118
|
|
7050
7119
|
_this = _super.call(this);
|
7051
7120
|
|
7052
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "connectionState",
|
7053
|
-
|
7054
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "conversationsPromise", null);
|
7055
|
-
|
7056
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_ensureReady", null);
|
7057
|
-
|
7058
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_resolveEnsureReady", null);
|
7059
|
-
|
7060
|
-
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_rejectEnsureReady", null);
|
7121
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "connectionState", "unknown");
|
7061
7122
|
|
7062
7123
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "version", SDK_VERSION);
|
7063
7124
|
|
7064
7125
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "parsePushNotification", Client_1.parsePushNotification);
|
7065
7126
|
|
7066
|
-
_this.fpaToken = fpaToken;
|
7067
|
-
_this.options = options;
|
7127
|
+
_this.fpaToken = fpaToken !== null && fpaToken !== void 0 ? fpaToken : "";
|
7128
|
+
_this.options = options !== null && options !== void 0 ? options : {};
|
7068
7129
|
|
7069
7130
|
if (!_this.options.disableDeepClone) {
|
7070
7131
|
var _options = _objectSpread(_objectSpread({}, _this.options), {}, {
|
@@ -7078,25 +7139,25 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7078
7139
|
_this.options = _options;
|
7079
7140
|
}
|
7080
7141
|
|
7081
|
-
_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";
|
7082
7143
|
log.setLevel(_this.options.logLevel);
|
7083
|
-
var productId = _this.options.productId =
|
7144
|
+
var productId = _this.options.productId = "ip_messaging"; // Filling ClientMetadata
|
7084
7145
|
|
7085
7146
|
_this.options.clientMetadata = _this.options.clientMetadata || {};
|
7086
7147
|
|
7087
|
-
if (!_this.options.clientMetadata.hasOwnProperty(
|
7088
|
-
_this.options.clientMetadata.type =
|
7148
|
+
if (!_this.options.clientMetadata.hasOwnProperty("type")) {
|
7149
|
+
_this.options.clientMetadata.type = "conversations";
|
7089
7150
|
}
|
7090
7151
|
|
7091
|
-
if (!_this.options.clientMetadata.hasOwnProperty(
|
7092
|
-
_this.options.clientMetadata.sdk =
|
7152
|
+
if (!_this.options.clientMetadata.hasOwnProperty("sdk")) {
|
7153
|
+
_this.options.clientMetadata.sdk = "JS";
|
7093
7154
|
_this.options.clientMetadata.sdkv = SDK_VERSION;
|
7094
7155
|
} // Enable session local storage for Sync
|
7095
7156
|
|
7096
7157
|
|
7097
7158
|
_this.options.Sync = _this.options.Sync || {};
|
7098
7159
|
|
7099
|
-
if (typeof _this.options.Sync.enableSessionStorage ===
|
7160
|
+
if (typeof _this.options.Sync.enableSessionStorage === "undefined") {
|
7100
7161
|
_this.options.Sync.enableSessionStorage = true;
|
7101
7162
|
}
|
7102
7163
|
|
@@ -7105,11 +7166,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7105
7166
|
}
|
7106
7167
|
|
7107
7168
|
if (!fpaToken) {
|
7108
|
-
throw new Error(
|
7169
|
+
throw new Error("A valid Twilio token should be provided");
|
7109
7170
|
}
|
7110
7171
|
|
7111
7172
|
_this.services = new ClientServices();
|
7112
|
-
_this._myself = new User(
|
7173
|
+
_this._myself = new User("", "", null, _this.services);
|
7113
7174
|
var startTwilsock = !_this.options.twilsockClient; // Create default init registrations if none were provided.
|
7114
7175
|
// Otherwise, the outside party have to list all the init registrations they
|
7115
7176
|
// need.
|
@@ -7124,34 +7185,34 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7124
7185
|
|
7125
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);
|
7126
7187
|
|
7127
|
-
_this.services.twilsockClient.on(
|
7128
|
-
return _this.emit(
|
7188
|
+
_this.services.twilsockClient.on("tokenAboutToExpire", function (ttl) {
|
7189
|
+
return _this.emit("tokenAboutToExpire", ttl);
|
7129
7190
|
});
|
7130
7191
|
|
7131
|
-
_this.services.twilsockClient.on(
|
7132
|
-
return _this.emit(
|
7192
|
+
_this.services.twilsockClient.on("tokenExpired", function () {
|
7193
|
+
return _this.emit("tokenExpired");
|
7133
7194
|
});
|
7134
7195
|
|
7135
|
-
_this.services.twilsockClient.on(
|
7136
|
-
return _this.emit(
|
7196
|
+
_this.services.twilsockClient.on("connectionError", function (error) {
|
7197
|
+
return _this.emit("connectionError", error);
|
7137
7198
|
});
|
7138
7199
|
|
7139
|
-
_this.services.twilsockClient.on(
|
7200
|
+
_this.services.twilsockClient.on("stateChanged", function (state) {
|
7140
7201
|
log.debug("Handling stateChanged for ConversationsClient: new state ".concat(state));
|
7141
7202
|
|
7142
7203
|
if (state !== _this.connectionState) {
|
7143
7204
|
_this.connectionState = state;
|
7144
7205
|
|
7145
|
-
_this.emit(
|
7206
|
+
_this.emit("connectionStateChanged", _this.connectionState);
|
7146
7207
|
}
|
7147
7208
|
});
|
7148
7209
|
|
7149
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;
|
7150
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);
|
7151
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);
|
7152
|
-
var configurationOptions = options.Chat || options.IPMessaging || options || {};
|
7153
|
-
var region = configurationOptions.region || options.region;
|
7154
|
-
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");
|
7155
7216
|
_this.services.commandExecutor = new CommandExecutor(baseUrl, {
|
7156
7217
|
transport: _this.options.transport
|
7157
7218
|
}, productId);
|
@@ -7159,15 +7220,15 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7159
7220
|
var emitFailed = function emitFailed(err) {
|
7160
7221
|
_this._rejectEnsureReady(err);
|
7161
7222
|
|
7162
|
-
_this.emit(
|
7223
|
+
_this.emit("stateChanged", "failed");
|
7163
7224
|
};
|
7164
7225
|
|
7165
|
-
_this.services.twilsockClient.once(
|
7226
|
+
_this.services.twilsockClient.once("connectionError", emitFailed);
|
7166
7227
|
|
7167
|
-
_this.services.twilsockClient.once(
|
7228
|
+
_this.services.twilsockClient.once("disconnected", emitFailed); // ConversationsClient will be able to initialize only after twilsock is connected
|
7168
7229
|
|
7169
7230
|
|
7170
|
-
_this.services.twilsockClient.once(
|
7231
|
+
_this.services.twilsockClient.once("connected", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
7171
7232
|
var startupEvent;
|
7172
7233
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
7173
7234
|
while (1) {
|
@@ -7175,20 +7236,20 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7175
7236
|
case 0:
|
7176
7237
|
log.debug("ConversationsClient started INITIALIZING");
|
7177
7238
|
|
7178
|
-
_this.services.twilsockClient.off(
|
7239
|
+
_this.services.twilsockClient.off("connectionError", emitFailed);
|
7179
7240
|
|
7180
|
-
_this.services.twilsockClient.off(
|
7241
|
+
_this.services.twilsockClient.off("disconnected", emitFailed);
|
7181
7242
|
|
7182
7243
|
_context.prev = 3;
|
7183
|
-
startupEvent =
|
7244
|
+
startupEvent = "conversations.client.startup";
|
7184
7245
|
|
7185
|
-
_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);
|
7186
7247
|
|
7187
7248
|
_context.next = 8;
|
7188
7249
|
return _this._initialize();
|
7189
7250
|
|
7190
7251
|
case 8:
|
7191
|
-
_this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription(
|
7252
|
+
_this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription("", "", new Date()), startupEvent, twilsock.TelemetryPoint.End);
|
7192
7253
|
|
7193
7254
|
_context.next = 15;
|
7194
7255
|
break;
|
@@ -7200,7 +7261,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7200
7261
|
// Fail ChatClient if initialization is incomplete
|
7201
7262
|
_this._rejectEnsureReady(_context.t0);
|
7202
7263
|
|
7203
|
-
_this.emit(
|
7264
|
+
_this.emit("stateChanged", "failed");
|
7204
7265
|
|
7205
7266
|
case 15:
|
7206
7267
|
case "end":
|
@@ -7213,7 +7274,9 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7213
7274
|
_this._ensureReady = new Promise(function (resolve, reject) {
|
7214
7275
|
_this._resolveEnsureReady = resolve;
|
7215
7276
|
_this._rejectEnsureReady = reject;
|
7216
|
-
}).catch(function (
|
7277
|
+
}).catch(function () {
|
7278
|
+
return void 0;
|
7279
|
+
}); // @todo How to process unhandled rejection here?
|
7217
7280
|
|
7218
7281
|
if (startTwilsock) {
|
7219
7282
|
_this.services.twilsockClient.connect();
|
@@ -7242,7 +7305,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7242
7305
|
key: "reachabilityEnabled",
|
7243
7306
|
get: function get() {
|
7244
7307
|
if (!this.configuration) {
|
7245
|
-
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.");
|
7246
7309
|
}
|
7247
7310
|
|
7248
7311
|
return this.configuration.reachabilityEnabled;
|
@@ -7282,7 +7345,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7282
7345
|
switch (_context2.prev = _context2.next) {
|
7283
7346
|
case 0:
|
7284
7347
|
_context2.next = 2;
|
7285
|
-
return this.services.commandExecutor.fetchResource(
|
7348
|
+
return this.services.commandExecutor.fetchResource("Client/v2/Configuration");
|
7286
7349
|
|
7287
7350
|
case 2:
|
7288
7351
|
configurationResponse = _context2.sent;
|
@@ -7293,31 +7356,55 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7293
7356
|
this.services.typingIndicator = new TypingIndicator(this.getConversationBySid.bind(this), this.configuration, this.services);
|
7294
7357
|
this.services.network = new Network(this.configuration, this.services);
|
7295
7358
|
this.services.users = new Users(this._myself, this.configuration, this.services);
|
7296
|
-
this.services.users.on(
|
7297
|
-
|
7298
|
-
|
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);
|
7299
7367
|
});
|
7300
|
-
this.services.users.on('userUnsubscribed', this.emit.bind(this, 'userUnsubscribed'));
|
7301
7368
|
this.conversations = new Conversations(this.configuration, this.services);
|
7302
|
-
this.conversations.on(
|
7303
|
-
|
7304
|
-
|
7305
|
-
this.conversations.on(
|
7306
|
-
|
7307
|
-
|
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);
|
7308
7401
|
});
|
7309
|
-
this.conversations.on(
|
7310
|
-
|
7311
|
-
this.conversations.on('participantUpdated', function (args) {
|
7312
|
-
return _this4.emit('participantUpdated', args);
|
7402
|
+
this.conversations.on("typingStarted", function (participant) {
|
7403
|
+
return _this4.emit("typingStarted", participant);
|
7313
7404
|
});
|
7314
|
-
this.conversations.on(
|
7315
|
-
|
7316
|
-
return _this4.emit('messageUpdated', args);
|
7405
|
+
this.conversations.on("typingEnded", function (participant) {
|
7406
|
+
return _this4.emit("typingEnded", participant);
|
7317
7407
|
});
|
7318
|
-
this.conversations.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));
|
7319
|
-
this.conversations.on('typingStarted', this.emit.bind(this, 'typingStarted'));
|
7320
|
-
this.conversations.on('typingEnded', this.emit.bind(this, 'typingEnded'));
|
7321
7408
|
this.conversationsPromise = this.conversations.fetchConversations().then(function () {
|
7322
7409
|
return _this4.conversations;
|
7323
7410
|
}).catch(function (error) {
|
@@ -7332,12 +7419,12 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7332
7419
|
});
|
7333
7420
|
this.services.typingIndicator.initialize();
|
7334
7421
|
this.services.mcsClient = new mcsClient.McsClient(this.fpaToken, this.configuration.links.mediaService, this.configuration.links.mediaSetService, _objectSpread(_objectSpread({}, this.options), {}, {
|
7335
|
-
transport:
|
7422
|
+
transport: undefined
|
7336
7423
|
}));
|
7337
7424
|
|
7338
7425
|
this._resolveEnsureReady();
|
7339
7426
|
|
7340
|
-
this.emit(
|
7427
|
+
this.emit("stateChanged", "initialized");
|
7341
7428
|
|
7342
7429
|
case 33:
|
7343
7430
|
case "end":
|
@@ -7403,7 +7490,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7403
7490
|
return this._ensureReady;
|
7404
7491
|
|
7405
7492
|
case 2:
|
7406
|
-
log.info(
|
7493
|
+
log.info("updateToken");
|
7407
7494
|
|
7408
7495
|
if (!(this.fpaToken === token)) {
|
7409
7496
|
_context4.next = 5;
|
@@ -7565,7 +7652,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7565
7652
|
}, {
|
7566
7653
|
key: "getSubscribedConversations",
|
7567
7654
|
value: function () {
|
7568
|
-
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() {
|
7569
7656
|
return _regeneratorRuntime__default['default'].wrap(function _callee7$(_context7) {
|
7570
7657
|
while (1) {
|
7571
7658
|
switch (_context7.prev = _context7.next) {
|
@@ -7575,7 +7662,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7575
7662
|
|
7576
7663
|
case 2:
|
7577
7664
|
return _context7.abrupt("return", this.conversationsPromise.then(function (conversations) {
|
7578
|
-
return conversations.getConversations(
|
7665
|
+
return conversations.getConversations();
|
7579
7666
|
}));
|
7580
7667
|
|
7581
7668
|
case 3:
|
@@ -7586,7 +7673,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7586
7673
|
}, _callee7, this);
|
7587
7674
|
}));
|
7588
7675
|
|
7589
|
-
function getSubscribedConversations(
|
7676
|
+
function getSubscribedConversations() {
|
7590
7677
|
return _getSubscribedConversations.apply(this, arguments);
|
7591
7678
|
}
|
7592
7679
|
|
@@ -7623,7 +7710,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7623
7710
|
}, _callee8, this);
|
7624
7711
|
}));
|
7625
7712
|
|
7626
|
-
function createConversation(
|
7713
|
+
function createConversation(_x4) {
|
7627
7714
|
return _createConversation.apply(this, arguments);
|
7628
7715
|
}
|
7629
7716
|
|
@@ -7661,7 +7748,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7661
7748
|
}, _callee9, this);
|
7662
7749
|
}));
|
7663
7750
|
|
7664
|
-
function setPushRegistrationId(
|
7751
|
+
function setPushRegistrationId(_x5, _x6) {
|
7665
7752
|
return _setPushRegistrationId.apply(this, arguments);
|
7666
7753
|
}
|
7667
7754
|
|
@@ -7698,7 +7785,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7698
7785
|
}, _callee10, this);
|
7699
7786
|
}));
|
7700
7787
|
|
7701
|
-
function unsetPushRegistrationId(
|
7788
|
+
function unsetPushRegistrationId(_x7) {
|
7702
7789
|
return _unsetPushRegistrationId.apply(this, arguments);
|
7703
7790
|
}
|
7704
7791
|
|
@@ -7734,7 +7821,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7734
7821
|
}, _callee11, this);
|
7735
7822
|
}));
|
7736
7823
|
|
7737
|
-
function removePushRegistrations(
|
7824
|
+
function removePushRegistrations(_x8, _x9) {
|
7738
7825
|
return _removePushRegistrations.apply(this, arguments);
|
7739
7826
|
}
|
7740
7827
|
|
@@ -7757,8 +7844,8 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7757
7844
|
return this._ensureReady;
|
7758
7845
|
|
7759
7846
|
case 2:
|
7760
|
-
log.debug(
|
7761
|
-
this.emit(
|
7847
|
+
log.debug("handlePushNotification, notificationPayload=", notificationPayload);
|
7848
|
+
this.emit("pushNotification", Client_1.parsePushNotification(notificationPayload));
|
7762
7849
|
|
7763
7850
|
case 4:
|
7764
7851
|
case "end":
|
@@ -7768,7 +7855,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7768
7855
|
}, _callee12, this);
|
7769
7856
|
}));
|
7770
7857
|
|
7771
|
-
function handlePushNotification(
|
7858
|
+
function handlePushNotification(_x10) {
|
7772
7859
|
return _handlePushNotification.apply(this, arguments);
|
7773
7860
|
}
|
7774
7861
|
|
@@ -7803,7 +7890,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7803
7890
|
}, _callee13, this);
|
7804
7891
|
}));
|
7805
7892
|
|
7806
|
-
function getUser(
|
7893
|
+
function getUser(_x11) {
|
7807
7894
|
return _getUser.apply(this, arguments);
|
7808
7895
|
}
|
7809
7896
|
|
@@ -7890,7 +7977,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7890
7977
|
break;
|
7891
7978
|
}
|
7892
7979
|
|
7893
|
-
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.");
|
7894
7981
|
|
7895
7982
|
case 2:
|
7896
7983
|
client = new Client_1(token, options);
|
@@ -7908,7 +7995,7 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7908
7995
|
}, _callee15);
|
7909
7996
|
}));
|
7910
7997
|
|
7911
|
-
function create(
|
7998
|
+
function create(_x12, _x13) {
|
7912
7999
|
return _create.apply(this, arguments);
|
7913
8000
|
}
|
7914
8001
|
|
@@ -7920,11 +8007,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7920
8007
|
var result = {};
|
7921
8008
|
|
7922
8009
|
for (var key in Client_1.supportedPushDataFields) {
|
7923
|
-
if (typeof data[key] ===
|
8010
|
+
if (typeof data[key] === "undefined" || data[key] === null) {
|
7924
8011
|
continue;
|
7925
8012
|
}
|
7926
8013
|
|
7927
|
-
if (key !==
|
8014
|
+
if (key !== "message_index") {
|
7928
8015
|
result[Client_1.supportedPushDataFields[key]] = data[key];
|
7929
8016
|
continue;
|
7930
8017
|
}
|
@@ -7944,19 +8031,19 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7944
8031
|
}, {
|
7945
8032
|
key: "parsePushNotification",
|
7946
8033
|
value: function parsePushNotification(notificationPayload) {
|
7947
|
-
log.debug(
|
8034
|
+
log.debug("parsePushNotification, notificationPayload=", notificationPayload); // APNS specifics
|
7948
8035
|
|
7949
|
-
if (typeof notificationPayload.aps !==
|
8036
|
+
if (typeof notificationPayload.aps !== "undefined") {
|
7950
8037
|
if (!notificationPayload.twi_message_type) {
|
7951
|
-
throw new Error(
|
8038
|
+
throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
|
7952
8039
|
}
|
7953
8040
|
|
7954
8041
|
var data = Client_1.parsePushNotificationChatData(notificationPayload);
|
7955
8042
|
var apsPayload = notificationPayload.aps;
|
7956
|
-
var body
|
8043
|
+
var body;
|
7957
8044
|
var title = null;
|
7958
8045
|
|
7959
|
-
if (typeof apsPayload.alert ===
|
8046
|
+
if (typeof apsPayload.alert === "string") {
|
7960
8047
|
body = apsPayload.alert || null;
|
7961
8048
|
} else {
|
7962
8049
|
body = apsPayload.alert.body || null;
|
@@ -7975,11 +8062,11 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7975
8062
|
} // FCM specifics
|
7976
8063
|
|
7977
8064
|
|
7978
|
-
if (typeof notificationPayload.data !==
|
8065
|
+
if (typeof notificationPayload.data !== "undefined") {
|
7979
8066
|
var dataPayload = notificationPayload.data;
|
7980
8067
|
|
7981
8068
|
if (!dataPayload.twi_message_type) {
|
7982
|
-
throw new Error(
|
8069
|
+
throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
|
7983
8070
|
}
|
7984
8071
|
|
7985
8072
|
var _data = Client_1.parsePushNotificationChatData(notificationPayload.data);
|
@@ -7995,16 +8082,16 @@ exports.Client = Client_1 = (_temp = _class = /*#__PURE__*/function (_ReplayEven
|
|
7995
8082
|
});
|
7996
8083
|
}
|
7997
8084
|
|
7998
|
-
throw new Error(
|
8085
|
+
throw new Error("Provided push notification payload is not Programmable Chat notification");
|
7999
8086
|
}
|
8000
8087
|
}]);
|
8001
8088
|
|
8002
8089
|
return Client;
|
8003
|
-
}(replayEventEmitter.ReplayEventEmitter), _defineProperty__default['default'](_class, "version", SDK_VERSION), _defineProperty__default['default'](_class, "supportedPushChannels", [
|
8004
|
-
|
8005
|
-
|
8006
|
-
|
8007
|
-
}), _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);
|
8008
8095
|
|
8009
8096
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "updateToken", null);
|
8010
8097
|
|
@@ -8012,27 +8099,27 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
|
|
8012
8099
|
|
8013
8100
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "getConversationByUniqueName", null);
|
8014
8101
|
|
8015
|
-
__decorate([declarativeTypeValidator.validateTypesAsync([
|
8016
|
-
friendlyName: [
|
8017
|
-
isPrivate: [
|
8018
|
-
uniqueName: [
|
8102
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(["undefined", declarativeTypeValidator.objectSchema("conversation options", {
|
8103
|
+
friendlyName: ["string", "undefined"],
|
8104
|
+
isPrivate: ["boolean", "undefined"],
|
8105
|
+
uniqueName: ["string", "undefined"]
|
8019
8106
|
})]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], exports.Client.prototype, "createConversation", null);
|
8020
8107
|
|
8021
|
-
__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);
|
8022
8109
|
|
8023
|
-
__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);
|
8024
8111
|
|
8025
|
-
__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);
|
8026
8113
|
|
8027
8114
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.pureObject), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], exports.Client.prototype, "handlePushNotification", null);
|
8028
8115
|
|
8029
8116
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "getUser", null);
|
8030
8117
|
|
8031
|
-
__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);
|
8032
8119
|
|
8033
8120
|
__decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.pureObject), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", PushNotification)], exports.Client, "parsePushNotification", null);
|
8034
8121
|
|
8035
|
-
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);
|
8036
8123
|
|
8037
8124
|
exports.AggregatedDeliveryReceipt = AggregatedDeliveryReceipt;
|
8038
8125
|
exports.Conversation = Conversation;
|