@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/browser.js
CHANGED
@@ -128,6 +128,15 @@ This software includes platform.js under the following license.
|
|
128
128
|
*/
|
129
129
|
'use strict';
|
130
130
|
|
131
|
+
var global =
|
132
|
+
typeof global !== "undefined"
|
133
|
+
? global
|
134
|
+
: typeof self !== "undefined"
|
135
|
+
? self
|
136
|
+
: typeof window !== "undefined"
|
137
|
+
? window
|
138
|
+
: {};
|
139
|
+
|
131
140
|
Object.defineProperty(exports, '__esModule', { value: true });
|
132
141
|
|
133
142
|
require('core-js/modules/es.reflect.to-string-tag.js');
|
@@ -164,6 +173,7 @@ require('core-js/modules/es.regexp.exec.js');
|
|
164
173
|
require('core-js/modules/es.string.replace.js');
|
165
174
|
require('core-js/modules/es.array.join.js');
|
166
175
|
var declarativeTypeValidator = require('@twilio/declarative-type-validator');
|
176
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
167
177
|
require('core-js/modules/es.array.includes.js');
|
168
178
|
var replayEventEmitter = require('@twilio/replay-event-emitter');
|
169
179
|
var isEqual = require('lodash.isequal');
|
@@ -179,7 +189,6 @@ var twilsock = require('twilsock');
|
|
179
189
|
var notifications = require('@twilio/notifications');
|
180
190
|
var twilioSync = require('twilio-sync');
|
181
191
|
var mcsClient = require('@twilio/mcs-client');
|
182
|
-
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
183
192
|
require('core-js/modules/es.set.js');
|
184
193
|
require('core-js/modules/es.number.is-integer.js');
|
185
194
|
require('core-js/modules/es.typed-array.uint8-array.js');
|
@@ -211,10 +220,14 @@ require('core-js/modules/es.array-buffer.constructor.js');
|
|
211
220
|
require('isomorphic-form-data');
|
212
221
|
require('core-js/modules/es.array.sort.js');
|
213
222
|
require('core-js/modules/es.string.includes.js');
|
223
|
+
require('core-js/modules/es.string.starts-with.js');
|
224
|
+
var deprecationDecorator = require('@twilio/deprecation-decorator');
|
225
|
+
require('core-js/modules/es.object.entries.js');
|
214
226
|
require('core-js/modules/es.array.find.js');
|
215
227
|
require('core-js/modules/es.array.splice.js');
|
216
|
-
require('
|
228
|
+
var _wrapNativeSuper = require('@babel/runtime/helpers/wrapNativeSuper');
|
217
229
|
var uuid = require('uuid');
|
230
|
+
require('core-js/modules/es.object.freeze.js');
|
218
231
|
|
219
232
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
220
233
|
|
@@ -247,9 +260,10 @@ var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallChec
|
|
247
260
|
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
248
261
|
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
249
262
|
var loglevelLog__namespace = /*#__PURE__*/_interopNamespace(loglevelLog);
|
263
|
+
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
250
264
|
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
251
265
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
252
|
-
var
|
266
|
+
var _wrapNativeSuper__default = /*#__PURE__*/_interopDefaultLegacy(_wrapNativeSuper);
|
253
267
|
|
254
268
|
function __decorate(decorators, target, key, desc) {
|
255
269
|
var c = arguments.length,
|
@@ -389,9 +403,9 @@ var Logger = /*#__PURE__*/function () {
|
|
389
403
|
return Logger;
|
390
404
|
}();
|
391
405
|
|
392
|
-
function ownKeys$
|
406
|
+
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
407
|
|
394
|
-
function _objectSpread$
|
408
|
+
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
409
|
var TYPING_TIMEOUT = 5;
|
396
410
|
var HTTP_CACHE_LIFETIME = "PT5S";
|
397
411
|
var CONSUMPTION_HORIZON_SENDING_INTERVAL = "PT5S";
|
@@ -402,7 +416,7 @@ var MAXIMUM_ATTEMPTS_COUNT = 3;
|
|
402
416
|
var RETRY_WHEN_THROTTLED = true;
|
403
417
|
|
404
418
|
var Configuration = /*#__PURE__*/_createClass__default["default"](function Configuration() {
|
405
|
-
var _ref, _constructorOptions$u, _ref2, _constructorOptions$h, _ref3, _constructorOptions$c;
|
419
|
+
var _ref, _constructorOptions$u, _ref2, _constructorOptions$h, _ref3, _constructorOptions$c, _options$channelMetad;
|
406
420
|
|
407
421
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
408
422
|
var configurationResponse = arguments.length > 1 ? arguments[1] : undefined;
|
@@ -432,7 +446,7 @@ var Configuration = /*#__PURE__*/_createClass__default["default"](function Confi
|
|
432
446
|
emailBodiesAllowedContentTypes: configurationResponse.options.email_bodies_allowed_mime_types
|
433
447
|
};
|
434
448
|
this.typingIndicatorTimeoutOverride = constructorOptions.typingIndicatorTimeoutOverride;
|
435
|
-
this.backoffConfiguration = _objectSpread$
|
449
|
+
this.backoffConfiguration = _objectSpread$5({
|
436
450
|
min: MINIMUM_RETRY_DELAY,
|
437
451
|
max: MAXIMUM_RETRY_DELAY,
|
438
452
|
maxAttemptsCount: MAXIMUM_ATTEMPTS_COUNT
|
@@ -460,6 +474,8 @@ var Configuration = /*#__PURE__*/_createClass__default["default"](function Confi
|
|
460
474
|
logger.error("Failed to parse consumption report interval ".concat(consumptionReportInterval, ", using default value ").concat(CONSUMPTION_HORIZON_SENDING_INTERVAL));
|
461
475
|
this.consumptionReportInterval = iso8601Duration.toSeconds(iso8601Duration.parse(CONSUMPTION_HORIZON_SENDING_INTERVAL));
|
462
476
|
}
|
477
|
+
|
478
|
+
this.channelMetadataCacheCapacity = (_options$channelMetad = options.channelMetadataCacheCapacity) !== null && _options$channelMetad !== void 0 ? _options$channelMetad : 100;
|
463
479
|
});
|
464
480
|
|
465
481
|
/**
|
@@ -552,16 +568,21 @@ var UriBuilder = /*#__PURE__*/function () {
|
|
552
568
|
return UriBuilder;
|
553
569
|
}();
|
554
570
|
|
555
|
-
var
|
571
|
+
var json = declarativeTypeValidator.custom(function (value) {
|
556
572
|
return [["string", "number", "boolean", "object"].includes(_typeof__default["default"](value)), "a JSON type"];
|
557
573
|
});
|
558
|
-
var
|
574
|
+
var optionalJson = declarativeTypeValidator.custom(function (value) {
|
559
575
|
return [["undefined", "string", "number", "boolean", "object"].includes(_typeof__default["default"](value)), "an optional JSON type"];
|
560
576
|
});
|
577
|
+
var sendMediaOptions = declarativeTypeValidator.objectSchema("send media options", {
|
578
|
+
contentType: [declarativeTypeValidator.literal(null), "string"],
|
579
|
+
filename: ["string", "undefined"],
|
580
|
+
media: [declarativeTypeValidator.literal("null"), "string"].concat(_toConsumableArray__default["default"](typeof Buffer === "function" ? [Buffer] : []), _toConsumableArray__default["default"](typeof Blob === "function" ? [Blob] : []))
|
581
|
+
});
|
561
582
|
|
562
|
-
function _createSuper$
|
583
|
+
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
584
|
|
564
|
-
function _isNativeReflectConstruct$
|
585
|
+
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
586
|
var log$6 = Logger.scope("User");
|
566
587
|
/**
|
567
588
|
* Extended user information.
|
@@ -573,7 +594,7 @@ var log$6 = Logger.scope("User");
|
|
573
594
|
var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
574
595
|
_inherits__default["default"](User, _ReplayEventEmitter);
|
575
596
|
|
576
|
-
var _super = _createSuper$
|
597
|
+
var _super = _createSuper$9(User);
|
577
598
|
|
578
599
|
/**
|
579
600
|
* @internal
|
@@ -839,6 +860,10 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
839
860
|
log$6.debug(_this3.state.entityName + " (" + _this3.state.identity + ") itemUpdated: " + args.item.key);
|
840
861
|
return _this3._update(args.item.key, args.item.data);
|
841
862
|
});
|
863
|
+
map.on("itemAdded", function (args) {
|
864
|
+
log$6.debug(_this3.state.entityName + " (" + _this3.state.identity + ") itemAdded: " + args.item.key);
|
865
|
+
return _this3._update(args.item.key, args.item.data);
|
866
|
+
});
|
842
867
|
return Promise.all([map.get("friendlyName").then(function (item) {
|
843
868
|
return _this3._update(item.key, item.data);
|
844
869
|
}), map.get("attributes").then(function (item) {
|
@@ -1047,7 +1072,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1047
1072
|
this.identity = identity;
|
1048
1073
|
this.entityName = entityName;
|
1049
1074
|
this.links = {
|
1050
|
-
self: "".concat(this.configuration.links.users, "/").concat(this.identity)
|
1075
|
+
self: "".concat(this.configuration.links.users, "/").concat(encodeURIComponent(this.identity))
|
1051
1076
|
};
|
1052
1077
|
|
1053
1078
|
this._resolveInitializationPromise();
|
@@ -1064,15 +1089,15 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1064
1089
|
return User;
|
1065
1090
|
}(replayEventEmitter.ReplayEventEmitter);
|
1066
1091
|
|
1067
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
1092
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], User.prototype, "updateAttributes", null);
|
1068
1093
|
|
1069
1094
|
__decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], User.prototype, "updateFriendlyName", null);
|
1070
1095
|
|
1071
|
-
function _createForOfIteratorHelper$
|
1096
|
+
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
1097
|
|
1073
|
-
function _unsupportedIterableToArray$
|
1098
|
+
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
1099
|
|
1075
|
-
function _arrayLikeToArray$
|
1100
|
+
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
1101
|
|
1077
1102
|
var Network = /*#__PURE__*/function () {
|
1078
1103
|
function Network(configuration, services) {
|
@@ -1093,7 +1118,7 @@ var Network = /*#__PURE__*/function () {
|
|
1093
1118
|
}, {
|
1094
1119
|
key: "cleanupCache",
|
1095
1120
|
value: function cleanupCache() {
|
1096
|
-
var _iterator = _createForOfIteratorHelper$
|
1121
|
+
var _iterator = _createForOfIteratorHelper$4(this.cache),
|
1097
1122
|
_step;
|
1098
1123
|
|
1099
1124
|
try {
|
@@ -1237,9 +1262,9 @@ _defineProperty__default["default"](NotificationTypes, "REMOVED_FROM_CONVERSATIO
|
|
1237
1262
|
|
1238
1263
|
_defineProperty__default["default"](NotificationTypes, "CONSUMPTION_UPDATE", "twilio.channel.consumption_update");
|
1239
1264
|
|
1240
|
-
function _createSuper$
|
1265
|
+
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
1266
|
|
1242
|
-
function _isNativeReflectConstruct$
|
1267
|
+
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
1268
|
var log$5 = Logger.scope("Participant");
|
1244
1269
|
/**
|
1245
1270
|
* A participant represents a remote client in a conversation.
|
@@ -1248,7 +1273,7 @@ var log$5 = Logger.scope("Participant");
|
|
1248
1273
|
var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
1249
1274
|
_inherits__default["default"](Participant, _ReplayEventEmitter);
|
1250
1275
|
|
1251
|
-
var _super = _createSuper$
|
1276
|
+
var _super = _createSuper$8(Participant);
|
1252
1277
|
|
1253
1278
|
/**
|
1254
1279
|
* @internal
|
@@ -1618,11 +1643,11 @@ _defineProperty__default["default"](Participant, "typingEnded", "typingEnded");
|
|
1618
1643
|
|
1619
1644
|
_defineProperty__default["default"](Participant, "updated", "updated");
|
1620
1645
|
|
1621
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
1646
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Participant.prototype, "updateAttributes", null);
|
1622
1647
|
|
1623
|
-
function _createSuper$
|
1648
|
+
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
1649
|
|
1625
|
-
function _isNativeReflectConstruct$
|
1650
|
+
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
1651
|
var log$4 = Logger.scope("Participants");
|
1627
1652
|
/**
|
1628
1653
|
* @classdesc Represents the collection of participants for the conversation
|
@@ -1634,7 +1659,7 @@ var log$4 = Logger.scope("Participants");
|
|
1634
1659
|
var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
1635
1660
|
_inherits__default["default"](Participants, _ReplayEventEmitter);
|
1636
1661
|
|
1637
|
-
var _super = _createSuper$
|
1662
|
+
var _super = _createSuper$7(Participants);
|
1638
1663
|
|
1639
1664
|
function Participants(conversation, participants, links, configuration, services) {
|
1640
1665
|
var _this;
|
@@ -1691,13 +1716,14 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1691
1716
|
}()
|
1692
1717
|
}, {
|
1693
1718
|
key: "subscribe",
|
1694
|
-
value: function subscribe(
|
1719
|
+
value: function subscribe(arg) {
|
1695
1720
|
var _this2 = this;
|
1696
1721
|
|
1697
|
-
|
1698
|
-
id:
|
1722
|
+
var participantsMapPromise = typeof arg === "string" ? this.services.syncClient.map({
|
1723
|
+
id: arg,
|
1699
1724
|
mode: "open_existing"
|
1700
|
-
}).
|
1725
|
+
}) : Promise.resolve(arg);
|
1726
|
+
return this.rosterEntityPromise = this.rosterEntityPromise || participantsMapPromise.then(function (rosterMap) {
|
1701
1727
|
rosterMap.on("itemAdded", function (args) {
|
1702
1728
|
log$4.debug(_this2.conversation.sid + " itemAdded: " + args.item.key);
|
1703
1729
|
|
@@ -1969,7 +1995,6 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1969
1995
|
key: "add",
|
1970
1996
|
value: function () {
|
1971
1997
|
var _add = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(identity, attributes) {
|
1972
|
-
var participantResponse;
|
1973
1998
|
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context7) {
|
1974
1999
|
while (1) {
|
1975
2000
|
switch (_context7.prev = _context7.next) {
|
@@ -1981,14 +2006,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1981
2006
|
});
|
1982
2007
|
|
1983
2008
|
case 2:
|
1984
|
-
participantResponse = _context7.sent;
|
1985
|
-
_context7.next = 5;
|
1986
|
-
return this.upsertParticipantFromResponse(participantResponse);
|
1987
|
-
|
1988
|
-
case 5:
|
1989
2009
|
return _context7.abrupt("return", _context7.sent);
|
1990
2010
|
|
1991
|
-
case
|
2011
|
+
case 3:
|
1992
2012
|
case "end":
|
1993
2013
|
return _context7.stop();
|
1994
2014
|
}
|
@@ -2014,7 +2034,6 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2014
2034
|
|
2015
2035
|
var attributes,
|
2016
2036
|
bindingOptions,
|
2017
|
-
participantResponse,
|
2018
2037
|
_args8 = arguments;
|
2019
2038
|
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context8) {
|
2020
2039
|
while (1) {
|
@@ -2034,14 +2053,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2034
2053
|
});
|
2035
2054
|
|
2036
2055
|
case 4:
|
2037
|
-
participantResponse = _context8.sent;
|
2038
|
-
_context8.next = 7;
|
2039
|
-
return this.upsertParticipantFromResponse(participantResponse);
|
2040
|
-
|
2041
|
-
case 7:
|
2042
2056
|
return _context8.abrupt("return", _context8.sent);
|
2043
2057
|
|
2044
|
-
case
|
2058
|
+
case 5:
|
2045
2059
|
case "end":
|
2046
2060
|
return _context8.stop();
|
2047
2061
|
}
|
@@ -2062,7 +2076,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2062
2076
|
}, {
|
2063
2077
|
key: "remove",
|
2064
2078
|
value: function remove(identity) {
|
2065
|
-
return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(identity));
|
2079
|
+
return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(encodeURIComponent(identity)));
|
2066
2080
|
}
|
2067
2081
|
}]);
|
2068
2082
|
|
@@ -2314,7 +2328,7 @@ var Media = /*#__PURE__*/function () {
|
|
2314
2328
|
* Contains aggregated information about delivery statuses of a message across all participants
|
2315
2329
|
* of a conversation.
|
2316
2330
|
*
|
2317
|
-
* At any moment during the message delivery to a participant, the message can have zero or more of following
|
2331
|
+
* At any moment during the message delivery to a participant, the message can have zero or more of the following
|
2318
2332
|
* delivery statuses:
|
2319
2333
|
* * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
|
2320
2334
|
* * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
|
@@ -2557,22 +2571,264 @@ function DetailedDeliveryReceipt(descriptor) {
|
|
2557
2571
|
this.dateUpdated = descriptor.date_updated;
|
2558
2572
|
});
|
2559
2573
|
|
2560
|
-
|
2574
|
+
var collectActions = function collectActions(actions) {
|
2575
|
+
return actions.map(function (action) {
|
2576
|
+
var _action$id, _action$index, _action$phone, _action$url;
|
2561
2577
|
|
2562
|
-
|
2578
|
+
var rawData = JSON.stringify(action);
|
2563
2579
|
|
2564
|
-
|
2580
|
+
switch (action.type) {
|
2581
|
+
case "QUICK_REPLY":
|
2582
|
+
return {
|
2583
|
+
type: "reply",
|
2584
|
+
title: action.title,
|
2585
|
+
id: (_action$id = action.id) !== null && _action$id !== void 0 ? _action$id : "",
|
2586
|
+
index: (_action$index = action.index) !== null && _action$index !== void 0 ? _action$index : 0,
|
2587
|
+
rawData: rawData
|
2588
|
+
};
|
2565
2589
|
|
2566
|
-
|
2590
|
+
case "PHONE_NUMBER":
|
2591
|
+
return {
|
2592
|
+
type: "phone",
|
2593
|
+
title: action.title,
|
2594
|
+
phone: (_action$phone = action.phone) !== null && _action$phone !== void 0 ? _action$phone : "",
|
2595
|
+
rawData: rawData
|
2596
|
+
};
|
2597
|
+
|
2598
|
+
case "URL":
|
2599
|
+
return {
|
2600
|
+
type: "url",
|
2601
|
+
title: action.title,
|
2602
|
+
url: (_action$url = action.url) !== null && _action$url !== void 0 ? _action$url : "",
|
2603
|
+
rawData: rawData
|
2604
|
+
};
|
2605
|
+
|
2606
|
+
default:
|
2607
|
+
return {
|
2608
|
+
type: "other",
|
2609
|
+
rawData: rawData
|
2610
|
+
};
|
2611
|
+
}
|
2612
|
+
});
|
2613
|
+
};
|
2614
|
+
|
2615
|
+
var parseVariant = function parseVariant(type, data) {
|
2616
|
+
var rawData = JSON.stringify(data);
|
2617
|
+
|
2618
|
+
switch (type) {
|
2619
|
+
case "twilio/text":
|
2620
|
+
{
|
2621
|
+
var variant = data;
|
2622
|
+
return {
|
2623
|
+
type: "text",
|
2624
|
+
body: variant.body,
|
2625
|
+
rawData: rawData
|
2626
|
+
};
|
2627
|
+
}
|
2628
|
+
|
2629
|
+
case "twilio/media":
|
2630
|
+
{
|
2631
|
+
var _variant = data;
|
2632
|
+
return {
|
2633
|
+
type: "media",
|
2634
|
+
body: _variant.body,
|
2635
|
+
media: _variant.media,
|
2636
|
+
rawData: rawData
|
2637
|
+
};
|
2638
|
+
}
|
2639
|
+
|
2640
|
+
case "twilio/location":
|
2641
|
+
{
|
2642
|
+
var _variant2 = data;
|
2643
|
+
return {
|
2644
|
+
type: "location",
|
2645
|
+
longitude: _variant2.longitude,
|
2646
|
+
latitude: _variant2.latitude,
|
2647
|
+
label: _variant2.label,
|
2648
|
+
rawData: rawData
|
2649
|
+
};
|
2650
|
+
}
|
2651
|
+
|
2652
|
+
case "twilio/quick-reply":
|
2653
|
+
{
|
2654
|
+
var _variant3 = data;
|
2655
|
+
return {
|
2656
|
+
type: "quickReply",
|
2657
|
+
body: _variant3.body,
|
2658
|
+
replies: _variant3.actions,
|
2659
|
+
rawData: rawData
|
2660
|
+
};
|
2661
|
+
}
|
2662
|
+
|
2663
|
+
case "twilio/call-to-action":
|
2664
|
+
{
|
2665
|
+
var _variant4 = data;
|
2666
|
+
return {
|
2667
|
+
type: "callToAction",
|
2668
|
+
body: _variant4.body,
|
2669
|
+
actions: collectActions(_variant4.actions),
|
2670
|
+
rawData: rawData
|
2671
|
+
};
|
2672
|
+
}
|
2673
|
+
|
2674
|
+
case "twilio/list-picker":
|
2675
|
+
{
|
2676
|
+
var _variant5 = data;
|
2677
|
+
return {
|
2678
|
+
type: "listPicker",
|
2679
|
+
body: _variant5.body,
|
2680
|
+
button: _variant5.button,
|
2681
|
+
items: _variant5.items,
|
2682
|
+
rawData: rawData
|
2683
|
+
};
|
2684
|
+
}
|
2685
|
+
|
2686
|
+
case "twilio/card":
|
2687
|
+
{
|
2688
|
+
var _variant6$media, _variant6$actions;
|
2689
|
+
|
2690
|
+
var _variant6 = data;
|
2691
|
+
return {
|
2692
|
+
type: "card",
|
2693
|
+
title: _variant6.title,
|
2694
|
+
subtitle: _variant6.subtitle,
|
2695
|
+
media: (_variant6$media = _variant6.media) !== null && _variant6$media !== void 0 ? _variant6$media : [],
|
2696
|
+
actions: collectActions((_variant6$actions = _variant6.actions) !== null && _variant6$actions !== void 0 ? _variant6$actions : []),
|
2697
|
+
rawData: rawData
|
2698
|
+
};
|
2699
|
+
}
|
2700
|
+
|
2701
|
+
default:
|
2702
|
+
return {
|
2703
|
+
type: "other",
|
2704
|
+
rawData: rawData
|
2705
|
+
};
|
2706
|
+
}
|
2707
|
+
};
|
2708
|
+
|
2709
|
+
var collectVariants = function collectVariants(variants) {
|
2710
|
+
var variantsMap = new Map();
|
2711
|
+
|
2712
|
+
for (var _i = 0, _Object$entries = Object.entries(variants); _i < _Object$entries.length; _i++) {
|
2713
|
+
var _Object$entries$_i = _slicedToArray__default["default"](_Object$entries[_i], 2),
|
2714
|
+
key = _Object$entries$_i[0],
|
2715
|
+
value = _Object$entries$_i[1];
|
2716
|
+
|
2717
|
+
variantsMap.set(key, parseVariant(key, value));
|
2718
|
+
}
|
2719
|
+
|
2720
|
+
return variantsMap;
|
2721
|
+
};
|
2722
|
+
/**
|
2723
|
+
* Represents a variable for a content template. See
|
2724
|
+
* {@link ContentTemplate.variables}.
|
2725
|
+
*/
|
2726
|
+
|
2727
|
+
|
2728
|
+
var ContentTemplateVariable = /*#__PURE__*/function () {
|
2729
|
+
function ContentTemplateVariable(
|
2730
|
+
/**
|
2731
|
+
* Name of the variable.
|
2732
|
+
*/
|
2733
|
+
name,
|
2734
|
+
/**
|
2735
|
+
* Key of the variable
|
2736
|
+
*/
|
2737
|
+
value) {
|
2738
|
+
_classCallCheck__default["default"](this, ContentTemplateVariable);
|
2739
|
+
|
2740
|
+
this.name = name;
|
2741
|
+
this.value = value;
|
2742
|
+
}
|
2743
|
+
/**
|
2744
|
+
* Copies the variable with a new value.
|
2745
|
+
*
|
2746
|
+
* @param value The new value for the variable.
|
2747
|
+
*/
|
2748
|
+
|
2749
|
+
|
2750
|
+
_createClass__default["default"](ContentTemplateVariable, [{
|
2751
|
+
key: "copyWithValue",
|
2752
|
+
value: function copyWithValue(value) {
|
2753
|
+
return new ContentTemplateVariable(this.name, value);
|
2754
|
+
}
|
2755
|
+
}]);
|
2756
|
+
|
2757
|
+
return ContentTemplateVariable;
|
2758
|
+
}();
|
2759
|
+
/**
|
2760
|
+
* A rich content template.
|
2761
|
+
*
|
2762
|
+
* Use {@Link Client.getContentTemplates} to request all the templates available
|
2763
|
+
* for the current account.
|
2764
|
+
*/
|
2765
|
+
|
2766
|
+
|
2767
|
+
var ContentTemplate = /*#__PURE__*/_createClass__default["default"](
|
2768
|
+
/**
|
2769
|
+
* The server-assigned unique identifier for the template.
|
2770
|
+
*/
|
2771
|
+
|
2772
|
+
/**
|
2773
|
+
* Friendly name used to describe the content. Not visible to the recipient.
|
2774
|
+
*/
|
2775
|
+
|
2776
|
+
/**
|
2777
|
+
* Variables used by this template.
|
2778
|
+
*/
|
2779
|
+
|
2780
|
+
/**
|
2781
|
+
* Variants of the content. See {@link ContentData}.
|
2782
|
+
*/
|
2783
|
+
|
2784
|
+
/**
|
2785
|
+
* Date of creation.
|
2786
|
+
*/
|
2787
|
+
|
2788
|
+
/**
|
2789
|
+
* Date of the last update.
|
2790
|
+
*/
|
2791
|
+
|
2792
|
+
/**
|
2793
|
+
* @internal
|
2794
|
+
*/
|
2795
|
+
function ContentTemplate(contentTemplateResponse) {
|
2796
|
+
_classCallCheck__default["default"](this, ContentTemplate);
|
2797
|
+
|
2798
|
+
this.sid = contentTemplateResponse.sid;
|
2799
|
+
this.friendlyName = contentTemplateResponse.friendly_name;
|
2800
|
+
this.variables = Object.entries(JSON.parse(contentTemplateResponse.variables)).map(function (_ref) {
|
2801
|
+
var _ref2 = _slicedToArray__default["default"](_ref, 2),
|
2802
|
+
key = _ref2[0],
|
2803
|
+
value = _ref2[1];
|
2804
|
+
|
2805
|
+
return new ContentTemplateVariable(key, value);
|
2806
|
+
});
|
2807
|
+
this.variants = collectVariants(contentTemplateResponse.variants);
|
2808
|
+
this.dateCreated = new Date(contentTemplateResponse.date_created);
|
2809
|
+
this.dateUpdated = new Date(contentTemplateResponse.date_updated);
|
2810
|
+
});
|
2811
|
+
|
2812
|
+
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; }
|
2813
|
+
|
2814
|
+
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; }
|
2815
|
+
|
2816
|
+
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); }; }
|
2817
|
+
|
2818
|
+
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
2819
|
var log$3 = Logger.scope("Message");
|
2820
|
+
|
2821
|
+
var XHR = // eslint-disable-next-line @typescript-eslint/no-var-requires
|
2822
|
+
global["XMLHttpRequest"] || {};
|
2568
2823
|
/**
|
2569
2824
|
* A message in a conversation.
|
2570
2825
|
*/
|
2571
2826
|
|
2827
|
+
|
2572
2828
|
var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
2573
2829
|
_inherits__default["default"](Message, _ReplayEventEmitter);
|
2574
2830
|
|
2575
|
-
var _super = _createSuper$
|
2831
|
+
var _super = _createSuper$6(Message);
|
2576
2832
|
|
2577
2833
|
/**
|
2578
2834
|
* Conversation that the message is in.
|
@@ -2582,7 +2838,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2582
2838
|
* @internal
|
2583
2839
|
*/
|
2584
2840
|
function Message(index, data, conversation, links, configuration, services) {
|
2585
|
-
var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid;
|
2841
|
+
var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid, _data$channelMetadata;
|
2586
2842
|
|
2587
2843
|
var _this;
|
2588
2844
|
|
@@ -2598,6 +2854,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2598
2854
|
index: index,
|
2599
2855
|
author: data.author,
|
2600
2856
|
subject: data.subject,
|
2857
|
+
contentSid: data.contentSid,
|
2601
2858
|
body: (_data$text = data.text) !== null && _data$text !== void 0 ? _data$text : null,
|
2602
2859
|
timestamp: data.timestamp ? new Date(data.timestamp) : null,
|
2603
2860
|
dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,
|
@@ -2607,11 +2864,12 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2607
2864
|
media: data.type === "media" && data.media ? new Media(data.media, _this.services) : null,
|
2608
2865
|
medias: data.type === "media" && data.medias ? data.medias.map(function (m) {
|
2609
2866
|
return new Media(m, _this.services);
|
2610
|
-
}) : data.type === "media" && data.media && !data.medias ? [new Media(_objectSpread$
|
2867
|
+
}) : data.type === "media" && data.media && !data.medias ? [new Media(_objectSpread$4(_objectSpread$4({}, data.media), {}, {
|
2611
2868
|
category: "media"
|
2612
2869
|
}), _this.services)] : null,
|
2613
2870
|
participantSid: (_data$memberSid = data.memberSid) !== null && _data$memberSid !== void 0 ? _data$memberSid : null,
|
2614
|
-
aggregatedDeliveryReceipt: data.delivery ? new AggregatedDeliveryReceipt(data.delivery) : null
|
2871
|
+
aggregatedDeliveryReceipt: data.delivery ? new AggregatedDeliveryReceipt(data.delivery) : null,
|
2872
|
+
hasChannelMetadata: (_data$channelMetadata = data.channelMetadata) !== null && _data$channelMetadata !== void 0 ? _data$channelMetadata : false
|
2615
2873
|
};
|
2616
2874
|
return _this;
|
2617
2875
|
}
|
@@ -2652,6 +2910,15 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2652
2910
|
get: function get() {
|
2653
2911
|
return this.state.subject;
|
2654
2912
|
}
|
2913
|
+
/**
|
2914
|
+
* Unique identifier of {@link ContentTemplate} for this message.
|
2915
|
+
*/
|
2916
|
+
|
2917
|
+
}, {
|
2918
|
+
key: "contentSid",
|
2919
|
+
get: function get() {
|
2920
|
+
return this.state.contentSid;
|
2921
|
+
}
|
2655
2922
|
/**
|
2656
2923
|
* Body of the message.
|
2657
2924
|
*/
|
@@ -2671,14 +2938,15 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2671
2938
|
return this.state.dateUpdated;
|
2672
2939
|
}
|
2673
2940
|
/**
|
2674
|
-
* Index of
|
2675
|
-
*
|
2941
|
+
* Index of this message in the conversation's list of messages.
|
2942
|
+
*
|
2943
|
+
* By design, the message indices may have arbitrary gaps between them,
|
2676
2944
|
* that does not necessarily mean they were deleted or otherwise modified - just that
|
2677
2945
|
* messages may have some non-contiguous indices even if they are being sent immediately one after another.
|
2678
2946
|
*
|
2679
2947
|
* Trying to use indices for some calculations is going to be unreliable.
|
2680
2948
|
*
|
2681
|
-
* To calculate the number of unread messages it is better to use the
|
2949
|
+
* To calculate the number of unread messages, it is better to use the Read Horizon API.
|
2682
2950
|
* See {@link Conversation.getUnreadMessagesCount} for details.
|
2683
2951
|
*/
|
2684
2952
|
|
@@ -2760,6 +3028,19 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2760
3028
|
get: function get() {
|
2761
3029
|
return this.state.aggregatedDeliveryReceipt;
|
2762
3030
|
}
|
3031
|
+
/**
|
3032
|
+
* @deprecated
|
3033
|
+
* Return a (possibly empty) array of media matching a specific set of categories.
|
3034
|
+
* Allowed category is so far only 'media'.
|
3035
|
+
* @param categories Array of categories to match.
|
3036
|
+
* @returns Array of media descriptors matching given categories.
|
3037
|
+
*/
|
3038
|
+
|
3039
|
+
}, {
|
3040
|
+
key: "getMediaByCategory",
|
3041
|
+
value: function getMediaByCategory(categories) {
|
3042
|
+
return this.getMediaByCategories(categories);
|
3043
|
+
}
|
2763
3044
|
/**
|
2764
3045
|
* Return a (possibly empty) array of media matching a specific set of categories.
|
2765
3046
|
* Allowed category is so far only 'media'.
|
@@ -2980,32 +3261,27 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2980
3261
|
|
2981
3262
|
case 2:
|
2982
3263
|
paginator = _context2.sent;
|
2983
|
-
detailedDeliveryReceipts =
|
3264
|
+
detailedDeliveryReceipts = paginator.items;
|
2984
3265
|
|
2985
3266
|
case 4:
|
2986
|
-
|
2987
|
-
|
2988
|
-
|
2989
|
-
if (paginator.hasNextPage) {
|
2990
|
-
_context2.next = 8;
|
3267
|
+
if (!paginator.hasNextPage) {
|
3268
|
+
_context2.next = 11;
|
2991
3269
|
break;
|
2992
3270
|
}
|
2993
3271
|
|
2994
|
-
|
2995
|
-
|
2996
|
-
case 8:
|
2997
|
-
_context2.next = 10;
|
3272
|
+
_context2.next = 7;
|
2998
3273
|
return paginator.nextPage();
|
2999
3274
|
|
3000
|
-
case
|
3275
|
+
case 7:
|
3001
3276
|
paginator = _context2.sent;
|
3277
|
+
detailedDeliveryReceipts = [].concat(_toConsumableArray__default["default"](detailedDeliveryReceipts), _toConsumableArray__default["default"](paginator.items));
|
3002
3278
|
_context2.next = 4;
|
3003
3279
|
break;
|
3004
3280
|
|
3005
|
-
case
|
3281
|
+
case 11:
|
3006
3282
|
return _context2.abrupt("return", detailedDeliveryReceipts);
|
3007
3283
|
|
3008
|
-
case
|
3284
|
+
case 12:
|
3009
3285
|
case "end":
|
3010
3286
|
return _context2.stop();
|
3011
3287
|
}
|
@@ -3121,6 +3397,59 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3121
3397
|
|
3122
3398
|
return updateAttributes;
|
3123
3399
|
}()
|
3400
|
+
/**
|
3401
|
+
* @deprecated
|
3402
|
+
* Get content URLs for all media attachments in the given set using a single operation.
|
3403
|
+
* @param contentSet Set of media attachments to query content URLs.
|
3404
|
+
*/
|
3405
|
+
|
3406
|
+
}, {
|
3407
|
+
key: "attachTemporaryUrlsFor",
|
3408
|
+
value: function () {
|
3409
|
+
var _attachTemporaryUrlsFor = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(contentSet) {
|
3410
|
+
var _this3 = this;
|
3411
|
+
|
3412
|
+
var sids;
|
3413
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context6) {
|
3414
|
+
while (1) {
|
3415
|
+
switch (_context6.prev = _context6.next) {
|
3416
|
+
case 0:
|
3417
|
+
// We ignore existing mcsMedia members of each of the media entries.
|
3418
|
+
// Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.
|
3419
|
+
sids = contentSet === null || contentSet === void 0 ? void 0 : contentSet.map(function (m) {
|
3420
|
+
return m.sid;
|
3421
|
+
});
|
3422
|
+
|
3423
|
+
if (!(this.services.mcsClient && sids)) {
|
3424
|
+
_context6.next = 7;
|
3425
|
+
break;
|
3426
|
+
}
|
3427
|
+
|
3428
|
+
_context6.next = 4;
|
3429
|
+
return this.services.mcsClient.mediaSetGet(sids);
|
3430
|
+
|
3431
|
+
case 4:
|
3432
|
+
return _context6.abrupt("return", _context6.sent.map(function (item) {
|
3433
|
+
return new Media(item, _this3.services);
|
3434
|
+
}));
|
3435
|
+
|
3436
|
+
case 7:
|
3437
|
+
throw new Error("Media Content Service is unavailable");
|
3438
|
+
|
3439
|
+
case 8:
|
3440
|
+
case "end":
|
3441
|
+
return _context6.stop();
|
3442
|
+
}
|
3443
|
+
}
|
3444
|
+
}, _callee6, this);
|
3445
|
+
}));
|
3446
|
+
|
3447
|
+
function attachTemporaryUrlsFor(_x3) {
|
3448
|
+
return _attachTemporaryUrlsFor.apply(this, arguments);
|
3449
|
+
}
|
3450
|
+
|
3451
|
+
return attachTemporaryUrlsFor;
|
3452
|
+
}()
|
3124
3453
|
/**
|
3125
3454
|
* Get content URLs for all media attachments in the given set using a single operation.
|
3126
3455
|
* @param contentSet Set of media attachments to query content URLs.
|
@@ -3144,53 +3473,53 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3144
3473
|
}, {
|
3145
3474
|
key: "getTemporaryContentUrlsForMediaSids",
|
3146
3475
|
value: function getTemporaryContentUrlsForMediaSids(mediaSids) {
|
3147
|
-
var
|
3476
|
+
var _this4 = this;
|
3148
3477
|
|
3149
3478
|
return new mcsClient.CancellablePromise( /*#__PURE__*/function () {
|
3150
|
-
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
3479
|
+
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(resolve, reject, onCancel) {
|
3151
3480
|
var mediaGetRequest, urls;
|
3152
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
3481
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context7) {
|
3153
3482
|
while (1) {
|
3154
|
-
switch (
|
3483
|
+
switch (_context7.prev = _context7.next) {
|
3155
3484
|
case 0:
|
3156
|
-
mediaGetRequest =
|
3485
|
+
mediaGetRequest = _this4.services.mcsClient.mediaSetGetContentUrls(mediaSids !== null && mediaSids !== void 0 ? mediaSids : []);
|
3157
3486
|
|
3158
|
-
if (!(!
|
3159
|
-
|
3487
|
+
if (!(!_this4.services.mcsClient || !mediaSids)) {
|
3488
|
+
_context7.next = 4;
|
3160
3489
|
break;
|
3161
3490
|
}
|
3162
3491
|
|
3163
3492
|
reject(new Error("Media Content Service is unavailable"));
|
3164
|
-
return
|
3493
|
+
return _context7.abrupt("return");
|
3165
3494
|
|
3166
3495
|
case 4:
|
3167
3496
|
onCancel(function () {
|
3168
3497
|
mediaGetRequest.cancel();
|
3169
3498
|
});
|
3170
|
-
|
3171
|
-
|
3499
|
+
_context7.prev = 5;
|
3500
|
+
_context7.next = 8;
|
3172
3501
|
return mediaGetRequest;
|
3173
3502
|
|
3174
3503
|
case 8:
|
3175
|
-
urls =
|
3504
|
+
urls = _context7.sent;
|
3176
3505
|
resolve(urls);
|
3177
|
-
|
3506
|
+
_context7.next = 15;
|
3178
3507
|
break;
|
3179
3508
|
|
3180
3509
|
case 12:
|
3181
|
-
|
3182
|
-
|
3183
|
-
reject(
|
3510
|
+
_context7.prev = 12;
|
3511
|
+
_context7.t0 = _context7["catch"](5);
|
3512
|
+
reject(_context7.t0);
|
3184
3513
|
|
3185
3514
|
case 15:
|
3186
3515
|
case "end":
|
3187
|
-
return
|
3516
|
+
return _context7.stop();
|
3188
3517
|
}
|
3189
3518
|
}
|
3190
|
-
},
|
3519
|
+
}, _callee7, null, [[5, 12]]);
|
3191
3520
|
}));
|
3192
3521
|
|
3193
|
-
return function (
|
3522
|
+
return function (_x4, _x5, _x6) {
|
3194
3523
|
return _ref.apply(this, arguments);
|
3195
3524
|
};
|
3196
3525
|
}());
|
@@ -3213,25 +3542,25 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3213
3542
|
}, {
|
3214
3543
|
key: "_getDetailedDeliveryReceiptsPaginator",
|
3215
3544
|
value: function () {
|
3216
|
-
var _getDetailedDeliveryReceiptsPaginator2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
3217
|
-
var
|
3545
|
+
var _getDetailedDeliveryReceiptsPaginator2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8(options) {
|
3546
|
+
var _this5 = this;
|
3218
3547
|
|
3219
3548
|
var messagesReceiptsUrl, url, response;
|
3220
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
3549
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context8) {
|
3221
3550
|
while (1) {
|
3222
|
-
switch (
|
3551
|
+
switch (_context8.prev = _context8.next) {
|
3223
3552
|
case 0:
|
3224
3553
|
messagesReceiptsUrl = this.configuration.links.messagesReceipts.replace("%s", this.conversation.sid).replace("%s", this.sid);
|
3225
3554
|
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
|
-
|
3555
|
+
_context8.next = 4;
|
3227
3556
|
return this.services.network.get(url);
|
3228
3557
|
|
3229
3558
|
case 4:
|
3230
|
-
response =
|
3231
|
-
return
|
3559
|
+
response = _context8.sent;
|
3560
|
+
return _context8.abrupt("return", new RestPaginator(response.body.delivery_receipts.map(function (x) {
|
3232
3561
|
return new DetailedDeliveryReceipt(x);
|
3233
3562
|
}), function (pageToken, pageSize) {
|
3234
|
-
return
|
3563
|
+
return _this5._getDetailedDeliveryReceiptsPaginator({
|
3235
3564
|
pageToken: pageToken,
|
3236
3565
|
pageSize: pageSize
|
3237
3566
|
});
|
@@ -3239,46 +3568,236 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3239
3568
|
|
3240
3569
|
case 6:
|
3241
3570
|
case "end":
|
3242
|
-
return
|
3571
|
+
return _context8.stop();
|
3243
3572
|
}
|
3244
3573
|
}
|
3245
|
-
},
|
3574
|
+
}, _callee8, this);
|
3246
3575
|
}));
|
3247
3576
|
|
3248
|
-
function _getDetailedDeliveryReceiptsPaginator(
|
3577
|
+
function _getDetailedDeliveryReceiptsPaginator(_x7) {
|
3249
3578
|
return _getDetailedDeliveryReceiptsPaginator2.apply(this, arguments);
|
3250
3579
|
}
|
3251
3580
|
|
3252
3581
|
return _getDetailedDeliveryReceiptsPaginator;
|
3253
3582
|
}()
|
3254
|
-
|
3583
|
+
/**
|
3584
|
+
* Get the {@link ContentData} for this message. Resolves to `null` when
|
3585
|
+
* {@link Message.contentSid} is null.
|
3586
|
+
*/
|
3255
3587
|
|
3256
|
-
|
3257
|
-
|
3588
|
+
}, {
|
3589
|
+
key: "getContentData",
|
3590
|
+
value: function getContentData() {
|
3591
|
+
var _this6 = this;
|
3258
3592
|
|
3259
|
-
|
3593
|
+
return new mcsClient.CancellablePromise( /*#__PURE__*/function () {
|
3594
|
+
var _ref2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9(resolve, reject, onCancel) {
|
3595
|
+
var bodies, twilioPrefix, filteredMedias, contentMedia, urlPromise, url, jsonStringPromise, json, jsonString, dataType;
|
3596
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context9) {
|
3597
|
+
while (1) {
|
3598
|
+
switch (_context9.prev = _context9.next) {
|
3599
|
+
case 0:
|
3600
|
+
if (!(_this6.state.contentSid === null)) {
|
3601
|
+
_context9.next = 3;
|
3602
|
+
break;
|
3603
|
+
}
|
3260
3604
|
|
3261
|
-
|
3605
|
+
resolve(null);
|
3606
|
+
return _context9.abrupt("return");
|
3262
3607
|
|
3263
|
-
|
3608
|
+
case 3:
|
3609
|
+
bodies = _this6.getMediaByCategories(["body"]);
|
3264
3610
|
|
3265
|
-
|
3611
|
+
if (!(bodies === null)) {
|
3612
|
+
_context9.next = 7;
|
3613
|
+
break;
|
3614
|
+
}
|
3266
3615
|
|
3267
|
-
|
3616
|
+
resolve(null);
|
3617
|
+
return _context9.abrupt("return");
|
3268
3618
|
|
3269
|
-
|
3619
|
+
case 7:
|
3620
|
+
twilioPrefix = "application/x-vnd.com.twilio.rich.";
|
3621
|
+
filteredMedias = bodies.filter(function (media) {
|
3622
|
+
return media.contentType.startsWith(twilioPrefix);
|
3623
|
+
});
|
3270
3624
|
|
3271
|
-
|
3625
|
+
if (!(filteredMedias.length === 0)) {
|
3626
|
+
_context9.next = 12;
|
3627
|
+
break;
|
3628
|
+
}
|
3272
3629
|
|
3273
|
-
|
3630
|
+
resolve(null);
|
3631
|
+
return _context9.abrupt("return");
|
3274
3632
|
|
3275
|
-
|
3633
|
+
case 12:
|
3634
|
+
contentMedia = filteredMedias[0];
|
3635
|
+
urlPromise = contentMedia.getContentTemporaryUrl();
|
3636
|
+
onCancel(function () {
|
3637
|
+
urlPromise.cancel();
|
3638
|
+
});
|
3639
|
+
_context9.prev = 15;
|
3640
|
+
_context9.next = 18;
|
3641
|
+
return urlPromise;
|
3276
3642
|
|
3277
|
-
|
3643
|
+
case 18:
|
3644
|
+
url = _context9.sent;
|
3645
|
+
_context9.next = 25;
|
3646
|
+
break;
|
3278
3647
|
|
3279
|
-
|
3648
|
+
case 21:
|
3649
|
+
_context9.prev = 21;
|
3650
|
+
_context9.t0 = _context9["catch"](15);
|
3651
|
+
reject(_context9.t0);
|
3652
|
+
return _context9.abrupt("return");
|
3280
3653
|
|
3281
|
-
|
3654
|
+
case 25:
|
3655
|
+
if (!(url === null)) {
|
3656
|
+
_context9.next = 28;
|
3657
|
+
break;
|
3658
|
+
}
|
3659
|
+
|
3660
|
+
resolve(null);
|
3661
|
+
return _context9.abrupt("return");
|
3662
|
+
|
3663
|
+
case 28:
|
3664
|
+
jsonStringPromise = new Promise(function (resolve, reject) {
|
3665
|
+
var _url;
|
3666
|
+
|
3667
|
+
var isCancelled = false;
|
3668
|
+
var xhr = new XHR();
|
3669
|
+
xhr.open("GET", (_url = url) !== null && _url !== void 0 ? _url : "", true);
|
3670
|
+
xhr.responseType = "text";
|
3671
|
+
|
3672
|
+
xhr.onreadystatechange = function () {
|
3673
|
+
if (xhr.readyState !== 4 || isCancelled) {
|
3674
|
+
return;
|
3675
|
+
}
|
3676
|
+
|
3677
|
+
resolve(xhr.responseText);
|
3678
|
+
};
|
3679
|
+
|
3680
|
+
xhr.onerror = function () {
|
3681
|
+
reject(xhr.statusText);
|
3682
|
+
};
|
3683
|
+
|
3684
|
+
onCancel(function () {
|
3685
|
+
isCancelled = true;
|
3686
|
+
xhr.abort();
|
3687
|
+
reject(new Error("XHR has been aborted"));
|
3688
|
+
});
|
3689
|
+
xhr.send();
|
3690
|
+
});
|
3691
|
+
_context9.prev = 29;
|
3692
|
+
_context9.next = 32;
|
3693
|
+
return jsonStringPromise;
|
3694
|
+
|
3695
|
+
case 32:
|
3696
|
+
jsonString = _context9.sent;
|
3697
|
+
json = JSON.parse(jsonString);
|
3698
|
+
_context9.next = 40;
|
3699
|
+
break;
|
3700
|
+
|
3701
|
+
case 36:
|
3702
|
+
_context9.prev = 36;
|
3703
|
+
_context9.t1 = _context9["catch"](29);
|
3704
|
+
reject(_context9.t1);
|
3705
|
+
return _context9.abrupt("return");
|
3706
|
+
|
3707
|
+
case 40:
|
3708
|
+
dataType = contentMedia.contentType.replace(twilioPrefix, "").replace(".", "/");
|
3709
|
+
resolve(parseVariant(dataType, json.data));
|
3710
|
+
|
3711
|
+
case 42:
|
3712
|
+
case "end":
|
3713
|
+
return _context9.stop();
|
3714
|
+
}
|
3715
|
+
}
|
3716
|
+
}, _callee9, null, [[15, 21], [29, 36]]);
|
3717
|
+
}));
|
3718
|
+
|
3719
|
+
return function (_x8, _x9, _x10) {
|
3720
|
+
return _ref2.apply(this, arguments);
|
3721
|
+
};
|
3722
|
+
}());
|
3723
|
+
}
|
3724
|
+
/**
|
3725
|
+
* Get the {@link ChannelMetadata} for this message. Resolves to `null` if
|
3726
|
+
* the message doesn't have any channel metadata.
|
3727
|
+
*/
|
3728
|
+
|
3729
|
+
}, {
|
3730
|
+
key: "getChannelMetadata",
|
3731
|
+
value: function () {
|
3732
|
+
var _getChannelMetadata = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee10() {
|
3733
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee10$(_context10) {
|
3734
|
+
while (1) {
|
3735
|
+
switch (_context10.prev = _context10.next) {
|
3736
|
+
case 0:
|
3737
|
+
if (this.state.hasChannelMetadata) {
|
3738
|
+
_context10.next = 2;
|
3739
|
+
break;
|
3740
|
+
}
|
3741
|
+
|
3742
|
+
return _context10.abrupt("return", null);
|
3743
|
+
|
3744
|
+
case 2:
|
3745
|
+
_context10.next = 4;
|
3746
|
+
return this.services.channelMetadataClient.getChannelMetadata(this.conversation.sid, this.sid);
|
3747
|
+
|
3748
|
+
case 4:
|
3749
|
+
return _context10.abrupt("return", _context10.sent);
|
3750
|
+
|
3751
|
+
case 5:
|
3752
|
+
case "end":
|
3753
|
+
return _context10.stop();
|
3754
|
+
}
|
3755
|
+
}
|
3756
|
+
}, _callee10, this);
|
3757
|
+
}));
|
3758
|
+
|
3759
|
+
function getChannelMetadata() {
|
3760
|
+
return _getChannelMetadata.apply(this, arguments);
|
3761
|
+
}
|
3762
|
+
|
3763
|
+
return getChannelMetadata;
|
3764
|
+
}()
|
3765
|
+
}]);
|
3766
|
+
|
3767
|
+
return Message;
|
3768
|
+
}(replayEventEmitter.ReplayEventEmitter);
|
3769
|
+
|
3770
|
+
_defineProperty__default["default"](Message, "updated", "updated");
|
3771
|
+
|
3772
|
+
__decorate([deprecationDecorator.deprecated("getMediaByCategory", "getMediaByCategories"), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", Array)], Message.prototype, "getMediaByCategory", null);
|
3773
|
+
|
3774
|
+
__decorate([declarativeTypeValidator.validateTypes([declarativeTypeValidator.nonEmptyString, "undefined"]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailBody", null);
|
3775
|
+
|
3776
|
+
__decorate([declarativeTypeValidator.validateTypes([declarativeTypeValidator.nonEmptyString, "undefined"]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailHistory", null);
|
3777
|
+
|
3778
|
+
__decorate([declarativeTypeValidator.validateTypesAsync("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Message.prototype, "updateBody", null);
|
3779
|
+
|
3780
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Message.prototype, "updateAttributes", null);
|
3781
|
+
|
3782
|
+
__decorate([deprecationDecorator.deprecated("attachTemporaryUrlsFor", "getTemporaryContentUrlsForMedia"), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", Promise)], Message.prototype, "attachTemporaryUrlsFor", null);
|
3783
|
+
|
3784
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyArray("media", Media)), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", mcsClient.CancellablePromise)], Message.prototype, "getTemporaryContentUrlsForMedia", null);
|
3785
|
+
|
3786
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyArray("strings", "string")), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", mcsClient.CancellablePromise)], Message.prototype, "getTemporaryContentUrlsForMediaSids", null);
|
3787
|
+
|
3788
|
+
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; }
|
3789
|
+
|
3790
|
+
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; }
|
3791
|
+
|
3792
|
+
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; } } }; }
|
3793
|
+
|
3794
|
+
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); }
|
3795
|
+
|
3796
|
+
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; }
|
3797
|
+
|
3798
|
+
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); }; }
|
3799
|
+
|
3800
|
+
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
3801
|
var log$2 = Logger.scope("Messages");
|
3283
3802
|
/**
|
3284
3803
|
* Represents the collection of messages in a conversation
|
@@ -3287,7 +3806,7 @@ var log$2 = Logger.scope("Messages");
|
|
3287
3806
|
var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
3288
3807
|
_inherits__default["default"](Messages, _ReplayEventEmitter);
|
3289
3808
|
|
3290
|
-
var _super = _createSuper$
|
3809
|
+
var _super = _createSuper$5(Messages);
|
3291
3810
|
|
3292
3811
|
function Messages(conversation, configuration, services) {
|
3293
3812
|
var _this;
|
@@ -3304,14 +3823,15 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3304
3823
|
}
|
3305
3824
|
/**
|
3306
3825
|
* Subscribe to the Messages Event Stream
|
3307
|
-
* @param
|
3826
|
+
* @param arg - Name of the Sync object, or the SyncList itself, that
|
3827
|
+
* represents the Messages resource.
|
3308
3828
|
*/
|
3309
3829
|
|
3310
3830
|
|
3311
3831
|
_createClass__default["default"](Messages, [{
|
3312
3832
|
key: "subscribe",
|
3313
3833
|
value: function () {
|
3314
|
-
var _subscribe = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(
|
3834
|
+
var _subscribe = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(arg) {
|
3315
3835
|
var _this2 = this;
|
3316
3836
|
|
3317
3837
|
var list;
|
@@ -3327,10 +3847,10 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3327
3847
|
return _context.abrupt("return", this.messagesListPromise);
|
3328
3848
|
|
3329
3849
|
case 2:
|
3330
|
-
this.messagesListPromise = this.services.syncClient.list({
|
3331
|
-
id:
|
3850
|
+
this.messagesListPromise = typeof arg === "string" ? this.services.syncClient.list({
|
3851
|
+
id: arg,
|
3332
3852
|
mode: "open_existing"
|
3333
|
-
});
|
3853
|
+
}) : Promise.resolve(arg);
|
3334
3854
|
_context.prev = 3;
|
3335
3855
|
_context.next = 6;
|
3336
3856
|
return this.messagesListPromise;
|
@@ -3481,7 +4001,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3481
4001
|
return request.cancel();
|
3482
4002
|
});
|
3483
4003
|
});
|
3484
|
-
_iterator = _createForOfIteratorHelper$
|
4004
|
+
_iterator = _createForOfIteratorHelper$3(message.mediaContent);
|
3485
4005
|
_context3.prev = 4;
|
3486
4006
|
|
3487
4007
|
_iterator.s();
|
@@ -3543,7 +4063,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3543
4063
|
media_sids: media.map(function (m) {
|
3544
4064
|
return m.sid;
|
3545
4065
|
}),
|
3546
|
-
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined
|
4066
|
+
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined,
|
4067
|
+
content_sid: message.contentSid,
|
4068
|
+
content_variables: typeof message.contentVariables !== "undefined" ? JSON.stringify(message.contentVariables.reduce(function (accum, current) {
|
4069
|
+
return _objectSpread$3(_objectSpread$3({}, accum), {}, _defineProperty__default["default"]({}, current.name, current.value));
|
4070
|
+
}, {})) : undefined
|
3547
4071
|
});
|
3548
4072
|
_context3.prev = 34;
|
3549
4073
|
_context3.t4 = resolve;
|
@@ -4014,6 +4538,29 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
4014
4538
|
this.emailHistories.set(contentType, history);
|
4015
4539
|
return this;
|
4016
4540
|
}
|
4541
|
+
/**
|
4542
|
+
* Adds {@link ContentTemplate} SID for the message alongside optional
|
4543
|
+
* variables. When no variables provided, the default values will be used.
|
4544
|
+
*
|
4545
|
+
* Adding the content SID converts the message to a rich message. In this
|
4546
|
+
* case, other fields are ignored and the message is sent using the content
|
4547
|
+
* from the the {@link ContentTemplate}.
|
4548
|
+
*
|
4549
|
+
* Use {@link Client.getContentTemplates} to request all available
|
4550
|
+
* {@link ContentTemplate}s.
|
4551
|
+
*
|
4552
|
+
* @param contentSid SID of the {@link ContentTemplate}
|
4553
|
+
* @param variables Custom variables to resolve the template.
|
4554
|
+
*/
|
4555
|
+
|
4556
|
+
}, {
|
4557
|
+
key: "setContentTemplate",
|
4558
|
+
value: function setContentTemplate(contentSid) {
|
4559
|
+
var contentVariables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
4560
|
+
this.message.contentSid = contentSid;
|
4561
|
+
this.message.contentVariables = contentVariables;
|
4562
|
+
return this;
|
4563
|
+
}
|
4017
4564
|
/**
|
4018
4565
|
* Adds media to the message.
|
4019
4566
|
* @param payload Media to add.
|
@@ -4088,29 +4635,34 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
4088
4635
|
value: function buildAndSend() {
|
4089
4636
|
return this.build().send();
|
4090
4637
|
}
|
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
4638
|
}]);
|
4101
4639
|
|
4102
4640
|
return MessageBuilder;
|
4103
4641
|
}();
|
4104
4642
|
|
4105
|
-
|
4643
|
+
__decorate([declarativeTypeValidator.validateTypes("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setBody", null);
|
4106
4644
|
|
4107
|
-
|
4645
|
+
__decorate([declarativeTypeValidator.validateTypes("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setSubject", null);
|
4108
4646
|
|
4109
|
-
|
4647
|
+
__decorate([declarativeTypeValidator.validateTypes(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setAttributes", null);
|
4110
4648
|
|
4111
|
-
|
4649
|
+
__decorate([declarativeTypeValidator.validateTypes("string", [FormData, sendMediaOptions]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setEmailBody", null);
|
4112
4650
|
|
4113
|
-
|
4651
|
+
__decorate([declarativeTypeValidator.validateTypes("string", [FormData, sendMediaOptions]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setEmailHistory", null);
|
4652
|
+
|
4653
|
+
__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);
|
4654
|
+
|
4655
|
+
__decorate([declarativeTypeValidator.validateTypes([FormData, sendMediaOptions]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "addMedia", null);
|
4656
|
+
|
4657
|
+
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; } } }; }
|
4658
|
+
|
4659
|
+
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); }
|
4660
|
+
|
4661
|
+
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; }
|
4662
|
+
|
4663
|
+
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); }; }
|
4664
|
+
|
4665
|
+
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
4666
|
/**
|
4115
4667
|
* Map of the fields that will be processed with update messages.
|
4116
4668
|
*/
|
@@ -4138,7 +4690,7 @@ var fieldMappings = {
|
|
4138
4690
|
var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
4139
4691
|
_inherits__default["default"](Conversation, _ReplayEventEmitter);
|
4140
4692
|
|
4141
|
-
var _super = _createSuper$
|
4693
|
+
var _super = _createSuper$4(Conversation);
|
4142
4694
|
|
4143
4695
|
/**
|
4144
4696
|
* Fired when a participant has joined the conversation.
|
@@ -4868,7 +5420,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4868
5420
|
return getMessagesCount;
|
4869
5421
|
}()
|
4870
5422
|
/**
|
4871
|
-
* Get unread messages
|
5423
|
+
* Get count of unread messages for the user if they are a participant of this
|
4872
5424
|
* conversation. Rejects if the user is not a participant of the conversation.
|
4873
5425
|
*
|
4874
5426
|
* Use this method to obtain the number of unread messages together with
|
@@ -4876,12 +5428,19 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4876
5428
|
* message indices which may have gaps. See {@link Message.index} for details.
|
4877
5429
|
*
|
4878
5430
|
* 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
|
5431
|
+
* correct, but it will also be possibly incorrect for a few seconds. The
|
4880
5432
|
* Conversations system does not provide real time events for counter values
|
4881
5433
|
* changes.
|
4882
5434
|
*
|
4883
5435
|
* This is useful for any UI badges, but it is not recommended to build any
|
4884
5436
|
* core application logic based on these counters being accurate in real time.
|
5437
|
+
*
|
5438
|
+
* If the read horizon is not set, this function will return null. This could mean
|
5439
|
+
* that all messages in the conversation are unread, or that the read horizon system
|
5440
|
+
* is not being used. How to interpret this `null` value is up to the customer application.
|
5441
|
+
*
|
5442
|
+
* @return Number of unread messages based on the current read horizon set for
|
5443
|
+
* the user or `null` if the read horizon is not set.
|
4885
5444
|
*/
|
4886
5445
|
|
4887
5446
|
}, {
|
@@ -4986,7 +5545,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4986
5545
|
}
|
4987
5546
|
|
4988
5547
|
_context14.next = 3;
|
4989
|
-
return this._services.commandExecutor.mutateResource("delete", "".concat(this._links.participants, "/").concat(this._configuration.userIdentity));
|
5548
|
+
return this._services.commandExecutor.mutateResource("delete", "".concat(this._links.participants, "/").concat(encodeURIComponent(this._configuration.userIdentity)));
|
4990
5549
|
|
4991
5550
|
case 3:
|
4992
5551
|
return _context14.abrupt("return", this);
|
@@ -5094,7 +5653,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5094
5653
|
}()
|
5095
5654
|
/**
|
5096
5655
|
* New interface to prepare for sending a message.
|
5097
|
-
* Use this instead of {@link
|
5656
|
+
* Use this instead of {@link Conversation.sendMessage}.
|
5098
5657
|
* @return A MessageBuilder to help set all message sending options.
|
5099
5658
|
*/
|
5100
5659
|
|
@@ -5154,7 +5713,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5154
5713
|
}()
|
5155
5714
|
/**
|
5156
5715
|
* Set all messages in the conversation unread.
|
5157
|
-
* @
|
5716
|
+
* @returns New count of unread messages after this update.
|
5158
5717
|
*/
|
5159
5718
|
|
5160
5719
|
}, {
|
@@ -5312,7 +5871,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5312
5871
|
* Set the last read message index to the current read horizon.
|
5313
5872
|
* @param index Message index to set as last read. If null is provided, then
|
5314
5873
|
* the behavior is identical to {@link Conversation.setAllMessagesUnread}.
|
5315
|
-
* @returns
|
5874
|
+
* @returns New count of unread messages after this update.
|
5316
5875
|
*/
|
5317
5876
|
|
5318
5877
|
}, {
|
@@ -5461,6 +6020,65 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5461
6020
|
|
5462
6021
|
return _subscribe;
|
5463
6022
|
}()
|
6023
|
+
/**
|
6024
|
+
* Fetch participants and messages of the conversation. This method needs to
|
6025
|
+
* be called during conversation initialization to catch broken conversations
|
6026
|
+
* (broken conversations are conversations that have essential Sync entities
|
6027
|
+
* missing, i.e. the conversation document, the messages list or the
|
6028
|
+
* participant map). In case of this conversation being broken, the method
|
6029
|
+
* will throw an exception that will be caught and handled gracefully.
|
6030
|
+
* @internal
|
6031
|
+
*/
|
6032
|
+
|
6033
|
+
}, {
|
6034
|
+
key: "_fetchStreams",
|
6035
|
+
value: function () {
|
6036
|
+
var _fetchStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee25() {
|
6037
|
+
var _this$_entity, _this$_entity2;
|
6038
|
+
|
6039
|
+
var data;
|
6040
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee25$(_context25) {
|
6041
|
+
while (1) {
|
6042
|
+
switch (_context25.prev = _context25.next) {
|
6043
|
+
case 0:
|
6044
|
+
_context25.next = 2;
|
6045
|
+
return this._subscribe();
|
6046
|
+
|
6047
|
+
case 2:
|
6048
|
+
Conversation._logger.trace("_streamsAvailable, this.entity.data=", (_this$_entity = this._entity) === null || _this$_entity === void 0 ? void 0 : _this$_entity.data);
|
6049
|
+
|
6050
|
+
data = (_this$_entity2 = this._entity) === null || _this$_entity2 === void 0 ? void 0 : _this$_entity2.data;
|
6051
|
+
_context25.next = 6;
|
6052
|
+
return this._services.syncClient.list({
|
6053
|
+
id: data.messages,
|
6054
|
+
mode: "open_existing"
|
6055
|
+
});
|
6056
|
+
|
6057
|
+
case 6:
|
6058
|
+
this._messagesList = _context25.sent;
|
6059
|
+
_context25.next = 9;
|
6060
|
+
return this._services.syncClient.map({
|
6061
|
+
id: data.roster,
|
6062
|
+
mode: "open_existing"
|
6063
|
+
});
|
6064
|
+
|
6065
|
+
case 9:
|
6066
|
+
this._participantsMap = _context25.sent;
|
6067
|
+
|
6068
|
+
case 10:
|
6069
|
+
case "end":
|
6070
|
+
return _context25.stop();
|
6071
|
+
}
|
6072
|
+
}
|
6073
|
+
}, _callee25, this);
|
6074
|
+
}));
|
6075
|
+
|
6076
|
+
function _fetchStreams() {
|
6077
|
+
return _fetchStreams2.apply(this, arguments);
|
6078
|
+
}
|
6079
|
+
|
6080
|
+
return _fetchStreams;
|
6081
|
+
}()
|
5464
6082
|
/**
|
5465
6083
|
* Load the attributes of this conversation and instantiate its participants
|
5466
6084
|
* and messages. This or _subscribe will need to be called before any events
|
@@ -5472,48 +6090,48 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5472
6090
|
}, {
|
5473
6091
|
key: "_subscribeStreams",
|
5474
6092
|
value: function () {
|
5475
|
-
var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
5476
|
-
var _this$
|
6093
|
+
var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee26() {
|
6094
|
+
var _this$_entity3, _this$_entity4, _this$_messagesList, _this$_participantsMa, data, messagesObjectName, rosterObjectName;
|
5477
6095
|
|
5478
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
6096
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee26$(_context26) {
|
5479
6097
|
while (1) {
|
5480
|
-
switch (
|
6098
|
+
switch (_context26.prev = _context26.next) {
|
5481
6099
|
case 0:
|
5482
|
-
|
5483
|
-
|
6100
|
+
_context26.prev = 0;
|
6101
|
+
_context26.next = 3;
|
5484
6102
|
return this._subscribe();
|
5485
6103
|
|
5486
6104
|
case 3:
|
5487
|
-
Conversation._logger.trace("_subscribeStreams, this.entity.data=", (_this$
|
6105
|
+
Conversation._logger.trace("_subscribeStreams, this.entity.data=", (_this$_entity3 = this._entity) === null || _this$_entity3 === void 0 ? void 0 : _this$_entity3.data);
|
5488
6106
|
|
5489
|
-
data = (_this$
|
6107
|
+
data = (_this$_entity4 = this._entity) === null || _this$_entity4 === void 0 ? void 0 : _this$_entity4.data;
|
5490
6108
|
messagesObjectName = data.messages;
|
5491
6109
|
rosterObjectName = data.roster;
|
5492
|
-
|
5493
|
-
return Promise.all([this._messagesEntity.subscribe(messagesObjectName), this._participantsEntity.subscribe(rosterObjectName)]);
|
6110
|
+
_context26.next = 9;
|
6111
|
+
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
6112
|
|
5495
6113
|
case 9:
|
5496
|
-
|
6114
|
+
_context26.next = 16;
|
5497
6115
|
break;
|
5498
6116
|
|
5499
6117
|
case 11:
|
5500
|
-
|
5501
|
-
|
6118
|
+
_context26.prev = 11;
|
6119
|
+
_context26.t0 = _context26["catch"](0);
|
5502
6120
|
|
5503
6121
|
if (this._services.syncClient.connectionState !== "disconnected") {
|
5504
|
-
Conversation._logger.error("Failed to subscribe on conversation objects", this.sid,
|
6122
|
+
Conversation._logger.error("Failed to subscribe on conversation objects", this.sid, _context26.t0);
|
5505
6123
|
}
|
5506
6124
|
|
5507
|
-
Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid,
|
6125
|
+
Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context26.t0);
|
5508
6126
|
|
5509
|
-
throw
|
6127
|
+
throw _context26.t0;
|
5510
6128
|
|
5511
6129
|
case 16:
|
5512
6130
|
case "end":
|
5513
|
-
return
|
6131
|
+
return _context26.stop();
|
5514
6132
|
}
|
5515
6133
|
}
|
5516
|
-
},
|
6134
|
+
}, _callee26, this, [[0, 11]]);
|
5517
6135
|
}));
|
5518
6136
|
|
5519
6137
|
function _subscribeStreams() {
|
@@ -5530,17 +6148,17 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5530
6148
|
}, {
|
5531
6149
|
key: "_unsubscribe",
|
5532
6150
|
value: function () {
|
5533
|
-
var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
5534
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
6151
|
+
var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee27() {
|
6152
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee27$(_context27) {
|
5535
6153
|
while (1) {
|
5536
|
-
switch (
|
6154
|
+
switch (_context27.prev = _context27.next) {
|
5537
6155
|
case 0:
|
5538
6156
|
if (!this._entity) {
|
5539
|
-
|
6157
|
+
_context27.next = 5;
|
5540
6158
|
break;
|
5541
6159
|
}
|
5542
6160
|
|
5543
|
-
|
6161
|
+
_context27.next = 3;
|
5544
6162
|
return this._entity.close();
|
5545
6163
|
|
5546
6164
|
case 3:
|
@@ -5548,14 +6166,14 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5548
6166
|
this._entityPromise = null;
|
5549
6167
|
|
5550
6168
|
case 5:
|
5551
|
-
return
|
6169
|
+
return _context27.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
|
5552
6170
|
|
5553
6171
|
case 6:
|
5554
6172
|
case "end":
|
5555
|
-
return
|
6173
|
+
return _context27.stop();
|
5556
6174
|
}
|
5557
6175
|
}
|
5558
|
-
},
|
6176
|
+
}, _callee27, this);
|
5559
6177
|
}));
|
5560
6178
|
|
5561
6179
|
function _unsubscribe() {
|
@@ -5732,7 +6350,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5732
6350
|
}, {
|
5733
6351
|
key: "_onMessageAdded",
|
5734
6352
|
value: function _onMessageAdded(message) {
|
5735
|
-
var _iterator = _createForOfIteratorHelper$
|
6353
|
+
var _iterator = _createForOfIteratorHelper$2(this._participants.values()),
|
5736
6354
|
_step;
|
5737
6355
|
|
5738
6356
|
try {
|
@@ -5761,27 +6379,27 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5761
6379
|
}, {
|
5762
6380
|
key: "_setLastReadMessageIndex",
|
5763
6381
|
value: function () {
|
5764
|
-
var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
6382
|
+
var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee28(index) {
|
5765
6383
|
var result;
|
5766
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
6384
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee28$(_context28) {
|
5767
6385
|
while (1) {
|
5768
|
-
switch (
|
6386
|
+
switch (_context28.prev = _context28.next) {
|
5769
6387
|
case 0:
|
5770
|
-
|
6388
|
+
_context28.next = 2;
|
5771
6389
|
return this._services.commandExecutor.mutateResource("post", "".concat(this._configuration.links.myConversations, "/").concat(this.sid), {
|
5772
6390
|
last_read_message_index: index
|
5773
6391
|
});
|
5774
6392
|
|
5775
6393
|
case 2:
|
5776
|
-
result =
|
5777
|
-
return
|
6394
|
+
result = _context28.sent;
|
6395
|
+
return _context28.abrupt("return", result.unread_messages_count);
|
5778
6396
|
|
5779
6397
|
case 4:
|
5780
6398
|
case "end":
|
5781
|
-
return
|
6399
|
+
return _context28.stop();
|
5782
6400
|
}
|
5783
6401
|
}
|
5784
|
-
},
|
6402
|
+
}, _callee28, this);
|
5785
6403
|
}));
|
5786
6404
|
|
5787
6405
|
function _setLastReadMessageIndex(_x19) {
|
@@ -5806,7 +6424,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5806
6424
|
}
|
5807
6425
|
|
5808
6426
|
try {
|
5809
|
-
|
6427
|
+
if (update.dateCreated) {
|
6428
|
+
update.dateCreated = new Date(update.dateCreated);
|
6429
|
+
}
|
5810
6430
|
} catch (e) {
|
5811
6431
|
Conversation._logger.warn("Retrieved malformed dateCreated from the server for conversation: " + conversationSid);
|
5812
6432
|
|
@@ -5814,7 +6434,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5814
6434
|
}
|
5815
6435
|
|
5816
6436
|
try {
|
5817
|
-
|
6437
|
+
if (update.dateUpdated) {
|
6438
|
+
update.dateUpdated = new Date(update.dateUpdated);
|
6439
|
+
}
|
5818
6440
|
} catch (e) {
|
5819
6441
|
Conversation._logger.warn("Retrieved malformed dateUpdated from the server for conversation: " + conversationSid);
|
5820
6442
|
|
@@ -5858,9 +6480,9 @@ _defineProperty__default["default"](Conversation, "removed", "removed");
|
|
5858
6480
|
|
5859
6481
|
_defineProperty__default["default"](Conversation, "_logger", Logger.scope("Conversation"));
|
5860
6482
|
|
5861
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString,
|
6483
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, optionalJson), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "add", null);
|
5862
6484
|
|
5863
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString,
|
6485
|
+
__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
6486
|
|
5865
6487
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonNegativeInteger), __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", Promise)], Conversation.prototype, "advanceLastReadMessageIndex", null);
|
5866
6488
|
|
@@ -5883,13 +6505,13 @@ __decorate([declarativeTypeValidator.validateTypesAsync(["string", FormData, dec
|
|
5883
6505
|
|
5884
6506
|
return [isValid, "a non-empty string, an instance of Buffer or an instance of Blob"];
|
5885
6507
|
})
|
5886
|
-
})],
|
6508
|
+
})], optionalJson, ["undefined", declarativeTypeValidator.literal(null), declarativeTypeValidator.objectSchema("email attributes", {
|
5887
6509
|
subject: [declarativeTypeValidator.nonEmptyString, "undefined"]
|
5888
6510
|
})]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "sendMessage", null);
|
5889
6511
|
|
5890
6512
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("default", "muted")), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "setUserNotificationLevel", null);
|
5891
6513
|
|
5892
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
6514
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateAttributes", null);
|
5893
6515
|
|
5894
6516
|
__decorate([declarativeTypeValidator.validateTypesAsync("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateFriendlyName", null);
|
5895
6517
|
|
@@ -5936,19 +6558,19 @@ var Deferred = /*#__PURE__*/function () {
|
|
5936
6558
|
return Deferred;
|
5937
6559
|
}();
|
5938
6560
|
|
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; } } }; }
|
6561
|
+
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
6562
|
|
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); }
|
6563
|
+
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
6564
|
|
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; }
|
6565
|
+
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
6566
|
|
5945
6567
|
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
6568
|
|
5947
6569
|
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
6570
|
|
5949
|
-
function _createSuper$
|
6571
|
+
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
6572
|
|
5951
|
-
function _isNativeReflectConstruct$
|
6573
|
+
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
6574
|
var log$1 = Logger.scope("Conversations");
|
5953
6575
|
/**
|
5954
6576
|
* Represents conversations collection
|
@@ -5958,7 +6580,7 @@ var log$1 = Logger.scope("Conversations");
|
|
5958
6580
|
var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
5959
6581
|
_inherits__default["default"](Conversations, _ReplayEventEmitter);
|
5960
6582
|
|
5961
|
-
var _super = _createSuper$
|
6583
|
+
var _super = _createSuper$3(Conversations);
|
5962
6584
|
|
5963
6585
|
function Conversations(configuration, services) {
|
5964
6586
|
var _this;
|
@@ -6120,7 +6742,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6120
6742
|
case 9:
|
6121
6743
|
myConversations = _context2.sent;
|
6122
6744
|
upserts = [];
|
6123
|
-
_iterator = _createForOfIteratorHelper(myConversations);
|
6745
|
+
_iterator = _createForOfIteratorHelper$1(myConversations);
|
6124
6746
|
|
6125
6747
|
try {
|
6126
6748
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
@@ -6393,7 +7015,9 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6393
7015
|
case 2:
|
6394
7016
|
items = _context8.sent;
|
6395
7017
|
return _context8.abrupt("return", {
|
6396
|
-
items: items
|
7018
|
+
items: items.filter(function (item) {
|
7019
|
+
return item !== null;
|
7020
|
+
}),
|
6397
7021
|
hasNextPage: page.hasNextPage,
|
6398
7022
|
hasPrevPage: page.hasPrevPage,
|
6399
7023
|
nextPage: function nextPage() {
|
@@ -6555,7 +7179,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6555
7179
|
break;
|
6556
7180
|
}
|
6557
7181
|
|
6558
|
-
log$1.trace("upsertChannel: the
|
7182
|
+
log$1.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring", sid);
|
6559
7183
|
return _context10.abrupt("return", null);
|
6560
7184
|
|
6561
7185
|
case 12:
|
@@ -6569,10 +7193,40 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6569
7193
|
};
|
6570
7194
|
newConversation = new Conversation(data, sid, links, this.configuration, this.services);
|
6571
7195
|
this.conversations.set(sid, newConversation);
|
6572
|
-
_context10.
|
7196
|
+
_context10.prev = 17;
|
7197
|
+
_context10.next = 20;
|
6573
7198
|
return newConversation._subscribe();
|
6574
7199
|
|
6575
|
-
case
|
7200
|
+
case 20:
|
7201
|
+
if (!(data.status === "joined")) {
|
7202
|
+
_context10.next = 23;
|
7203
|
+
break;
|
7204
|
+
}
|
7205
|
+
|
7206
|
+
_context10.next = 23;
|
7207
|
+
return newConversation._fetchStreams();
|
7208
|
+
|
7209
|
+
case 23:
|
7210
|
+
_context10.next = 32;
|
7211
|
+
break;
|
7212
|
+
|
7213
|
+
case 25:
|
7214
|
+
_context10.prev = 25;
|
7215
|
+
_context10.t0 = _context10["catch"](17);
|
7216
|
+
|
7217
|
+
if (!(_context10.t0.name !== "SyncError")) {
|
7218
|
+
_context10.next = 29;
|
7219
|
+
break;
|
7220
|
+
}
|
7221
|
+
|
7222
|
+
throw _context10.t0;
|
7223
|
+
|
7224
|
+
case 29:
|
7225
|
+
log$1.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring", sid, _context10.t0);
|
7226
|
+
this.conversations.delete(sid);
|
7227
|
+
return _context10.abrupt("return", null);
|
7228
|
+
|
7229
|
+
case 32:
|
6576
7230
|
this._registerForEvents(newConversation);
|
6577
7231
|
|
6578
7232
|
this.emit("conversationAdded", newConversation);
|
@@ -6585,12 +7239,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6585
7239
|
|
6586
7240
|
return _context10.abrupt("return", newConversation);
|
6587
7241
|
|
6588
|
-
case
|
7242
|
+
case 36:
|
6589
7243
|
case "end":
|
6590
7244
|
return _context10.stop();
|
6591
7245
|
}
|
6592
7246
|
}
|
6593
|
-
}, _callee10, this);
|
7247
|
+
}, _callee10, this, [[17, 25]]);
|
6594
7248
|
}));
|
6595
7249
|
|
6596
7250
|
function _upsertConversation(_x10, _x11, _x12) {
|
@@ -6713,9 +7367,9 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6713
7367
|
return Conversations;
|
6714
7368
|
}(replayEventEmitter.ReplayEventEmitter);
|
6715
7369
|
|
6716
|
-
function _createSuper$
|
7370
|
+
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
7371
|
|
6718
|
-
function _isNativeReflectConstruct$
|
7372
|
+
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
7373
|
/**
|
6720
7374
|
* Container for known users
|
6721
7375
|
*/
|
@@ -6723,7 +7377,7 @@ function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !
|
|
6723
7377
|
var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
6724
7378
|
_inherits__default["default"](Users, _ReplayEventEmitter);
|
6725
7379
|
|
6726
|
-
var _super = _createSuper$
|
7380
|
+
var _super = _createSuper$2(Users);
|
6727
7381
|
|
6728
7382
|
function Users(myself, configuration, services) {
|
6729
7383
|
var _this;
|
@@ -7170,12 +7824,16 @@ function PushNotification(data) {
|
|
7170
7824
|
this.data = data.data || {};
|
7171
7825
|
});
|
7172
7826
|
|
7173
|
-
var version = "3.0.
|
7827
|
+
var version = "3.0.1-rc.102";
|
7174
7828
|
|
7175
7829
|
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
7830
|
|
7177
7831
|
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
7832
|
|
7833
|
+
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); }; }
|
7834
|
+
|
7835
|
+
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; } }
|
7836
|
+
|
7179
7837
|
var trimSlashes = function trimSlashes(url) {
|
7180
7838
|
return url.replace(/(^\/+|\/+$)/g, "");
|
7181
7839
|
};
|
@@ -7184,6 +7842,20 @@ var isMutationConflictResponse = function isMutationConflictResponse(response) {
|
|
7184
7842
|
return response.status.code === 202;
|
7185
7843
|
};
|
7186
7844
|
|
7845
|
+
var ChannelMetadataNotFoundError = /*#__PURE__*/function (_Error) {
|
7846
|
+
_inherits__default["default"](ChannelMetadataNotFoundError, _Error);
|
7847
|
+
|
7848
|
+
var _super = _createSuper$1(ChannelMetadataNotFoundError);
|
7849
|
+
|
7850
|
+
function ChannelMetadataNotFoundError(message) {
|
7851
|
+
_classCallCheck__default["default"](this, ChannelMetadataNotFoundError);
|
7852
|
+
|
7853
|
+
return _super.call(this, message);
|
7854
|
+
}
|
7855
|
+
|
7856
|
+
return _createClass__default["default"](ChannelMetadataNotFoundError);
|
7857
|
+
}( /*#__PURE__*/_wrapNativeSuper__default["default"](Error));
|
7858
|
+
|
7187
7859
|
var CommandExecutor = /*#__PURE__*/function () {
|
7188
7860
|
function CommandExecutor(_serviceUrl, _services, _productId) {
|
7189
7861
|
_classCallCheck__default["default"](this, CommandExecutor);
|
@@ -7281,40 +7953,91 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
7281
7953
|
}, {
|
7282
7954
|
key: "fetchResource",
|
7283
7955
|
value: function () {
|
7284
|
-
var _fetchResource = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
7956
|
+
var _fetchResource = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(url, requestBody) {
|
7285
7957
|
var _this = this;
|
7286
7958
|
|
7287
|
-
var maxAttemptsCount,
|
7288
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
7959
|
+
var maxAttemptsCount, retrier, resolution;
|
7960
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
7289
7961
|
while (1) {
|
7290
|
-
switch (
|
7962
|
+
switch (_context3.prev = _context3.next) {
|
7291
7963
|
case 0:
|
7292
7964
|
maxAttemptsCount = 6;
|
7293
|
-
|
7294
|
-
_context2.next = 4;
|
7295
|
-
return new operationRetrier.AsyncRetrier({
|
7965
|
+
retrier = new operationRetrier.AsyncRetrier({
|
7296
7966
|
min: 50,
|
7297
7967
|
max: 1600,
|
7298
7968
|
maxAttemptsCount: maxAttemptsCount
|
7299
|
-
}).run(function () {
|
7300
|
-
return _this._makeRequest("get", url, requestBody);
|
7301
7969
|
});
|
7970
|
+
_context3.prev = 2;
|
7971
|
+
_context3.next = 5;
|
7972
|
+
return retrier.run( /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
|
7973
|
+
var response, _e$body, _e$body2;
|
7974
|
+
|
7975
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
7976
|
+
while (1) {
|
7977
|
+
switch (_context2.prev = _context2.next) {
|
7978
|
+
case 0:
|
7979
|
+
_context2.prev = 0;
|
7980
|
+
_context2.next = 3;
|
7981
|
+
return _this._makeRequest("get", url, requestBody);
|
7982
|
+
|
7983
|
+
case 3:
|
7984
|
+
response = _context2.sent;
|
7985
|
+
return _context2.abrupt("return", {
|
7986
|
+
type: "success",
|
7987
|
+
data: response.body
|
7988
|
+
});
|
7989
|
+
|
7990
|
+
case 7:
|
7991
|
+
_context2.prev = 7;
|
7992
|
+
_context2.t0 = _context2["catch"](0);
|
7993
|
+
|
7994
|
+
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)) {
|
7995
|
+
_context2.next = 11;
|
7996
|
+
break;
|
7997
|
+
}
|
7998
|
+
|
7999
|
+
return _context2.abrupt("return", {
|
8000
|
+
type: "noMetadata"
|
8001
|
+
});
|
8002
|
+
|
8003
|
+
case 11:
|
8004
|
+
throw _context2.t0;
|
8005
|
+
|
8006
|
+
case 12:
|
8007
|
+
case "end":
|
8008
|
+
return _context2.stop();
|
8009
|
+
}
|
8010
|
+
}
|
8011
|
+
}, _callee2, null, [[0, 7]]);
|
8012
|
+
})));
|
7302
8013
|
|
7303
|
-
case
|
7304
|
-
|
7305
|
-
|
8014
|
+
case 5:
|
8015
|
+
resolution = _context3.sent;
|
8016
|
+
_context3.next = 11;
|
8017
|
+
break;
|
7306
8018
|
|
7307
8019
|
case 8:
|
7308
|
-
|
7309
|
-
|
8020
|
+
_context3.prev = 8;
|
8021
|
+
_context3.t0 = _context3["catch"](2);
|
7310
8022
|
throw new Error("Fetch resource from \"".concat(url, "\" failed."));
|
7311
8023
|
|
7312
8024
|
case 11:
|
8025
|
+
if (!(resolution.type === "noMetadata")) {
|
8026
|
+
_context3.next = 13;
|
8027
|
+
break;
|
8028
|
+
}
|
8029
|
+
|
8030
|
+
throw new ChannelMetadataNotFoundError("No metadata found.");
|
8031
|
+
|
8032
|
+
case 13:
|
8033
|
+
return _context3.abrupt("return", resolution.data);
|
8034
|
+
|
8035
|
+
case 14:
|
7313
8036
|
case "end":
|
7314
|
-
return
|
8037
|
+
return _context3.stop();
|
7315
8038
|
}
|
7316
8039
|
}
|
7317
|
-
},
|
8040
|
+
}, _callee3, null, [[2, 8]]);
|
7318
8041
|
}));
|
7319
8042
|
|
7320
8043
|
function fetchResource(_x5, _x6) {
|
@@ -7326,40 +8049,40 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
7326
8049
|
}, {
|
7327
8050
|
key: "mutateResource",
|
7328
8051
|
value: function () {
|
7329
|
-
var _mutateResource = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
8052
|
+
var _mutateResource = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(method, url, requestBody) {
|
7330
8053
|
var result;
|
7331
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
8054
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
|
7332
8055
|
while (1) {
|
7333
|
-
switch (
|
8056
|
+
switch (_context4.prev = _context4.next) {
|
7334
8057
|
case 0:
|
7335
|
-
|
8058
|
+
_context4.next = 2;
|
7336
8059
|
return this._makeRequest(method, url, requestBody, {
|
7337
8060
|
"X-Twilio-Mutation-Id": uuid.v4()
|
7338
8061
|
});
|
7339
8062
|
|
7340
8063
|
case 2:
|
7341
|
-
result =
|
8064
|
+
result = _context4.sent;
|
7342
8065
|
|
7343
8066
|
if (!isMutationConflictResponse(result)) {
|
7344
|
-
|
8067
|
+
_context4.next = 7;
|
7345
8068
|
break;
|
7346
8069
|
}
|
7347
8070
|
|
7348
|
-
|
8071
|
+
_context4.next = 6;
|
7349
8072
|
return this.fetchResource(result.body.resource_url);
|
7350
8073
|
|
7351
8074
|
case 6:
|
7352
|
-
return
|
8075
|
+
return _context4.abrupt("return", _context4.sent);
|
7353
8076
|
|
7354
8077
|
case 7:
|
7355
|
-
return
|
8078
|
+
return _context4.abrupt("return", result.body);
|
7356
8079
|
|
7357
8080
|
case 8:
|
7358
8081
|
case "end":
|
7359
|
-
return
|
8082
|
+
return _context4.stop();
|
7360
8083
|
}
|
7361
8084
|
}
|
7362
|
-
},
|
8085
|
+
}, _callee4, this);
|
7363
8086
|
}));
|
7364
8087
|
|
7365
8088
|
function mutateResource(_x7, _x8, _x9) {
|
@@ -7373,6 +8096,593 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
7373
8096
|
return CommandExecutor;
|
7374
8097
|
}();
|
7375
8098
|
|
8099
|
+
var ContentClient = /*#__PURE__*/function () {
|
8100
|
+
function ContentClient(_services) {
|
8101
|
+
var _pageSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
|
8102
|
+
|
8103
|
+
var _cacheTtlMs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5000;
|
8104
|
+
|
8105
|
+
_classCallCheck__default["default"](this, ContentClient);
|
8106
|
+
|
8107
|
+
_defineProperty__default["default"](this, "_cachedTemplates", null);
|
8108
|
+
|
8109
|
+
this._services = _services;
|
8110
|
+
this._pageSize = _pageSize;
|
8111
|
+
this._cacheTtlMs = _cacheTtlMs;
|
8112
|
+
}
|
8113
|
+
|
8114
|
+
_createClass__default["default"](ContentClient, [{
|
8115
|
+
key: "getContentTemplates",
|
8116
|
+
value: function () {
|
8117
|
+
var _getContentTemplates = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
8118
|
+
var _this = this;
|
8119
|
+
|
8120
|
+
var _yield$this$_fetchCon, _yield$this$_fetchCon2, templatesPage, nextToken, templates, _yield$this$_fetchCon3, _yield$this$_fetchCon4;
|
8121
|
+
|
8122
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
8123
|
+
while (1) {
|
8124
|
+
switch (_context.prev = _context.next) {
|
8125
|
+
case 0:
|
8126
|
+
if (!(this._cachedTemplates !== null)) {
|
8127
|
+
_context.next = 2;
|
8128
|
+
break;
|
8129
|
+
}
|
8130
|
+
|
8131
|
+
return _context.abrupt("return", this._cachedTemplates);
|
8132
|
+
|
8133
|
+
case 2:
|
8134
|
+
_context.next = 4;
|
8135
|
+
return this._fetchContentTemplates();
|
8136
|
+
|
8137
|
+
case 4:
|
8138
|
+
_yield$this$_fetchCon = _context.sent;
|
8139
|
+
_yield$this$_fetchCon2 = _slicedToArray__default["default"](_yield$this$_fetchCon, 2);
|
8140
|
+
templatesPage = _yield$this$_fetchCon2[0];
|
8141
|
+
nextToken = _yield$this$_fetchCon2[1];
|
8142
|
+
templates = templatesPage;
|
8143
|
+
|
8144
|
+
case 9:
|
8145
|
+
if (!(nextToken !== null)) {
|
8146
|
+
_context.next = 19;
|
8147
|
+
break;
|
8148
|
+
}
|
8149
|
+
|
8150
|
+
_context.next = 12;
|
8151
|
+
return this._fetchContentTemplates(nextToken);
|
8152
|
+
|
8153
|
+
case 12:
|
8154
|
+
_yield$this$_fetchCon3 = _context.sent;
|
8155
|
+
_yield$this$_fetchCon4 = _slicedToArray__default["default"](_yield$this$_fetchCon3, 2);
|
8156
|
+
templatesPage = _yield$this$_fetchCon4[0];
|
8157
|
+
nextToken = _yield$this$_fetchCon4[1];
|
8158
|
+
templates = [].concat(_toConsumableArray__default["default"](templates), _toConsumableArray__default["default"](templatesPage));
|
8159
|
+
_context.next = 9;
|
8160
|
+
break;
|
8161
|
+
|
8162
|
+
case 19:
|
8163
|
+
this._cachedTemplates = Object.freeze(templates);
|
8164
|
+
setTimeout(function () {
|
8165
|
+
_this._cachedTemplates = null;
|
8166
|
+
}, this._cacheTtlMs);
|
8167
|
+
return _context.abrupt("return", templates);
|
8168
|
+
|
8169
|
+
case 22:
|
8170
|
+
case "end":
|
8171
|
+
return _context.stop();
|
8172
|
+
}
|
8173
|
+
}
|
8174
|
+
}, _callee, this);
|
8175
|
+
}));
|
8176
|
+
|
8177
|
+
function getContentTemplates() {
|
8178
|
+
return _getContentTemplates.apply(this, arguments);
|
8179
|
+
}
|
8180
|
+
|
8181
|
+
return getContentTemplates;
|
8182
|
+
}()
|
8183
|
+
}, {
|
8184
|
+
key: "_fetchContentTemplates",
|
8185
|
+
value: function () {
|
8186
|
+
var _fetchContentTemplates2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(pageToken) {
|
8187
|
+
var contentTemplatesUrl, url, response;
|
8188
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
8189
|
+
while (1) {
|
8190
|
+
switch (_context2.prev = _context2.next) {
|
8191
|
+
case 0:
|
8192
|
+
contentTemplatesUrl = "Client/v2/ContentTemplates";
|
8193
|
+
url = new UriBuilder(contentTemplatesUrl);
|
8194
|
+
url.arg("PageSize", this._pageSize);
|
8195
|
+
|
8196
|
+
if (pageToken !== undefined) {
|
8197
|
+
url.arg("PageToken", pageToken);
|
8198
|
+
}
|
8199
|
+
|
8200
|
+
_context2.next = 6;
|
8201
|
+
return this._services.commandExecutor.fetchResource(url.build());
|
8202
|
+
|
8203
|
+
case 6:
|
8204
|
+
response = _context2.sent;
|
8205
|
+
return _context2.abrupt("return", [response.templates.map(function (template) {
|
8206
|
+
return new ContentTemplate(template);
|
8207
|
+
}), response.meta.next_token]);
|
8208
|
+
|
8209
|
+
case 8:
|
8210
|
+
case "end":
|
8211
|
+
return _context2.stop();
|
8212
|
+
}
|
8213
|
+
}
|
8214
|
+
}, _callee2, this);
|
8215
|
+
}));
|
8216
|
+
|
8217
|
+
function _fetchContentTemplates(_x) {
|
8218
|
+
return _fetchContentTemplates2.apply(this, arguments);
|
8219
|
+
}
|
8220
|
+
|
8221
|
+
return _fetchContentTemplates;
|
8222
|
+
}()
|
8223
|
+
}]);
|
8224
|
+
|
8225
|
+
return ContentClient;
|
8226
|
+
}();
|
8227
|
+
|
8228
|
+
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; } } }; }
|
8229
|
+
|
8230
|
+
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); }
|
8231
|
+
|
8232
|
+
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; }
|
8233
|
+
|
8234
|
+
var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
|
8235
|
+
function QuickLRU() {
|
8236
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
8237
|
+
|
8238
|
+
_classCallCheck__default["default"](this, QuickLRU);
|
8239
|
+
|
8240
|
+
if (!(options.maxSize && options.maxSize > 0)) {
|
8241
|
+
throw new TypeError('`maxSize` must be a number greater than 0');
|
8242
|
+
}
|
8243
|
+
|
8244
|
+
this.maxSize = options.maxSize;
|
8245
|
+
this.onEviction = options.onEviction;
|
8246
|
+
this.cache = new Map();
|
8247
|
+
this.oldCache = new Map();
|
8248
|
+
this._size = 0;
|
8249
|
+
}
|
8250
|
+
|
8251
|
+
_createClass__default["default"](QuickLRU, [{
|
8252
|
+
key: "_set",
|
8253
|
+
value: function _set(key, value) {
|
8254
|
+
this.cache.set(key, value);
|
8255
|
+
this._size++;
|
8256
|
+
|
8257
|
+
if (this._size >= this.maxSize) {
|
8258
|
+
this._size = 0;
|
8259
|
+
|
8260
|
+
if (typeof this.onEviction === 'function') {
|
8261
|
+
var _iterator = _createForOfIteratorHelper(this.oldCache.entries()),
|
8262
|
+
_step;
|
8263
|
+
|
8264
|
+
try {
|
8265
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
8266
|
+
var _step$value = _slicedToArray__default["default"](_step.value, 2),
|
8267
|
+
_key = _step$value[0],
|
8268
|
+
_value = _step$value[1];
|
8269
|
+
|
8270
|
+
this.onEviction(_key, _value);
|
8271
|
+
}
|
8272
|
+
} catch (err) {
|
8273
|
+
_iterator.e(err);
|
8274
|
+
} finally {
|
8275
|
+
_iterator.f();
|
8276
|
+
}
|
8277
|
+
}
|
8278
|
+
|
8279
|
+
this.oldCache = this.cache;
|
8280
|
+
this.cache = new Map();
|
8281
|
+
}
|
8282
|
+
}
|
8283
|
+
}, {
|
8284
|
+
key: "get",
|
8285
|
+
value: function get(key) {
|
8286
|
+
if (this.cache.has(key)) {
|
8287
|
+
return this.cache.get(key);
|
8288
|
+
}
|
8289
|
+
|
8290
|
+
if (this.oldCache.has(key)) {
|
8291
|
+
var value = this.oldCache.get(key);
|
8292
|
+
this.oldCache.delete(key);
|
8293
|
+
|
8294
|
+
this._set(key, value);
|
8295
|
+
|
8296
|
+
return value;
|
8297
|
+
}
|
8298
|
+
}
|
8299
|
+
}, {
|
8300
|
+
key: "set",
|
8301
|
+
value: function set(key, value) {
|
8302
|
+
if (this.cache.has(key)) {
|
8303
|
+
this.cache.set(key, value);
|
8304
|
+
} else {
|
8305
|
+
this._set(key, value);
|
8306
|
+
}
|
8307
|
+
|
8308
|
+
return this;
|
8309
|
+
}
|
8310
|
+
}, {
|
8311
|
+
key: "has",
|
8312
|
+
value: function has(key) {
|
8313
|
+
return this.cache.has(key) || this.oldCache.has(key);
|
8314
|
+
}
|
8315
|
+
}, {
|
8316
|
+
key: "peek",
|
8317
|
+
value: function peek(key) {
|
8318
|
+
if (this.cache.has(key)) {
|
8319
|
+
return this.cache.get(key);
|
8320
|
+
}
|
8321
|
+
|
8322
|
+
if (this.oldCache.has(key)) {
|
8323
|
+
return this.oldCache.get(key);
|
8324
|
+
}
|
8325
|
+
}
|
8326
|
+
}, {
|
8327
|
+
key: "delete",
|
8328
|
+
value: function _delete(key) {
|
8329
|
+
var deleted = this.cache.delete(key);
|
8330
|
+
|
8331
|
+
if (deleted) {
|
8332
|
+
this._size--;
|
8333
|
+
}
|
8334
|
+
|
8335
|
+
return this.oldCache.delete(key) || deleted;
|
8336
|
+
}
|
8337
|
+
}, {
|
8338
|
+
key: "clear",
|
8339
|
+
value: function clear() {
|
8340
|
+
this.cache.clear();
|
8341
|
+
this.oldCache.clear();
|
8342
|
+
this._size = 0;
|
8343
|
+
}
|
8344
|
+
}, {
|
8345
|
+
key: "keys",
|
8346
|
+
value: /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function keys() {
|
8347
|
+
var _iterator2, _step2, _step2$value, key;
|
8348
|
+
|
8349
|
+
return _regeneratorRuntime__default["default"].wrap(function keys$(_context) {
|
8350
|
+
while (1) {
|
8351
|
+
switch (_context.prev = _context.next) {
|
8352
|
+
case 0:
|
8353
|
+
_iterator2 = _createForOfIteratorHelper(this);
|
8354
|
+
_context.prev = 1;
|
8355
|
+
|
8356
|
+
_iterator2.s();
|
8357
|
+
|
8358
|
+
case 3:
|
8359
|
+
if ((_step2 = _iterator2.n()).done) {
|
8360
|
+
_context.next = 9;
|
8361
|
+
break;
|
8362
|
+
}
|
8363
|
+
|
8364
|
+
_step2$value = _slicedToArray__default["default"](_step2.value, 1), key = _step2$value[0];
|
8365
|
+
_context.next = 7;
|
8366
|
+
return key;
|
8367
|
+
|
8368
|
+
case 7:
|
8369
|
+
_context.next = 3;
|
8370
|
+
break;
|
8371
|
+
|
8372
|
+
case 9:
|
8373
|
+
_context.next = 14;
|
8374
|
+
break;
|
8375
|
+
|
8376
|
+
case 11:
|
8377
|
+
_context.prev = 11;
|
8378
|
+
_context.t0 = _context["catch"](1);
|
8379
|
+
|
8380
|
+
_iterator2.e(_context.t0);
|
8381
|
+
|
8382
|
+
case 14:
|
8383
|
+
_context.prev = 14;
|
8384
|
+
|
8385
|
+
_iterator2.f();
|
8386
|
+
|
8387
|
+
return _context.finish(14);
|
8388
|
+
|
8389
|
+
case 17:
|
8390
|
+
case "end":
|
8391
|
+
return _context.stop();
|
8392
|
+
}
|
8393
|
+
}
|
8394
|
+
}, keys, this, [[1, 11, 14, 17]]);
|
8395
|
+
})
|
8396
|
+
}, {
|
8397
|
+
key: "values",
|
8398
|
+
value: /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function values() {
|
8399
|
+
var _iterator3, _step3, _step3$value, value;
|
8400
|
+
|
8401
|
+
return _regeneratorRuntime__default["default"].wrap(function values$(_context2) {
|
8402
|
+
while (1) {
|
8403
|
+
switch (_context2.prev = _context2.next) {
|
8404
|
+
case 0:
|
8405
|
+
_iterator3 = _createForOfIteratorHelper(this);
|
8406
|
+
_context2.prev = 1;
|
8407
|
+
|
8408
|
+
_iterator3.s();
|
8409
|
+
|
8410
|
+
case 3:
|
8411
|
+
if ((_step3 = _iterator3.n()).done) {
|
8412
|
+
_context2.next = 9;
|
8413
|
+
break;
|
8414
|
+
}
|
8415
|
+
|
8416
|
+
_step3$value = _slicedToArray__default["default"](_step3.value, 2), value = _step3$value[1];
|
8417
|
+
_context2.next = 7;
|
8418
|
+
return value;
|
8419
|
+
|
8420
|
+
case 7:
|
8421
|
+
_context2.next = 3;
|
8422
|
+
break;
|
8423
|
+
|
8424
|
+
case 9:
|
8425
|
+
_context2.next = 14;
|
8426
|
+
break;
|
8427
|
+
|
8428
|
+
case 11:
|
8429
|
+
_context2.prev = 11;
|
8430
|
+
_context2.t0 = _context2["catch"](1);
|
8431
|
+
|
8432
|
+
_iterator3.e(_context2.t0);
|
8433
|
+
|
8434
|
+
case 14:
|
8435
|
+
_context2.prev = 14;
|
8436
|
+
|
8437
|
+
_iterator3.f();
|
8438
|
+
|
8439
|
+
return _context2.finish(14);
|
8440
|
+
|
8441
|
+
case 17:
|
8442
|
+
case "end":
|
8443
|
+
return _context2.stop();
|
8444
|
+
}
|
8445
|
+
}
|
8446
|
+
}, values, this, [[1, 11, 14, 17]]);
|
8447
|
+
})
|
8448
|
+
}, {
|
8449
|
+
key: _Symbol$iterator,
|
8450
|
+
value: /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function value() {
|
8451
|
+
var _iterator4, _step4, item, _iterator5, _step5, _item, _item2, key;
|
8452
|
+
|
8453
|
+
return _regeneratorRuntime__default["default"].wrap(function value$(_context3) {
|
8454
|
+
while (1) {
|
8455
|
+
switch (_context3.prev = _context3.next) {
|
8456
|
+
case 0:
|
8457
|
+
_iterator4 = _createForOfIteratorHelper(this.cache);
|
8458
|
+
_context3.prev = 1;
|
8459
|
+
|
8460
|
+
_iterator4.s();
|
8461
|
+
|
8462
|
+
case 3:
|
8463
|
+
if ((_step4 = _iterator4.n()).done) {
|
8464
|
+
_context3.next = 9;
|
8465
|
+
break;
|
8466
|
+
}
|
8467
|
+
|
8468
|
+
item = _step4.value;
|
8469
|
+
_context3.next = 7;
|
8470
|
+
return item;
|
8471
|
+
|
8472
|
+
case 7:
|
8473
|
+
_context3.next = 3;
|
8474
|
+
break;
|
8475
|
+
|
8476
|
+
case 9:
|
8477
|
+
_context3.next = 14;
|
8478
|
+
break;
|
8479
|
+
|
8480
|
+
case 11:
|
8481
|
+
_context3.prev = 11;
|
8482
|
+
_context3.t0 = _context3["catch"](1);
|
8483
|
+
|
8484
|
+
_iterator4.e(_context3.t0);
|
8485
|
+
|
8486
|
+
case 14:
|
8487
|
+
_context3.prev = 14;
|
8488
|
+
|
8489
|
+
_iterator4.f();
|
8490
|
+
|
8491
|
+
return _context3.finish(14);
|
8492
|
+
|
8493
|
+
case 17:
|
8494
|
+
_iterator5 = _createForOfIteratorHelper(this.oldCache);
|
8495
|
+
_context3.prev = 18;
|
8496
|
+
|
8497
|
+
_iterator5.s();
|
8498
|
+
|
8499
|
+
case 20:
|
8500
|
+
if ((_step5 = _iterator5.n()).done) {
|
8501
|
+
_context3.next = 28;
|
8502
|
+
break;
|
8503
|
+
}
|
8504
|
+
|
8505
|
+
_item = _step5.value;
|
8506
|
+
_item2 = _slicedToArray__default["default"](_item, 1), key = _item2[0];
|
8507
|
+
|
8508
|
+
if (this.cache.has(key)) {
|
8509
|
+
_context3.next = 26;
|
8510
|
+
break;
|
8511
|
+
}
|
8512
|
+
|
8513
|
+
_context3.next = 26;
|
8514
|
+
return _item;
|
8515
|
+
|
8516
|
+
case 26:
|
8517
|
+
_context3.next = 20;
|
8518
|
+
break;
|
8519
|
+
|
8520
|
+
case 28:
|
8521
|
+
_context3.next = 33;
|
8522
|
+
break;
|
8523
|
+
|
8524
|
+
case 30:
|
8525
|
+
_context3.prev = 30;
|
8526
|
+
_context3.t1 = _context3["catch"](18);
|
8527
|
+
|
8528
|
+
_iterator5.e(_context3.t1);
|
8529
|
+
|
8530
|
+
case 33:
|
8531
|
+
_context3.prev = 33;
|
8532
|
+
|
8533
|
+
_iterator5.f();
|
8534
|
+
|
8535
|
+
return _context3.finish(33);
|
8536
|
+
|
8537
|
+
case 36:
|
8538
|
+
case "end":
|
8539
|
+
return _context3.stop();
|
8540
|
+
}
|
8541
|
+
}
|
8542
|
+
}, value, this, [[1, 11, 14, 17], [18, 30, 33, 36]]);
|
8543
|
+
})
|
8544
|
+
}, {
|
8545
|
+
key: "size",
|
8546
|
+
get: function get() {
|
8547
|
+
var oldCacheSize = 0;
|
8548
|
+
|
8549
|
+
var _iterator6 = _createForOfIteratorHelper(this.oldCache.keys()),
|
8550
|
+
_step6;
|
8551
|
+
|
8552
|
+
try {
|
8553
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
8554
|
+
var key = _step6.value;
|
8555
|
+
|
8556
|
+
if (!this.cache.has(key)) {
|
8557
|
+
oldCacheSize++;
|
8558
|
+
}
|
8559
|
+
}
|
8560
|
+
} catch (err) {
|
8561
|
+
_iterator6.e(err);
|
8562
|
+
} finally {
|
8563
|
+
_iterator6.f();
|
8564
|
+
}
|
8565
|
+
|
8566
|
+
return Math.min(this._size + oldCacheSize, this.maxSize);
|
8567
|
+
}
|
8568
|
+
}]);
|
8569
|
+
|
8570
|
+
return QuickLRU;
|
8571
|
+
}(Symbol.iterator);
|
8572
|
+
|
8573
|
+
var quickLru = QuickLRU;
|
8574
|
+
|
8575
|
+
/**
|
8576
|
+
* Represents channel metadata.
|
8577
|
+
*/
|
8578
|
+
|
8579
|
+
var ChannelMetadata = /*#__PURE__*/_createClass__default["default"](
|
8580
|
+
/**
|
8581
|
+
* Communication channel type.
|
8582
|
+
*/
|
8583
|
+
|
8584
|
+
/**
|
8585
|
+
* The actual metadata.
|
8586
|
+
*/
|
8587
|
+
|
8588
|
+
/**
|
8589
|
+
* @internal
|
8590
|
+
*/
|
8591
|
+
function ChannelMetadata(type, data) {
|
8592
|
+
_classCallCheck__default["default"](this, ChannelMetadata);
|
8593
|
+
|
8594
|
+
this.type = type;
|
8595
|
+
this.data = data;
|
8596
|
+
Object.freeze(data);
|
8597
|
+
});
|
8598
|
+
|
8599
|
+
var ChannelMetadataClient = /*#__PURE__*/function () {
|
8600
|
+
function ChannelMetadataClient(services, configuration) {
|
8601
|
+
_classCallCheck__default["default"](this, ChannelMetadataClient);
|
8602
|
+
|
8603
|
+
this._services = services;
|
8604
|
+
this._configuration = configuration;
|
8605
|
+
this._cache = new quickLru({
|
8606
|
+
maxSize: configuration.channelMetadataCacheCapacity
|
8607
|
+
});
|
8608
|
+
}
|
8609
|
+
|
8610
|
+
_createClass__default["default"](ChannelMetadataClient, [{
|
8611
|
+
key: "getChannelMetadata",
|
8612
|
+
value: function () {
|
8613
|
+
var _getChannelMetadata = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(conversationSid, messageSid) {
|
8614
|
+
var key, cachedItem, url, metadataResponse, metadata;
|
8615
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
8616
|
+
while (1) {
|
8617
|
+
switch (_context.prev = _context.next) {
|
8618
|
+
case 0:
|
8619
|
+
key = "".concat(conversationSid, ",").concat(messageSid);
|
8620
|
+
cachedItem = this._cache.get(key);
|
8621
|
+
|
8622
|
+
if (!cachedItem) {
|
8623
|
+
_context.next = 4;
|
8624
|
+
break;
|
8625
|
+
}
|
8626
|
+
|
8627
|
+
return _context.abrupt("return", cachedItem.item);
|
8628
|
+
|
8629
|
+
case 4:
|
8630
|
+
url = "".concat(this._configuration.links.conversations, "/").concat(conversationSid, "/Messages/").concat(messageSid, "/ChannelMetadata");
|
8631
|
+
_context.prev = 5;
|
8632
|
+
_context.next = 8;
|
8633
|
+
return this._services.commandExecutor.fetchResource(url);
|
8634
|
+
|
8635
|
+
case 8:
|
8636
|
+
metadataResponse = _context.sent;
|
8637
|
+
_context.next = 17;
|
8638
|
+
break;
|
8639
|
+
|
8640
|
+
case 11:
|
8641
|
+
_context.prev = 11;
|
8642
|
+
_context.t0 = _context["catch"](5);
|
8643
|
+
|
8644
|
+
if (!(_context.t0 instanceof ChannelMetadataNotFoundError)) {
|
8645
|
+
_context.next = 16;
|
8646
|
+
break;
|
8647
|
+
}
|
8648
|
+
|
8649
|
+
this._cache.set(key, {
|
8650
|
+
item: null
|
8651
|
+
});
|
8652
|
+
|
8653
|
+
return _context.abrupt("return", null);
|
8654
|
+
|
8655
|
+
case 16:
|
8656
|
+
throw new Error(_context.t0);
|
8657
|
+
|
8658
|
+
case 17:
|
8659
|
+
metadata = new ChannelMetadata(metadataResponse.type, metadataResponse.data);
|
8660
|
+
|
8661
|
+
this._cache.set(key, {
|
8662
|
+
item: metadata
|
8663
|
+
});
|
8664
|
+
|
8665
|
+
return _context.abrupt("return", metadata);
|
8666
|
+
|
8667
|
+
case 20:
|
8668
|
+
case "end":
|
8669
|
+
return _context.stop();
|
8670
|
+
}
|
8671
|
+
}
|
8672
|
+
}, _callee, this, [[5, 11]]);
|
8673
|
+
}));
|
8674
|
+
|
8675
|
+
function getChannelMetadata(_x, _x2) {
|
8676
|
+
return _getChannelMetadata.apply(this, arguments);
|
8677
|
+
}
|
8678
|
+
|
8679
|
+
return getChannelMetadata;
|
8680
|
+
}()
|
8681
|
+
}]);
|
8682
|
+
|
8683
|
+
return ChannelMetadataClient;
|
8684
|
+
}();
|
8685
|
+
|
7376
8686
|
var _class;
|
7377
8687
|
|
7378
8688
|
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 +8882,25 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7572
8882
|
*/
|
7573
8883
|
|
7574
8884
|
/**
|
8885
|
+
* @deprecated Use initialized or initFailed events instead
|
7575
8886
|
* Fired when the state of the client has been changed.
|
7576
8887
|
*
|
7577
8888
|
* Parameters:
|
8889
|
+
* 1. {@link State} `state` - the new client state
|
8890
|
+
* @event
|
8891
|
+
*/
|
8892
|
+
|
8893
|
+
/**
|
8894
|
+
* Fired when the client has completed initialization successfully.
|
8895
|
+
* @event
|
8896
|
+
*/
|
8897
|
+
|
8898
|
+
/**
|
8899
|
+
* Fired when the client initialization failed.
|
8900
|
+
*
|
8901
|
+
* Parameters:
|
7578
8902
|
* 1. object `data` - info object provided with the event. It has the
|
7579
|
-
* following
|
7580
|
-
* * {@link State} `state` - the new client state
|
8903
|
+
* following property:
|
7581
8904
|
* * Error? `error` - the initialization error if present
|
7582
8905
|
* @event
|
7583
8906
|
*/
|
@@ -7749,12 +9072,14 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7749
9072
|
_this._services.commandExecutor = new CommandExecutor(baseUrl, {
|
7750
9073
|
transport: _this._options.transport
|
7751
9074
|
}, productId);
|
9075
|
+
_this._services.contentClient = new ContentClient(_this._services);
|
7752
9076
|
|
7753
9077
|
var emitFailed = function emitFailed(error) {
|
7754
9078
|
_this._rejectEnsureReady(error);
|
7755
9079
|
|
7756
|
-
_this.emit("stateChanged",
|
7757
|
-
|
9080
|
+
_this.emit("stateChanged", "failed");
|
9081
|
+
|
9082
|
+
_this.emit("initFailed", {
|
7758
9083
|
error: error
|
7759
9084
|
});
|
7760
9085
|
};
|
@@ -7766,11 +9091,11 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7766
9091
|
});
|
7767
9092
|
};
|
7768
9093
|
|
7769
|
-
_this._services.twilsockClient.
|
9094
|
+
_this._services.twilsockClient.once("connectionError", emitFailed);
|
7770
9095
|
|
7771
|
-
_this._services.twilsockClient.
|
9096
|
+
_this._services.twilsockClient.once("disconnected", emitDisconnected);
|
7772
9097
|
|
7773
|
-
_this._services.twilsockClient.
|
9098
|
+
_this._services.twilsockClient.once("connected", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
7774
9099
|
var startupEvent, connectionError;
|
7775
9100
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
7776
9101
|
while (1) {
|
@@ -7793,7 +9118,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7793
9118
|
case 8:
|
7794
9119
|
_this._services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription("", "", new Date()), startupEvent, twilsock.TelemetryPoint.End);
|
7795
9120
|
|
7796
|
-
_context.next =
|
9121
|
+
_context.next = 17;
|
7797
9122
|
break;
|
7798
9123
|
|
7799
9124
|
case 11:
|
@@ -7807,12 +9132,13 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7807
9132
|
|
7808
9133
|
_this._rejectEnsureReady(connectionError);
|
7809
9134
|
|
7810
|
-
_this.emit("stateChanged",
|
7811
|
-
|
9135
|
+
_this.emit("stateChanged", "failed");
|
9136
|
+
|
9137
|
+
_this.emit("initFailed", {
|
7812
9138
|
error: connectionError
|
7813
9139
|
});
|
7814
9140
|
|
7815
|
-
case
|
9141
|
+
case 17:
|
7816
9142
|
case "end":
|
7817
9143
|
return _context.stop();
|
7818
9144
|
}
|
@@ -7859,6 +9185,17 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7859
9185
|
|
7860
9186
|
return this._configuration.reachabilityEnabled;
|
7861
9187
|
}
|
9188
|
+
/**
|
9189
|
+
* @deprecated
|
9190
|
+
* Current token.
|
9191
|
+
* @internal
|
9192
|
+
*/
|
9193
|
+
|
9194
|
+
}, {
|
9195
|
+
key: "token",
|
9196
|
+
get: function get() {
|
9197
|
+
return this._fpaToken;
|
9198
|
+
}
|
7862
9199
|
/**
|
7863
9200
|
* @deprecated Call constructor directly.
|
7864
9201
|
*
|
@@ -7997,16 +9334,32 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7997
9334
|
conversation = _context4.sent;
|
7998
9335
|
|
7999
9336
|
if (conversation) {
|
8000
|
-
_context4.next =
|
9337
|
+
_context4.next = 12;
|
9338
|
+
break;
|
9339
|
+
}
|
9340
|
+
|
9341
|
+
_context4.next = 10;
|
9342
|
+
return this.peekConversationBySid(conversationSid);
|
9343
|
+
|
9344
|
+
case 10:
|
9345
|
+
conversation = _context4.sent;
|
9346
|
+
|
9347
|
+
if (conversation) {
|
9348
|
+
deprecationDecorator.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");
|
9349
|
+
}
|
9350
|
+
|
9351
|
+
case 12:
|
9352
|
+
if (conversation) {
|
9353
|
+
_context4.next = 14;
|
8001
9354
|
break;
|
8002
9355
|
}
|
8003
9356
|
|
8004
9357
|
throw new Error("Conversation with SID ".concat(conversationSid, " was not found."));
|
8005
9358
|
|
8006
|
-
case
|
9359
|
+
case 14:
|
8007
9360
|
return _context4.abrupt("return", conversation);
|
8008
9361
|
|
8009
|
-
case
|
9362
|
+
case 15:
|
8010
9363
|
case "end":
|
8011
9364
|
return _context4.stop();
|
8012
9365
|
}
|
@@ -8492,6 +9845,43 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8492
9845
|
});
|
8493
9846
|
return this.getTemporaryContentUrlsForMediaSids(sids);
|
8494
9847
|
}
|
9848
|
+
/**
|
9849
|
+
* Returns rich content templates belonging to the account. Rich content
|
9850
|
+
* templates can be created via the Twilio console or the REST API.
|
9851
|
+
*/
|
9852
|
+
|
9853
|
+
}, {
|
9854
|
+
key: "getContentTemplates",
|
9855
|
+
value: function () {
|
9856
|
+
var _getContentTemplates = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee16() {
|
9857
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee16$(_context16) {
|
9858
|
+
while (1) {
|
9859
|
+
switch (_context16.prev = _context16.next) {
|
9860
|
+
case 0:
|
9861
|
+
_context16.next = 2;
|
9862
|
+
return this._ensureReady;
|
9863
|
+
|
9864
|
+
case 2:
|
9865
|
+
_context16.next = 4;
|
9866
|
+
return this._services.contentClient.getContentTemplates();
|
9867
|
+
|
9868
|
+
case 4:
|
9869
|
+
return _context16.abrupt("return", _context16.sent);
|
9870
|
+
|
9871
|
+
case 5:
|
9872
|
+
case "end":
|
9873
|
+
return _context16.stop();
|
9874
|
+
}
|
9875
|
+
}
|
9876
|
+
}, _callee16, this);
|
9877
|
+
}));
|
9878
|
+
|
9879
|
+
function getContentTemplates() {
|
9880
|
+
return _getContentTemplates.apply(this, arguments);
|
9881
|
+
}
|
9882
|
+
|
9883
|
+
return getContentTemplates;
|
9884
|
+
}()
|
8495
9885
|
/**
|
8496
9886
|
* Initialize the client.
|
8497
9887
|
*/
|
@@ -8499,20 +9889,21 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8499
9889
|
}, {
|
8500
9890
|
key: "_initialize",
|
8501
9891
|
value: function () {
|
8502
|
-
var _initialize2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
9892
|
+
var _initialize2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee17() {
|
8503
9893
|
var _this3 = this;
|
8504
9894
|
|
8505
9895
|
var configurationResponse;
|
8506
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
9896
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee17$(_context17) {
|
8507
9897
|
while (1) {
|
8508
|
-
switch (
|
9898
|
+
switch (_context17.prev = _context17.next) {
|
8509
9899
|
case 0:
|
8510
|
-
|
9900
|
+
_context17.next = 2;
|
8511
9901
|
return this._services.commandExecutor.fetchResource("Client/v2/Configuration");
|
8512
9902
|
|
8513
9903
|
case 2:
|
8514
|
-
configurationResponse =
|
9904
|
+
configurationResponse = _context17.sent;
|
8515
9905
|
this._configuration = new Configuration(this._options, configurationResponse, Client_1._logger);
|
9906
|
+
this._services.channelMetadataClient = new ChannelMetadataClient(this._services, this._configuration);
|
8516
9907
|
|
8517
9908
|
this._myself._resolveInitialization(this._configuration, this._configuration.userIdentity, this._configuration.userInfo, true);
|
8518
9909
|
|
@@ -8591,10 +9982,10 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8591
9982
|
}).catch(function (error) {
|
8592
9983
|
throw error;
|
8593
9984
|
});
|
8594
|
-
|
9985
|
+
_context17.next = 29;
|
8595
9986
|
return this._services.users.myself._ensureFetched();
|
8596
9987
|
|
8597
|
-
case
|
9988
|
+
case 29:
|
8598
9989
|
Client_1._supportedPushChannels.forEach(function (channelType) {
|
8599
9990
|
return _this3._subscribeToPushNotifications(channelType);
|
8600
9991
|
});
|
@@ -8607,16 +9998,15 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8607
9998
|
|
8608
9999
|
this._resolveEnsureReady();
|
8609
10000
|
|
8610
|
-
this.emit("stateChanged",
|
8611
|
-
|
8612
|
-
});
|
10001
|
+
this.emit("stateChanged", "initialized");
|
10002
|
+
this.emit("initialized");
|
8613
10003
|
|
8614
|
-
case
|
10004
|
+
case 35:
|
8615
10005
|
case "end":
|
8616
|
-
return
|
10006
|
+
return _context17.stop();
|
8617
10007
|
}
|
8618
10008
|
}
|
8619
|
-
},
|
10009
|
+
}, _callee17, this);
|
8620
10010
|
}));
|
8621
10011
|
|
8622
10012
|
function _initialize() {
|
@@ -8656,14 +10046,14 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8656
10046
|
}], [{
|
8657
10047
|
key: "create",
|
8658
10048
|
value: function () {
|
8659
|
-
var _create = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
10049
|
+
var _create = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee18(token, options) {
|
8660
10050
|
var client;
|
8661
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
10051
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee18$(_context18) {
|
8662
10052
|
while (1) {
|
8663
|
-
switch (
|
10053
|
+
switch (_context18.prev = _context18.next) {
|
8664
10054
|
case 0:
|
8665
10055
|
if (!(options !== null && options !== void 0 && options.twilsockClient)) {
|
8666
|
-
|
10056
|
+
_context18.next = 2;
|
8667
10057
|
break;
|
8668
10058
|
}
|
8669
10059
|
|
@@ -8671,18 +10061,18 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8671
10061
|
|
8672
10062
|
case 2:
|
8673
10063
|
client = new Client_1(token, options);
|
8674
|
-
|
10064
|
+
_context18.next = 5;
|
8675
10065
|
return client._ensureReady;
|
8676
10066
|
|
8677
10067
|
case 5:
|
8678
|
-
return
|
10068
|
+
return _context18.abrupt("return", client);
|
8679
10069
|
|
8680
10070
|
case 6:
|
8681
10071
|
case "end":
|
8682
|
-
return
|
10072
|
+
return _context18.stop();
|
8683
10073
|
}
|
8684
10074
|
}
|
8685
|
-
},
|
10075
|
+
}, _callee18);
|
8686
10076
|
}));
|
8687
10077
|
|
8688
10078
|
function create(_x16, _x17) {
|
@@ -8815,7 +10205,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8815
10205
|
}]);
|
8816
10206
|
|
8817
10207
|
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", {
|
10208
|
+
}(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
10209
|
conversation_sid: "conversationSid",
|
8820
10210
|
conversation_title: "conversationTitle",
|
8821
10211
|
message_sid: "messageSid",
|
@@ -8825,6 +10215,8 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8825
10215
|
|
8826
10216
|
}), _class);
|
8827
10217
|
|
10218
|
+
__decorate([deprecationDecorator.deprecated("token"), __metadata("design:type", String), __metadata("design:paramtypes", [])], exports.Client.prototype, "token", null);
|
10219
|
+
|
8828
10220
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "updateToken", null);
|
8829
10221
|
|
8830
10222
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "getConversationBySid", null);
|
@@ -8853,7 +10245,7 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
|
|
8853
10245
|
|
8854
10246
|
__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
10247
|
|
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);
|
10248
|
+
__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
10249
|
|
8858
10250
|
__decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.pureObject), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", PushNotification)], exports.Client, "parsePushNotification", null);
|
8859
10251
|
|
@@ -8864,6 +10256,9 @@ Object.defineProperty(exports, 'CancellablePromise', {
|
|
8864
10256
|
get: function () { return mcsClient.CancellablePromise; }
|
8865
10257
|
});
|
8866
10258
|
exports.AggregatedDeliveryReceipt = AggregatedDeliveryReceipt;
|
10259
|
+
exports.ChannelMetadata = ChannelMetadata;
|
10260
|
+
exports.ContentTemplate = ContentTemplate;
|
10261
|
+
exports.ContentTemplateVariable = ContentTemplateVariable;
|
8867
10262
|
exports.Conversation = Conversation;
|
8868
10263
|
exports.DetailedDeliveryReceipt = DetailedDeliveryReceipt;
|
8869
10264
|
exports.Media = Media;
|