@twilio/conversations 3.0.0-rc.9 → 3.0.1-rc.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -28
- package/builds/browser.js +1659 -264
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +650 -25
- package/builds/lib.js +1650 -264
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +4300 -1842
- package/builds/twilio-conversations.min.js +1 -1
- package/dist/aggregated-delivery-receipt.js +10 -1
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/channel-metadata-client.js +192 -0
- package/dist/channel-metadata-client.js.map +1 -0
- package/dist/client.js +70 -10
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +48 -6
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +14 -3
- package/dist/configuration.js.map +1 -1
- package/dist/content-client.js +184 -0
- package/dist/content-client.js.map +1 -0
- package/dist/content-template.js +310 -0
- package/dist/content-template.js.map +1 -0
- package/dist/conversation.js +59 -16
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +25 -3
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +23 -6
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +17 -8
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +9 -0
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js +9 -0
- package/dist/detailed-delivery-receipt.js.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/notification-types.js +9 -0
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/interfaces/{attributes.js → rules.js} +26 -7
- package/dist/interfaces/rules.js.map +1 -0
- package/dist/logger.js +9 -0
- package/dist/logger.js.map +1 -1
- package/dist/media.js +9 -0
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +77 -6
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +156 -12
- package/dist/message.js.map +1 -1
- package/dist/node_modules/quick-lru/index.js +265 -0
- package/dist/node_modules/quick-lru/index.js.map +1 -0
- package/dist/node_modules/tslib/tslib.es6.js +9 -0
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/packages/conversations/package.json.js +10 -1
- package/dist/packages/conversations/package.json.js.map +1 -1
- package/dist/participant.js +11 -2
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js +9 -0
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js +9 -0
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +9 -0
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +9 -0
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js +9 -0
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +20 -3
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js +9 -0
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js +9 -0
- package/dist/util/index.js.map +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/classes/AggregatedDeliveryReceipt.html +1 -1
- package/docs/classes/ChannelMetadata.html +3050 -0
- package/docs/classes/Client.html +64 -25
- package/docs/classes/ContentTemplate.html +3116 -0
- package/docs/classes/ContentTemplateVariable.html +3116 -0
- package/docs/classes/Conversation.html +14 -9
- package/docs/classes/Message.html +76 -5
- package/docs/classes/MessageBuilder.html +41 -0
- package/docs/classes/Participant.html +2 -2
- package/docs/index.html +849 -25
- package/docs/interfaces/ClientOptions.html +16 -0
- package/docs/modules.html +848 -24
- package/package.json +18 -14
- package/CHANGELOG.md +0 -509
- package/dist/interfaces/attributes.js.map +0 -1
package/builds/lib.js
CHANGED
@@ -164,6 +164,7 @@ require('core-js/modules/es.regexp.exec.js');
|
|
164
164
|
require('core-js/modules/es.string.replace.js');
|
165
165
|
require('core-js/modules/es.array.join.js');
|
166
166
|
var declarativeTypeValidator = require('@twilio/declarative-type-validator');
|
167
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
167
168
|
require('core-js/modules/es.array.includes.js');
|
168
169
|
var replayEventEmitter = require('@twilio/replay-event-emitter');
|
169
170
|
var isEqual = require('lodash.isequal');
|
@@ -179,7 +180,6 @@ var twilsock = require('twilsock');
|
|
179
180
|
var notifications = require('@twilio/notifications');
|
180
181
|
var twilioSync = require('twilio-sync');
|
181
182
|
var mcsClient = require('@twilio/mcs-client');
|
182
|
-
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
183
183
|
require('core-js/modules/es.set.js');
|
184
184
|
require('core-js/modules/es.number.is-integer.js');
|
185
185
|
require('core-js/modules/es.typed-array.uint8-array.js');
|
@@ -211,10 +211,14 @@ require('core-js/modules/es.array-buffer.constructor.js');
|
|
211
211
|
require('isomorphic-form-data');
|
212
212
|
require('core-js/modules/es.array.sort.js');
|
213
213
|
require('core-js/modules/es.string.includes.js');
|
214
|
+
require('core-js/modules/es.string.starts-with.js');
|
215
|
+
var deprecationDecorator = require('@twilio/deprecation-decorator');
|
216
|
+
require('core-js/modules/es.object.entries.js');
|
214
217
|
require('core-js/modules/es.array.find.js');
|
215
218
|
require('core-js/modules/es.array.splice.js');
|
216
|
-
require('
|
219
|
+
var _wrapNativeSuper = require('@babel/runtime/helpers/wrapNativeSuper');
|
217
220
|
var uuid = require('uuid');
|
221
|
+
require('core-js/modules/es.object.freeze.js');
|
218
222
|
|
219
223
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
220
224
|
|
@@ -247,9 +251,10 @@ var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallChec
|
|
247
251
|
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
248
252
|
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
249
253
|
var loglevelLog__namespace = /*#__PURE__*/_interopNamespace(loglevelLog);
|
254
|
+
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
250
255
|
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
251
256
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
252
|
-
var
|
257
|
+
var _wrapNativeSuper__default = /*#__PURE__*/_interopDefaultLegacy(_wrapNativeSuper);
|
253
258
|
|
254
259
|
function __decorate(decorators, target, key, desc) {
|
255
260
|
var c = arguments.length,
|
@@ -389,9 +394,9 @@ var Logger = /*#__PURE__*/function () {
|
|
389
394
|
return Logger;
|
390
395
|
}();
|
391
396
|
|
392
|
-
function ownKeys$
|
397
|
+
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
393
398
|
|
394
|
-
function _objectSpread$
|
399
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
395
400
|
var TYPING_TIMEOUT = 5;
|
396
401
|
var HTTP_CACHE_LIFETIME = "PT5S";
|
397
402
|
var CONSUMPTION_HORIZON_SENDING_INTERVAL = "PT5S";
|
@@ -402,7 +407,7 @@ var MAXIMUM_ATTEMPTS_COUNT = 3;
|
|
402
407
|
var RETRY_WHEN_THROTTLED = true;
|
403
408
|
|
404
409
|
var Configuration = /*#__PURE__*/_createClass__default["default"](function Configuration() {
|
405
|
-
var _ref, _constructorOptions$u, _ref2, _constructorOptions$h, _ref3, _constructorOptions$c;
|
410
|
+
var _ref, _constructorOptions$u, _ref2, _constructorOptions$h, _ref3, _constructorOptions$c, _options$channelMetad;
|
406
411
|
|
407
412
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
408
413
|
var configurationResponse = arguments.length > 1 ? arguments[1] : undefined;
|
@@ -432,7 +437,7 @@ var Configuration = /*#__PURE__*/_createClass__default["default"](function Confi
|
|
432
437
|
emailBodiesAllowedContentTypes: configurationResponse.options.email_bodies_allowed_mime_types
|
433
438
|
};
|
434
439
|
this.typingIndicatorTimeoutOverride = constructorOptions.typingIndicatorTimeoutOverride;
|
435
|
-
this.backoffConfiguration = _objectSpread$
|
440
|
+
this.backoffConfiguration = _objectSpread$5({
|
436
441
|
min: MINIMUM_RETRY_DELAY,
|
437
442
|
max: MAXIMUM_RETRY_DELAY,
|
438
443
|
maxAttemptsCount: MAXIMUM_ATTEMPTS_COUNT
|
@@ -460,6 +465,8 @@ var Configuration = /*#__PURE__*/_createClass__default["default"](function Confi
|
|
460
465
|
logger.error("Failed to parse consumption report interval ".concat(consumptionReportInterval, ", using default value ").concat(CONSUMPTION_HORIZON_SENDING_INTERVAL));
|
461
466
|
this.consumptionReportInterval = iso8601Duration.toSeconds(iso8601Duration.parse(CONSUMPTION_HORIZON_SENDING_INTERVAL));
|
462
467
|
}
|
468
|
+
|
469
|
+
this.channelMetadataCacheCapacity = (_options$channelMetad = options.channelMetadataCacheCapacity) !== null && _options$channelMetad !== void 0 ? _options$channelMetad : 100;
|
463
470
|
});
|
464
471
|
|
465
472
|
/**
|
@@ -552,16 +559,21 @@ var UriBuilder = /*#__PURE__*/function () {
|
|
552
559
|
return UriBuilder;
|
553
560
|
}();
|
554
561
|
|
555
|
-
var
|
562
|
+
var json = declarativeTypeValidator.custom(function (value) {
|
556
563
|
return [["string", "number", "boolean", "object"].includes(_typeof__default["default"](value)), "a JSON type"];
|
557
564
|
});
|
558
|
-
var
|
565
|
+
var optionalJson = declarativeTypeValidator.custom(function (value) {
|
559
566
|
return [["undefined", "string", "number", "boolean", "object"].includes(_typeof__default["default"](value)), "an optional JSON type"];
|
560
567
|
});
|
568
|
+
var sendMediaOptions = declarativeTypeValidator.objectSchema("send media options", {
|
569
|
+
contentType: [declarativeTypeValidator.literal(null), "string"],
|
570
|
+
filename: ["string", "undefined"],
|
571
|
+
media: [declarativeTypeValidator.literal("null"), "string"].concat(_toConsumableArray__default["default"](typeof Buffer === "function" ? [Buffer] : []), _toConsumableArray__default["default"](typeof Blob === "function" ? [Blob] : []))
|
572
|
+
});
|
561
573
|
|
562
|
-
function _createSuper$
|
574
|
+
function _createSuper$9(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$9(); 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); }; }
|
563
575
|
|
564
|
-
function _isNativeReflectConstruct$
|
576
|
+
function _isNativeReflectConstruct$9() { 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; } }
|
565
577
|
var log$6 = Logger.scope("User");
|
566
578
|
/**
|
567
579
|
* Extended user information.
|
@@ -573,7 +585,7 @@ var log$6 = Logger.scope("User");
|
|
573
585
|
var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
574
586
|
_inherits__default["default"](User, _ReplayEventEmitter);
|
575
587
|
|
576
|
-
var _super = _createSuper$
|
588
|
+
var _super = _createSuper$9(User);
|
577
589
|
|
578
590
|
/**
|
579
591
|
* @internal
|
@@ -839,6 +851,10 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
839
851
|
log$6.debug(_this3.state.entityName + " (" + _this3.state.identity + ") itemUpdated: " + args.item.key);
|
840
852
|
return _this3._update(args.item.key, args.item.data);
|
841
853
|
});
|
854
|
+
map.on("itemAdded", function (args) {
|
855
|
+
log$6.debug(_this3.state.entityName + " (" + _this3.state.identity + ") itemAdded: " + args.item.key);
|
856
|
+
return _this3._update(args.item.key, args.item.data);
|
857
|
+
});
|
842
858
|
return Promise.all([map.get("friendlyName").then(function (item) {
|
843
859
|
return _this3._update(item.key, item.data);
|
844
860
|
}), map.get("attributes").then(function (item) {
|
@@ -1047,7 +1063,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1047
1063
|
this.identity = identity;
|
1048
1064
|
this.entityName = entityName;
|
1049
1065
|
this.links = {
|
1050
|
-
self: "".concat(this.configuration.links.users, "/").concat(this.identity)
|
1066
|
+
self: "".concat(this.configuration.links.users, "/").concat(encodeURIComponent(this.identity))
|
1051
1067
|
};
|
1052
1068
|
|
1053
1069
|
this._resolveInitializationPromise();
|
@@ -1064,15 +1080,15 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1064
1080
|
return User;
|
1065
1081
|
}(replayEventEmitter.ReplayEventEmitter);
|
1066
1082
|
|
1067
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
1083
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], User.prototype, "updateAttributes", null);
|
1068
1084
|
|
1069
1085
|
__decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], User.prototype, "updateFriendlyName", null);
|
1070
1086
|
|
1071
|
-
function _createForOfIteratorHelper$
|
1087
|
+
function _createForOfIteratorHelper$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(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; } } }; }
|
1072
1088
|
|
1073
|
-
function _unsupportedIterableToArray$
|
1089
|
+
function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); }
|
1074
1090
|
|
1075
|
-
function _arrayLikeToArray$
|
1091
|
+
function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
1076
1092
|
|
1077
1093
|
var Network = /*#__PURE__*/function () {
|
1078
1094
|
function Network(configuration, services) {
|
@@ -1093,7 +1109,7 @@ var Network = /*#__PURE__*/function () {
|
|
1093
1109
|
}, {
|
1094
1110
|
key: "cleanupCache",
|
1095
1111
|
value: function cleanupCache() {
|
1096
|
-
var _iterator = _createForOfIteratorHelper$
|
1112
|
+
var _iterator = _createForOfIteratorHelper$4(this.cache),
|
1097
1113
|
_step;
|
1098
1114
|
|
1099
1115
|
try {
|
@@ -1237,9 +1253,9 @@ _defineProperty__default["default"](NotificationTypes, "REMOVED_FROM_CONVERSATIO
|
|
1237
1253
|
|
1238
1254
|
_defineProperty__default["default"](NotificationTypes, "CONSUMPTION_UPDATE", "twilio.channel.consumption_update");
|
1239
1255
|
|
1240
|
-
function _createSuper$
|
1256
|
+
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); }; }
|
1241
1257
|
|
1242
|
-
function _isNativeReflectConstruct$
|
1258
|
+
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; } }
|
1243
1259
|
var log$5 = Logger.scope("Participant");
|
1244
1260
|
/**
|
1245
1261
|
* A participant represents a remote client in a conversation.
|
@@ -1248,7 +1264,7 @@ var log$5 = Logger.scope("Participant");
|
|
1248
1264
|
var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
1249
1265
|
_inherits__default["default"](Participant, _ReplayEventEmitter);
|
1250
1266
|
|
1251
|
-
var _super = _createSuper$
|
1267
|
+
var _super = _createSuper$8(Participant);
|
1252
1268
|
|
1253
1269
|
/**
|
1254
1270
|
* @internal
|
@@ -1618,11 +1634,11 @@ _defineProperty__default["default"](Participant, "typingEnded", "typingEnded");
|
|
1618
1634
|
|
1619
1635
|
_defineProperty__default["default"](Participant, "updated", "updated");
|
1620
1636
|
|
1621
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
1637
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Participant.prototype, "updateAttributes", null);
|
1622
1638
|
|
1623
|
-
function _createSuper$
|
1639
|
+
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); }; }
|
1624
1640
|
|
1625
|
-
function _isNativeReflectConstruct$
|
1641
|
+
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; } }
|
1626
1642
|
var log$4 = Logger.scope("Participants");
|
1627
1643
|
/**
|
1628
1644
|
* @classdesc Represents the collection of participants for the conversation
|
@@ -1634,7 +1650,7 @@ var log$4 = Logger.scope("Participants");
|
|
1634
1650
|
var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
1635
1651
|
_inherits__default["default"](Participants, _ReplayEventEmitter);
|
1636
1652
|
|
1637
|
-
var _super = _createSuper$
|
1653
|
+
var _super = _createSuper$7(Participants);
|
1638
1654
|
|
1639
1655
|
function Participants(conversation, participants, links, configuration, services) {
|
1640
1656
|
var _this;
|
@@ -1691,13 +1707,14 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1691
1707
|
}()
|
1692
1708
|
}, {
|
1693
1709
|
key: "subscribe",
|
1694
|
-
value: function subscribe(
|
1710
|
+
value: function subscribe(arg) {
|
1695
1711
|
var _this2 = this;
|
1696
1712
|
|
1697
|
-
|
1698
|
-
id:
|
1713
|
+
var participantsMapPromise = typeof arg === "string" ? this.services.syncClient.map({
|
1714
|
+
id: arg,
|
1699
1715
|
mode: "open_existing"
|
1700
|
-
}).
|
1716
|
+
}) : Promise.resolve(arg);
|
1717
|
+
return this.rosterEntityPromise = this.rosterEntityPromise || participantsMapPromise.then(function (rosterMap) {
|
1701
1718
|
rosterMap.on("itemAdded", function (args) {
|
1702
1719
|
log$4.debug(_this2.conversation.sid + " itemAdded: " + args.item.key);
|
1703
1720
|
|
@@ -1969,7 +1986,6 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1969
1986
|
key: "add",
|
1970
1987
|
value: function () {
|
1971
1988
|
var _add = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(identity, attributes) {
|
1972
|
-
var participantResponse;
|
1973
1989
|
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context7) {
|
1974
1990
|
while (1) {
|
1975
1991
|
switch (_context7.prev = _context7.next) {
|
@@ -1981,14 +1997,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1981
1997
|
});
|
1982
1998
|
|
1983
1999
|
case 2:
|
1984
|
-
participantResponse = _context7.sent;
|
1985
|
-
_context7.next = 5;
|
1986
|
-
return this.upsertParticipantFromResponse(participantResponse);
|
1987
|
-
|
1988
|
-
case 5:
|
1989
2000
|
return _context7.abrupt("return", _context7.sent);
|
1990
2001
|
|
1991
|
-
case
|
2002
|
+
case 3:
|
1992
2003
|
case "end":
|
1993
2004
|
return _context7.stop();
|
1994
2005
|
}
|
@@ -2014,7 +2025,6 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2014
2025
|
|
2015
2026
|
var attributes,
|
2016
2027
|
bindingOptions,
|
2017
|
-
participantResponse,
|
2018
2028
|
_args8 = arguments;
|
2019
2029
|
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context8) {
|
2020
2030
|
while (1) {
|
@@ -2034,14 +2044,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2034
2044
|
});
|
2035
2045
|
|
2036
2046
|
case 4:
|
2037
|
-
participantResponse = _context8.sent;
|
2038
|
-
_context8.next = 7;
|
2039
|
-
return this.upsertParticipantFromResponse(participantResponse);
|
2040
|
-
|
2041
|
-
case 7:
|
2042
2047
|
return _context8.abrupt("return", _context8.sent);
|
2043
2048
|
|
2044
|
-
case
|
2049
|
+
case 5:
|
2045
2050
|
case "end":
|
2046
2051
|
return _context8.stop();
|
2047
2052
|
}
|
@@ -2062,7 +2067,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2062
2067
|
}, {
|
2063
2068
|
key: "remove",
|
2064
2069
|
value: function remove(identity) {
|
2065
|
-
return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(identity));
|
2070
|
+
return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(encodeURIComponent(identity)));
|
2066
2071
|
}
|
2067
2072
|
}]);
|
2068
2073
|
|
@@ -2314,7 +2319,7 @@ var Media = /*#__PURE__*/function () {
|
|
2314
2319
|
* Contains aggregated information about delivery statuses of a message across all participants
|
2315
2320
|
* of a conversation.
|
2316
2321
|
*
|
2317
|
-
* At any moment during the message delivery to a participant, the message can have zero or more of following
|
2322
|
+
* At any moment during the message delivery to a participant, the message can have zero or more of the following
|
2318
2323
|
* delivery statuses:
|
2319
2324
|
* * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
|
2320
2325
|
* * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
|
@@ -2557,22 +2562,264 @@ function DetailedDeliveryReceipt(descriptor) {
|
|
2557
2562
|
this.dateUpdated = descriptor.date_updated;
|
2558
2563
|
});
|
2559
2564
|
|
2560
|
-
|
2565
|
+
var collectActions = function collectActions(actions) {
|
2566
|
+
return actions.map(function (action) {
|
2567
|
+
var _action$id, _action$index, _action$phone, _action$url;
|
2561
2568
|
|
2562
|
-
|
2569
|
+
var rawData = JSON.stringify(action);
|
2563
2570
|
|
2564
|
-
|
2571
|
+
switch (action.type) {
|
2572
|
+
case "QUICK_REPLY":
|
2573
|
+
return {
|
2574
|
+
type: "reply",
|
2575
|
+
title: action.title,
|
2576
|
+
id: (_action$id = action.id) !== null && _action$id !== void 0 ? _action$id : "",
|
2577
|
+
index: (_action$index = action.index) !== null && _action$index !== void 0 ? _action$index : 0,
|
2578
|
+
rawData: rawData
|
2579
|
+
};
|
2565
2580
|
|
2566
|
-
|
2581
|
+
case "PHONE_NUMBER":
|
2582
|
+
return {
|
2583
|
+
type: "phone",
|
2584
|
+
title: action.title,
|
2585
|
+
phone: (_action$phone = action.phone) !== null && _action$phone !== void 0 ? _action$phone : "",
|
2586
|
+
rawData: rawData
|
2587
|
+
};
|
2588
|
+
|
2589
|
+
case "URL":
|
2590
|
+
return {
|
2591
|
+
type: "url",
|
2592
|
+
title: action.title,
|
2593
|
+
url: (_action$url = action.url) !== null && _action$url !== void 0 ? _action$url : "",
|
2594
|
+
rawData: rawData
|
2595
|
+
};
|
2596
|
+
|
2597
|
+
default:
|
2598
|
+
return {
|
2599
|
+
type: "other",
|
2600
|
+
rawData: rawData
|
2601
|
+
};
|
2602
|
+
}
|
2603
|
+
});
|
2604
|
+
};
|
2605
|
+
|
2606
|
+
var parseVariant = function parseVariant(type, data) {
|
2607
|
+
var rawData = JSON.stringify(data);
|
2608
|
+
|
2609
|
+
switch (type) {
|
2610
|
+
case "twilio/text":
|
2611
|
+
{
|
2612
|
+
var variant = data;
|
2613
|
+
return {
|
2614
|
+
type: "text",
|
2615
|
+
body: variant.body,
|
2616
|
+
rawData: rawData
|
2617
|
+
};
|
2618
|
+
}
|
2619
|
+
|
2620
|
+
case "twilio/media":
|
2621
|
+
{
|
2622
|
+
var _variant = data;
|
2623
|
+
return {
|
2624
|
+
type: "media",
|
2625
|
+
body: _variant.body,
|
2626
|
+
media: _variant.media,
|
2627
|
+
rawData: rawData
|
2628
|
+
};
|
2629
|
+
}
|
2630
|
+
|
2631
|
+
case "twilio/location":
|
2632
|
+
{
|
2633
|
+
var _variant2 = data;
|
2634
|
+
return {
|
2635
|
+
type: "location",
|
2636
|
+
longitude: _variant2.longitude,
|
2637
|
+
latitude: _variant2.latitude,
|
2638
|
+
label: _variant2.label,
|
2639
|
+
rawData: rawData
|
2640
|
+
};
|
2641
|
+
}
|
2642
|
+
|
2643
|
+
case "twilio/quick-reply":
|
2644
|
+
{
|
2645
|
+
var _variant3 = data;
|
2646
|
+
return {
|
2647
|
+
type: "quickReply",
|
2648
|
+
body: _variant3.body,
|
2649
|
+
replies: _variant3.actions,
|
2650
|
+
rawData: rawData
|
2651
|
+
};
|
2652
|
+
}
|
2653
|
+
|
2654
|
+
case "twilio/call-to-action":
|
2655
|
+
{
|
2656
|
+
var _variant4 = data;
|
2657
|
+
return {
|
2658
|
+
type: "callToAction",
|
2659
|
+
body: _variant4.body,
|
2660
|
+
actions: collectActions(_variant4.actions),
|
2661
|
+
rawData: rawData
|
2662
|
+
};
|
2663
|
+
}
|
2664
|
+
|
2665
|
+
case "twilio/list-picker":
|
2666
|
+
{
|
2667
|
+
var _variant5 = data;
|
2668
|
+
return {
|
2669
|
+
type: "listPicker",
|
2670
|
+
body: _variant5.body,
|
2671
|
+
button: _variant5.button,
|
2672
|
+
items: _variant5.items,
|
2673
|
+
rawData: rawData
|
2674
|
+
};
|
2675
|
+
}
|
2676
|
+
|
2677
|
+
case "twilio/card":
|
2678
|
+
{
|
2679
|
+
var _variant6$media, _variant6$actions;
|
2680
|
+
|
2681
|
+
var _variant6 = data;
|
2682
|
+
return {
|
2683
|
+
type: "card",
|
2684
|
+
title: _variant6.title,
|
2685
|
+
subtitle: _variant6.subtitle,
|
2686
|
+
media: (_variant6$media = _variant6.media) !== null && _variant6$media !== void 0 ? _variant6$media : [],
|
2687
|
+
actions: collectActions((_variant6$actions = _variant6.actions) !== null && _variant6$actions !== void 0 ? _variant6$actions : []),
|
2688
|
+
rawData: rawData
|
2689
|
+
};
|
2690
|
+
}
|
2691
|
+
|
2692
|
+
default:
|
2693
|
+
return {
|
2694
|
+
type: "other",
|
2695
|
+
rawData: rawData
|
2696
|
+
};
|
2697
|
+
}
|
2698
|
+
};
|
2699
|
+
|
2700
|
+
var collectVariants = function collectVariants(variants) {
|
2701
|
+
var variantsMap = new Map();
|
2702
|
+
|
2703
|
+
for (var _i = 0, _Object$entries = Object.entries(variants); _i < _Object$entries.length; _i++) {
|
2704
|
+
var _Object$entries$_i = _slicedToArray__default["default"](_Object$entries[_i], 2),
|
2705
|
+
key = _Object$entries$_i[0],
|
2706
|
+
value = _Object$entries$_i[1];
|
2707
|
+
|
2708
|
+
variantsMap.set(key, parseVariant(key, value));
|
2709
|
+
}
|
2710
|
+
|
2711
|
+
return variantsMap;
|
2712
|
+
};
|
2713
|
+
/**
|
2714
|
+
* Represents a variable for a content template. See
|
2715
|
+
* {@link ContentTemplate.variables}.
|
2716
|
+
*/
|
2717
|
+
|
2718
|
+
|
2719
|
+
var ContentTemplateVariable = /*#__PURE__*/function () {
|
2720
|
+
function ContentTemplateVariable(
|
2721
|
+
/**
|
2722
|
+
* Name of the variable.
|
2723
|
+
*/
|
2724
|
+
name,
|
2725
|
+
/**
|
2726
|
+
* Key of the variable
|
2727
|
+
*/
|
2728
|
+
value) {
|
2729
|
+
_classCallCheck__default["default"](this, ContentTemplateVariable);
|
2730
|
+
|
2731
|
+
this.name = name;
|
2732
|
+
this.value = value;
|
2733
|
+
}
|
2734
|
+
/**
|
2735
|
+
* Copies the variable with a new value.
|
2736
|
+
*
|
2737
|
+
* @param value The new value for the variable.
|
2738
|
+
*/
|
2739
|
+
|
2740
|
+
|
2741
|
+
_createClass__default["default"](ContentTemplateVariable, [{
|
2742
|
+
key: "copyWithValue",
|
2743
|
+
value: function copyWithValue(value) {
|
2744
|
+
return new ContentTemplateVariable(this.name, value);
|
2745
|
+
}
|
2746
|
+
}]);
|
2747
|
+
|
2748
|
+
return ContentTemplateVariable;
|
2749
|
+
}();
|
2750
|
+
/**
|
2751
|
+
* A rich content template.
|
2752
|
+
*
|
2753
|
+
* Use {@Link Client.getContentTemplates} to request all the templates available
|
2754
|
+
* for the current account.
|
2755
|
+
*/
|
2756
|
+
|
2757
|
+
|
2758
|
+
var ContentTemplate = /*#__PURE__*/_createClass__default["default"](
|
2759
|
+
/**
|
2760
|
+
* The server-assigned unique identifier for the template.
|
2761
|
+
*/
|
2762
|
+
|
2763
|
+
/**
|
2764
|
+
* Friendly name used to describe the content. Not visible to the recipient.
|
2765
|
+
*/
|
2766
|
+
|
2767
|
+
/**
|
2768
|
+
* Variables used by this template.
|
2769
|
+
*/
|
2770
|
+
|
2771
|
+
/**
|
2772
|
+
* Variants of the content. See {@link ContentData}.
|
2773
|
+
*/
|
2774
|
+
|
2775
|
+
/**
|
2776
|
+
* Date of creation.
|
2777
|
+
*/
|
2778
|
+
|
2779
|
+
/**
|
2780
|
+
* Date of the last update.
|
2781
|
+
*/
|
2782
|
+
|
2783
|
+
/**
|
2784
|
+
* @internal
|
2785
|
+
*/
|
2786
|
+
function ContentTemplate(contentTemplateResponse) {
|
2787
|
+
_classCallCheck__default["default"](this, ContentTemplate);
|
2788
|
+
|
2789
|
+
this.sid = contentTemplateResponse.sid;
|
2790
|
+
this.friendlyName = contentTemplateResponse.friendly_name;
|
2791
|
+
this.variables = Object.entries(JSON.parse(contentTemplateResponse.variables)).map(function (_ref) {
|
2792
|
+
var _ref2 = _slicedToArray__default["default"](_ref, 2),
|
2793
|
+
key = _ref2[0],
|
2794
|
+
value = _ref2[1];
|
2795
|
+
|
2796
|
+
return new ContentTemplateVariable(key, value);
|
2797
|
+
});
|
2798
|
+
this.variants = collectVariants(contentTemplateResponse.variants);
|
2799
|
+
this.dateCreated = new Date(contentTemplateResponse.date_created);
|
2800
|
+
this.dateUpdated = new Date(contentTemplateResponse.date_updated);
|
2801
|
+
});
|
2802
|
+
|
2803
|
+
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
2804
|
+
|
2805
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
2806
|
+
|
2807
|
+
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); }; }
|
2808
|
+
|
2809
|
+
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; } }
|
2567
2810
|
var log$3 = Logger.scope("Message");
|
2811
|
+
|
2812
|
+
var XHR = // eslint-disable-next-line @typescript-eslint/no-var-requires
|
2813
|
+
global["XMLHttpRequest"] || require("xmlhttprequest").XMLHttpRequest;
|
2568
2814
|
/**
|
2569
2815
|
* A message in a conversation.
|
2570
2816
|
*/
|
2571
2817
|
|
2818
|
+
|
2572
2819
|
var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
2573
2820
|
_inherits__default["default"](Message, _ReplayEventEmitter);
|
2574
2821
|
|
2575
|
-
var _super = _createSuper$
|
2822
|
+
var _super = _createSuper$6(Message);
|
2576
2823
|
|
2577
2824
|
/**
|
2578
2825
|
* Conversation that the message is in.
|
@@ -2582,7 +2829,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2582
2829
|
* @internal
|
2583
2830
|
*/
|
2584
2831
|
function Message(index, data, conversation, links, configuration, services) {
|
2585
|
-
var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid;
|
2832
|
+
var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid, _data$channelMetadata;
|
2586
2833
|
|
2587
2834
|
var _this;
|
2588
2835
|
|
@@ -2598,6 +2845,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2598
2845
|
index: index,
|
2599
2846
|
author: data.author,
|
2600
2847
|
subject: data.subject,
|
2848
|
+
contentSid: data.contentSid,
|
2601
2849
|
body: (_data$text = data.text) !== null && _data$text !== void 0 ? _data$text : null,
|
2602
2850
|
timestamp: data.timestamp ? new Date(data.timestamp) : null,
|
2603
2851
|
dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,
|
@@ -2607,11 +2855,12 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2607
2855
|
media: data.type === "media" && data.media ? new Media(data.media, _this.services) : null,
|
2608
2856
|
medias: data.type === "media" && data.medias ? data.medias.map(function (m) {
|
2609
2857
|
return new Media(m, _this.services);
|
2610
|
-
}) : data.type === "media" && data.media && !data.medias ? [new Media(_objectSpread$
|
2858
|
+
}) : data.type === "media" && data.media && !data.medias ? [new Media(_objectSpread$4(_objectSpread$4({}, data.media), {}, {
|
2611
2859
|
category: "media"
|
2612
2860
|
}), _this.services)] : null,
|
2613
2861
|
participantSid: (_data$memberSid = data.memberSid) !== null && _data$memberSid !== void 0 ? _data$memberSid : null,
|
2614
|
-
aggregatedDeliveryReceipt: data.delivery ? new AggregatedDeliveryReceipt(data.delivery) : null
|
2862
|
+
aggregatedDeliveryReceipt: data.delivery ? new AggregatedDeliveryReceipt(data.delivery) : null,
|
2863
|
+
hasChannelMetadata: (_data$channelMetadata = data.channelMetadata) !== null && _data$channelMetadata !== void 0 ? _data$channelMetadata : false
|
2615
2864
|
};
|
2616
2865
|
return _this;
|
2617
2866
|
}
|
@@ -2652,6 +2901,15 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2652
2901
|
get: function get() {
|
2653
2902
|
return this.state.subject;
|
2654
2903
|
}
|
2904
|
+
/**
|
2905
|
+
* Unique identifier of {@link ContentTemplate} for this message.
|
2906
|
+
*/
|
2907
|
+
|
2908
|
+
}, {
|
2909
|
+
key: "contentSid",
|
2910
|
+
get: function get() {
|
2911
|
+
return this.state.contentSid;
|
2912
|
+
}
|
2655
2913
|
/**
|
2656
2914
|
* Body of the message.
|
2657
2915
|
*/
|
@@ -2671,14 +2929,15 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2671
2929
|
return this.state.dateUpdated;
|
2672
2930
|
}
|
2673
2931
|
/**
|
2674
|
-
* Index of
|
2675
|
-
*
|
2932
|
+
* Index of this message in the conversation's list of messages.
|
2933
|
+
*
|
2934
|
+
* By design, the message indices may have arbitrary gaps between them,
|
2676
2935
|
* that does not necessarily mean they were deleted or otherwise modified - just that
|
2677
2936
|
* messages may have some non-contiguous indices even if they are being sent immediately one after another.
|
2678
2937
|
*
|
2679
2938
|
* Trying to use indices for some calculations is going to be unreliable.
|
2680
2939
|
*
|
2681
|
-
* To calculate the number of unread messages it is better to use the
|
2940
|
+
* To calculate the number of unread messages, it is better to use the Read Horizon API.
|
2682
2941
|
* See {@link Conversation.getUnreadMessagesCount} for details.
|
2683
2942
|
*/
|
2684
2943
|
|
@@ -2760,6 +3019,19 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2760
3019
|
get: function get() {
|
2761
3020
|
return this.state.aggregatedDeliveryReceipt;
|
2762
3021
|
}
|
3022
|
+
/**
|
3023
|
+
* @deprecated
|
3024
|
+
* Return a (possibly empty) array of media matching a specific set of categories.
|
3025
|
+
* Allowed category is so far only 'media'.
|
3026
|
+
* @param categories Array of categories to match.
|
3027
|
+
* @returns Array of media descriptors matching given categories.
|
3028
|
+
*/
|
3029
|
+
|
3030
|
+
}, {
|
3031
|
+
key: "getMediaByCategory",
|
3032
|
+
value: function getMediaByCategory(categories) {
|
3033
|
+
return this.getMediaByCategories(categories);
|
3034
|
+
}
|
2763
3035
|
/**
|
2764
3036
|
* Return a (possibly empty) array of media matching a specific set of categories.
|
2765
3037
|
* Allowed category is so far only 'media'.
|
@@ -2980,32 +3252,27 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2980
3252
|
|
2981
3253
|
case 2:
|
2982
3254
|
paginator = _context2.sent;
|
2983
|
-
detailedDeliveryReceipts =
|
3255
|
+
detailedDeliveryReceipts = paginator.items;
|
2984
3256
|
|
2985
3257
|
case 4:
|
2986
|
-
|
2987
|
-
|
2988
|
-
|
2989
|
-
if (paginator.hasNextPage) {
|
2990
|
-
_context2.next = 8;
|
3258
|
+
if (!paginator.hasNextPage) {
|
3259
|
+
_context2.next = 11;
|
2991
3260
|
break;
|
2992
3261
|
}
|
2993
3262
|
|
2994
|
-
|
2995
|
-
|
2996
|
-
case 8:
|
2997
|
-
_context2.next = 10;
|
3263
|
+
_context2.next = 7;
|
2998
3264
|
return paginator.nextPage();
|
2999
3265
|
|
3000
|
-
case
|
3266
|
+
case 7:
|
3001
3267
|
paginator = _context2.sent;
|
3268
|
+
detailedDeliveryReceipts = [].concat(_toConsumableArray__default["default"](detailedDeliveryReceipts), _toConsumableArray__default["default"](paginator.items));
|
3002
3269
|
_context2.next = 4;
|
3003
3270
|
break;
|
3004
3271
|
|
3005
|
-
case
|
3272
|
+
case 11:
|
3006
3273
|
return _context2.abrupt("return", detailedDeliveryReceipts);
|
3007
3274
|
|
3008
|
-
case
|
3275
|
+
case 12:
|
3009
3276
|
case "end":
|
3010
3277
|
return _context2.stop();
|
3011
3278
|
}
|
@@ -3121,6 +3388,59 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3121
3388
|
|
3122
3389
|
return updateAttributes;
|
3123
3390
|
}()
|
3391
|
+
/**
|
3392
|
+
* @deprecated
|
3393
|
+
* Get content URLs for all media attachments in the given set using a single operation.
|
3394
|
+
* @param contentSet Set of media attachments to query content URLs.
|
3395
|
+
*/
|
3396
|
+
|
3397
|
+
}, {
|
3398
|
+
key: "attachTemporaryUrlsFor",
|
3399
|
+
value: function () {
|
3400
|
+
var _attachTemporaryUrlsFor = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(contentSet) {
|
3401
|
+
var _this3 = this;
|
3402
|
+
|
3403
|
+
var sids;
|
3404
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context6) {
|
3405
|
+
while (1) {
|
3406
|
+
switch (_context6.prev = _context6.next) {
|
3407
|
+
case 0:
|
3408
|
+
// We ignore existing mcsMedia members of each of the media entries.
|
3409
|
+
// Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.
|
3410
|
+
sids = contentSet === null || contentSet === void 0 ? void 0 : contentSet.map(function (m) {
|
3411
|
+
return m.sid;
|
3412
|
+
});
|
3413
|
+
|
3414
|
+
if (!(this.services.mcsClient && sids)) {
|
3415
|
+
_context6.next = 7;
|
3416
|
+
break;
|
3417
|
+
}
|
3418
|
+
|
3419
|
+
_context6.next = 4;
|
3420
|
+
return this.services.mcsClient.mediaSetGet(sids);
|
3421
|
+
|
3422
|
+
case 4:
|
3423
|
+
return _context6.abrupt("return", _context6.sent.map(function (item) {
|
3424
|
+
return new Media(item, _this3.services);
|
3425
|
+
}));
|
3426
|
+
|
3427
|
+
case 7:
|
3428
|
+
throw new Error("Media Content Service is unavailable");
|
3429
|
+
|
3430
|
+
case 8:
|
3431
|
+
case "end":
|
3432
|
+
return _context6.stop();
|
3433
|
+
}
|
3434
|
+
}
|
3435
|
+
}, _callee6, this);
|
3436
|
+
}));
|
3437
|
+
|
3438
|
+
function attachTemporaryUrlsFor(_x3) {
|
3439
|
+
return _attachTemporaryUrlsFor.apply(this, arguments);
|
3440
|
+
}
|
3441
|
+
|
3442
|
+
return attachTemporaryUrlsFor;
|
3443
|
+
}()
|
3124
3444
|
/**
|
3125
3445
|
* Get content URLs for all media attachments in the given set using a single operation.
|
3126
3446
|
* @param contentSet Set of media attachments to query content URLs.
|
@@ -3144,53 +3464,53 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3144
3464
|
}, {
|
3145
3465
|
key: "getTemporaryContentUrlsForMediaSids",
|
3146
3466
|
value: function getTemporaryContentUrlsForMediaSids(mediaSids) {
|
3147
|
-
var
|
3467
|
+
var _this4 = this;
|
3148
3468
|
|
3149
3469
|
return new mcsClient.CancellablePromise( /*#__PURE__*/function () {
|
3150
|
-
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
3470
|
+
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(resolve, reject, onCancel) {
|
3151
3471
|
var mediaGetRequest, urls;
|
3152
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
3472
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context7) {
|
3153
3473
|
while (1) {
|
3154
|
-
switch (
|
3474
|
+
switch (_context7.prev = _context7.next) {
|
3155
3475
|
case 0:
|
3156
|
-
mediaGetRequest =
|
3476
|
+
mediaGetRequest = _this4.services.mcsClient.mediaSetGetContentUrls(mediaSids !== null && mediaSids !== void 0 ? mediaSids : []);
|
3157
3477
|
|
3158
|
-
if (!(!
|
3159
|
-
|
3478
|
+
if (!(!_this4.services.mcsClient || !mediaSids)) {
|
3479
|
+
_context7.next = 4;
|
3160
3480
|
break;
|
3161
3481
|
}
|
3162
3482
|
|
3163
3483
|
reject(new Error("Media Content Service is unavailable"));
|
3164
|
-
return
|
3484
|
+
return _context7.abrupt("return");
|
3165
3485
|
|
3166
3486
|
case 4:
|
3167
3487
|
onCancel(function () {
|
3168
3488
|
mediaGetRequest.cancel();
|
3169
3489
|
});
|
3170
|
-
|
3171
|
-
|
3490
|
+
_context7.prev = 5;
|
3491
|
+
_context7.next = 8;
|
3172
3492
|
return mediaGetRequest;
|
3173
3493
|
|
3174
3494
|
case 8:
|
3175
|
-
urls =
|
3495
|
+
urls = _context7.sent;
|
3176
3496
|
resolve(urls);
|
3177
|
-
|
3497
|
+
_context7.next = 15;
|
3178
3498
|
break;
|
3179
3499
|
|
3180
3500
|
case 12:
|
3181
|
-
|
3182
|
-
|
3183
|
-
reject(
|
3501
|
+
_context7.prev = 12;
|
3502
|
+
_context7.t0 = _context7["catch"](5);
|
3503
|
+
reject(_context7.t0);
|
3184
3504
|
|
3185
3505
|
case 15:
|
3186
3506
|
case "end":
|
3187
|
-
return
|
3507
|
+
return _context7.stop();
|
3188
3508
|
}
|
3189
3509
|
}
|
3190
|
-
},
|
3510
|
+
}, _callee7, null, [[5, 12]]);
|
3191
3511
|
}));
|
3192
3512
|
|
3193
|
-
return function (
|
3513
|
+
return function (_x4, _x5, _x6) {
|
3194
3514
|
return _ref.apply(this, arguments);
|
3195
3515
|
};
|
3196
3516
|
}());
|
@@ -3213,25 +3533,25 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3213
3533
|
}, {
|
3214
3534
|
key: "_getDetailedDeliveryReceiptsPaginator",
|
3215
3535
|
value: function () {
|
3216
|
-
var _getDetailedDeliveryReceiptsPaginator2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
3217
|
-
var
|
3536
|
+
var _getDetailedDeliveryReceiptsPaginator2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8(options) {
|
3537
|
+
var _this5 = this;
|
3218
3538
|
|
3219
3539
|
var messagesReceiptsUrl, url, response;
|
3220
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
3540
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context8) {
|
3221
3541
|
while (1) {
|
3222
|
-
switch (
|
3542
|
+
switch (_context8.prev = _context8.next) {
|
3223
3543
|
case 0:
|
3224
3544
|
messagesReceiptsUrl = this.configuration.links.messagesReceipts.replace("%s", this.conversation.sid).replace("%s", this.sid);
|
3225
3545
|
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();
|
3226
|
-
|
3546
|
+
_context8.next = 4;
|
3227
3547
|
return this.services.network.get(url);
|
3228
3548
|
|
3229
3549
|
case 4:
|
3230
|
-
response =
|
3231
|
-
return
|
3550
|
+
response = _context8.sent;
|
3551
|
+
return _context8.abrupt("return", new RestPaginator(response.body.delivery_receipts.map(function (x) {
|
3232
3552
|
return new DetailedDeliveryReceipt(x);
|
3233
3553
|
}), function (pageToken, pageSize) {
|
3234
|
-
return
|
3554
|
+
return _this5._getDetailedDeliveryReceiptsPaginator({
|
3235
3555
|
pageToken: pageToken,
|
3236
3556
|
pageSize: pageSize
|
3237
3557
|
});
|
@@ -3239,46 +3559,236 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3239
3559
|
|
3240
3560
|
case 6:
|
3241
3561
|
case "end":
|
3242
|
-
return
|
3562
|
+
return _context8.stop();
|
3243
3563
|
}
|
3244
3564
|
}
|
3245
|
-
},
|
3565
|
+
}, _callee8, this);
|
3246
3566
|
}));
|
3247
3567
|
|
3248
|
-
function _getDetailedDeliveryReceiptsPaginator(
|
3568
|
+
function _getDetailedDeliveryReceiptsPaginator(_x7) {
|
3249
3569
|
return _getDetailedDeliveryReceiptsPaginator2.apply(this, arguments);
|
3250
3570
|
}
|
3251
3571
|
|
3252
3572
|
return _getDetailedDeliveryReceiptsPaginator;
|
3253
3573
|
}()
|
3254
|
-
|
3574
|
+
/**
|
3575
|
+
* Get the {@link ContentData} for this message. Resolves to `null` when
|
3576
|
+
* {@link Message.contentSid} is null.
|
3577
|
+
*/
|
3255
3578
|
|
3256
|
-
|
3257
|
-
|
3579
|
+
}, {
|
3580
|
+
key: "getContentData",
|
3581
|
+
value: function getContentData() {
|
3582
|
+
var _this6 = this;
|
3258
3583
|
|
3259
|
-
|
3584
|
+
return new mcsClient.CancellablePromise( /*#__PURE__*/function () {
|
3585
|
+
var _ref2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9(resolve, reject, onCancel) {
|
3586
|
+
var bodies, twilioPrefix, filteredMedias, contentMedia, urlPromise, url, jsonStringPromise, json, jsonString, dataType;
|
3587
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context9) {
|
3588
|
+
while (1) {
|
3589
|
+
switch (_context9.prev = _context9.next) {
|
3590
|
+
case 0:
|
3591
|
+
if (!(_this6.state.contentSid === null)) {
|
3592
|
+
_context9.next = 3;
|
3593
|
+
break;
|
3594
|
+
}
|
3260
3595
|
|
3261
|
-
|
3596
|
+
resolve(null);
|
3597
|
+
return _context9.abrupt("return");
|
3262
3598
|
|
3263
|
-
|
3599
|
+
case 3:
|
3600
|
+
bodies = _this6.getMediaByCategories(["body"]);
|
3264
3601
|
|
3265
|
-
|
3602
|
+
if (!(bodies === null)) {
|
3603
|
+
_context9.next = 7;
|
3604
|
+
break;
|
3605
|
+
}
|
3266
3606
|
|
3267
|
-
|
3607
|
+
resolve(null);
|
3608
|
+
return _context9.abrupt("return");
|
3268
3609
|
|
3269
|
-
|
3610
|
+
case 7:
|
3611
|
+
twilioPrefix = "application/x-vnd.com.twilio.rich.";
|
3612
|
+
filteredMedias = bodies.filter(function (media) {
|
3613
|
+
return media.contentType.startsWith(twilioPrefix);
|
3614
|
+
});
|
3270
3615
|
|
3271
|
-
|
3616
|
+
if (!(filteredMedias.length === 0)) {
|
3617
|
+
_context9.next = 12;
|
3618
|
+
break;
|
3619
|
+
}
|
3272
3620
|
|
3273
|
-
|
3621
|
+
resolve(null);
|
3622
|
+
return _context9.abrupt("return");
|
3274
3623
|
|
3275
|
-
|
3624
|
+
case 12:
|
3625
|
+
contentMedia = filteredMedias[0];
|
3626
|
+
urlPromise = contentMedia.getContentTemporaryUrl();
|
3627
|
+
onCancel(function () {
|
3628
|
+
urlPromise.cancel();
|
3629
|
+
});
|
3630
|
+
_context9.prev = 15;
|
3631
|
+
_context9.next = 18;
|
3632
|
+
return urlPromise;
|
3276
3633
|
|
3277
|
-
|
3634
|
+
case 18:
|
3635
|
+
url = _context9.sent;
|
3636
|
+
_context9.next = 25;
|
3637
|
+
break;
|
3278
3638
|
|
3279
|
-
|
3639
|
+
case 21:
|
3640
|
+
_context9.prev = 21;
|
3641
|
+
_context9.t0 = _context9["catch"](15);
|
3642
|
+
reject(_context9.t0);
|
3643
|
+
return _context9.abrupt("return");
|
3280
3644
|
|
3281
|
-
|
3645
|
+
case 25:
|
3646
|
+
if (!(url === null)) {
|
3647
|
+
_context9.next = 28;
|
3648
|
+
break;
|
3649
|
+
}
|
3650
|
+
|
3651
|
+
resolve(null);
|
3652
|
+
return _context9.abrupt("return");
|
3653
|
+
|
3654
|
+
case 28:
|
3655
|
+
jsonStringPromise = new Promise(function (resolve, reject) {
|
3656
|
+
var _url;
|
3657
|
+
|
3658
|
+
var isCancelled = false;
|
3659
|
+
var xhr = new XHR();
|
3660
|
+
xhr.open("GET", (_url = url) !== null && _url !== void 0 ? _url : "", true);
|
3661
|
+
xhr.responseType = "text";
|
3662
|
+
|
3663
|
+
xhr.onreadystatechange = function () {
|
3664
|
+
if (xhr.readyState !== 4 || isCancelled) {
|
3665
|
+
return;
|
3666
|
+
}
|
3667
|
+
|
3668
|
+
resolve(xhr.responseText);
|
3669
|
+
};
|
3670
|
+
|
3671
|
+
xhr.onerror = function () {
|
3672
|
+
reject(xhr.statusText);
|
3673
|
+
};
|
3674
|
+
|
3675
|
+
onCancel(function () {
|
3676
|
+
isCancelled = true;
|
3677
|
+
xhr.abort();
|
3678
|
+
reject(new Error("XHR has been aborted"));
|
3679
|
+
});
|
3680
|
+
xhr.send();
|
3681
|
+
});
|
3682
|
+
_context9.prev = 29;
|
3683
|
+
_context9.next = 32;
|
3684
|
+
return jsonStringPromise;
|
3685
|
+
|
3686
|
+
case 32:
|
3687
|
+
jsonString = _context9.sent;
|
3688
|
+
json = JSON.parse(jsonString);
|
3689
|
+
_context9.next = 40;
|
3690
|
+
break;
|
3691
|
+
|
3692
|
+
case 36:
|
3693
|
+
_context9.prev = 36;
|
3694
|
+
_context9.t1 = _context9["catch"](29);
|
3695
|
+
reject(_context9.t1);
|
3696
|
+
return _context9.abrupt("return");
|
3697
|
+
|
3698
|
+
case 40:
|
3699
|
+
dataType = contentMedia.contentType.replace(twilioPrefix, "").replace(".", "/");
|
3700
|
+
resolve(parseVariant(dataType, json.data));
|
3701
|
+
|
3702
|
+
case 42:
|
3703
|
+
case "end":
|
3704
|
+
return _context9.stop();
|
3705
|
+
}
|
3706
|
+
}
|
3707
|
+
}, _callee9, null, [[15, 21], [29, 36]]);
|
3708
|
+
}));
|
3709
|
+
|
3710
|
+
return function (_x8, _x9, _x10) {
|
3711
|
+
return _ref2.apply(this, arguments);
|
3712
|
+
};
|
3713
|
+
}());
|
3714
|
+
}
|
3715
|
+
/**
|
3716
|
+
* Get the {@link ChannelMetadata} for this message. Resolves to `null` if
|
3717
|
+
* the message doesn't have any channel metadata.
|
3718
|
+
*/
|
3719
|
+
|
3720
|
+
}, {
|
3721
|
+
key: "getChannelMetadata",
|
3722
|
+
value: function () {
|
3723
|
+
var _getChannelMetadata = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee10() {
|
3724
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee10$(_context10) {
|
3725
|
+
while (1) {
|
3726
|
+
switch (_context10.prev = _context10.next) {
|
3727
|
+
case 0:
|
3728
|
+
if (this.state.hasChannelMetadata) {
|
3729
|
+
_context10.next = 2;
|
3730
|
+
break;
|
3731
|
+
}
|
3732
|
+
|
3733
|
+
return _context10.abrupt("return", null);
|
3734
|
+
|
3735
|
+
case 2:
|
3736
|
+
_context10.next = 4;
|
3737
|
+
return this.services.channelMetadataClient.getChannelMetadata(this.conversation.sid, this.sid);
|
3738
|
+
|
3739
|
+
case 4:
|
3740
|
+
return _context10.abrupt("return", _context10.sent);
|
3741
|
+
|
3742
|
+
case 5:
|
3743
|
+
case "end":
|
3744
|
+
return _context10.stop();
|
3745
|
+
}
|
3746
|
+
}
|
3747
|
+
}, _callee10, this);
|
3748
|
+
}));
|
3749
|
+
|
3750
|
+
function getChannelMetadata() {
|
3751
|
+
return _getChannelMetadata.apply(this, arguments);
|
3752
|
+
}
|
3753
|
+
|
3754
|
+
return getChannelMetadata;
|
3755
|
+
}()
|
3756
|
+
}]);
|
3757
|
+
|
3758
|
+
return Message;
|
3759
|
+
}(replayEventEmitter.ReplayEventEmitter);
|
3760
|
+
|
3761
|
+
_defineProperty__default["default"](Message, "updated", "updated");
|
3762
|
+
|
3763
|
+
__decorate([deprecationDecorator.deprecated("getMediaByCategory", "getMediaByCategories"), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", Array)], Message.prototype, "getMediaByCategory", null);
|
3764
|
+
|
3765
|
+
__decorate([declarativeTypeValidator.validateTypes([declarativeTypeValidator.nonEmptyString, "undefined"]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailBody", null);
|
3766
|
+
|
3767
|
+
__decorate([declarativeTypeValidator.validateTypes([declarativeTypeValidator.nonEmptyString, "undefined"]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailHistory", null);
|
3768
|
+
|
3769
|
+
__decorate([declarativeTypeValidator.validateTypesAsync("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Message.prototype, "updateBody", null);
|
3770
|
+
|
3771
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Message.prototype, "updateAttributes", null);
|
3772
|
+
|
3773
|
+
__decorate([deprecationDecorator.deprecated("attachTemporaryUrlsFor", "getTemporaryContentUrlsForMedia"), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", Promise)], Message.prototype, "attachTemporaryUrlsFor", null);
|
3774
|
+
|
3775
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyArray("media", Media)), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", mcsClient.CancellablePromise)], Message.prototype, "getTemporaryContentUrlsForMedia", null);
|
3776
|
+
|
3777
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyArray("strings", "string")), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", mcsClient.CancellablePromise)], Message.prototype, "getTemporaryContentUrlsForMediaSids", null);
|
3778
|
+
|
3779
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
3780
|
+
|
3781
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
3782
|
+
|
3783
|
+
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; } } }; }
|
3784
|
+
|
3785
|
+
function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
|
3786
|
+
|
3787
|
+
function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
3788
|
+
|
3789
|
+
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); }; }
|
3790
|
+
|
3791
|
+
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; } }
|
3282
3792
|
var log$2 = Logger.scope("Messages");
|
3283
3793
|
/**
|
3284
3794
|
* Represents the collection of messages in a conversation
|
@@ -3287,7 +3797,7 @@ var log$2 = Logger.scope("Messages");
|
|
3287
3797
|
var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
3288
3798
|
_inherits__default["default"](Messages, _ReplayEventEmitter);
|
3289
3799
|
|
3290
|
-
var _super = _createSuper$
|
3800
|
+
var _super = _createSuper$5(Messages);
|
3291
3801
|
|
3292
3802
|
function Messages(conversation, configuration, services) {
|
3293
3803
|
var _this;
|
@@ -3304,14 +3814,15 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3304
3814
|
}
|
3305
3815
|
/**
|
3306
3816
|
* Subscribe to the Messages Event Stream
|
3307
|
-
* @param
|
3817
|
+
* @param arg - Name of the Sync object, or the SyncList itself, that
|
3818
|
+
* represents the Messages resource.
|
3308
3819
|
*/
|
3309
3820
|
|
3310
3821
|
|
3311
3822
|
_createClass__default["default"](Messages, [{
|
3312
3823
|
key: "subscribe",
|
3313
3824
|
value: function () {
|
3314
|
-
var _subscribe = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(
|
3825
|
+
var _subscribe = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(arg) {
|
3315
3826
|
var _this2 = this;
|
3316
3827
|
|
3317
3828
|
var list;
|
@@ -3327,10 +3838,10 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3327
3838
|
return _context.abrupt("return", this.messagesListPromise);
|
3328
3839
|
|
3329
3840
|
case 2:
|
3330
|
-
this.messagesListPromise = this.services.syncClient.list({
|
3331
|
-
id:
|
3841
|
+
this.messagesListPromise = typeof arg === "string" ? this.services.syncClient.list({
|
3842
|
+
id: arg,
|
3332
3843
|
mode: "open_existing"
|
3333
|
-
});
|
3844
|
+
}) : Promise.resolve(arg);
|
3334
3845
|
_context.prev = 3;
|
3335
3846
|
_context.next = 6;
|
3336
3847
|
return this.messagesListPromise;
|
@@ -3481,7 +3992,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3481
3992
|
return request.cancel();
|
3482
3993
|
});
|
3483
3994
|
});
|
3484
|
-
_iterator = _createForOfIteratorHelper$
|
3995
|
+
_iterator = _createForOfIteratorHelper$3(message.mediaContent);
|
3485
3996
|
_context3.prev = 4;
|
3486
3997
|
|
3487
3998
|
_iterator.s();
|
@@ -3543,7 +4054,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3543
4054
|
media_sids: media.map(function (m) {
|
3544
4055
|
return m.sid;
|
3545
4056
|
}),
|
3546
|
-
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined
|
4057
|
+
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined,
|
4058
|
+
content_sid: message.contentSid,
|
4059
|
+
content_variables: typeof message.contentVariables !== "undefined" ? JSON.stringify(message.contentVariables.reduce(function (accum, current) {
|
4060
|
+
return _objectSpread$3(_objectSpread$3({}, accum), {}, _defineProperty__default["default"]({}, current.name, current.value));
|
4061
|
+
}, {})) : undefined
|
3547
4062
|
});
|
3548
4063
|
_context3.prev = 34;
|
3549
4064
|
_context3.t4 = resolve;
|
@@ -4014,6 +4529,29 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
4014
4529
|
this.emailHistories.set(contentType, history);
|
4015
4530
|
return this;
|
4016
4531
|
}
|
4532
|
+
/**
|
4533
|
+
* Adds {@link ContentTemplate} SID for the message alongside optional
|
4534
|
+
* variables. When no variables provided, the default values will be used.
|
4535
|
+
*
|
4536
|
+
* Adding the content SID converts the message to a rich message. In this
|
4537
|
+
* case, other fields are ignored and the message is sent using the content
|
4538
|
+
* from the the {@link ContentTemplate}.
|
4539
|
+
*
|
4540
|
+
* Use {@link Client.getContentTemplates} to request all available
|
4541
|
+
* {@link ContentTemplate}s.
|
4542
|
+
*
|
4543
|
+
* @param contentSid SID of the {@link ContentTemplate}
|
4544
|
+
* @param variables Custom variables to resolve the template.
|
4545
|
+
*/
|
4546
|
+
|
4547
|
+
}, {
|
4548
|
+
key: "setContentTemplate",
|
4549
|
+
value: function setContentTemplate(contentSid) {
|
4550
|
+
var contentVariables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
4551
|
+
this.message.contentSid = contentSid;
|
4552
|
+
this.message.contentVariables = contentVariables;
|
4553
|
+
return this;
|
4554
|
+
}
|
4017
4555
|
/**
|
4018
4556
|
* Adds media to the message.
|
4019
4557
|
* @param payload Media to add.
|
@@ -4088,29 +4626,34 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
4088
4626
|
value: function buildAndSend() {
|
4089
4627
|
return this.build().send();
|
4090
4628
|
}
|
4091
|
-
}, {
|
4092
|
-
key: "getPayloadContentType",
|
4093
|
-
value: function getPayloadContentType(payload) {
|
4094
|
-
if (typeof FormData !== "undefined" && payload instanceof FormData) {
|
4095
|
-
return payload.get("Content-Type");
|
4096
|
-
}
|
4097
|
-
|
4098
|
-
return payload.contentType;
|
4099
|
-
}
|
4100
4629
|
}]);
|
4101
4630
|
|
4102
4631
|
return MessageBuilder;
|
4103
4632
|
}();
|
4104
4633
|
|
4105
|
-
|
4634
|
+
__decorate([declarativeTypeValidator.validateTypes("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setBody", null);
|
4106
4635
|
|
4107
|
-
|
4636
|
+
__decorate([declarativeTypeValidator.validateTypes("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setSubject", null);
|
4108
4637
|
|
4109
|
-
|
4638
|
+
__decorate([declarativeTypeValidator.validateTypes(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setAttributes", null);
|
4110
4639
|
|
4111
|
-
|
4640
|
+
__decorate([declarativeTypeValidator.validateTypes("string", [FormData, sendMediaOptions]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setEmailBody", null);
|
4112
4641
|
|
4113
|
-
|
4642
|
+
__decorate([declarativeTypeValidator.validateTypes("string", [FormData, sendMediaOptions]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setEmailHistory", null);
|
4643
|
+
|
4644
|
+
__decorate([declarativeTypeValidator.validateTypes("string", [declarativeTypeValidator.array("content variables", ContentTemplateVariable), "undefined"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Array]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setContentTemplate", null);
|
4645
|
+
|
4646
|
+
__decorate([declarativeTypeValidator.validateTypes([FormData, sendMediaOptions]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "addMedia", null);
|
4647
|
+
|
4648
|
+
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; } } }; }
|
4649
|
+
|
4650
|
+
function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
|
4651
|
+
|
4652
|
+
function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
4653
|
+
|
4654
|
+
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); }; }
|
4655
|
+
|
4656
|
+
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; } }
|
4114
4657
|
/**
|
4115
4658
|
* Map of the fields that will be processed with update messages.
|
4116
4659
|
*/
|
@@ -4138,7 +4681,7 @@ var fieldMappings = {
|
|
4138
4681
|
var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
4139
4682
|
_inherits__default["default"](Conversation, _ReplayEventEmitter);
|
4140
4683
|
|
4141
|
-
var _super = _createSuper$
|
4684
|
+
var _super = _createSuper$4(Conversation);
|
4142
4685
|
|
4143
4686
|
/**
|
4144
4687
|
* Fired when a participant has joined the conversation.
|
@@ -4868,7 +5411,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4868
5411
|
return getMessagesCount;
|
4869
5412
|
}()
|
4870
5413
|
/**
|
4871
|
-
* Get unread messages
|
5414
|
+
* Get count of unread messages for the user if they are a participant of this
|
4872
5415
|
* conversation. Rejects if the user is not a participant of the conversation.
|
4873
5416
|
*
|
4874
5417
|
* Use this method to obtain the number of unread messages together with
|
@@ -4876,12 +5419,19 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4876
5419
|
* message indices which may have gaps. See {@link Message.index} for details.
|
4877
5420
|
*
|
4878
5421
|
* This method is semi-realtime. This means that this data will be eventually
|
4879
|
-
* correct, but will also be possibly incorrect for a few seconds. The
|
5422
|
+
* correct, but it will also be possibly incorrect for a few seconds. The
|
4880
5423
|
* Conversations system does not provide real time events for counter values
|
4881
5424
|
* changes.
|
4882
5425
|
*
|
4883
5426
|
* This is useful for any UI badges, but it is not recommended to build any
|
4884
5427
|
* core application logic based on these counters being accurate in real time.
|
5428
|
+
*
|
5429
|
+
* If the read horizon is not set, this function will return null. This could mean
|
5430
|
+
* that all messages in the conversation are unread, or that the read horizon system
|
5431
|
+
* is not being used. How to interpret this `null` value is up to the customer application.
|
5432
|
+
*
|
5433
|
+
* @return Number of unread messages based on the current read horizon set for
|
5434
|
+
* the user or `null` if the read horizon is not set.
|
4885
5435
|
*/
|
4886
5436
|
|
4887
5437
|
}, {
|
@@ -4986,7 +5536,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4986
5536
|
}
|
4987
5537
|
|
4988
5538
|
_context14.next = 3;
|
4989
|
-
return this._services.commandExecutor.mutateResource("delete", "".concat(this._links.participants, "/").concat(this._configuration.userIdentity));
|
5539
|
+
return this._services.commandExecutor.mutateResource("delete", "".concat(this._links.participants, "/").concat(encodeURIComponent(this._configuration.userIdentity)));
|
4990
5540
|
|
4991
5541
|
case 3:
|
4992
5542
|
return _context14.abrupt("return", this);
|
@@ -5094,7 +5644,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5094
5644
|
}()
|
5095
5645
|
/**
|
5096
5646
|
* New interface to prepare for sending a message.
|
5097
|
-
* Use this instead of {@link
|
5647
|
+
* Use this instead of {@link Conversation.sendMessage}.
|
5098
5648
|
* @return A MessageBuilder to help set all message sending options.
|
5099
5649
|
*/
|
5100
5650
|
|
@@ -5154,7 +5704,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5154
5704
|
}()
|
5155
5705
|
/**
|
5156
5706
|
* Set all messages in the conversation unread.
|
5157
|
-
* @
|
5707
|
+
* @returns New count of unread messages after this update.
|
5158
5708
|
*/
|
5159
5709
|
|
5160
5710
|
}, {
|
@@ -5312,7 +5862,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5312
5862
|
* Set the last read message index to the current read horizon.
|
5313
5863
|
* @param index Message index to set as last read. If null is provided, then
|
5314
5864
|
* the behavior is identical to {@link Conversation.setAllMessagesUnread}.
|
5315
|
-
* @returns
|
5865
|
+
* @returns New count of unread messages after this update.
|
5316
5866
|
*/
|
5317
5867
|
|
5318
5868
|
}, {
|
@@ -5461,6 +6011,65 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5461
6011
|
|
5462
6012
|
return _subscribe;
|
5463
6013
|
}()
|
6014
|
+
/**
|
6015
|
+
* Fetch participants and messages of the conversation. This method needs to
|
6016
|
+
* be called during conversation initialization to catch broken conversations
|
6017
|
+
* (broken conversations are conversations that have essential Sync entities
|
6018
|
+
* missing, i.e. the conversation document, the messages list or the
|
6019
|
+
* participant map). In case of this conversation being broken, the method
|
6020
|
+
* will throw an exception that will be caught and handled gracefully.
|
6021
|
+
* @internal
|
6022
|
+
*/
|
6023
|
+
|
6024
|
+
}, {
|
6025
|
+
key: "_fetchStreams",
|
6026
|
+
value: function () {
|
6027
|
+
var _fetchStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee25() {
|
6028
|
+
var _this$_entity, _this$_entity2;
|
6029
|
+
|
6030
|
+
var data;
|
6031
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee25$(_context25) {
|
6032
|
+
while (1) {
|
6033
|
+
switch (_context25.prev = _context25.next) {
|
6034
|
+
case 0:
|
6035
|
+
_context25.next = 2;
|
6036
|
+
return this._subscribe();
|
6037
|
+
|
6038
|
+
case 2:
|
6039
|
+
Conversation._logger.trace("_streamsAvailable, this.entity.data=", (_this$_entity = this._entity) === null || _this$_entity === void 0 ? void 0 : _this$_entity.data);
|
6040
|
+
|
6041
|
+
data = (_this$_entity2 = this._entity) === null || _this$_entity2 === void 0 ? void 0 : _this$_entity2.data;
|
6042
|
+
_context25.next = 6;
|
6043
|
+
return this._services.syncClient.list({
|
6044
|
+
id: data.messages,
|
6045
|
+
mode: "open_existing"
|
6046
|
+
});
|
6047
|
+
|
6048
|
+
case 6:
|
6049
|
+
this._messagesList = _context25.sent;
|
6050
|
+
_context25.next = 9;
|
6051
|
+
return this._services.syncClient.map({
|
6052
|
+
id: data.roster,
|
6053
|
+
mode: "open_existing"
|
6054
|
+
});
|
6055
|
+
|
6056
|
+
case 9:
|
6057
|
+
this._participantsMap = _context25.sent;
|
6058
|
+
|
6059
|
+
case 10:
|
6060
|
+
case "end":
|
6061
|
+
return _context25.stop();
|
6062
|
+
}
|
6063
|
+
}
|
6064
|
+
}, _callee25, this);
|
6065
|
+
}));
|
6066
|
+
|
6067
|
+
function _fetchStreams() {
|
6068
|
+
return _fetchStreams2.apply(this, arguments);
|
6069
|
+
}
|
6070
|
+
|
6071
|
+
return _fetchStreams;
|
6072
|
+
}()
|
5464
6073
|
/**
|
5465
6074
|
* Load the attributes of this conversation and instantiate its participants
|
5466
6075
|
* and messages. This or _subscribe will need to be called before any events
|
@@ -5472,48 +6081,48 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5472
6081
|
}, {
|
5473
6082
|
key: "_subscribeStreams",
|
5474
6083
|
value: function () {
|
5475
|
-
var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
5476
|
-
var _this$
|
6084
|
+
var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee26() {
|
6085
|
+
var _this$_entity3, _this$_entity4, _this$_messagesList, _this$_participantsMa, data, messagesObjectName, rosterObjectName;
|
5477
6086
|
|
5478
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
6087
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee26$(_context26) {
|
5479
6088
|
while (1) {
|
5480
|
-
switch (
|
6089
|
+
switch (_context26.prev = _context26.next) {
|
5481
6090
|
case 0:
|
5482
|
-
|
5483
|
-
|
6091
|
+
_context26.prev = 0;
|
6092
|
+
_context26.next = 3;
|
5484
6093
|
return this._subscribe();
|
5485
6094
|
|
5486
6095
|
case 3:
|
5487
|
-
Conversation._logger.trace("_subscribeStreams, this.entity.data=", (_this$
|
6096
|
+
Conversation._logger.trace("_subscribeStreams, this.entity.data=", (_this$_entity3 = this._entity) === null || _this$_entity3 === void 0 ? void 0 : _this$_entity3.data);
|
5488
6097
|
|
5489
|
-
data = (_this$
|
6098
|
+
data = (_this$_entity4 = this._entity) === null || _this$_entity4 === void 0 ? void 0 : _this$_entity4.data;
|
5490
6099
|
messagesObjectName = data.messages;
|
5491
6100
|
rosterObjectName = data.roster;
|
5492
|
-
|
5493
|
-
return Promise.all([this._messagesEntity.subscribe(messagesObjectName), this._participantsEntity.subscribe(rosterObjectName)]);
|
6101
|
+
_context26.next = 9;
|
6102
|
+
return Promise.all([this._messagesEntity.subscribe((_this$_messagesList = this._messagesList) !== null && _this$_messagesList !== void 0 ? _this$_messagesList : messagesObjectName), this._participantsEntity.subscribe((_this$_participantsMa = this._participantsMap) !== null && _this$_participantsMa !== void 0 ? _this$_participantsMa : rosterObjectName)]);
|
5494
6103
|
|
5495
6104
|
case 9:
|
5496
|
-
|
6105
|
+
_context26.next = 16;
|
5497
6106
|
break;
|
5498
6107
|
|
5499
6108
|
case 11:
|
5500
|
-
|
5501
|
-
|
6109
|
+
_context26.prev = 11;
|
6110
|
+
_context26.t0 = _context26["catch"](0);
|
5502
6111
|
|
5503
6112
|
if (this._services.syncClient.connectionState !== "disconnected") {
|
5504
|
-
Conversation._logger.error("Failed to subscribe on conversation objects", this.sid,
|
6113
|
+
Conversation._logger.error("Failed to subscribe on conversation objects", this.sid, _context26.t0);
|
5505
6114
|
}
|
5506
6115
|
|
5507
|
-
Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid,
|
6116
|
+
Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context26.t0);
|
5508
6117
|
|
5509
|
-
throw
|
6118
|
+
throw _context26.t0;
|
5510
6119
|
|
5511
6120
|
case 16:
|
5512
6121
|
case "end":
|
5513
|
-
return
|
6122
|
+
return _context26.stop();
|
5514
6123
|
}
|
5515
6124
|
}
|
5516
|
-
},
|
6125
|
+
}, _callee26, this, [[0, 11]]);
|
5517
6126
|
}));
|
5518
6127
|
|
5519
6128
|
function _subscribeStreams() {
|
@@ -5530,17 +6139,17 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5530
6139
|
}, {
|
5531
6140
|
key: "_unsubscribe",
|
5532
6141
|
value: function () {
|
5533
|
-
var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
5534
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
6142
|
+
var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee27() {
|
6143
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee27$(_context27) {
|
5535
6144
|
while (1) {
|
5536
|
-
switch (
|
6145
|
+
switch (_context27.prev = _context27.next) {
|
5537
6146
|
case 0:
|
5538
6147
|
if (!this._entity) {
|
5539
|
-
|
6148
|
+
_context27.next = 5;
|
5540
6149
|
break;
|
5541
6150
|
}
|
5542
6151
|
|
5543
|
-
|
6152
|
+
_context27.next = 3;
|
5544
6153
|
return this._entity.close();
|
5545
6154
|
|
5546
6155
|
case 3:
|
@@ -5548,14 +6157,14 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5548
6157
|
this._entityPromise = null;
|
5549
6158
|
|
5550
6159
|
case 5:
|
5551
|
-
return
|
6160
|
+
return _context27.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
|
5552
6161
|
|
5553
6162
|
case 6:
|
5554
6163
|
case "end":
|
5555
|
-
return
|
6164
|
+
return _context27.stop();
|
5556
6165
|
}
|
5557
6166
|
}
|
5558
|
-
},
|
6167
|
+
}, _callee27, this);
|
5559
6168
|
}));
|
5560
6169
|
|
5561
6170
|
function _unsubscribe() {
|
@@ -5732,7 +6341,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5732
6341
|
}, {
|
5733
6342
|
key: "_onMessageAdded",
|
5734
6343
|
value: function _onMessageAdded(message) {
|
5735
|
-
var _iterator = _createForOfIteratorHelper$
|
6344
|
+
var _iterator = _createForOfIteratorHelper$2(this._participants.values()),
|
5736
6345
|
_step;
|
5737
6346
|
|
5738
6347
|
try {
|
@@ -5761,27 +6370,27 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5761
6370
|
}, {
|
5762
6371
|
key: "_setLastReadMessageIndex",
|
5763
6372
|
value: function () {
|
5764
|
-
var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
6373
|
+
var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee28(index) {
|
5765
6374
|
var result;
|
5766
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
6375
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee28$(_context28) {
|
5767
6376
|
while (1) {
|
5768
|
-
switch (
|
6377
|
+
switch (_context28.prev = _context28.next) {
|
5769
6378
|
case 0:
|
5770
|
-
|
6379
|
+
_context28.next = 2;
|
5771
6380
|
return this._services.commandExecutor.mutateResource("post", "".concat(this._configuration.links.myConversations, "/").concat(this.sid), {
|
5772
6381
|
last_read_message_index: index
|
5773
6382
|
});
|
5774
6383
|
|
5775
6384
|
case 2:
|
5776
|
-
result =
|
5777
|
-
return
|
6385
|
+
result = _context28.sent;
|
6386
|
+
return _context28.abrupt("return", result.unread_messages_count);
|
5778
6387
|
|
5779
6388
|
case 4:
|
5780
6389
|
case "end":
|
5781
|
-
return
|
6390
|
+
return _context28.stop();
|
5782
6391
|
}
|
5783
6392
|
}
|
5784
|
-
},
|
6393
|
+
}, _callee28, this);
|
5785
6394
|
}));
|
5786
6395
|
|
5787
6396
|
function _setLastReadMessageIndex(_x19) {
|
@@ -5806,7 +6415,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5806
6415
|
}
|
5807
6416
|
|
5808
6417
|
try {
|
5809
|
-
|
6418
|
+
if (update.dateCreated) {
|
6419
|
+
update.dateCreated = new Date(update.dateCreated);
|
6420
|
+
}
|
5810
6421
|
} catch (e) {
|
5811
6422
|
Conversation._logger.warn("Retrieved malformed dateCreated from the server for conversation: " + conversationSid);
|
5812
6423
|
|
@@ -5814,7 +6425,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5814
6425
|
}
|
5815
6426
|
|
5816
6427
|
try {
|
5817
|
-
|
6428
|
+
if (update.dateUpdated) {
|
6429
|
+
update.dateUpdated = new Date(update.dateUpdated);
|
6430
|
+
}
|
5818
6431
|
} catch (e) {
|
5819
6432
|
Conversation._logger.warn("Retrieved malformed dateUpdated from the server for conversation: " + conversationSid);
|
5820
6433
|
|
@@ -5858,9 +6471,9 @@ _defineProperty__default["default"](Conversation, "removed", "removed");
|
|
5858
6471
|
|
5859
6472
|
_defineProperty__default["default"](Conversation, "_logger", Logger.scope("Conversation"));
|
5860
6473
|
|
5861
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString,
|
6474
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, optionalJson), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "add", null);
|
5862
6475
|
|
5863
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString,
|
6476
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString, optionalJson), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "addNonChatParticipant", null);
|
5864
6477
|
|
5865
6478
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonNegativeInteger), __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", Promise)], Conversation.prototype, "advanceLastReadMessageIndex", null);
|
5866
6479
|
|
@@ -5883,13 +6496,13 @@ __decorate([declarativeTypeValidator.validateTypesAsync(["string", FormData, dec
|
|
5883
6496
|
|
5884
6497
|
return [isValid, "a non-empty string, an instance of Buffer or an instance of Blob"];
|
5885
6498
|
})
|
5886
|
-
})],
|
6499
|
+
})], optionalJson, ["undefined", declarativeTypeValidator.literal(null), declarativeTypeValidator.objectSchema("email attributes", {
|
5887
6500
|
subject: [declarativeTypeValidator.nonEmptyString, "undefined"]
|
5888
6501
|
})]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "sendMessage", null);
|
5889
6502
|
|
5890
6503
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("default", "muted")), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "setUserNotificationLevel", null);
|
5891
6504
|
|
5892
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
6505
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateAttributes", null);
|
5893
6506
|
|
5894
6507
|
__decorate([declarativeTypeValidator.validateTypesAsync("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateFriendlyName", null);
|
5895
6508
|
|
@@ -5936,19 +6549,19 @@ var Deferred = /*#__PURE__*/function () {
|
|
5936
6549
|
return Deferred;
|
5937
6550
|
}();
|
5938
6551
|
|
5939
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(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; } } }; }
|
6552
|
+
function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(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; } } }; }
|
5940
6553
|
|
5941
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
6554
|
+
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
5942
6555
|
|
5943
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
6556
|
+
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
5944
6557
|
|
5945
6558
|
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
5946
6559
|
|
5947
6560
|
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
5948
6561
|
|
5949
|
-
function _createSuper$
|
6562
|
+
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); }; }
|
5950
6563
|
|
5951
|
-
function _isNativeReflectConstruct$
|
6564
|
+
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; } }
|
5952
6565
|
var log$1 = Logger.scope("Conversations");
|
5953
6566
|
/**
|
5954
6567
|
* Represents conversations collection
|
@@ -5958,7 +6571,7 @@ var log$1 = Logger.scope("Conversations");
|
|
5958
6571
|
var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
5959
6572
|
_inherits__default["default"](Conversations, _ReplayEventEmitter);
|
5960
6573
|
|
5961
|
-
var _super = _createSuper$
|
6574
|
+
var _super = _createSuper$3(Conversations);
|
5962
6575
|
|
5963
6576
|
function Conversations(configuration, services) {
|
5964
6577
|
var _this;
|
@@ -6120,7 +6733,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6120
6733
|
case 9:
|
6121
6734
|
myConversations = _context2.sent;
|
6122
6735
|
upserts = [];
|
6123
|
-
_iterator = _createForOfIteratorHelper(myConversations);
|
6736
|
+
_iterator = _createForOfIteratorHelper$1(myConversations);
|
6124
6737
|
|
6125
6738
|
try {
|
6126
6739
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
@@ -6393,7 +7006,9 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6393
7006
|
case 2:
|
6394
7007
|
items = _context8.sent;
|
6395
7008
|
return _context8.abrupt("return", {
|
6396
|
-
items: items
|
7009
|
+
items: items.filter(function (item) {
|
7010
|
+
return item !== null;
|
7011
|
+
}),
|
6397
7012
|
hasNextPage: page.hasNextPage,
|
6398
7013
|
hasPrevPage: page.hasPrevPage,
|
6399
7014
|
nextPage: function nextPage() {
|
@@ -6555,7 +7170,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6555
7170
|
break;
|
6556
7171
|
}
|
6557
7172
|
|
6558
|
-
log$1.trace("upsertChannel: the
|
7173
|
+
log$1.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring", sid);
|
6559
7174
|
return _context10.abrupt("return", null);
|
6560
7175
|
|
6561
7176
|
case 12:
|
@@ -6569,10 +7184,40 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6569
7184
|
};
|
6570
7185
|
newConversation = new Conversation(data, sid, links, this.configuration, this.services);
|
6571
7186
|
this.conversations.set(sid, newConversation);
|
6572
|
-
_context10.
|
7187
|
+
_context10.prev = 17;
|
7188
|
+
_context10.next = 20;
|
6573
7189
|
return newConversation._subscribe();
|
6574
7190
|
|
6575
|
-
case
|
7191
|
+
case 20:
|
7192
|
+
if (!(data.status === "joined")) {
|
7193
|
+
_context10.next = 23;
|
7194
|
+
break;
|
7195
|
+
}
|
7196
|
+
|
7197
|
+
_context10.next = 23;
|
7198
|
+
return newConversation._fetchStreams();
|
7199
|
+
|
7200
|
+
case 23:
|
7201
|
+
_context10.next = 32;
|
7202
|
+
break;
|
7203
|
+
|
7204
|
+
case 25:
|
7205
|
+
_context10.prev = 25;
|
7206
|
+
_context10.t0 = _context10["catch"](17);
|
7207
|
+
|
7208
|
+
if (!(_context10.t0.name !== "SyncError")) {
|
7209
|
+
_context10.next = 29;
|
7210
|
+
break;
|
7211
|
+
}
|
7212
|
+
|
7213
|
+
throw _context10.t0;
|
7214
|
+
|
7215
|
+
case 29:
|
7216
|
+
log$1.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring", sid, _context10.t0);
|
7217
|
+
this.conversations.delete(sid);
|
7218
|
+
return _context10.abrupt("return", null);
|
7219
|
+
|
7220
|
+
case 32:
|
6576
7221
|
this._registerForEvents(newConversation);
|
6577
7222
|
|
6578
7223
|
this.emit("conversationAdded", newConversation);
|
@@ -6585,12 +7230,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6585
7230
|
|
6586
7231
|
return _context10.abrupt("return", newConversation);
|
6587
7232
|
|
6588
|
-
case
|
7233
|
+
case 36:
|
6589
7234
|
case "end":
|
6590
7235
|
return _context10.stop();
|
6591
7236
|
}
|
6592
7237
|
}
|
6593
|
-
}, _callee10, this);
|
7238
|
+
}, _callee10, this, [[17, 25]]);
|
6594
7239
|
}));
|
6595
7240
|
|
6596
7241
|
function _upsertConversation(_x10, _x11, _x12) {
|
@@ -6713,9 +7358,9 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6713
7358
|
return Conversations;
|
6714
7359
|
}(replayEventEmitter.ReplayEventEmitter);
|
6715
7360
|
|
6716
|
-
function _createSuper$
|
7361
|
+
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); }; }
|
6717
7362
|
|
6718
|
-
function _isNativeReflectConstruct$
|
7363
|
+
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; } }
|
6719
7364
|
/**
|
6720
7365
|
* Container for known users
|
6721
7366
|
*/
|
@@ -6723,7 +7368,7 @@ function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !
|
|
6723
7368
|
var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
6724
7369
|
_inherits__default["default"](Users, _ReplayEventEmitter);
|
6725
7370
|
|
6726
|
-
var _super = _createSuper$
|
7371
|
+
var _super = _createSuper$2(Users);
|
6727
7372
|
|
6728
7373
|
function Users(myself, configuration, services) {
|
6729
7374
|
var _this;
|
@@ -7170,12 +7815,16 @@ function PushNotification(data) {
|
|
7170
7815
|
this.data = data.data || {};
|
7171
7816
|
});
|
7172
7817
|
|
7173
|
-
var version = "3.0.
|
7818
|
+
var version = "3.0.1-rc.102";
|
7174
7819
|
|
7175
7820
|
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
7176
7821
|
|
7177
7822
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7178
7823
|
|
7824
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
|
7825
|
+
|
7826
|
+
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
7827
|
+
|
7179
7828
|
var trimSlashes = function trimSlashes(url) {
|
7180
7829
|
return url.replace(/(^\/+|\/+$)/g, "");
|
7181
7830
|
};
|
@@ -7184,6 +7833,20 @@ var isMutationConflictResponse = function isMutationConflictResponse(response) {
|
|
7184
7833
|
return response.status.code === 202;
|
7185
7834
|
};
|
7186
7835
|
|
7836
|
+
var ChannelMetadataNotFoundError = /*#__PURE__*/function (_Error) {
|
7837
|
+
_inherits__default["default"](ChannelMetadataNotFoundError, _Error);
|
7838
|
+
|
7839
|
+
var _super = _createSuper$1(ChannelMetadataNotFoundError);
|
7840
|
+
|
7841
|
+
function ChannelMetadataNotFoundError(message) {
|
7842
|
+
_classCallCheck__default["default"](this, ChannelMetadataNotFoundError);
|
7843
|
+
|
7844
|
+
return _super.call(this, message);
|
7845
|
+
}
|
7846
|
+
|
7847
|
+
return _createClass__default["default"](ChannelMetadataNotFoundError);
|
7848
|
+
}( /*#__PURE__*/_wrapNativeSuper__default["default"](Error));
|
7849
|
+
|
7187
7850
|
var CommandExecutor = /*#__PURE__*/function () {
|
7188
7851
|
function CommandExecutor(_serviceUrl, _services, _productId) {
|
7189
7852
|
_classCallCheck__default["default"](this, CommandExecutor);
|
@@ -7281,40 +7944,91 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
7281
7944
|
}, {
|
7282
7945
|
key: "fetchResource",
|
7283
7946
|
value: function () {
|
7284
|
-
var _fetchResource = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
7947
|
+
var _fetchResource = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(url, requestBody) {
|
7285
7948
|
var _this = this;
|
7286
7949
|
|
7287
|
-
var maxAttemptsCount,
|
7288
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
7950
|
+
var maxAttemptsCount, retrier, resolution;
|
7951
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
7289
7952
|
while (1) {
|
7290
|
-
switch (
|
7953
|
+
switch (_context3.prev = _context3.next) {
|
7291
7954
|
case 0:
|
7292
7955
|
maxAttemptsCount = 6;
|
7293
|
-
|
7294
|
-
_context2.next = 4;
|
7295
|
-
return new operationRetrier.AsyncRetrier({
|
7956
|
+
retrier = new operationRetrier.AsyncRetrier({
|
7296
7957
|
min: 50,
|
7297
7958
|
max: 1600,
|
7298
7959
|
maxAttemptsCount: maxAttemptsCount
|
7299
|
-
}).run(function () {
|
7300
|
-
return _this._makeRequest("get", url, requestBody);
|
7301
7960
|
});
|
7961
|
+
_context3.prev = 2;
|
7962
|
+
_context3.next = 5;
|
7963
|
+
return retrier.run( /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
|
7964
|
+
var response, _e$body, _e$body2;
|
7965
|
+
|
7966
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
7967
|
+
while (1) {
|
7968
|
+
switch (_context2.prev = _context2.next) {
|
7969
|
+
case 0:
|
7970
|
+
_context2.prev = 0;
|
7971
|
+
_context2.next = 3;
|
7972
|
+
return _this._makeRequest("get", url, requestBody);
|
7973
|
+
|
7974
|
+
case 3:
|
7975
|
+
response = _context2.sent;
|
7976
|
+
return _context2.abrupt("return", {
|
7977
|
+
type: "success",
|
7978
|
+
data: response.body
|
7979
|
+
});
|
7980
|
+
|
7981
|
+
case 7:
|
7982
|
+
_context2.prev = 7;
|
7983
|
+
_context2.t0 = _context2["catch"](0);
|
7984
|
+
|
7985
|
+
if (!((_context2.t0 === null || _context2.t0 === void 0 ? void 0 : (_e$body = _context2.t0.body) === null || _e$body === void 0 ? void 0 : _e$body.status) === 404 && (_context2.t0 === null || _context2.t0 === void 0 ? void 0 : (_e$body2 = _context2.t0.body) === null || _e$body2 === void 0 ? void 0 : _e$body2.code) === 50530)) {
|
7986
|
+
_context2.next = 11;
|
7987
|
+
break;
|
7988
|
+
}
|
7989
|
+
|
7990
|
+
return _context2.abrupt("return", {
|
7991
|
+
type: "noMetadata"
|
7992
|
+
});
|
7993
|
+
|
7994
|
+
case 11:
|
7995
|
+
throw _context2.t0;
|
7996
|
+
|
7997
|
+
case 12:
|
7998
|
+
case "end":
|
7999
|
+
return _context2.stop();
|
8000
|
+
}
|
8001
|
+
}
|
8002
|
+
}, _callee2, null, [[0, 7]]);
|
8003
|
+
})));
|
7302
8004
|
|
7303
|
-
case
|
7304
|
-
|
7305
|
-
|
8005
|
+
case 5:
|
8006
|
+
resolution = _context3.sent;
|
8007
|
+
_context3.next = 11;
|
8008
|
+
break;
|
7306
8009
|
|
7307
8010
|
case 8:
|
7308
|
-
|
7309
|
-
|
8011
|
+
_context3.prev = 8;
|
8012
|
+
_context3.t0 = _context3["catch"](2);
|
7310
8013
|
throw new Error("Fetch resource from \"".concat(url, "\" failed."));
|
7311
8014
|
|
7312
8015
|
case 11:
|
8016
|
+
if (!(resolution.type === "noMetadata")) {
|
8017
|
+
_context3.next = 13;
|
8018
|
+
break;
|
8019
|
+
}
|
8020
|
+
|
8021
|
+
throw new ChannelMetadataNotFoundError("No metadata found.");
|
8022
|
+
|
8023
|
+
case 13:
|
8024
|
+
return _context3.abrupt("return", resolution.data);
|
8025
|
+
|
8026
|
+
case 14:
|
7313
8027
|
case "end":
|
7314
|
-
return
|
8028
|
+
return _context3.stop();
|
7315
8029
|
}
|
7316
8030
|
}
|
7317
|
-
},
|
8031
|
+
}, _callee3, null, [[2, 8]]);
|
7318
8032
|
}));
|
7319
8033
|
|
7320
8034
|
function fetchResource(_x5, _x6) {
|
@@ -7326,40 +8040,40 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
7326
8040
|
}, {
|
7327
8041
|
key: "mutateResource",
|
7328
8042
|
value: function () {
|
7329
|
-
var _mutateResource = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
8043
|
+
var _mutateResource = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(method, url, requestBody) {
|
7330
8044
|
var result;
|
7331
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
8045
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
|
7332
8046
|
while (1) {
|
7333
|
-
switch (
|
8047
|
+
switch (_context4.prev = _context4.next) {
|
7334
8048
|
case 0:
|
7335
|
-
|
8049
|
+
_context4.next = 2;
|
7336
8050
|
return this._makeRequest(method, url, requestBody, {
|
7337
8051
|
"X-Twilio-Mutation-Id": uuid.v4()
|
7338
8052
|
});
|
7339
8053
|
|
7340
8054
|
case 2:
|
7341
|
-
result =
|
8055
|
+
result = _context4.sent;
|
7342
8056
|
|
7343
8057
|
if (!isMutationConflictResponse(result)) {
|
7344
|
-
|
8058
|
+
_context4.next = 7;
|
7345
8059
|
break;
|
7346
8060
|
}
|
7347
8061
|
|
7348
|
-
|
8062
|
+
_context4.next = 6;
|
7349
8063
|
return this.fetchResource(result.body.resource_url);
|
7350
8064
|
|
7351
8065
|
case 6:
|
7352
|
-
return
|
8066
|
+
return _context4.abrupt("return", _context4.sent);
|
7353
8067
|
|
7354
8068
|
case 7:
|
7355
|
-
return
|
8069
|
+
return _context4.abrupt("return", result.body);
|
7356
8070
|
|
7357
8071
|
case 8:
|
7358
8072
|
case "end":
|
7359
|
-
return
|
8073
|
+
return _context4.stop();
|
7360
8074
|
}
|
7361
8075
|
}
|
7362
|
-
},
|
8076
|
+
}, _callee4, this);
|
7363
8077
|
}));
|
7364
8078
|
|
7365
8079
|
function mutateResource(_x7, _x8, _x9) {
|
@@ -7373,6 +8087,593 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
7373
8087
|
return CommandExecutor;
|
7374
8088
|
}();
|
7375
8089
|
|
8090
|
+
var ContentClient = /*#__PURE__*/function () {
|
8091
|
+
function ContentClient(_services) {
|
8092
|
+
var _pageSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
|
8093
|
+
|
8094
|
+
var _cacheTtlMs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5000;
|
8095
|
+
|
8096
|
+
_classCallCheck__default["default"](this, ContentClient);
|
8097
|
+
|
8098
|
+
_defineProperty__default["default"](this, "_cachedTemplates", null);
|
8099
|
+
|
8100
|
+
this._services = _services;
|
8101
|
+
this._pageSize = _pageSize;
|
8102
|
+
this._cacheTtlMs = _cacheTtlMs;
|
8103
|
+
}
|
8104
|
+
|
8105
|
+
_createClass__default["default"](ContentClient, [{
|
8106
|
+
key: "getContentTemplates",
|
8107
|
+
value: function () {
|
8108
|
+
var _getContentTemplates = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
8109
|
+
var _this = this;
|
8110
|
+
|
8111
|
+
var _yield$this$_fetchCon, _yield$this$_fetchCon2, templatesPage, nextToken, templates, _yield$this$_fetchCon3, _yield$this$_fetchCon4;
|
8112
|
+
|
8113
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
8114
|
+
while (1) {
|
8115
|
+
switch (_context.prev = _context.next) {
|
8116
|
+
case 0:
|
8117
|
+
if (!(this._cachedTemplates !== null)) {
|
8118
|
+
_context.next = 2;
|
8119
|
+
break;
|
8120
|
+
}
|
8121
|
+
|
8122
|
+
return _context.abrupt("return", this._cachedTemplates);
|
8123
|
+
|
8124
|
+
case 2:
|
8125
|
+
_context.next = 4;
|
8126
|
+
return this._fetchContentTemplates();
|
8127
|
+
|
8128
|
+
case 4:
|
8129
|
+
_yield$this$_fetchCon = _context.sent;
|
8130
|
+
_yield$this$_fetchCon2 = _slicedToArray__default["default"](_yield$this$_fetchCon, 2);
|
8131
|
+
templatesPage = _yield$this$_fetchCon2[0];
|
8132
|
+
nextToken = _yield$this$_fetchCon2[1];
|
8133
|
+
templates = templatesPage;
|
8134
|
+
|
8135
|
+
case 9:
|
8136
|
+
if (!(nextToken !== null)) {
|
8137
|
+
_context.next = 19;
|
8138
|
+
break;
|
8139
|
+
}
|
8140
|
+
|
8141
|
+
_context.next = 12;
|
8142
|
+
return this._fetchContentTemplates(nextToken);
|
8143
|
+
|
8144
|
+
case 12:
|
8145
|
+
_yield$this$_fetchCon3 = _context.sent;
|
8146
|
+
_yield$this$_fetchCon4 = _slicedToArray__default["default"](_yield$this$_fetchCon3, 2);
|
8147
|
+
templatesPage = _yield$this$_fetchCon4[0];
|
8148
|
+
nextToken = _yield$this$_fetchCon4[1];
|
8149
|
+
templates = [].concat(_toConsumableArray__default["default"](templates), _toConsumableArray__default["default"](templatesPage));
|
8150
|
+
_context.next = 9;
|
8151
|
+
break;
|
8152
|
+
|
8153
|
+
case 19:
|
8154
|
+
this._cachedTemplates = Object.freeze(templates);
|
8155
|
+
setTimeout(function () {
|
8156
|
+
_this._cachedTemplates = null;
|
8157
|
+
}, this._cacheTtlMs);
|
8158
|
+
return _context.abrupt("return", templates);
|
8159
|
+
|
8160
|
+
case 22:
|
8161
|
+
case "end":
|
8162
|
+
return _context.stop();
|
8163
|
+
}
|
8164
|
+
}
|
8165
|
+
}, _callee, this);
|
8166
|
+
}));
|
8167
|
+
|
8168
|
+
function getContentTemplates() {
|
8169
|
+
return _getContentTemplates.apply(this, arguments);
|
8170
|
+
}
|
8171
|
+
|
8172
|
+
return getContentTemplates;
|
8173
|
+
}()
|
8174
|
+
}, {
|
8175
|
+
key: "_fetchContentTemplates",
|
8176
|
+
value: function () {
|
8177
|
+
var _fetchContentTemplates2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(pageToken) {
|
8178
|
+
var contentTemplatesUrl, url, response;
|
8179
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
8180
|
+
while (1) {
|
8181
|
+
switch (_context2.prev = _context2.next) {
|
8182
|
+
case 0:
|
8183
|
+
contentTemplatesUrl = "Client/v2/ContentTemplates";
|
8184
|
+
url = new UriBuilder(contentTemplatesUrl);
|
8185
|
+
url.arg("PageSize", this._pageSize);
|
8186
|
+
|
8187
|
+
if (pageToken !== undefined) {
|
8188
|
+
url.arg("PageToken", pageToken);
|
8189
|
+
}
|
8190
|
+
|
8191
|
+
_context2.next = 6;
|
8192
|
+
return this._services.commandExecutor.fetchResource(url.build());
|
8193
|
+
|
8194
|
+
case 6:
|
8195
|
+
response = _context2.sent;
|
8196
|
+
return _context2.abrupt("return", [response.templates.map(function (template) {
|
8197
|
+
return new ContentTemplate(template);
|
8198
|
+
}), response.meta.next_token]);
|
8199
|
+
|
8200
|
+
case 8:
|
8201
|
+
case "end":
|
8202
|
+
return _context2.stop();
|
8203
|
+
}
|
8204
|
+
}
|
8205
|
+
}, _callee2, this);
|
8206
|
+
}));
|
8207
|
+
|
8208
|
+
function _fetchContentTemplates(_x) {
|
8209
|
+
return _fetchContentTemplates2.apply(this, arguments);
|
8210
|
+
}
|
8211
|
+
|
8212
|
+
return _fetchContentTemplates;
|
8213
|
+
}()
|
8214
|
+
}]);
|
8215
|
+
|
8216
|
+
return ContentClient;
|
8217
|
+
}();
|
8218
|
+
|
8219
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(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; } } }; }
|
8220
|
+
|
8221
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
8222
|
+
|
8223
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
8224
|
+
|
8225
|
+
var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
|
8226
|
+
function QuickLRU() {
|
8227
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
8228
|
+
|
8229
|
+
_classCallCheck__default["default"](this, QuickLRU);
|
8230
|
+
|
8231
|
+
if (!(options.maxSize && options.maxSize > 0)) {
|
8232
|
+
throw new TypeError('`maxSize` must be a number greater than 0');
|
8233
|
+
}
|
8234
|
+
|
8235
|
+
this.maxSize = options.maxSize;
|
8236
|
+
this.onEviction = options.onEviction;
|
8237
|
+
this.cache = new Map();
|
8238
|
+
this.oldCache = new Map();
|
8239
|
+
this._size = 0;
|
8240
|
+
}
|
8241
|
+
|
8242
|
+
_createClass__default["default"](QuickLRU, [{
|
8243
|
+
key: "_set",
|
8244
|
+
value: function _set(key, value) {
|
8245
|
+
this.cache.set(key, value);
|
8246
|
+
this._size++;
|
8247
|
+
|
8248
|
+
if (this._size >= this.maxSize) {
|
8249
|
+
this._size = 0;
|
8250
|
+
|
8251
|
+
if (typeof this.onEviction === 'function') {
|
8252
|
+
var _iterator = _createForOfIteratorHelper(this.oldCache.entries()),
|
8253
|
+
_step;
|
8254
|
+
|
8255
|
+
try {
|
8256
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
8257
|
+
var _step$value = _slicedToArray__default["default"](_step.value, 2),
|
8258
|
+
_key = _step$value[0],
|
8259
|
+
_value = _step$value[1];
|
8260
|
+
|
8261
|
+
this.onEviction(_key, _value);
|
8262
|
+
}
|
8263
|
+
} catch (err) {
|
8264
|
+
_iterator.e(err);
|
8265
|
+
} finally {
|
8266
|
+
_iterator.f();
|
8267
|
+
}
|
8268
|
+
}
|
8269
|
+
|
8270
|
+
this.oldCache = this.cache;
|
8271
|
+
this.cache = new Map();
|
8272
|
+
}
|
8273
|
+
}
|
8274
|
+
}, {
|
8275
|
+
key: "get",
|
8276
|
+
value: function get(key) {
|
8277
|
+
if (this.cache.has(key)) {
|
8278
|
+
return this.cache.get(key);
|
8279
|
+
}
|
8280
|
+
|
8281
|
+
if (this.oldCache.has(key)) {
|
8282
|
+
var value = this.oldCache.get(key);
|
8283
|
+
this.oldCache.delete(key);
|
8284
|
+
|
8285
|
+
this._set(key, value);
|
8286
|
+
|
8287
|
+
return value;
|
8288
|
+
}
|
8289
|
+
}
|
8290
|
+
}, {
|
8291
|
+
key: "set",
|
8292
|
+
value: function set(key, value) {
|
8293
|
+
if (this.cache.has(key)) {
|
8294
|
+
this.cache.set(key, value);
|
8295
|
+
} else {
|
8296
|
+
this._set(key, value);
|
8297
|
+
}
|
8298
|
+
|
8299
|
+
return this;
|
8300
|
+
}
|
8301
|
+
}, {
|
8302
|
+
key: "has",
|
8303
|
+
value: function has(key) {
|
8304
|
+
return this.cache.has(key) || this.oldCache.has(key);
|
8305
|
+
}
|
8306
|
+
}, {
|
8307
|
+
key: "peek",
|
8308
|
+
value: function peek(key) {
|
8309
|
+
if (this.cache.has(key)) {
|
8310
|
+
return this.cache.get(key);
|
8311
|
+
}
|
8312
|
+
|
8313
|
+
if (this.oldCache.has(key)) {
|
8314
|
+
return this.oldCache.get(key);
|
8315
|
+
}
|
8316
|
+
}
|
8317
|
+
}, {
|
8318
|
+
key: "delete",
|
8319
|
+
value: function _delete(key) {
|
8320
|
+
var deleted = this.cache.delete(key);
|
8321
|
+
|
8322
|
+
if (deleted) {
|
8323
|
+
this._size--;
|
8324
|
+
}
|
8325
|
+
|
8326
|
+
return this.oldCache.delete(key) || deleted;
|
8327
|
+
}
|
8328
|
+
}, {
|
8329
|
+
key: "clear",
|
8330
|
+
value: function clear() {
|
8331
|
+
this.cache.clear();
|
8332
|
+
this.oldCache.clear();
|
8333
|
+
this._size = 0;
|
8334
|
+
}
|
8335
|
+
}, {
|
8336
|
+
key: "keys",
|
8337
|
+
value: /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function keys() {
|
8338
|
+
var _iterator2, _step2, _step2$value, key;
|
8339
|
+
|
8340
|
+
return _regeneratorRuntime__default["default"].wrap(function keys$(_context) {
|
8341
|
+
while (1) {
|
8342
|
+
switch (_context.prev = _context.next) {
|
8343
|
+
case 0:
|
8344
|
+
_iterator2 = _createForOfIteratorHelper(this);
|
8345
|
+
_context.prev = 1;
|
8346
|
+
|
8347
|
+
_iterator2.s();
|
8348
|
+
|
8349
|
+
case 3:
|
8350
|
+
if ((_step2 = _iterator2.n()).done) {
|
8351
|
+
_context.next = 9;
|
8352
|
+
break;
|
8353
|
+
}
|
8354
|
+
|
8355
|
+
_step2$value = _slicedToArray__default["default"](_step2.value, 1), key = _step2$value[0];
|
8356
|
+
_context.next = 7;
|
8357
|
+
return key;
|
8358
|
+
|
8359
|
+
case 7:
|
8360
|
+
_context.next = 3;
|
8361
|
+
break;
|
8362
|
+
|
8363
|
+
case 9:
|
8364
|
+
_context.next = 14;
|
8365
|
+
break;
|
8366
|
+
|
8367
|
+
case 11:
|
8368
|
+
_context.prev = 11;
|
8369
|
+
_context.t0 = _context["catch"](1);
|
8370
|
+
|
8371
|
+
_iterator2.e(_context.t0);
|
8372
|
+
|
8373
|
+
case 14:
|
8374
|
+
_context.prev = 14;
|
8375
|
+
|
8376
|
+
_iterator2.f();
|
8377
|
+
|
8378
|
+
return _context.finish(14);
|
8379
|
+
|
8380
|
+
case 17:
|
8381
|
+
case "end":
|
8382
|
+
return _context.stop();
|
8383
|
+
}
|
8384
|
+
}
|
8385
|
+
}, keys, this, [[1, 11, 14, 17]]);
|
8386
|
+
})
|
8387
|
+
}, {
|
8388
|
+
key: "values",
|
8389
|
+
value: /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function values() {
|
8390
|
+
var _iterator3, _step3, _step3$value, value;
|
8391
|
+
|
8392
|
+
return _regeneratorRuntime__default["default"].wrap(function values$(_context2) {
|
8393
|
+
while (1) {
|
8394
|
+
switch (_context2.prev = _context2.next) {
|
8395
|
+
case 0:
|
8396
|
+
_iterator3 = _createForOfIteratorHelper(this);
|
8397
|
+
_context2.prev = 1;
|
8398
|
+
|
8399
|
+
_iterator3.s();
|
8400
|
+
|
8401
|
+
case 3:
|
8402
|
+
if ((_step3 = _iterator3.n()).done) {
|
8403
|
+
_context2.next = 9;
|
8404
|
+
break;
|
8405
|
+
}
|
8406
|
+
|
8407
|
+
_step3$value = _slicedToArray__default["default"](_step3.value, 2), value = _step3$value[1];
|
8408
|
+
_context2.next = 7;
|
8409
|
+
return value;
|
8410
|
+
|
8411
|
+
case 7:
|
8412
|
+
_context2.next = 3;
|
8413
|
+
break;
|
8414
|
+
|
8415
|
+
case 9:
|
8416
|
+
_context2.next = 14;
|
8417
|
+
break;
|
8418
|
+
|
8419
|
+
case 11:
|
8420
|
+
_context2.prev = 11;
|
8421
|
+
_context2.t0 = _context2["catch"](1);
|
8422
|
+
|
8423
|
+
_iterator3.e(_context2.t0);
|
8424
|
+
|
8425
|
+
case 14:
|
8426
|
+
_context2.prev = 14;
|
8427
|
+
|
8428
|
+
_iterator3.f();
|
8429
|
+
|
8430
|
+
return _context2.finish(14);
|
8431
|
+
|
8432
|
+
case 17:
|
8433
|
+
case "end":
|
8434
|
+
return _context2.stop();
|
8435
|
+
}
|
8436
|
+
}
|
8437
|
+
}, values, this, [[1, 11, 14, 17]]);
|
8438
|
+
})
|
8439
|
+
}, {
|
8440
|
+
key: _Symbol$iterator,
|
8441
|
+
value: /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function value() {
|
8442
|
+
var _iterator4, _step4, item, _iterator5, _step5, _item, _item2, key;
|
8443
|
+
|
8444
|
+
return _regeneratorRuntime__default["default"].wrap(function value$(_context3) {
|
8445
|
+
while (1) {
|
8446
|
+
switch (_context3.prev = _context3.next) {
|
8447
|
+
case 0:
|
8448
|
+
_iterator4 = _createForOfIteratorHelper(this.cache);
|
8449
|
+
_context3.prev = 1;
|
8450
|
+
|
8451
|
+
_iterator4.s();
|
8452
|
+
|
8453
|
+
case 3:
|
8454
|
+
if ((_step4 = _iterator4.n()).done) {
|
8455
|
+
_context3.next = 9;
|
8456
|
+
break;
|
8457
|
+
}
|
8458
|
+
|
8459
|
+
item = _step4.value;
|
8460
|
+
_context3.next = 7;
|
8461
|
+
return item;
|
8462
|
+
|
8463
|
+
case 7:
|
8464
|
+
_context3.next = 3;
|
8465
|
+
break;
|
8466
|
+
|
8467
|
+
case 9:
|
8468
|
+
_context3.next = 14;
|
8469
|
+
break;
|
8470
|
+
|
8471
|
+
case 11:
|
8472
|
+
_context3.prev = 11;
|
8473
|
+
_context3.t0 = _context3["catch"](1);
|
8474
|
+
|
8475
|
+
_iterator4.e(_context3.t0);
|
8476
|
+
|
8477
|
+
case 14:
|
8478
|
+
_context3.prev = 14;
|
8479
|
+
|
8480
|
+
_iterator4.f();
|
8481
|
+
|
8482
|
+
return _context3.finish(14);
|
8483
|
+
|
8484
|
+
case 17:
|
8485
|
+
_iterator5 = _createForOfIteratorHelper(this.oldCache);
|
8486
|
+
_context3.prev = 18;
|
8487
|
+
|
8488
|
+
_iterator5.s();
|
8489
|
+
|
8490
|
+
case 20:
|
8491
|
+
if ((_step5 = _iterator5.n()).done) {
|
8492
|
+
_context3.next = 28;
|
8493
|
+
break;
|
8494
|
+
}
|
8495
|
+
|
8496
|
+
_item = _step5.value;
|
8497
|
+
_item2 = _slicedToArray__default["default"](_item, 1), key = _item2[0];
|
8498
|
+
|
8499
|
+
if (this.cache.has(key)) {
|
8500
|
+
_context3.next = 26;
|
8501
|
+
break;
|
8502
|
+
}
|
8503
|
+
|
8504
|
+
_context3.next = 26;
|
8505
|
+
return _item;
|
8506
|
+
|
8507
|
+
case 26:
|
8508
|
+
_context3.next = 20;
|
8509
|
+
break;
|
8510
|
+
|
8511
|
+
case 28:
|
8512
|
+
_context3.next = 33;
|
8513
|
+
break;
|
8514
|
+
|
8515
|
+
case 30:
|
8516
|
+
_context3.prev = 30;
|
8517
|
+
_context3.t1 = _context3["catch"](18);
|
8518
|
+
|
8519
|
+
_iterator5.e(_context3.t1);
|
8520
|
+
|
8521
|
+
case 33:
|
8522
|
+
_context3.prev = 33;
|
8523
|
+
|
8524
|
+
_iterator5.f();
|
8525
|
+
|
8526
|
+
return _context3.finish(33);
|
8527
|
+
|
8528
|
+
case 36:
|
8529
|
+
case "end":
|
8530
|
+
return _context3.stop();
|
8531
|
+
}
|
8532
|
+
}
|
8533
|
+
}, value, this, [[1, 11, 14, 17], [18, 30, 33, 36]]);
|
8534
|
+
})
|
8535
|
+
}, {
|
8536
|
+
key: "size",
|
8537
|
+
get: function get() {
|
8538
|
+
var oldCacheSize = 0;
|
8539
|
+
|
8540
|
+
var _iterator6 = _createForOfIteratorHelper(this.oldCache.keys()),
|
8541
|
+
_step6;
|
8542
|
+
|
8543
|
+
try {
|
8544
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
8545
|
+
var key = _step6.value;
|
8546
|
+
|
8547
|
+
if (!this.cache.has(key)) {
|
8548
|
+
oldCacheSize++;
|
8549
|
+
}
|
8550
|
+
}
|
8551
|
+
} catch (err) {
|
8552
|
+
_iterator6.e(err);
|
8553
|
+
} finally {
|
8554
|
+
_iterator6.f();
|
8555
|
+
}
|
8556
|
+
|
8557
|
+
return Math.min(this._size + oldCacheSize, this.maxSize);
|
8558
|
+
}
|
8559
|
+
}]);
|
8560
|
+
|
8561
|
+
return QuickLRU;
|
8562
|
+
}(Symbol.iterator);
|
8563
|
+
|
8564
|
+
var quickLru = QuickLRU;
|
8565
|
+
|
8566
|
+
/**
|
8567
|
+
* Represents channel metadata.
|
8568
|
+
*/
|
8569
|
+
|
8570
|
+
var ChannelMetadata = /*#__PURE__*/_createClass__default["default"](
|
8571
|
+
/**
|
8572
|
+
* Communication channel type.
|
8573
|
+
*/
|
8574
|
+
|
8575
|
+
/**
|
8576
|
+
* The actual metadata.
|
8577
|
+
*/
|
8578
|
+
|
8579
|
+
/**
|
8580
|
+
* @internal
|
8581
|
+
*/
|
8582
|
+
function ChannelMetadata(type, data) {
|
8583
|
+
_classCallCheck__default["default"](this, ChannelMetadata);
|
8584
|
+
|
8585
|
+
this.type = type;
|
8586
|
+
this.data = data;
|
8587
|
+
Object.freeze(data);
|
8588
|
+
});
|
8589
|
+
|
8590
|
+
var ChannelMetadataClient = /*#__PURE__*/function () {
|
8591
|
+
function ChannelMetadataClient(services, configuration) {
|
8592
|
+
_classCallCheck__default["default"](this, ChannelMetadataClient);
|
8593
|
+
|
8594
|
+
this._services = services;
|
8595
|
+
this._configuration = configuration;
|
8596
|
+
this._cache = new quickLru({
|
8597
|
+
maxSize: configuration.channelMetadataCacheCapacity
|
8598
|
+
});
|
8599
|
+
}
|
8600
|
+
|
8601
|
+
_createClass__default["default"](ChannelMetadataClient, [{
|
8602
|
+
key: "getChannelMetadata",
|
8603
|
+
value: function () {
|
8604
|
+
var _getChannelMetadata = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(conversationSid, messageSid) {
|
8605
|
+
var key, cachedItem, url, metadataResponse, metadata;
|
8606
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
8607
|
+
while (1) {
|
8608
|
+
switch (_context.prev = _context.next) {
|
8609
|
+
case 0:
|
8610
|
+
key = "".concat(conversationSid, ",").concat(messageSid);
|
8611
|
+
cachedItem = this._cache.get(key);
|
8612
|
+
|
8613
|
+
if (!cachedItem) {
|
8614
|
+
_context.next = 4;
|
8615
|
+
break;
|
8616
|
+
}
|
8617
|
+
|
8618
|
+
return _context.abrupt("return", cachedItem.item);
|
8619
|
+
|
8620
|
+
case 4:
|
8621
|
+
url = "".concat(this._configuration.links.conversations, "/").concat(conversationSid, "/Messages/").concat(messageSid, "/ChannelMetadata");
|
8622
|
+
_context.prev = 5;
|
8623
|
+
_context.next = 8;
|
8624
|
+
return this._services.commandExecutor.fetchResource(url);
|
8625
|
+
|
8626
|
+
case 8:
|
8627
|
+
metadataResponse = _context.sent;
|
8628
|
+
_context.next = 17;
|
8629
|
+
break;
|
8630
|
+
|
8631
|
+
case 11:
|
8632
|
+
_context.prev = 11;
|
8633
|
+
_context.t0 = _context["catch"](5);
|
8634
|
+
|
8635
|
+
if (!(_context.t0 instanceof ChannelMetadataNotFoundError)) {
|
8636
|
+
_context.next = 16;
|
8637
|
+
break;
|
8638
|
+
}
|
8639
|
+
|
8640
|
+
this._cache.set(key, {
|
8641
|
+
item: null
|
8642
|
+
});
|
8643
|
+
|
8644
|
+
return _context.abrupt("return", null);
|
8645
|
+
|
8646
|
+
case 16:
|
8647
|
+
throw new Error(_context.t0);
|
8648
|
+
|
8649
|
+
case 17:
|
8650
|
+
metadata = new ChannelMetadata(metadataResponse.type, metadataResponse.data);
|
8651
|
+
|
8652
|
+
this._cache.set(key, {
|
8653
|
+
item: metadata
|
8654
|
+
});
|
8655
|
+
|
8656
|
+
return _context.abrupt("return", metadata);
|
8657
|
+
|
8658
|
+
case 20:
|
8659
|
+
case "end":
|
8660
|
+
return _context.stop();
|
8661
|
+
}
|
8662
|
+
}
|
8663
|
+
}, _callee, this, [[5, 11]]);
|
8664
|
+
}));
|
8665
|
+
|
8666
|
+
function getChannelMetadata(_x, _x2) {
|
8667
|
+
return _getChannelMetadata.apply(this, arguments);
|
8668
|
+
}
|
8669
|
+
|
8670
|
+
return getChannelMetadata;
|
8671
|
+
}()
|
8672
|
+
}]);
|
8673
|
+
|
8674
|
+
return ChannelMetadataClient;
|
8675
|
+
}();
|
8676
|
+
|
7376
8677
|
var _class;
|
7377
8678
|
|
7378
8679
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
@@ -7572,12 +8873,25 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7572
8873
|
*/
|
7573
8874
|
|
7574
8875
|
/**
|
8876
|
+
* @deprecated Use initialized or initFailed events instead
|
7575
8877
|
* Fired when the state of the client has been changed.
|
7576
8878
|
*
|
7577
8879
|
* Parameters:
|
8880
|
+
* 1. {@link State} `state` - the new client state
|
8881
|
+
* @event
|
8882
|
+
*/
|
8883
|
+
|
8884
|
+
/**
|
8885
|
+
* Fired when the client has completed initialization successfully.
|
8886
|
+
* @event
|
8887
|
+
*/
|
8888
|
+
|
8889
|
+
/**
|
8890
|
+
* Fired when the client initialization failed.
|
8891
|
+
*
|
8892
|
+
* Parameters:
|
7578
8893
|
* 1. object `data` - info object provided with the event. It has the
|
7579
|
-
* following
|
7580
|
-
* * {@link State} `state` - the new client state
|
8894
|
+
* following property:
|
7581
8895
|
* * Error? `error` - the initialization error if present
|
7582
8896
|
* @event
|
7583
8897
|
*/
|
@@ -7749,12 +9063,14 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7749
9063
|
_this._services.commandExecutor = new CommandExecutor(baseUrl, {
|
7750
9064
|
transport: _this._options.transport
|
7751
9065
|
}, productId);
|
9066
|
+
_this._services.contentClient = new ContentClient(_this._services);
|
7752
9067
|
|
7753
9068
|
var emitFailed = function emitFailed(error) {
|
7754
9069
|
_this._rejectEnsureReady(error);
|
7755
9070
|
|
7756
|
-
_this.emit("stateChanged",
|
7757
|
-
|
9071
|
+
_this.emit("stateChanged", "failed");
|
9072
|
+
|
9073
|
+
_this.emit("initFailed", {
|
7758
9074
|
error: error
|
7759
9075
|
});
|
7760
9076
|
};
|
@@ -7766,11 +9082,11 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7766
9082
|
});
|
7767
9083
|
};
|
7768
9084
|
|
7769
|
-
_this._services.twilsockClient.
|
9085
|
+
_this._services.twilsockClient.once("connectionError", emitFailed);
|
7770
9086
|
|
7771
|
-
_this._services.twilsockClient.
|
9087
|
+
_this._services.twilsockClient.once("disconnected", emitDisconnected);
|
7772
9088
|
|
7773
|
-
_this._services.twilsockClient.
|
9089
|
+
_this._services.twilsockClient.once("connected", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
7774
9090
|
var startupEvent, connectionError;
|
7775
9091
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
7776
9092
|
while (1) {
|
@@ -7793,7 +9109,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7793
9109
|
case 8:
|
7794
9110
|
_this._services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription("", "", new Date()), startupEvent, twilsock.TelemetryPoint.End);
|
7795
9111
|
|
7796
|
-
_context.next =
|
9112
|
+
_context.next = 17;
|
7797
9113
|
break;
|
7798
9114
|
|
7799
9115
|
case 11:
|
@@ -7807,12 +9123,13 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7807
9123
|
|
7808
9124
|
_this._rejectEnsureReady(connectionError);
|
7809
9125
|
|
7810
|
-
_this.emit("stateChanged",
|
7811
|
-
|
9126
|
+
_this.emit("stateChanged", "failed");
|
9127
|
+
|
9128
|
+
_this.emit("initFailed", {
|
7812
9129
|
error: connectionError
|
7813
9130
|
});
|
7814
9131
|
|
7815
|
-
case
|
9132
|
+
case 17:
|
7816
9133
|
case "end":
|
7817
9134
|
return _context.stop();
|
7818
9135
|
}
|
@@ -7859,6 +9176,17 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7859
9176
|
|
7860
9177
|
return this._configuration.reachabilityEnabled;
|
7861
9178
|
}
|
9179
|
+
/**
|
9180
|
+
* @deprecated
|
9181
|
+
* Current token.
|
9182
|
+
* @internal
|
9183
|
+
*/
|
9184
|
+
|
9185
|
+
}, {
|
9186
|
+
key: "token",
|
9187
|
+
get: function get() {
|
9188
|
+
return this._fpaToken;
|
9189
|
+
}
|
7862
9190
|
/**
|
7863
9191
|
* @deprecated Call constructor directly.
|
7864
9192
|
*
|
@@ -7997,16 +9325,32 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7997
9325
|
conversation = _context4.sent;
|
7998
9326
|
|
7999
9327
|
if (conversation) {
|
8000
|
-
_context4.next =
|
9328
|
+
_context4.next = 12;
|
9329
|
+
break;
|
9330
|
+
}
|
9331
|
+
|
9332
|
+
_context4.next = 10;
|
9333
|
+
return this.peekConversationBySid(conversationSid);
|
9334
|
+
|
9335
|
+
case 10:
|
9336
|
+
conversation = _context4.sent;
|
9337
|
+
|
9338
|
+
if (conversation) {
|
9339
|
+
deprecationDecorator.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");
|
9340
|
+
}
|
9341
|
+
|
9342
|
+
case 12:
|
9343
|
+
if (conversation) {
|
9344
|
+
_context4.next = 14;
|
8001
9345
|
break;
|
8002
9346
|
}
|
8003
9347
|
|
8004
9348
|
throw new Error("Conversation with SID ".concat(conversationSid, " was not found."));
|
8005
9349
|
|
8006
|
-
case
|
9350
|
+
case 14:
|
8007
9351
|
return _context4.abrupt("return", conversation);
|
8008
9352
|
|
8009
|
-
case
|
9353
|
+
case 15:
|
8010
9354
|
case "end":
|
8011
9355
|
return _context4.stop();
|
8012
9356
|
}
|
@@ -8492,6 +9836,43 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8492
9836
|
});
|
8493
9837
|
return this.getTemporaryContentUrlsForMediaSids(sids);
|
8494
9838
|
}
|
9839
|
+
/**
|
9840
|
+
* Returns rich content templates belonging to the account. Rich content
|
9841
|
+
* templates can be created via the Twilio console or the REST API.
|
9842
|
+
*/
|
9843
|
+
|
9844
|
+
}, {
|
9845
|
+
key: "getContentTemplates",
|
9846
|
+
value: function () {
|
9847
|
+
var _getContentTemplates = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee16() {
|
9848
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee16$(_context16) {
|
9849
|
+
while (1) {
|
9850
|
+
switch (_context16.prev = _context16.next) {
|
9851
|
+
case 0:
|
9852
|
+
_context16.next = 2;
|
9853
|
+
return this._ensureReady;
|
9854
|
+
|
9855
|
+
case 2:
|
9856
|
+
_context16.next = 4;
|
9857
|
+
return this._services.contentClient.getContentTemplates();
|
9858
|
+
|
9859
|
+
case 4:
|
9860
|
+
return _context16.abrupt("return", _context16.sent);
|
9861
|
+
|
9862
|
+
case 5:
|
9863
|
+
case "end":
|
9864
|
+
return _context16.stop();
|
9865
|
+
}
|
9866
|
+
}
|
9867
|
+
}, _callee16, this);
|
9868
|
+
}));
|
9869
|
+
|
9870
|
+
function getContentTemplates() {
|
9871
|
+
return _getContentTemplates.apply(this, arguments);
|
9872
|
+
}
|
9873
|
+
|
9874
|
+
return getContentTemplates;
|
9875
|
+
}()
|
8495
9876
|
/**
|
8496
9877
|
* Initialize the client.
|
8497
9878
|
*/
|
@@ -8499,20 +9880,21 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8499
9880
|
}, {
|
8500
9881
|
key: "_initialize",
|
8501
9882
|
value: function () {
|
8502
|
-
var _initialize2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
9883
|
+
var _initialize2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee17() {
|
8503
9884
|
var _this3 = this;
|
8504
9885
|
|
8505
9886
|
var configurationResponse;
|
8506
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
9887
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee17$(_context17) {
|
8507
9888
|
while (1) {
|
8508
|
-
switch (
|
9889
|
+
switch (_context17.prev = _context17.next) {
|
8509
9890
|
case 0:
|
8510
|
-
|
9891
|
+
_context17.next = 2;
|
8511
9892
|
return this._services.commandExecutor.fetchResource("Client/v2/Configuration");
|
8512
9893
|
|
8513
9894
|
case 2:
|
8514
|
-
configurationResponse =
|
9895
|
+
configurationResponse = _context17.sent;
|
8515
9896
|
this._configuration = new Configuration(this._options, configurationResponse, Client_1._logger);
|
9897
|
+
this._services.channelMetadataClient = new ChannelMetadataClient(this._services, this._configuration);
|
8516
9898
|
|
8517
9899
|
this._myself._resolveInitialization(this._configuration, this._configuration.userIdentity, this._configuration.userInfo, true);
|
8518
9900
|
|
@@ -8591,10 +9973,10 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8591
9973
|
}).catch(function (error) {
|
8592
9974
|
throw error;
|
8593
9975
|
});
|
8594
|
-
|
9976
|
+
_context17.next = 29;
|
8595
9977
|
return this._services.users.myself._ensureFetched();
|
8596
9978
|
|
8597
|
-
case
|
9979
|
+
case 29:
|
8598
9980
|
Client_1._supportedPushChannels.forEach(function (channelType) {
|
8599
9981
|
return _this3._subscribeToPushNotifications(channelType);
|
8600
9982
|
});
|
@@ -8607,16 +9989,15 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8607
9989
|
|
8608
9990
|
this._resolveEnsureReady();
|
8609
9991
|
|
8610
|
-
this.emit("stateChanged",
|
8611
|
-
|
8612
|
-
});
|
9992
|
+
this.emit("stateChanged", "initialized");
|
9993
|
+
this.emit("initialized");
|
8613
9994
|
|
8614
|
-
case
|
9995
|
+
case 35:
|
8615
9996
|
case "end":
|
8616
|
-
return
|
9997
|
+
return _context17.stop();
|
8617
9998
|
}
|
8618
9999
|
}
|
8619
|
-
},
|
10000
|
+
}, _callee17, this);
|
8620
10001
|
}));
|
8621
10002
|
|
8622
10003
|
function _initialize() {
|
@@ -8656,14 +10037,14 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8656
10037
|
}], [{
|
8657
10038
|
key: "create",
|
8658
10039
|
value: function () {
|
8659
|
-
var _create = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
10040
|
+
var _create = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee18(token, options) {
|
8660
10041
|
var client;
|
8661
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
10042
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee18$(_context18) {
|
8662
10043
|
while (1) {
|
8663
|
-
switch (
|
10044
|
+
switch (_context18.prev = _context18.next) {
|
8664
10045
|
case 0:
|
8665
10046
|
if (!(options !== null && options !== void 0 && options.twilsockClient)) {
|
8666
|
-
|
10047
|
+
_context18.next = 2;
|
8667
10048
|
break;
|
8668
10049
|
}
|
8669
10050
|
|
@@ -8671,18 +10052,18 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8671
10052
|
|
8672
10053
|
case 2:
|
8673
10054
|
client = new Client_1(token, options);
|
8674
|
-
|
10055
|
+
_context18.next = 5;
|
8675
10056
|
return client._ensureReady;
|
8676
10057
|
|
8677
10058
|
case 5:
|
8678
|
-
return
|
10059
|
+
return _context18.abrupt("return", client);
|
8679
10060
|
|
8680
10061
|
case 6:
|
8681
10062
|
case "end":
|
8682
|
-
return
|
10063
|
+
return _context18.stop();
|
8683
10064
|
}
|
8684
10065
|
}
|
8685
|
-
},
|
10066
|
+
}, _callee18);
|
8686
10067
|
}));
|
8687
10068
|
|
8688
10069
|
function create(_x16, _x17) {
|
@@ -8815,7 +10196,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8815
10196
|
}]);
|
8816
10197
|
|
8817
10198
|
return Client;
|
8818
|
-
}(replayEventEmitter.ReplayEventEmitter), _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"), _defineProperty__default["default"](_class, "version", version), _defineProperty__default["default"](_class, "_logger", Logger.scope("Client")), _defineProperty__default["default"](_class, "_supportedPushChannels", ["fcm", "apn"]), _defineProperty__default["default"](_class, "_supportedPushDataFields", {
|
10199
|
+
}(replayEventEmitter.ReplayEventEmitter), _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, "initialized", "initialized"), _defineProperty__default["default"](_class, "initFailed", "initFailed"), _defineProperty__default["default"](_class, "connectionStateChanged", "connectionStateChanged"), _defineProperty__default["default"](_class, "connectionError", "connectionError"), _defineProperty__default["default"](_class, "version", version), _defineProperty__default["default"](_class, "_logger", Logger.scope("Client")), _defineProperty__default["default"](_class, "_supportedPushChannels", ["fcm", "apn"]), _defineProperty__default["default"](_class, "_supportedPushDataFields", {
|
8819
10200
|
conversation_sid: "conversationSid",
|
8820
10201
|
conversation_title: "conversationTitle",
|
8821
10202
|
message_sid: "messageSid",
|
@@ -8825,6 +10206,8 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8825
10206
|
|
8826
10207
|
}), _class);
|
8827
10208
|
|
10209
|
+
__decorate([deprecationDecorator.deprecated("token"), __metadata("design:type", String), __metadata("design:paramtypes", [])], exports.Client.prototype, "token", null);
|
10210
|
+
|
8828
10211
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "updateToken", null);
|
8829
10212
|
|
8830
10213
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "getConversationBySid", null);
|
@@ -8853,7 +10236,7 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
|
|
8853
10236
|
|
8854
10237
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyArray("media", Media)), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", mcsClient.CancellablePromise)], exports.Client.prototype, "getTemporaryContentUrlsForMedia", null);
|
8855
10238
|
|
8856
|
-
__decorate([declarativeTypeValidator.validateTypesAsync("string", ["undefined", declarativeTypeValidator.pureObject]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], exports.Client, "create", null);
|
10239
|
+
__decorate([deprecationDecorator.deprecated("Client.create()", "new Client()"), declarativeTypeValidator.validateTypesAsync("string", ["undefined", declarativeTypeValidator.pureObject]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], exports.Client, "create", null);
|
8857
10240
|
|
8858
10241
|
__decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.pureObject), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", PushNotification)], exports.Client, "parsePushNotification", null);
|
8859
10242
|
|
@@ -8864,6 +10247,9 @@ Object.defineProperty(exports, 'CancellablePromise', {
|
|
8864
10247
|
get: function () { return mcsClient.CancellablePromise; }
|
8865
10248
|
});
|
8866
10249
|
exports.AggregatedDeliveryReceipt = AggregatedDeliveryReceipt;
|
10250
|
+
exports.ChannelMetadata = ChannelMetadata;
|
10251
|
+
exports.ContentTemplate = ContentTemplate;
|
10252
|
+
exports.ContentTemplateVariable = ContentTemplateVariable;
|
8867
10253
|
exports.Conversation = Conversation;
|
8868
10254
|
exports.DetailedDeliveryReceipt = DetailedDeliveryReceipt;
|
8869
10255
|
exports.Media = Media;
|