@twilio/conversations 3.0.0-rc.9 → 3.0.1-rc.0
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 +39 -29
- package/builds/browser.esm.js +10846 -0
- package/builds/browser.esm.js.map +1 -0
- package/builds/browser.js +2505 -479
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +805 -70
- package/builds/lib.esm.d.ts +3178 -0
- package/builds/lib.esm.js +10845 -0
- package/builds/lib.js +2505 -479
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +25853 -24412
- package/builds/twilio-conversations.js.map +1 -0
- package/builds/twilio-conversations.min.js +2 -1
- package/builds/twilio-conversations.min.js.map +1 -0
- package/dist/aggregated-delivery-receipt.js +10 -5
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/channel-metadata-client.js +187 -0
- package/dist/channel-metadata-client.js.map +1 -0
- package/dist/client.js +266 -192
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +53 -15
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +23 -12
- package/dist/configuration.js.map +1 -1
- package/dist/content-client.js +180 -0
- package/dist/content-client.js.map +1 -0
- package/dist/content-template.js +304 -0
- package/dist/content-template.js.map +1 -0
- package/dist/conversation.js +213 -134
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +70 -50
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +40 -27
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +38 -32
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +19 -14
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js +9 -4
- package/dist/detailed-delivery-receipt.js.map +1 -1
- package/dist/index.js +26 -41
- package/dist/index.js.map +1 -1
- package/dist/interfaces/notification-types.js +9 -4
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/interfaces/rules.js +160 -0
- package/dist/interfaces/rules.js.map +1 -0
- package/dist/logger.js +17 -28
- package/dist/logger.js.map +1 -1
- package/dist/media.js +40 -24
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +79 -12
- package/dist/message-builder.js.map +1 -1
- package/dist/message-recipients-client.js +231 -0
- package/dist/message-recipients-client.js.map +1 -0
- package/dist/message.js +258 -92
- package/dist/message.js.map +1 -1
- package/dist/node_modules/quick-lru/index.js +261 -0
- package/dist/node_modules/quick-lru/index.js.map +1 -0
- package/dist/node_modules/tslib/tslib.es6.js +15 -5
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/packages/conversations/package.json.js +12 -7
- package/dist/packages/conversations/package.json.js.map +1 -1
- package/dist/participant.js +42 -38
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js +9 -4
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js +9 -4
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +11 -6
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +17 -11
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js +14 -9
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +40 -32
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js +9 -4
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js +44 -8
- package/dist/util/index.js.map +1 -1
- package/dist/{interfaces/attributes.js → utils/uuid.js} +17 -19
- package/dist/utils/uuid.js.map +1 -0
- package/package.json +21 -20
- package/CHANGELOG.md +0 -509
- package/dist/interfaces/attributes.js.map +0 -1
- package/docs/assets/css/main.css +0 -2660
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -248
- package/docs/assets/js/search.js +0 -1
- package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
- package/docs/classes/CancellablePromise.html +0 -3213
- package/docs/classes/Client.html +0 -4239
- package/docs/classes/Conversation.html +0 -4354
- package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
- package/docs/classes/Media.html +0 -3167
- package/docs/classes/Message.html +0 -3732
- package/docs/classes/MessageBuilder.html +0 -3277
- package/docs/classes/Participant.html +0 -3444
- package/docs/classes/PushNotification.html +0 -3130
- package/docs/classes/RestPaginator.html +0 -3160
- package/docs/classes/UnsentMessage.html +0 -3042
- package/docs/classes/User.html +0 -3349
- package/docs/index.html +0 -3509
- package/docs/interfaces/ClientOptions.html +0 -3034
- package/docs/interfaces/ConversationBindings.html +0 -3001
- package/docs/interfaces/ConversationEmailBinding.html +0 -3001
- package/docs/interfaces/ConversationLimits.html +0 -3098
- package/docs/interfaces/ConversationState.html +0 -3050
- package/docs/interfaces/ConversationUpdatedEventArgs.html +0 -3001
- package/docs/interfaces/CreateConversationOptions.html +0 -3066
- package/docs/interfaces/LastMessage.html +0 -3050
- package/docs/interfaces/Paginator.html +0 -3141
- package/docs/interfaces/ParticipantBindings.html +0 -3001
- package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
- package/docs/interfaces/PushNotificationData.html +0 -3114
- package/docs/interfaces/SendEmailOptions.html +0 -3034
- package/docs/interfaces/SendMediaOptions.html +0 -3068
- package/docs/modules.html +0 -3510
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');
|
|
@@ -145,10 +154,10 @@ var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
|
|
|
145
154
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
146
155
|
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
147
156
|
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
148
|
-
require('core-js/modules/es.object.to-string.js');
|
|
149
|
-
require('core-js/modules/es.promise.js');
|
|
150
157
|
require('core-js/modules/es.array.map.js');
|
|
158
|
+
require('core-js/modules/es.object.to-string.js');
|
|
151
159
|
require('core-js/modules/web.dom-collections.for-each.js');
|
|
160
|
+
require('core-js/modules/es.promise.js');
|
|
152
161
|
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
153
162
|
var _typeof = require('@babel/runtime/helpers/typeof');
|
|
154
163
|
require('core-js/modules/es.array.concat.js');
|
|
@@ -164,9 +173,9 @@ 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
|
-
var isEqual = require('lodash.isequal');
|
|
170
179
|
require('core-js/modules/es.array.slice.js');
|
|
171
180
|
require('core-js/modules/es.function.name.js');
|
|
172
181
|
require('core-js/modules/es.regexp.test.js');
|
|
@@ -179,7 +188,6 @@ var twilsock = require('twilsock');
|
|
|
179
188
|
var notifications = require('@twilio/notifications');
|
|
180
189
|
var twilioSync = require('twilio-sync');
|
|
181
190
|
var mcsClient = require('@twilio/mcs-client');
|
|
182
|
-
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
183
191
|
require('core-js/modules/es.set.js');
|
|
184
192
|
require('core-js/modules/es.number.is-integer.js');
|
|
185
193
|
require('core-js/modules/es.typed-array.uint8-array.js');
|
|
@@ -208,13 +216,16 @@ require('core-js/modules/es.typed-array.subarray.js');
|
|
|
208
216
|
require('core-js/modules/es.typed-array.to-locale-string.js');
|
|
209
217
|
require('core-js/modules/es.typed-array.to-string.js');
|
|
210
218
|
require('core-js/modules/es.array-buffer.constructor.js');
|
|
211
|
-
require('isomorphic-form-data');
|
|
212
219
|
require('core-js/modules/es.array.sort.js');
|
|
213
220
|
require('core-js/modules/es.string.includes.js');
|
|
221
|
+
require('core-js/modules/es.string.starts-with.js');
|
|
222
|
+
require('core-js/modules/es.weak-set.js');
|
|
223
|
+
var deprecationDecorator = require('@twilio/deprecation-decorator');
|
|
224
|
+
require('core-js/modules/es.object.entries.js');
|
|
214
225
|
require('core-js/modules/es.array.find.js');
|
|
215
226
|
require('core-js/modules/es.array.splice.js');
|
|
216
|
-
require('
|
|
217
|
-
|
|
227
|
+
var _wrapNativeSuper = require('@babel/runtime/helpers/wrapNativeSuper');
|
|
228
|
+
require('core-js/modules/es.object.freeze.js');
|
|
218
229
|
|
|
219
230
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
220
231
|
|
|
@@ -247,9 +258,9 @@ var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallChec
|
|
|
247
258
|
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
|
248
259
|
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
249
260
|
var loglevelLog__namespace = /*#__PURE__*/_interopNamespace(loglevelLog);
|
|
250
|
-
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
251
|
-
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
252
261
|
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
262
|
+
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
263
|
+
var _wrapNativeSuper__default = /*#__PURE__*/_interopDefaultLegacy(_wrapNativeSuper);
|
|
253
264
|
|
|
254
265
|
function __decorate(decorators, target, key, desc) {
|
|
255
266
|
var c = arguments.length,
|
|
@@ -287,11 +298,13 @@ var Logger = /*#__PURE__*/function () {
|
|
|
287
298
|
}, {
|
|
288
299
|
key: "trace",
|
|
289
300
|
value: function trace() {
|
|
290
|
-
|
|
291
|
-
args
|
|
292
|
-
|
|
301
|
+
if (log$7.getLevel() == log$7.levels.TRACE) {
|
|
302
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
303
|
+
args[_key] = arguments[_key];
|
|
304
|
+
}
|
|
293
305
|
|
|
294
|
-
|
|
306
|
+
log$7.debug.apply(null, prepareLine(this.prefix + "T", args));
|
|
307
|
+
}
|
|
295
308
|
}
|
|
296
309
|
}, {
|
|
297
310
|
key: "debug",
|
|
@@ -342,11 +355,13 @@ var Logger = /*#__PURE__*/function () {
|
|
|
342
355
|
}, {
|
|
343
356
|
key: "trace",
|
|
344
357
|
value: function trace() {
|
|
345
|
-
|
|
346
|
-
args
|
|
347
|
-
|
|
358
|
+
if (log$7.getLevel() == log$7.levels.TRACE) {
|
|
359
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
360
|
+
args[_key6] = arguments[_key6];
|
|
361
|
+
}
|
|
348
362
|
|
|
349
|
-
|
|
363
|
+
log$7.debug.apply(null, prepareLine("T", args));
|
|
364
|
+
}
|
|
350
365
|
}
|
|
351
366
|
}, {
|
|
352
367
|
key: "debug",
|
|
@@ -389,9 +404,9 @@ var Logger = /*#__PURE__*/function () {
|
|
|
389
404
|
return Logger;
|
|
390
405
|
}();
|
|
391
406
|
|
|
392
|
-
function ownKeys$
|
|
407
|
+
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
408
|
|
|
394
|
-
function _objectSpread$
|
|
409
|
+
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
410
|
var TYPING_TIMEOUT = 5;
|
|
396
411
|
var HTTP_CACHE_LIFETIME = "PT5S";
|
|
397
412
|
var CONSUMPTION_HORIZON_SENDING_INTERVAL = "PT5S";
|
|
@@ -400,9 +415,11 @@ var MINIMUM_RETRY_DELAY = 1000;
|
|
|
400
415
|
var MAXIMUM_RETRY_DELAY = 4000;
|
|
401
416
|
var MAXIMUM_ATTEMPTS_COUNT = 3;
|
|
402
417
|
var RETRY_WHEN_THROTTLED = true;
|
|
418
|
+
var CHANNEL_METADATA_CACHE_CAPACITY = 100;
|
|
419
|
+
var MESSAGE_RECIPIENTS_CACHE_CAPACITY = 1000;
|
|
403
420
|
|
|
404
421
|
var Configuration = /*#__PURE__*/_createClass__default["default"](function Configuration() {
|
|
405
|
-
var _ref, _constructorOptions$u, _ref2, _constructorOptions$h, _ref3, _constructorOptions$c;
|
|
422
|
+
var _ref, _constructorOptions$u, _ref2, _constructorOptions$h, _ref3, _constructorOptions$c, _options$channelMetad, _options$messageRecip;
|
|
406
423
|
|
|
407
424
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
408
425
|
var configurationResponse = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -432,7 +449,7 @@ var Configuration = /*#__PURE__*/_createClass__default["default"](function Confi
|
|
|
432
449
|
emailBodiesAllowedContentTypes: configurationResponse.options.email_bodies_allowed_mime_types
|
|
433
450
|
};
|
|
434
451
|
this.typingIndicatorTimeoutOverride = constructorOptions.typingIndicatorTimeoutOverride;
|
|
435
|
-
this.backoffConfiguration = _objectSpread$
|
|
452
|
+
this.backoffConfiguration = _objectSpread$5({
|
|
436
453
|
min: MINIMUM_RETRY_DELAY,
|
|
437
454
|
max: MAXIMUM_RETRY_DELAY,
|
|
438
455
|
maxAttemptsCount: MAXIMUM_ATTEMPTS_COUNT
|
|
@@ -460,6 +477,9 @@ var Configuration = /*#__PURE__*/_createClass__default["default"](function Confi
|
|
|
460
477
|
logger.error("Failed to parse consumption report interval ".concat(consumptionReportInterval, ", using default value ").concat(CONSUMPTION_HORIZON_SENDING_INTERVAL));
|
|
461
478
|
this.consumptionReportInterval = iso8601Duration.toSeconds(iso8601Duration.parse(CONSUMPTION_HORIZON_SENDING_INTERVAL));
|
|
462
479
|
}
|
|
480
|
+
|
|
481
|
+
this.channelMetadataCacheCapacity = (_options$channelMetad = options.channelMetadataCacheCapacity) !== null && _options$channelMetad !== void 0 ? _options$channelMetad : CHANNEL_METADATA_CACHE_CAPACITY;
|
|
482
|
+
this.messageRecipientsCacheCapacity = (_options$messageRecip = options.messageRecipientsCacheCapacity) !== null && _options$messageRecip !== void 0 ? _options$messageRecip : MESSAGE_RECIPIENTS_CACHE_CAPACITY;
|
|
463
483
|
});
|
|
464
484
|
|
|
465
485
|
/**
|
|
@@ -551,17 +571,72 @@ var UriBuilder = /*#__PURE__*/function () {
|
|
|
551
571
|
|
|
552
572
|
return UriBuilder;
|
|
553
573
|
}();
|
|
574
|
+
/**
|
|
575
|
+
* Deep equality check for objects
|
|
576
|
+
* @param a - first value to compare
|
|
577
|
+
* @param b - second value to compare
|
|
578
|
+
* @returns true if values are deeply equal
|
|
579
|
+
*/
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
function isEqual(a, b) {
|
|
583
|
+
if (a === b) {
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
if (a === null || b === null || a === undefined || b === undefined) {
|
|
588
|
+
return a === b;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
if (_typeof__default["default"](a) !== _typeof__default["default"](b)) {
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
if (_typeof__default["default"](a) !== "object") {
|
|
596
|
+
return a === b;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
600
|
+
if (a.length !== b.length) {
|
|
601
|
+
return false;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
return a.every(function (item, index) {
|
|
605
|
+
return isEqual(item, b[index]);
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
var aKeys = Object.keys(a);
|
|
614
|
+
var bKeys = Object.keys(b);
|
|
615
|
+
|
|
616
|
+
if (aKeys.length !== bKeys.length) {
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return aKeys.every(function (key) {
|
|
621
|
+
return isEqual(a[key], b[key]);
|
|
622
|
+
});
|
|
623
|
+
}
|
|
554
624
|
|
|
555
|
-
var
|
|
625
|
+
var json = declarativeTypeValidator.custom(function (value) {
|
|
556
626
|
return [["string", "number", "boolean", "object"].includes(_typeof__default["default"](value)), "a JSON type"];
|
|
557
627
|
});
|
|
558
|
-
var
|
|
628
|
+
var optionalJson = declarativeTypeValidator.custom(function (value) {
|
|
559
629
|
return [["undefined", "string", "number", "boolean", "object"].includes(_typeof__default["default"](value)), "an optional JSON type"];
|
|
560
630
|
});
|
|
631
|
+
var sendMediaOptions = declarativeTypeValidator.objectSchema("send media options", {
|
|
632
|
+
contentType: [declarativeTypeValidator.literal(null), "string"],
|
|
633
|
+
filename: ["string", "undefined"],
|
|
634
|
+
media: [declarativeTypeValidator.literal("null"), "string"].concat(_toConsumableArray__default["default"](typeof Buffer === "function" ? [Buffer] : []), _toConsumableArray__default["default"](typeof Blob === "function" ? [Blob] : []))
|
|
635
|
+
});
|
|
561
636
|
|
|
562
|
-
function _createSuper$
|
|
637
|
+
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
638
|
|
|
564
|
-
function _isNativeReflectConstruct$
|
|
639
|
+
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
640
|
var log$6 = Logger.scope("User");
|
|
566
641
|
/**
|
|
567
642
|
* Extended user information.
|
|
@@ -573,7 +648,7 @@ var log$6 = Logger.scope("User");
|
|
|
573
648
|
var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
574
649
|
_inherits__default["default"](User, _ReplayEventEmitter);
|
|
575
650
|
|
|
576
|
-
var _super = _createSuper$
|
|
651
|
+
var _super = _createSuper$9(User);
|
|
577
652
|
|
|
578
653
|
/**
|
|
579
654
|
* @internal
|
|
@@ -626,6 +701,22 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
626
701
|
* @event
|
|
627
702
|
*/
|
|
628
703
|
|
|
704
|
+
/**
|
|
705
|
+
* Fired when the client has subscribed to the user.
|
|
706
|
+
*
|
|
707
|
+
* Parameters:
|
|
708
|
+
* 1. {@link User} `user` - the user in question
|
|
709
|
+
* @event
|
|
710
|
+
*/
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Fired when the client has unsubscribed from the user.
|
|
714
|
+
*
|
|
715
|
+
* Parameters:
|
|
716
|
+
* 1. {@link User} `user` - the user in question
|
|
717
|
+
* @event
|
|
718
|
+
*/
|
|
719
|
+
|
|
629
720
|
|
|
630
721
|
_createClass__default["default"](User, [{
|
|
631
722
|
key: "identity",
|
|
@@ -720,7 +811,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
720
811
|
case 9:
|
|
721
812
|
updateAttributes = parseAttributes(value.value, "Retrieved malformed attributes from the server for user: ".concat(this.state.identity), log$6);
|
|
722
813
|
|
|
723
|
-
if (!
|
|
814
|
+
if (!isEqual(this.state.attributes, updateAttributes)) {
|
|
724
815
|
this.state.attributes = updateAttributes;
|
|
725
816
|
updateReasons.push("attributes");
|
|
726
817
|
}
|
|
@@ -839,6 +930,10 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
839
930
|
log$6.debug(_this3.state.entityName + " (" + _this3.state.identity + ") itemUpdated: " + args.item.key);
|
|
840
931
|
return _this3._update(args.item.key, args.item.data);
|
|
841
932
|
});
|
|
933
|
+
map.on("itemAdded", function (args) {
|
|
934
|
+
log$6.debug(_this3.state.entityName + " (" + _this3.state.identity + ") itemAdded: " + args.item.key);
|
|
935
|
+
return _this3._update(args.item.key, args.item.data);
|
|
936
|
+
});
|
|
842
937
|
return Promise.all([map.get("friendlyName").then(function (item) {
|
|
843
938
|
return _this3._update(item.key, item.data);
|
|
844
939
|
}), map.get("attributes").then(function (item) {
|
|
@@ -1047,7 +1142,7 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1047
1142
|
this.identity = identity;
|
|
1048
1143
|
this.entityName = entityName;
|
|
1049
1144
|
this.links = {
|
|
1050
|
-
self: "".concat(this.configuration.links.users, "/").concat(this.identity)
|
|
1145
|
+
self: "".concat(this.configuration.links.users, "/").concat(encodeURIComponent(this.identity))
|
|
1051
1146
|
};
|
|
1052
1147
|
|
|
1053
1148
|
this._resolveInitializationPromise();
|
|
@@ -1064,15 +1159,15 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1064
1159
|
return User;
|
|
1065
1160
|
}(replayEventEmitter.ReplayEventEmitter);
|
|
1066
1161
|
|
|
1067
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
|
1162
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], User.prototype, "updateAttributes", null);
|
|
1068
1163
|
|
|
1069
1164
|
__decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], User.prototype, "updateFriendlyName", null);
|
|
1070
1165
|
|
|
1071
|
-
function _createForOfIteratorHelper$
|
|
1166
|
+
function _createForOfIteratorHelper$5(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(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
1167
|
|
|
1073
|
-
function _unsupportedIterableToArray$
|
|
1168
|
+
function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(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$5(o, minLen); }
|
|
1074
1169
|
|
|
1075
|
-
function _arrayLikeToArray$
|
|
1170
|
+
function _arrayLikeToArray$5(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
1171
|
|
|
1077
1172
|
var Network = /*#__PURE__*/function () {
|
|
1078
1173
|
function Network(configuration, services) {
|
|
@@ -1093,7 +1188,7 @@ var Network = /*#__PURE__*/function () {
|
|
|
1093
1188
|
}, {
|
|
1094
1189
|
key: "cleanupCache",
|
|
1095
1190
|
value: function cleanupCache() {
|
|
1096
|
-
var _iterator = _createForOfIteratorHelper$
|
|
1191
|
+
var _iterator = _createForOfIteratorHelper$5(this.cache),
|
|
1097
1192
|
_step;
|
|
1098
1193
|
|
|
1099
1194
|
try {
|
|
@@ -1237,9 +1332,9 @@ _defineProperty__default["default"](NotificationTypes, "REMOVED_FROM_CONVERSATIO
|
|
|
1237
1332
|
|
|
1238
1333
|
_defineProperty__default["default"](NotificationTypes, "CONSUMPTION_UPDATE", "twilio.channel.consumption_update");
|
|
1239
1334
|
|
|
1240
|
-
function _createSuper$
|
|
1335
|
+
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
1336
|
|
|
1242
|
-
function _isNativeReflectConstruct$
|
|
1337
|
+
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
1338
|
var log$5 = Logger.scope("Participant");
|
|
1244
1339
|
/**
|
|
1245
1340
|
* A participant represents a remote client in a conversation.
|
|
@@ -1248,7 +1343,7 @@ var log$5 = Logger.scope("Participant");
|
|
|
1248
1343
|
var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1249
1344
|
_inherits__default["default"](Participant, _ReplayEventEmitter);
|
|
1250
1345
|
|
|
1251
|
-
var _super = _createSuper$
|
|
1346
|
+
var _super = _createSuper$8(Participant);
|
|
1252
1347
|
|
|
1253
1348
|
/**
|
|
1254
1349
|
* @internal
|
|
@@ -1294,6 +1389,24 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1294
1389
|
* @event
|
|
1295
1390
|
*/
|
|
1296
1391
|
|
|
1392
|
+
/**
|
|
1393
|
+
* Fired when the participant has stopped typing.
|
|
1394
|
+
*
|
|
1395
|
+
* Parameters:
|
|
1396
|
+
* 1. {@link Participant} `participant` - the participant in question
|
|
1397
|
+
* @event
|
|
1398
|
+
*/
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* Fired when the fields of the participant have been updated.
|
|
1402
|
+
*
|
|
1403
|
+
* Parameters:
|
|
1404
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
|
1405
|
+
* * {@link Participant} participant - the participant in question
|
|
1406
|
+
* * {@link ParticipantUpdateReason}[] updateReasons - array of reasons for the update
|
|
1407
|
+
* @event
|
|
1408
|
+
*/
|
|
1409
|
+
|
|
1297
1410
|
|
|
1298
1411
|
_createClass__default["default"](Participant, [{
|
|
1299
1412
|
key: "sid",
|
|
@@ -1420,8 +1533,9 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1420
1533
|
}
|
|
1421
1534
|
|
|
1422
1535
|
this.state.isTyping = true;
|
|
1423
|
-
this.emit(
|
|
1424
|
-
this.conversation.emit(
|
|
1536
|
+
this.emit(Participant.typingStarted, this);
|
|
1537
|
+
this.conversation.emit(Conversation.typingStarted, this); // @fixme layering violation
|
|
1538
|
+
|
|
1425
1539
|
this.state.typingTimeout = Number(setTimeout(function () {
|
|
1426
1540
|
return _this2._endTyping();
|
|
1427
1541
|
}, timeout));
|
|
@@ -1440,8 +1554,8 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1440
1554
|
}
|
|
1441
1555
|
|
|
1442
1556
|
this.state.isTyping = false;
|
|
1443
|
-
this.emit(
|
|
1444
|
-
this.conversation.emit(
|
|
1557
|
+
this.emit(Participant.typingEnded, this);
|
|
1558
|
+
this.conversation.emit(Conversation.typingEnded, this);
|
|
1445
1559
|
clearInterval(this.state.typingTimeout);
|
|
1446
1560
|
this.state.typingTimeout = null;
|
|
1447
1561
|
}
|
|
@@ -1456,7 +1570,7 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1456
1570
|
var updateReasons = [];
|
|
1457
1571
|
var updateAttributes = parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + this.state.sid, log$5);
|
|
1458
1572
|
|
|
1459
|
-
if (data.attributes && !
|
|
1573
|
+
if (data.attributes && !isEqual(this.state.attributes, updateAttributes)) {
|
|
1460
1574
|
this.state.attributes = updateAttributes;
|
|
1461
1575
|
updateReasons.push("attributes");
|
|
1462
1576
|
}
|
|
@@ -1494,13 +1608,13 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1494
1608
|
}
|
|
1495
1609
|
}
|
|
1496
1610
|
|
|
1497
|
-
if (data.bindings && !
|
|
1611
|
+
if (data.bindings && !isEqual(this.state.bindings, data.bindings)) {
|
|
1498
1612
|
this.state.bindings = data.bindings;
|
|
1499
1613
|
updateReasons.push("bindings");
|
|
1500
1614
|
}
|
|
1501
1615
|
|
|
1502
1616
|
if (updateReasons.length > 0) {
|
|
1503
|
-
this.emit(
|
|
1617
|
+
this.emit(Participant.updated, {
|
|
1504
1618
|
participant: this,
|
|
1505
1619
|
updateReasons: updateReasons
|
|
1506
1620
|
});
|
|
@@ -1618,11 +1732,11 @@ _defineProperty__default["default"](Participant, "typingEnded", "typingEnded");
|
|
|
1618
1732
|
|
|
1619
1733
|
_defineProperty__default["default"](Participant, "updated", "updated");
|
|
1620
1734
|
|
|
1621
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
|
1735
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Participant.prototype, "updateAttributes", null);
|
|
1622
1736
|
|
|
1623
|
-
function _createSuper$
|
|
1737
|
+
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
1738
|
|
|
1625
|
-
function _isNativeReflectConstruct$
|
|
1739
|
+
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
1740
|
var log$4 = Logger.scope("Participants");
|
|
1627
1741
|
/**
|
|
1628
1742
|
* @classdesc Represents the collection of participants for the conversation
|
|
@@ -1634,9 +1748,10 @@ var log$4 = Logger.scope("Participants");
|
|
|
1634
1748
|
var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1635
1749
|
_inherits__default["default"](Participants, _ReplayEventEmitter);
|
|
1636
1750
|
|
|
1637
|
-
var _super = _createSuper$
|
|
1751
|
+
var _super = _createSuper$7(Participants);
|
|
1638
1752
|
|
|
1639
|
-
|
|
1753
|
+
// passed in from Conversation
|
|
1754
|
+
function Participants(conversation, participants, links, services) {
|
|
1640
1755
|
var _this;
|
|
1641
1756
|
|
|
1642
1757
|
_classCallCheck__default["default"](this, Participants);
|
|
@@ -1648,7 +1763,6 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1648
1763
|
_this.conversation = conversation;
|
|
1649
1764
|
_this.participants = participants;
|
|
1650
1765
|
_this.links = links;
|
|
1651
|
-
_this.configuration = configuration;
|
|
1652
1766
|
_this.services = services;
|
|
1653
1767
|
return _this;
|
|
1654
1768
|
}
|
|
@@ -1691,21 +1805,22 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1691
1805
|
}()
|
|
1692
1806
|
}, {
|
|
1693
1807
|
key: "subscribe",
|
|
1694
|
-
value: function subscribe(
|
|
1808
|
+
value: function subscribe(arg) {
|
|
1695
1809
|
var _this2 = this;
|
|
1696
1810
|
|
|
1697
|
-
|
|
1698
|
-
id:
|
|
1811
|
+
var participantsMapPromise = typeof arg === "string" ? this.services.syncClient.map({
|
|
1812
|
+
id: arg,
|
|
1699
1813
|
mode: "open_existing"
|
|
1700
|
-
}).
|
|
1701
|
-
|
|
1814
|
+
}) : Promise.resolve(arg);
|
|
1815
|
+
return this.rosterEntityPromise = this.rosterEntityPromise || participantsMapPromise.then(function (rosterMap) {
|
|
1816
|
+
rosterMap.on(twilioSync.SyncMap.itemAdded, function (args) {
|
|
1702
1817
|
log$4.debug(_this2.conversation.sid + " itemAdded: " + args.item.key);
|
|
1703
1818
|
|
|
1704
1819
|
_this2.upsertParticipant(args.item.key, args.item.data).then(function (participant) {
|
|
1705
|
-
_this2.emit(
|
|
1820
|
+
_this2.emit(Conversation.participantJoined, participant);
|
|
1706
1821
|
});
|
|
1707
1822
|
});
|
|
1708
|
-
rosterMap.on(
|
|
1823
|
+
rosterMap.on(twilioSync.SyncMap.itemRemoved, function (args) {
|
|
1709
1824
|
log$4.debug(_this2.conversation.sid + " itemRemoved: " + args.key);
|
|
1710
1825
|
var participantSid = args.key;
|
|
1711
1826
|
|
|
@@ -1721,12 +1836,14 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1721
1836
|
return;
|
|
1722
1837
|
}
|
|
1723
1838
|
|
|
1724
|
-
_this2.emit(
|
|
1839
|
+
_this2.emit(Conversation.participantLeft, leftParticipant);
|
|
1725
1840
|
});
|
|
1726
|
-
rosterMap.on(
|
|
1841
|
+
rosterMap.on(twilioSync.SyncMap.itemUpdated, function (args) {
|
|
1727
1842
|
log$4.debug(_this2.conversation.sid + " itemUpdated: " + args.item.key);
|
|
1728
1843
|
|
|
1729
|
-
_this2.upsertParticipant(args.item.key, args.item.data)
|
|
1844
|
+
_this2.upsertParticipant(args.item.key, args.item.data).catch(function (e) {
|
|
1845
|
+
return log$4.error(e);
|
|
1846
|
+
});
|
|
1730
1847
|
});
|
|
1731
1848
|
var participantsPromises = [];
|
|
1732
1849
|
|
|
@@ -1820,8 +1937,8 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1820
1937
|
};
|
|
1821
1938
|
participant = new Participant(data, participantSid, this.conversation, links, this.services);
|
|
1822
1939
|
this.participants.set(participantSid, participant);
|
|
1823
|
-
participant.on(
|
|
1824
|
-
return _this3.emit(
|
|
1940
|
+
participant.on(Participant.updated, function (args) {
|
|
1941
|
+
return _this3.emit(Conversation.participantUpdated, args);
|
|
1825
1942
|
});
|
|
1826
1943
|
return _context3.abrupt("return", participant);
|
|
1827
1944
|
|
|
@@ -1969,7 +2086,6 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1969
2086
|
key: "add",
|
|
1970
2087
|
value: function () {
|
|
1971
2088
|
var _add = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(identity, attributes) {
|
|
1972
|
-
var participantResponse;
|
|
1973
2089
|
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context7) {
|
|
1974
2090
|
while (1) {
|
|
1975
2091
|
switch (_context7.prev = _context7.next) {
|
|
@@ -1981,14 +2097,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
1981
2097
|
});
|
|
1982
2098
|
|
|
1983
2099
|
case 2:
|
|
1984
|
-
participantResponse = _context7.sent;
|
|
1985
|
-
_context7.next = 5;
|
|
1986
|
-
return this.upsertParticipantFromResponse(participantResponse);
|
|
1987
|
-
|
|
1988
|
-
case 5:
|
|
1989
2100
|
return _context7.abrupt("return", _context7.sent);
|
|
1990
2101
|
|
|
1991
|
-
case
|
|
2102
|
+
case 3:
|
|
1992
2103
|
case "end":
|
|
1993
2104
|
return _context7.stop();
|
|
1994
2105
|
}
|
|
@@ -2014,7 +2125,6 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2014
2125
|
|
|
2015
2126
|
var attributes,
|
|
2016
2127
|
bindingOptions,
|
|
2017
|
-
participantResponse,
|
|
2018
2128
|
_args8 = arguments;
|
|
2019
2129
|
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context8) {
|
|
2020
2130
|
while (1) {
|
|
@@ -2034,14 +2144,9 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2034
2144
|
});
|
|
2035
2145
|
|
|
2036
2146
|
case 4:
|
|
2037
|
-
participantResponse = _context8.sent;
|
|
2038
|
-
_context8.next = 7;
|
|
2039
|
-
return this.upsertParticipantFromResponse(participantResponse);
|
|
2040
|
-
|
|
2041
|
-
case 7:
|
|
2042
2147
|
return _context8.abrupt("return", _context8.sent);
|
|
2043
2148
|
|
|
2044
|
-
case
|
|
2149
|
+
case 5:
|
|
2045
2150
|
case "end":
|
|
2046
2151
|
return _context8.stop();
|
|
2047
2152
|
}
|
|
@@ -2062,7 +2167,7 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2062
2167
|
}, {
|
|
2063
2168
|
key: "remove",
|
|
2064
2169
|
value: function remove(identity) {
|
|
2065
|
-
return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(identity));
|
|
2170
|
+
return this.services.commandExecutor.mutateResource("delete", "".concat(this.links.participants, "/").concat(encodeURIComponent(identity)));
|
|
2066
2171
|
}
|
|
2067
2172
|
}]);
|
|
2068
2173
|
|
|
@@ -2097,6 +2202,8 @@ var Media = /*#__PURE__*/function () {
|
|
|
2097
2202
|
* @internal
|
|
2098
2203
|
*/
|
|
2099
2204
|
function Media(data, services) {
|
|
2205
|
+
var _data$filename;
|
|
2206
|
+
|
|
2100
2207
|
_classCallCheck__default["default"](this, Media);
|
|
2101
2208
|
|
|
2102
2209
|
_defineProperty__default["default"](this, "mcsMedia", null);
|
|
@@ -2110,7 +2217,7 @@ var Media = /*#__PURE__*/function () {
|
|
|
2110
2217
|
this.state = {
|
|
2111
2218
|
sid: data.sid,
|
|
2112
2219
|
category: data.category,
|
|
2113
|
-
filename: data.filename,
|
|
2220
|
+
filename: (_data$filename = data.filename) !== null && _data$filename !== void 0 ? _data$filename : null,
|
|
2114
2221
|
contentType: data.contentType,
|
|
2115
2222
|
size: data.size
|
|
2116
2223
|
};
|
|
@@ -2183,10 +2290,12 @@ var Media = /*#__PURE__*/function () {
|
|
|
2183
2290
|
while (1) {
|
|
2184
2291
|
switch (_context.prev = _context.next) {
|
|
2185
2292
|
case 0:
|
|
2186
|
-
fetchMediaRequest = _this._fetchMcsMedia();
|
|
2293
|
+
fetchMediaRequest = _this.mcsMedia ? undefined : _this._fetchMcsMedia();
|
|
2187
2294
|
contentUrlRequest = (_this$mcsMedia = _this.mcsMedia) === null || _this$mcsMedia === void 0 ? void 0 : _this$mcsMedia.getContentUrl();
|
|
2188
2295
|
onCancel(function () {
|
|
2189
|
-
fetchMediaRequest
|
|
2296
|
+
if (fetchMediaRequest) {
|
|
2297
|
+
fetchMediaRequest.cancel();
|
|
2298
|
+
}
|
|
2190
2299
|
|
|
2191
2300
|
if (contentUrlRequest) {
|
|
2192
2301
|
contentUrlRequest.cancel();
|
|
@@ -2194,7 +2303,7 @@ var Media = /*#__PURE__*/function () {
|
|
|
2194
2303
|
});
|
|
2195
2304
|
_context.prev = 3;
|
|
2196
2305
|
|
|
2197
|
-
if (
|
|
2306
|
+
if (contentUrlRequest) {
|
|
2198
2307
|
_context.next = 9;
|
|
2199
2308
|
break;
|
|
2200
2309
|
}
|
|
@@ -2204,7 +2313,7 @@ var Media = /*#__PURE__*/function () {
|
|
|
2204
2313
|
|
|
2205
2314
|
case 7:
|
|
2206
2315
|
mcsMedia = _context.sent;
|
|
2207
|
-
contentUrlRequest = mcsMedia.getContentUrl();
|
|
2316
|
+
contentUrlRequest = mcsMedia === null || mcsMedia === void 0 ? void 0 : mcsMedia.getContentUrl();
|
|
2208
2317
|
|
|
2209
2318
|
case 9:
|
|
2210
2319
|
_context.t0 = resolve;
|
|
@@ -2261,13 +2370,11 @@ var Media = /*#__PURE__*/function () {
|
|
|
2261
2370
|
while (1) {
|
|
2262
2371
|
switch (_context2.prev = _context2.next) {
|
|
2263
2372
|
case 0:
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
if (!_this2.services.mcsClient) {
|
|
2267
|
-
_context2.next = 14;
|
|
2268
|
-
break;
|
|
2373
|
+
if (_this2.services.mcsClient === null) {
|
|
2374
|
+
reject(new Error("Media Content Service is unavailable"));
|
|
2269
2375
|
}
|
|
2270
2376
|
|
|
2377
|
+
request = _this2.services.mcsClient.get(_this2.state.sid);
|
|
2271
2378
|
onCancel(function () {
|
|
2272
2379
|
return request.cancel();
|
|
2273
2380
|
});
|
|
@@ -2277,27 +2384,22 @@ var Media = /*#__PURE__*/function () {
|
|
|
2277
2384
|
|
|
2278
2385
|
case 6:
|
|
2279
2386
|
_this2.mcsMedia = _context2.sent;
|
|
2387
|
+
_this2.state = _this2.mcsMedia._state();
|
|
2280
2388
|
resolve(_this2.mcsMedia);
|
|
2281
|
-
_context2.next =
|
|
2389
|
+
_context2.next = 14;
|
|
2282
2390
|
break;
|
|
2283
2391
|
|
|
2284
|
-
case
|
|
2285
|
-
_context2.prev =
|
|
2392
|
+
case 11:
|
|
2393
|
+
_context2.prev = 11;
|
|
2286
2394
|
_context2.t0 = _context2["catch"](3);
|
|
2287
2395
|
reject(_context2.t0);
|
|
2288
2396
|
|
|
2289
|
-
case 13:
|
|
2290
|
-
return _context2.abrupt("return");
|
|
2291
|
-
|
|
2292
2397
|
case 14:
|
|
2293
|
-
reject(new Error("Media Content Service is unavailable"));
|
|
2294
|
-
|
|
2295
|
-
case 15:
|
|
2296
2398
|
case "end":
|
|
2297
2399
|
return _context2.stop();
|
|
2298
2400
|
}
|
|
2299
2401
|
}
|
|
2300
|
-
}, _callee2, null, [[3,
|
|
2402
|
+
}, _callee2, null, [[3, 11]]);
|
|
2301
2403
|
}));
|
|
2302
2404
|
|
|
2303
2405
|
return function (_x4, _x5, _x6) {
|
|
@@ -2305,6 +2407,15 @@ var Media = /*#__PURE__*/function () {
|
|
|
2305
2407
|
};
|
|
2306
2408
|
}());
|
|
2307
2409
|
}
|
|
2410
|
+
/**
|
|
2411
|
+
* @internal
|
|
2412
|
+
*/
|
|
2413
|
+
|
|
2414
|
+
}, {
|
|
2415
|
+
key: "_state",
|
|
2416
|
+
value: function _state() {
|
|
2417
|
+
return this.state;
|
|
2418
|
+
}
|
|
2308
2419
|
}]);
|
|
2309
2420
|
|
|
2310
2421
|
return Media;
|
|
@@ -2314,7 +2425,7 @@ var Media = /*#__PURE__*/function () {
|
|
|
2314
2425
|
* Contains aggregated information about delivery statuses of a message across all participants
|
|
2315
2426
|
* of a conversation.
|
|
2316
2427
|
*
|
|
2317
|
-
* At any moment during the message delivery to a participant, the message can have zero or more of following
|
|
2428
|
+
* At any moment during the message delivery to a participant, the message can have zero or more of the following
|
|
2318
2429
|
* delivery statuses:
|
|
2319
2430
|
* * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
|
|
2320
2431
|
* * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
|
|
@@ -2557,22 +2668,274 @@ function DetailedDeliveryReceipt(descriptor) {
|
|
|
2557
2668
|
this.dateUpdated = descriptor.date_updated;
|
|
2558
2669
|
});
|
|
2559
2670
|
|
|
2560
|
-
|
|
2671
|
+
var collectActions = function collectActions(actions) {
|
|
2672
|
+
return actions.map(function (action) {
|
|
2673
|
+
var _action$id, _action$index, _action$phone, _action$url;
|
|
2561
2674
|
|
|
2562
|
-
|
|
2675
|
+
var rawData = JSON.stringify(action);
|
|
2563
2676
|
|
|
2564
|
-
|
|
2677
|
+
switch (action.type) {
|
|
2678
|
+
case "QUICK_REPLY":
|
|
2679
|
+
return {
|
|
2680
|
+
type: "reply",
|
|
2681
|
+
title: action.title,
|
|
2682
|
+
id: (_action$id = action.id) !== null && _action$id !== void 0 ? _action$id : "",
|
|
2683
|
+
index: (_action$index = action.index) !== null && _action$index !== void 0 ? _action$index : 0,
|
|
2684
|
+
rawData: rawData
|
|
2685
|
+
};
|
|
2565
2686
|
|
|
2566
|
-
|
|
2687
|
+
case "PHONE_NUMBER":
|
|
2688
|
+
return {
|
|
2689
|
+
type: "phone",
|
|
2690
|
+
title: action.title,
|
|
2691
|
+
phone: (_action$phone = action.phone) !== null && _action$phone !== void 0 ? _action$phone : "",
|
|
2692
|
+
rawData: rawData
|
|
2693
|
+
};
|
|
2694
|
+
|
|
2695
|
+
case "URL":
|
|
2696
|
+
return {
|
|
2697
|
+
type: "url",
|
|
2698
|
+
title: action.title,
|
|
2699
|
+
url: (_action$url = action.url) !== null && _action$url !== void 0 ? _action$url : "",
|
|
2700
|
+
rawData: rawData
|
|
2701
|
+
};
|
|
2702
|
+
|
|
2703
|
+
default:
|
|
2704
|
+
return {
|
|
2705
|
+
type: "other",
|
|
2706
|
+
rawData: rawData
|
|
2707
|
+
};
|
|
2708
|
+
}
|
|
2709
|
+
});
|
|
2710
|
+
};
|
|
2711
|
+
|
|
2712
|
+
var parseVariant = function parseVariant(type, data) {
|
|
2713
|
+
var rawData = JSON.stringify(data);
|
|
2714
|
+
|
|
2715
|
+
switch (type) {
|
|
2716
|
+
case "twilio/text":
|
|
2717
|
+
{
|
|
2718
|
+
var variant = data;
|
|
2719
|
+
return {
|
|
2720
|
+
type: "text",
|
|
2721
|
+
body: variant.body,
|
|
2722
|
+
rawData: rawData
|
|
2723
|
+
};
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
case "twilio/media":
|
|
2727
|
+
{
|
|
2728
|
+
var _variant = data;
|
|
2729
|
+
return {
|
|
2730
|
+
type: "media",
|
|
2731
|
+
body: _variant.body,
|
|
2732
|
+
media: _variant.media,
|
|
2733
|
+
rawData: rawData
|
|
2734
|
+
};
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
case "twilio/location":
|
|
2738
|
+
{
|
|
2739
|
+
var _variant2 = data;
|
|
2740
|
+
return {
|
|
2741
|
+
type: "location",
|
|
2742
|
+
longitude: _variant2.longitude,
|
|
2743
|
+
latitude: _variant2.latitude,
|
|
2744
|
+
label: _variant2.label,
|
|
2745
|
+
rawData: rawData
|
|
2746
|
+
};
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
case "twilio/quick-reply":
|
|
2750
|
+
{
|
|
2751
|
+
var _variant3 = data;
|
|
2752
|
+
return {
|
|
2753
|
+
type: "quickReply",
|
|
2754
|
+
body: _variant3.body,
|
|
2755
|
+
replies: _variant3.actions,
|
|
2756
|
+
rawData: rawData
|
|
2757
|
+
};
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
case "twilio/call-to-action":
|
|
2761
|
+
{
|
|
2762
|
+
var _variant4 = data;
|
|
2763
|
+
return {
|
|
2764
|
+
type: "callToAction",
|
|
2765
|
+
body: _variant4.body,
|
|
2766
|
+
actions: collectActions(_variant4.actions),
|
|
2767
|
+
rawData: rawData
|
|
2768
|
+
};
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
case "twilio/list-picker":
|
|
2772
|
+
{
|
|
2773
|
+
var _variant5 = data;
|
|
2774
|
+
return {
|
|
2775
|
+
type: "listPicker",
|
|
2776
|
+
body: _variant5.body,
|
|
2777
|
+
button: _variant5.button,
|
|
2778
|
+
items: _variant5.items,
|
|
2779
|
+
rawData: rawData
|
|
2780
|
+
};
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
case "twilio/card":
|
|
2784
|
+
{
|
|
2785
|
+
var _variant6$media, _variant6$actions;
|
|
2786
|
+
|
|
2787
|
+
var _variant6 = data;
|
|
2788
|
+
return {
|
|
2789
|
+
type: "card",
|
|
2790
|
+
title: _variant6.title,
|
|
2791
|
+
subtitle: _variant6.subtitle,
|
|
2792
|
+
media: (_variant6$media = _variant6.media) !== null && _variant6$media !== void 0 ? _variant6$media : [],
|
|
2793
|
+
actions: collectActions((_variant6$actions = _variant6.actions) !== null && _variant6$actions !== void 0 ? _variant6$actions : []),
|
|
2794
|
+
rawData: rawData
|
|
2795
|
+
};
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
default:
|
|
2799
|
+
return {
|
|
2800
|
+
type: "other",
|
|
2801
|
+
rawData: rawData
|
|
2802
|
+
};
|
|
2803
|
+
}
|
|
2804
|
+
};
|
|
2805
|
+
|
|
2806
|
+
var collectVariants = function collectVariants(variants) {
|
|
2807
|
+
var variantsMap = new Map();
|
|
2808
|
+
|
|
2809
|
+
for (var _i = 0, _Object$entries = Object.entries(variants); _i < _Object$entries.length; _i++) {
|
|
2810
|
+
var _Object$entries$_i = _slicedToArray__default["default"](_Object$entries[_i], 2),
|
|
2811
|
+
key = _Object$entries$_i[0],
|
|
2812
|
+
value = _Object$entries$_i[1];
|
|
2813
|
+
|
|
2814
|
+
variantsMap.set(key, parseVariant(key, value));
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
return variantsMap;
|
|
2818
|
+
};
|
|
2819
|
+
/**
|
|
2820
|
+
* Represents a variable for a content template. See
|
|
2821
|
+
* {@link ContentTemplate.variables}.
|
|
2822
|
+
*/
|
|
2823
|
+
|
|
2824
|
+
|
|
2825
|
+
var ContentTemplateVariable = /*#__PURE__*/function () {
|
|
2826
|
+
function ContentTemplateVariable(
|
|
2827
|
+
/**
|
|
2828
|
+
* Name of the variable.
|
|
2829
|
+
*/
|
|
2830
|
+
name,
|
|
2831
|
+
/**
|
|
2832
|
+
* Key of the variable
|
|
2833
|
+
*/
|
|
2834
|
+
value) {
|
|
2835
|
+
_classCallCheck__default["default"](this, ContentTemplateVariable);
|
|
2836
|
+
|
|
2837
|
+
this.name = name;
|
|
2838
|
+
this.value = value;
|
|
2839
|
+
}
|
|
2840
|
+
/**
|
|
2841
|
+
* Copies the variable with a new value.
|
|
2842
|
+
*
|
|
2843
|
+
* @param value The new value for the variable.
|
|
2844
|
+
*/
|
|
2845
|
+
|
|
2846
|
+
|
|
2847
|
+
_createClass__default["default"](ContentTemplateVariable, [{
|
|
2848
|
+
key: "copyWithValue",
|
|
2849
|
+
value: function copyWithValue(value) {
|
|
2850
|
+
return new ContentTemplateVariable(this.name, value);
|
|
2851
|
+
}
|
|
2852
|
+
}]);
|
|
2853
|
+
|
|
2854
|
+
return ContentTemplateVariable;
|
|
2855
|
+
}();
|
|
2856
|
+
/**
|
|
2857
|
+
* A rich content template.
|
|
2858
|
+
*
|
|
2859
|
+
* Use {@Link Client.getContentTemplates} to request all the templates available
|
|
2860
|
+
* for the current account.
|
|
2861
|
+
*/
|
|
2862
|
+
|
|
2863
|
+
|
|
2864
|
+
var ContentTemplate = /*#__PURE__*/_createClass__default["default"](
|
|
2865
|
+
/**
|
|
2866
|
+
* The server-assigned unique identifier for the template.
|
|
2867
|
+
*/
|
|
2868
|
+
|
|
2869
|
+
/**
|
|
2870
|
+
* Friendly name used to describe the content. Not visible to the recipient.
|
|
2871
|
+
*/
|
|
2872
|
+
|
|
2873
|
+
/**
|
|
2874
|
+
* Variables used by this template.
|
|
2875
|
+
*/
|
|
2876
|
+
|
|
2877
|
+
/**
|
|
2878
|
+
* Variants of the content. See {@link ContentData}.
|
|
2879
|
+
*/
|
|
2880
|
+
|
|
2881
|
+
/**
|
|
2882
|
+
* Date of creation.
|
|
2883
|
+
*/
|
|
2884
|
+
|
|
2885
|
+
/**
|
|
2886
|
+
* Date of the last update.
|
|
2887
|
+
*/
|
|
2888
|
+
|
|
2889
|
+
/**
|
|
2890
|
+
* @internal
|
|
2891
|
+
*/
|
|
2892
|
+
function ContentTemplate(contentTemplateResponse) {
|
|
2893
|
+
_classCallCheck__default["default"](this, ContentTemplate);
|
|
2894
|
+
|
|
2895
|
+
this.sid = contentTemplateResponse.sid;
|
|
2896
|
+
this.friendlyName = contentTemplateResponse.friendly_name;
|
|
2897
|
+
this.variables = Object.entries(JSON.parse(contentTemplateResponse.variables)).map(function (_ref) {
|
|
2898
|
+
var _ref2 = _slicedToArray__default["default"](_ref, 2),
|
|
2899
|
+
key = _ref2[0],
|
|
2900
|
+
value = _ref2[1];
|
|
2901
|
+
|
|
2902
|
+
return new ContentTemplateVariable(key, value);
|
|
2903
|
+
});
|
|
2904
|
+
this.variants = collectVariants(contentTemplateResponse.variants);
|
|
2905
|
+
this.dateCreated = new Date(contentTemplateResponse.date_created);
|
|
2906
|
+
this.dateUpdated = new Date(contentTemplateResponse.date_updated);
|
|
2907
|
+
});
|
|
2908
|
+
|
|
2909
|
+
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; }
|
|
2910
|
+
|
|
2911
|
+
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; }
|
|
2912
|
+
|
|
2913
|
+
function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
|
|
2914
|
+
|
|
2915
|
+
function _isNativeReflectConstruct$6() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
2916
|
+
|
|
2917
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
2918
|
+
|
|
2919
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
2920
|
+
|
|
2921
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
2567
2922
|
var log$3 = Logger.scope("Message");
|
|
2923
|
+
|
|
2924
|
+
var XHR = // eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
2925
|
+
global["XMLHttpRequest"] || {};
|
|
2568
2926
|
/**
|
|
2569
2927
|
* A message in a conversation.
|
|
2570
2928
|
*/
|
|
2571
2929
|
|
|
2930
|
+
|
|
2931
|
+
var _wrapMedia = /*#__PURE__*/new WeakSet();
|
|
2932
|
+
|
|
2933
|
+
var _assignMedias = /*#__PURE__*/new WeakSet();
|
|
2934
|
+
|
|
2572
2935
|
var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2573
2936
|
_inherits__default["default"](Message, _ReplayEventEmitter);
|
|
2574
2937
|
|
|
2575
|
-
var _super = _createSuper$
|
|
2938
|
+
var _super = _createSuper$6(Message);
|
|
2576
2939
|
|
|
2577
2940
|
/**
|
|
2578
2941
|
* Conversation that the message is in.
|
|
@@ -2582,13 +2945,18 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2582
2945
|
* @internal
|
|
2583
2946
|
*/
|
|
2584
2947
|
function Message(index, data, conversation, links, configuration, services) {
|
|
2585
|
-
var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid;
|
|
2948
|
+
var _data$text, _data$lastUpdatedBy, _data$type, _data$memberSid, _data$channelMetadata, _data$medias, _data$media;
|
|
2586
2949
|
|
|
2587
2950
|
var _this;
|
|
2588
2951
|
|
|
2589
2952
|
_classCallCheck__default["default"](this, Message);
|
|
2590
2953
|
|
|
2591
2954
|
_this = _super.call(this);
|
|
2955
|
+
|
|
2956
|
+
_classPrivateMethodInitSpec(_assertThisInitialized__default["default"](_this), _assignMedias);
|
|
2957
|
+
|
|
2958
|
+
_classPrivateMethodInitSpec(_assertThisInitialized__default["default"](_this), _wrapMedia);
|
|
2959
|
+
|
|
2592
2960
|
_this.conversation = conversation;
|
|
2593
2961
|
_this.links = links;
|
|
2594
2962
|
_this.configuration = configuration;
|
|
@@ -2598,21 +2966,22 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2598
2966
|
index: index,
|
|
2599
2967
|
author: data.author,
|
|
2600
2968
|
subject: data.subject,
|
|
2969
|
+
contentSid: data.contentSid,
|
|
2601
2970
|
body: (_data$text = data.text) !== null && _data$text !== void 0 ? _data$text : null,
|
|
2602
2971
|
timestamp: data.timestamp ? new Date(data.timestamp) : null,
|
|
2603
2972
|
dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,
|
|
2604
2973
|
lastUpdatedBy: (_data$lastUpdatedBy = data.lastUpdatedBy) !== null && _data$lastUpdatedBy !== void 0 ? _data$lastUpdatedBy : null,
|
|
2605
2974
|
attributes: parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(data.sid), log$3),
|
|
2606
2975
|
type: (_data$type = data.type) !== null && _data$type !== void 0 ? _data$type : "text",
|
|
2607
|
-
media:
|
|
2608
|
-
medias:
|
|
2609
|
-
return new Media(m, _this.services);
|
|
2610
|
-
}) : data.type === "media" && data.media && !data.medias ? [new Media(_objectSpread$3(_objectSpread$3({}, data.media), {}, {
|
|
2611
|
-
category: "media"
|
|
2612
|
-
}), _this.services)] : null,
|
|
2976
|
+
media: null,
|
|
2977
|
+
medias: null,
|
|
2613
2978
|
participantSid: (_data$memberSid = data.memberSid) !== null && _data$memberSid !== void 0 ? _data$memberSid : null,
|
|
2614
|
-
aggregatedDeliveryReceipt: data.delivery ? new AggregatedDeliveryReceipt(data.delivery) : null
|
|
2979
|
+
aggregatedDeliveryReceipt: data.delivery ? new AggregatedDeliveryReceipt(data.delivery) : null,
|
|
2980
|
+
hasChannelMetadata: (_data$channelMetadata = data.channelMetadata) !== null && _data$channelMetadata !== void 0 ? _data$channelMetadata : false
|
|
2615
2981
|
};
|
|
2982
|
+
|
|
2983
|
+
_classPrivateMethodGet(_assertThisInitialized__default["default"](_this), _assignMedias, _assignMedias2).call(_assertThisInitialized__default["default"](_this), (_data$medias = data.medias) !== null && _data$medias !== void 0 ? _data$medias : null, (_data$media = data.media) !== null && _data$media !== void 0 ? _data$media : null);
|
|
2984
|
+
|
|
2616
2985
|
return _this;
|
|
2617
2986
|
}
|
|
2618
2987
|
/**
|
|
@@ -2652,6 +3021,15 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2652
3021
|
get: function get() {
|
|
2653
3022
|
return this.state.subject;
|
|
2654
3023
|
}
|
|
3024
|
+
/**
|
|
3025
|
+
* Unique identifier of {@link ContentTemplate} for this message.
|
|
3026
|
+
*/
|
|
3027
|
+
|
|
3028
|
+
}, {
|
|
3029
|
+
key: "contentSid",
|
|
3030
|
+
get: function get() {
|
|
3031
|
+
return this.state.contentSid;
|
|
3032
|
+
}
|
|
2655
3033
|
/**
|
|
2656
3034
|
* Body of the message.
|
|
2657
3035
|
*/
|
|
@@ -2671,14 +3049,15 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2671
3049
|
return this.state.dateUpdated;
|
|
2672
3050
|
}
|
|
2673
3051
|
/**
|
|
2674
|
-
* Index of
|
|
2675
|
-
*
|
|
3052
|
+
* Index of this message in the conversation's list of messages.
|
|
3053
|
+
*
|
|
3054
|
+
* By design, the message indices may have arbitrary gaps between them,
|
|
2676
3055
|
* that does not necessarily mean they were deleted or otherwise modified - just that
|
|
2677
3056
|
* messages may have some non-contiguous indices even if they are being sent immediately one after another.
|
|
2678
3057
|
*
|
|
2679
3058
|
* Trying to use indices for some calculations is going to be unreliable.
|
|
2680
3059
|
*
|
|
2681
|
-
* To calculate the number of unread messages it is better to use the
|
|
3060
|
+
* To calculate the number of unread messages, it is better to use the Read Horizon API.
|
|
2682
3061
|
* See {@link Conversation.getUnreadMessagesCount} for details.
|
|
2683
3062
|
*/
|
|
2684
3063
|
|
|
@@ -2760,6 +3139,19 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2760
3139
|
get: function get() {
|
|
2761
3140
|
return this.state.aggregatedDeliveryReceipt;
|
|
2762
3141
|
}
|
|
3142
|
+
/**
|
|
3143
|
+
* @deprecated
|
|
3144
|
+
* Return a (possibly empty) array of media matching a specific set of categories.
|
|
3145
|
+
* Allowed category is so far only 'media'.
|
|
3146
|
+
* @param categories Array of categories to match.
|
|
3147
|
+
* @returns Array of media descriptors matching given categories.
|
|
3148
|
+
*/
|
|
3149
|
+
|
|
3150
|
+
}, {
|
|
3151
|
+
key: "getMediaByCategory",
|
|
3152
|
+
value: function getMediaByCategory(categories) {
|
|
3153
|
+
return this.getMediaByCategories(categories);
|
|
3154
|
+
}
|
|
2763
3155
|
/**
|
|
2764
3156
|
* Return a (possibly empty) array of media matching a specific set of categories.
|
|
2765
3157
|
* Allowed category is so far only 'media'.
|
|
@@ -2811,6 +3203,12 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2811
3203
|
}, {
|
|
2812
3204
|
key: "_update",
|
|
2813
3205
|
value: function _update(data) {
|
|
3206
|
+
var _data$medias2,
|
|
3207
|
+
_this2 = this,
|
|
3208
|
+
_this$state$medias2,
|
|
3209
|
+
_classPrivateMethodGe2,
|
|
3210
|
+
_this$state$media;
|
|
3211
|
+
|
|
2814
3212
|
var updateReasons = [];
|
|
2815
3213
|
|
|
2816
3214
|
if ((data.text || typeof data.text === "string") && data.text !== this.state.body) {
|
|
@@ -2845,7 +3243,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2845
3243
|
|
|
2846
3244
|
var updatedAttributes = parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(this.sid), log$3);
|
|
2847
3245
|
|
|
2848
|
-
if (!
|
|
3246
|
+
if (!isEqual(this.state.attributes, updatedAttributes)) {
|
|
2849
3247
|
this.state.attributes = updatedAttributes;
|
|
2850
3248
|
updateReasons.push("attributes");
|
|
2851
3249
|
}
|
|
@@ -2863,6 +3261,29 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2863
3261
|
|
|
2864
3262
|
updateReasons.push("deliveryReceipt");
|
|
2865
3263
|
}
|
|
3264
|
+
} // @fixme: This is a fairly heavy check.
|
|
3265
|
+
// Map data back and forth to perform a necessary field massage.
|
|
3266
|
+
|
|
3267
|
+
|
|
3268
|
+
var input = ((_data$medias2 = data.medias) !== null && _data$medias2 !== void 0 ? _data$medias2 : []).map(function (value) {
|
|
3269
|
+
var _classPrivateMethodGe;
|
|
3270
|
+
|
|
3271
|
+
return (_classPrivateMethodGe = _classPrivateMethodGet(_this2, _wrapMedia, _wrapMedia2).call(_this2, value)) === null || _classPrivateMethodGe === void 0 ? void 0 : _classPrivateMethodGe._state();
|
|
3272
|
+
}).filter(function (el) {
|
|
3273
|
+
return !(el === null);
|
|
3274
|
+
});
|
|
3275
|
+
var current = ((_this$state$medias2 = this.state.medias) !== null && _this$state$medias2 !== void 0 ? _this$state$medias2 : []).map(function (value) {
|
|
3276
|
+
return value._state();
|
|
3277
|
+
}).filter(function (el) {
|
|
3278
|
+
return !(el === null);
|
|
3279
|
+
});
|
|
3280
|
+
|
|
3281
|
+
if (!isEqual(input, current) || !isEqual((_classPrivateMethodGe2 = _classPrivateMethodGet(this, _wrapMedia, _wrapMedia2).call(this, data.media)) === null || _classPrivateMethodGe2 === void 0 ? void 0 : _classPrivateMethodGe2._state(), (_this$state$media = this.state.media) === null || _this$state$media === void 0 ? void 0 : _this$state$media._state())) {
|
|
3282
|
+
var _data$medias3, _data$media2;
|
|
3283
|
+
|
|
3284
|
+
_classPrivateMethodGet(this, _assignMedias, _assignMedias2).call(this, (_data$medias3 = data.medias) !== null && _data$medias3 !== void 0 ? _data$medias3 : null, (_data$media2 = data.media) !== null && _data$media2 !== void 0 ? _data$media2 : null);
|
|
3285
|
+
|
|
3286
|
+
updateReasons.push("media");
|
|
2866
3287
|
}
|
|
2867
3288
|
|
|
2868
3289
|
if (updateReasons.length > 0) {
|
|
@@ -2880,9 +3301,9 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2880
3301
|
key: "getParticipant",
|
|
2881
3302
|
value: function () {
|
|
2882
3303
|
var _getParticipant = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
2883
|
-
var
|
|
3304
|
+
var _this3 = this;
|
|
2884
3305
|
|
|
2885
|
-
var participant,
|
|
3306
|
+
var participant, errorMessage;
|
|
2886
3307
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
2887
3308
|
while (1) {
|
|
2888
3309
|
switch (_context.prev = _context.next) {
|
|
@@ -2896,7 +3317,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2896
3317
|
|
|
2897
3318
|
_context.next = 4;
|
|
2898
3319
|
return this.conversation.getParticipantBySid(this.state.participantSid).catch(function () {
|
|
2899
|
-
log$3.debug("Participant with sid \"".concat(
|
|
3320
|
+
log$3.debug("Participant with sid \"".concat(_this3.participantSid, "\" not found for message ").concat(_this3.sid));
|
|
2900
3321
|
return null;
|
|
2901
3322
|
});
|
|
2902
3323
|
|
|
@@ -2911,7 +3332,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2911
3332
|
|
|
2912
3333
|
_context.next = 8;
|
|
2913
3334
|
return this.conversation.getParticipantByIdentity(this.state.author).catch(function () {
|
|
2914
|
-
log$3.debug("Participant with identity \"".concat(
|
|
3335
|
+
log$3.debug("Participant with identity \"".concat(_this3.author, "\" not found for message ").concat(_this3.sid));
|
|
2915
3336
|
return null;
|
|
2916
3337
|
});
|
|
2917
3338
|
|
|
@@ -2927,26 +3348,26 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2927
3348
|
return _context.abrupt("return", participant);
|
|
2928
3349
|
|
|
2929
3350
|
case 11:
|
|
2930
|
-
|
|
3351
|
+
errorMessage = "Participant with ";
|
|
2931
3352
|
|
|
2932
3353
|
if (this.state.participantSid) {
|
|
2933
|
-
|
|
3354
|
+
errorMessage += "SID '" + this.state.participantSid + "' ";
|
|
2934
3355
|
}
|
|
2935
3356
|
|
|
2936
3357
|
if (this.state.author) {
|
|
2937
3358
|
if (this.state.participantSid) {
|
|
2938
|
-
|
|
3359
|
+
errorMessage += "or ";
|
|
2939
3360
|
}
|
|
2940
3361
|
|
|
2941
|
-
|
|
3362
|
+
errorMessage += "identity '" + this.state.author + "' ";
|
|
2942
3363
|
}
|
|
2943
3364
|
|
|
2944
|
-
if (
|
|
2945
|
-
|
|
3365
|
+
if (errorMessage === "Participant with ") {
|
|
3366
|
+
errorMessage = "Participant ";
|
|
2946
3367
|
}
|
|
2947
3368
|
|
|
2948
|
-
|
|
2949
|
-
throw new Error(
|
|
3369
|
+
errorMessage += "was not found";
|
|
3370
|
+
throw new Error(errorMessage);
|
|
2950
3371
|
|
|
2951
3372
|
case 17:
|
|
2952
3373
|
case "end":
|
|
@@ -2980,32 +3401,27 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
2980
3401
|
|
|
2981
3402
|
case 2:
|
|
2982
3403
|
paginator = _context2.sent;
|
|
2983
|
-
detailedDeliveryReceipts =
|
|
3404
|
+
detailedDeliveryReceipts = paginator.items;
|
|
2984
3405
|
|
|
2985
3406
|
case 4:
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
if (paginator.hasNextPage) {
|
|
2990
|
-
_context2.next = 8;
|
|
3407
|
+
if (!paginator.hasNextPage) {
|
|
3408
|
+
_context2.next = 11;
|
|
2991
3409
|
break;
|
|
2992
3410
|
}
|
|
2993
3411
|
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
case 8:
|
|
2997
|
-
_context2.next = 10;
|
|
3412
|
+
_context2.next = 7;
|
|
2998
3413
|
return paginator.nextPage();
|
|
2999
3414
|
|
|
3000
|
-
case
|
|
3415
|
+
case 7:
|
|
3001
3416
|
paginator = _context2.sent;
|
|
3417
|
+
detailedDeliveryReceipts = [].concat(_toConsumableArray__default["default"](detailedDeliveryReceipts), _toConsumableArray__default["default"](paginator.items));
|
|
3002
3418
|
_context2.next = 4;
|
|
3003
3419
|
break;
|
|
3004
3420
|
|
|
3005
|
-
case
|
|
3421
|
+
case 11:
|
|
3006
3422
|
return _context2.abrupt("return", detailedDeliveryReceipts);
|
|
3007
3423
|
|
|
3008
|
-
case
|
|
3424
|
+
case 12:
|
|
3009
3425
|
case "end":
|
|
3010
3426
|
return _context2.stop();
|
|
3011
3427
|
}
|
|
@@ -3121,6 +3537,59 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3121
3537
|
|
|
3122
3538
|
return updateAttributes;
|
|
3123
3539
|
}()
|
|
3540
|
+
/**
|
|
3541
|
+
* @deprecated
|
|
3542
|
+
* Get content URLs for all media attachments in the given set using a single operation.
|
|
3543
|
+
* @param contentSet Set of media attachments to query content URLs.
|
|
3544
|
+
*/
|
|
3545
|
+
|
|
3546
|
+
}, {
|
|
3547
|
+
key: "attachTemporaryUrlsFor",
|
|
3548
|
+
value: function () {
|
|
3549
|
+
var _attachTemporaryUrlsFor = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(contentSet) {
|
|
3550
|
+
var _this4 = this;
|
|
3551
|
+
|
|
3552
|
+
var sids;
|
|
3553
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context6) {
|
|
3554
|
+
while (1) {
|
|
3555
|
+
switch (_context6.prev = _context6.next) {
|
|
3556
|
+
case 0:
|
|
3557
|
+
// We ignore existing mcsMedia members of each of the media entries.
|
|
3558
|
+
// Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.
|
|
3559
|
+
sids = contentSet === null || contentSet === void 0 ? void 0 : contentSet.map(function (m) {
|
|
3560
|
+
return m.sid;
|
|
3561
|
+
});
|
|
3562
|
+
|
|
3563
|
+
if (!(this.services.mcsClient && sids)) {
|
|
3564
|
+
_context6.next = 7;
|
|
3565
|
+
break;
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
_context6.next = 4;
|
|
3569
|
+
return this.services.mcsClient.mediaSetGet(sids);
|
|
3570
|
+
|
|
3571
|
+
case 4:
|
|
3572
|
+
return _context6.abrupt("return", _context6.sent.map(function (item) {
|
|
3573
|
+
return new Media(item, _this4.services);
|
|
3574
|
+
}));
|
|
3575
|
+
|
|
3576
|
+
case 7:
|
|
3577
|
+
throw new Error("Media Content Service is unavailable");
|
|
3578
|
+
|
|
3579
|
+
case 8:
|
|
3580
|
+
case "end":
|
|
3581
|
+
return _context6.stop();
|
|
3582
|
+
}
|
|
3583
|
+
}
|
|
3584
|
+
}, _callee6, this);
|
|
3585
|
+
}));
|
|
3586
|
+
|
|
3587
|
+
function attachTemporaryUrlsFor(_x3) {
|
|
3588
|
+
return _attachTemporaryUrlsFor.apply(this, arguments);
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
return attachTemporaryUrlsFor;
|
|
3592
|
+
}()
|
|
3124
3593
|
/**
|
|
3125
3594
|
* Get content URLs for all media attachments in the given set using a single operation.
|
|
3126
3595
|
* @param contentSet Set of media attachments to query content URLs.
|
|
@@ -3144,53 +3613,53 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3144
3613
|
}, {
|
|
3145
3614
|
key: "getTemporaryContentUrlsForMediaSids",
|
|
3146
3615
|
value: function getTemporaryContentUrlsForMediaSids(mediaSids) {
|
|
3147
|
-
var
|
|
3616
|
+
var _this5 = this;
|
|
3148
3617
|
|
|
3149
3618
|
return new mcsClient.CancellablePromise( /*#__PURE__*/function () {
|
|
3150
|
-
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
3619
|
+
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(resolve, reject, onCancel) {
|
|
3151
3620
|
var mediaGetRequest, urls;
|
|
3152
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
3621
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context7) {
|
|
3153
3622
|
while (1) {
|
|
3154
|
-
switch (
|
|
3623
|
+
switch (_context7.prev = _context7.next) {
|
|
3155
3624
|
case 0:
|
|
3156
|
-
mediaGetRequest =
|
|
3625
|
+
mediaGetRequest = _this5.services.mcsClient.mediaSetGetContentUrls(mediaSids !== null && mediaSids !== void 0 ? mediaSids : []);
|
|
3157
3626
|
|
|
3158
|
-
if (!(!
|
|
3159
|
-
|
|
3627
|
+
if (!(!_this5.services.mcsClient || !mediaSids)) {
|
|
3628
|
+
_context7.next = 4;
|
|
3160
3629
|
break;
|
|
3161
3630
|
}
|
|
3162
3631
|
|
|
3163
3632
|
reject(new Error("Media Content Service is unavailable"));
|
|
3164
|
-
return
|
|
3633
|
+
return _context7.abrupt("return");
|
|
3165
3634
|
|
|
3166
3635
|
case 4:
|
|
3167
3636
|
onCancel(function () {
|
|
3168
3637
|
mediaGetRequest.cancel();
|
|
3169
3638
|
});
|
|
3170
|
-
|
|
3171
|
-
|
|
3639
|
+
_context7.prev = 5;
|
|
3640
|
+
_context7.next = 8;
|
|
3172
3641
|
return mediaGetRequest;
|
|
3173
3642
|
|
|
3174
3643
|
case 8:
|
|
3175
|
-
urls =
|
|
3644
|
+
urls = _context7.sent;
|
|
3176
3645
|
resolve(urls);
|
|
3177
|
-
|
|
3646
|
+
_context7.next = 15;
|
|
3178
3647
|
break;
|
|
3179
3648
|
|
|
3180
3649
|
case 12:
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
reject(
|
|
3650
|
+
_context7.prev = 12;
|
|
3651
|
+
_context7.t0 = _context7["catch"](5);
|
|
3652
|
+
reject(_context7.t0);
|
|
3184
3653
|
|
|
3185
3654
|
case 15:
|
|
3186
3655
|
case "end":
|
|
3187
|
-
return
|
|
3656
|
+
return _context7.stop();
|
|
3188
3657
|
}
|
|
3189
3658
|
}
|
|
3190
|
-
},
|
|
3659
|
+
}, _callee7, null, [[5, 12]]);
|
|
3191
3660
|
}));
|
|
3192
3661
|
|
|
3193
|
-
return function (
|
|
3662
|
+
return function (_x4, _x5, _x6) {
|
|
3194
3663
|
return _ref.apply(this, arguments);
|
|
3195
3664
|
};
|
|
3196
3665
|
}());
|
|
@@ -3213,25 +3682,25 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3213
3682
|
}, {
|
|
3214
3683
|
key: "_getDetailedDeliveryReceiptsPaginator",
|
|
3215
3684
|
value: function () {
|
|
3216
|
-
var _getDetailedDeliveryReceiptsPaginator2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
3217
|
-
var
|
|
3685
|
+
var _getDetailedDeliveryReceiptsPaginator2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8(options) {
|
|
3686
|
+
var _this6 = this;
|
|
3218
3687
|
|
|
3219
3688
|
var messagesReceiptsUrl, url, response;
|
|
3220
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
3689
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context8) {
|
|
3221
3690
|
while (1) {
|
|
3222
|
-
switch (
|
|
3691
|
+
switch (_context8.prev = _context8.next) {
|
|
3223
3692
|
case 0:
|
|
3224
3693
|
messagesReceiptsUrl = this.configuration.links.messagesReceipts.replace("%s", this.conversation.sid).replace("%s", this.sid);
|
|
3225
3694
|
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
|
-
|
|
3695
|
+
_context8.next = 4;
|
|
3227
3696
|
return this.services.network.get(url);
|
|
3228
3697
|
|
|
3229
3698
|
case 4:
|
|
3230
|
-
response =
|
|
3231
|
-
return
|
|
3699
|
+
response = _context8.sent;
|
|
3700
|
+
return _context8.abrupt("return", new RestPaginator(response.body.delivery_receipts.map(function (x) {
|
|
3232
3701
|
return new DetailedDeliveryReceipt(x);
|
|
3233
3702
|
}), function (pageToken, pageSize) {
|
|
3234
|
-
return
|
|
3703
|
+
return _this6._getDetailedDeliveryReceiptsPaginator({
|
|
3235
3704
|
pageToken: pageToken,
|
|
3236
3705
|
pageSize: pageSize
|
|
3237
3706
|
});
|
|
@@ -3239,46 +3708,290 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3239
3708
|
|
|
3240
3709
|
case 6:
|
|
3241
3710
|
case "end":
|
|
3242
|
-
return
|
|
3711
|
+
return _context8.stop();
|
|
3243
3712
|
}
|
|
3244
3713
|
}
|
|
3245
|
-
},
|
|
3714
|
+
}, _callee8, this);
|
|
3246
3715
|
}));
|
|
3247
3716
|
|
|
3248
|
-
function _getDetailedDeliveryReceiptsPaginator(
|
|
3717
|
+
function _getDetailedDeliveryReceiptsPaginator(_x7) {
|
|
3249
3718
|
return _getDetailedDeliveryReceiptsPaginator2.apply(this, arguments);
|
|
3250
3719
|
}
|
|
3251
3720
|
|
|
3252
3721
|
return _getDetailedDeliveryReceiptsPaginator;
|
|
3253
3722
|
}()
|
|
3723
|
+
/**
|
|
3724
|
+
* Get the {@link ContentData} for this message. Resolves to `null` when
|
|
3725
|
+
* {@link Message.contentSid} is null.
|
|
3726
|
+
*/
|
|
3727
|
+
|
|
3728
|
+
}, {
|
|
3729
|
+
key: "getContentData",
|
|
3730
|
+
value: function getContentData() {
|
|
3731
|
+
var _this7 = this;
|
|
3732
|
+
|
|
3733
|
+
return new mcsClient.CancellablePromise( /*#__PURE__*/function () {
|
|
3734
|
+
var _ref2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9(resolve, reject, onCancel) {
|
|
3735
|
+
var bodies, twilioPrefix, filteredMedias, contentMedia, urlPromise, url, jsonStringPromise, json, jsonString, dataType;
|
|
3736
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context9) {
|
|
3737
|
+
while (1) {
|
|
3738
|
+
switch (_context9.prev = _context9.next) {
|
|
3739
|
+
case 0:
|
|
3740
|
+
if (!(_this7.state.contentSid === null)) {
|
|
3741
|
+
_context9.next = 3;
|
|
3742
|
+
break;
|
|
3743
|
+
}
|
|
3744
|
+
|
|
3745
|
+
resolve(null);
|
|
3746
|
+
return _context9.abrupt("return");
|
|
3747
|
+
|
|
3748
|
+
case 3:
|
|
3749
|
+
bodies = _this7.getMediaByCategories(["body"]);
|
|
3750
|
+
|
|
3751
|
+
if (!(bodies === null)) {
|
|
3752
|
+
_context9.next = 7;
|
|
3753
|
+
break;
|
|
3754
|
+
}
|
|
3755
|
+
|
|
3756
|
+
resolve(null);
|
|
3757
|
+
return _context9.abrupt("return");
|
|
3758
|
+
|
|
3759
|
+
case 7:
|
|
3760
|
+
twilioPrefix = "application/x-vnd.com.twilio.rich.";
|
|
3761
|
+
filteredMedias = bodies.filter(function (media) {
|
|
3762
|
+
return media.contentType.startsWith(twilioPrefix);
|
|
3763
|
+
});
|
|
3764
|
+
|
|
3765
|
+
if (!(filteredMedias.length === 0)) {
|
|
3766
|
+
_context9.next = 12;
|
|
3767
|
+
break;
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
resolve(null);
|
|
3771
|
+
return _context9.abrupt("return");
|
|
3772
|
+
|
|
3773
|
+
case 12:
|
|
3774
|
+
contentMedia = filteredMedias[0];
|
|
3775
|
+
urlPromise = contentMedia.getContentTemporaryUrl();
|
|
3776
|
+
onCancel(function () {
|
|
3777
|
+
urlPromise.cancel();
|
|
3778
|
+
});
|
|
3779
|
+
_context9.prev = 15;
|
|
3780
|
+
_context9.next = 18;
|
|
3781
|
+
return urlPromise;
|
|
3782
|
+
|
|
3783
|
+
case 18:
|
|
3784
|
+
url = _context9.sent;
|
|
3785
|
+
_context9.next = 25;
|
|
3786
|
+
break;
|
|
3787
|
+
|
|
3788
|
+
case 21:
|
|
3789
|
+
_context9.prev = 21;
|
|
3790
|
+
_context9.t0 = _context9["catch"](15);
|
|
3791
|
+
reject(_context9.t0);
|
|
3792
|
+
return _context9.abrupt("return");
|
|
3793
|
+
|
|
3794
|
+
case 25:
|
|
3795
|
+
if (!(url === null)) {
|
|
3796
|
+
_context9.next = 28;
|
|
3797
|
+
break;
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
resolve(null);
|
|
3801
|
+
return _context9.abrupt("return");
|
|
3802
|
+
|
|
3803
|
+
case 28:
|
|
3804
|
+
jsonStringPromise = new Promise(function (resolve, reject) {
|
|
3805
|
+
var _url;
|
|
3806
|
+
|
|
3807
|
+
var isCancelled = false;
|
|
3808
|
+
var xhr = new XHR();
|
|
3809
|
+
xhr.open("GET", (_url = url) !== null && _url !== void 0 ? _url : "", true);
|
|
3810
|
+
xhr.responseType = "text";
|
|
3811
|
+
|
|
3812
|
+
xhr.onreadystatechange = function () {
|
|
3813
|
+
if (xhr.readyState !== 4 || isCancelled) {
|
|
3814
|
+
return;
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3817
|
+
resolve(xhr.responseText);
|
|
3818
|
+
};
|
|
3819
|
+
|
|
3820
|
+
xhr.onerror = function () {
|
|
3821
|
+
reject(xhr.statusText);
|
|
3822
|
+
};
|
|
3823
|
+
|
|
3824
|
+
onCancel(function () {
|
|
3825
|
+
isCancelled = true;
|
|
3826
|
+
xhr.abort();
|
|
3827
|
+
reject(new Error("XHR has been aborted"));
|
|
3828
|
+
});
|
|
3829
|
+
xhr.send();
|
|
3830
|
+
});
|
|
3831
|
+
_context9.prev = 29;
|
|
3832
|
+
_context9.next = 32;
|
|
3833
|
+
return jsonStringPromise;
|
|
3834
|
+
|
|
3835
|
+
case 32:
|
|
3836
|
+
jsonString = _context9.sent;
|
|
3837
|
+
json = JSON.parse(jsonString);
|
|
3838
|
+
_context9.next = 40;
|
|
3839
|
+
break;
|
|
3840
|
+
|
|
3841
|
+
case 36:
|
|
3842
|
+
_context9.prev = 36;
|
|
3843
|
+
_context9.t1 = _context9["catch"](29);
|
|
3844
|
+
reject(_context9.t1);
|
|
3845
|
+
return _context9.abrupt("return");
|
|
3846
|
+
|
|
3847
|
+
case 40:
|
|
3848
|
+
dataType = contentMedia.contentType.replace(twilioPrefix, "").replace(".", "/");
|
|
3849
|
+
resolve(parseVariant(dataType, json.data));
|
|
3850
|
+
|
|
3851
|
+
case 42:
|
|
3852
|
+
case "end":
|
|
3853
|
+
return _context9.stop();
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
}, _callee9, null, [[15, 21], [29, 36]]);
|
|
3857
|
+
}));
|
|
3858
|
+
|
|
3859
|
+
return function (_x8, _x9, _x10) {
|
|
3860
|
+
return _ref2.apply(this, arguments);
|
|
3861
|
+
};
|
|
3862
|
+
}());
|
|
3863
|
+
}
|
|
3864
|
+
/**
|
|
3865
|
+
* Get the {@link ChannelMetadata} for this message. Resolves to `null` if
|
|
3866
|
+
* the message doesn't have any channel metadata.
|
|
3867
|
+
*/
|
|
3868
|
+
|
|
3869
|
+
}, {
|
|
3870
|
+
key: "getChannelMetadata",
|
|
3871
|
+
value: function () {
|
|
3872
|
+
var _getChannelMetadata = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee10() {
|
|
3873
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee10$(_context10) {
|
|
3874
|
+
while (1) {
|
|
3875
|
+
switch (_context10.prev = _context10.next) {
|
|
3876
|
+
case 0:
|
|
3877
|
+
if (this.state.hasChannelMetadata) {
|
|
3878
|
+
_context10.next = 2;
|
|
3879
|
+
break;
|
|
3880
|
+
}
|
|
3881
|
+
|
|
3882
|
+
return _context10.abrupt("return", null);
|
|
3883
|
+
|
|
3884
|
+
case 2:
|
|
3885
|
+
_context10.next = 4;
|
|
3886
|
+
return this.services.channelMetadataClient.getChannelMetadata(this.conversation.sid, this.sid);
|
|
3887
|
+
|
|
3888
|
+
case 4:
|
|
3889
|
+
return _context10.abrupt("return", _context10.sent);
|
|
3890
|
+
|
|
3891
|
+
case 5:
|
|
3892
|
+
case "end":
|
|
3893
|
+
return _context10.stop();
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
}, _callee10, this);
|
|
3897
|
+
}));
|
|
3898
|
+
|
|
3899
|
+
function getChannelMetadata() {
|
|
3900
|
+
return _getChannelMetadata.apply(this, arguments);
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
return getChannelMetadata;
|
|
3904
|
+
}()
|
|
3905
|
+
/**
|
|
3906
|
+
* Get recipients of the message.
|
|
3907
|
+
*/
|
|
3908
|
+
|
|
3909
|
+
}, {
|
|
3910
|
+
key: "getMessageRecipients",
|
|
3911
|
+
value: function () {
|
|
3912
|
+
var _getMessageRecipients = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee11() {
|
|
3913
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee11$(_context11) {
|
|
3914
|
+
while (1) {
|
|
3915
|
+
switch (_context11.prev = _context11.next) {
|
|
3916
|
+
case 0:
|
|
3917
|
+
_context11.next = 2;
|
|
3918
|
+
return this.services.messageRecipientsClient.getRecipientsFromMessage(this.conversation.sid, this.sid);
|
|
3919
|
+
|
|
3920
|
+
case 2:
|
|
3921
|
+
return _context11.abrupt("return", _context11.sent);
|
|
3922
|
+
|
|
3923
|
+
case 3:
|
|
3924
|
+
case "end":
|
|
3925
|
+
return _context11.stop();
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
}, _callee11, this);
|
|
3929
|
+
}));
|
|
3930
|
+
|
|
3931
|
+
function getMessageRecipients() {
|
|
3932
|
+
return _getMessageRecipients.apply(this, arguments);
|
|
3933
|
+
}
|
|
3934
|
+
|
|
3935
|
+
return getMessageRecipients;
|
|
3936
|
+
}()
|
|
3254
3937
|
}]);
|
|
3255
3938
|
|
|
3256
3939
|
return Message;
|
|
3257
3940
|
}(replayEventEmitter.ReplayEventEmitter);
|
|
3258
3941
|
|
|
3942
|
+
function _wrapMedia2(media) {
|
|
3943
|
+
var category = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
3944
|
+
return media ? category ? new Media(_objectSpread$4(_objectSpread$4({}, media), {}, {
|
|
3945
|
+
category: category
|
|
3946
|
+
}), this.services) : new Media(media, this.services) : null;
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3949
|
+
function _assignMedias2(medias, media) {
|
|
3950
|
+
var _this8 = this;
|
|
3951
|
+
|
|
3952
|
+
this.state.media = _classPrivateMethodGet(this, _wrapMedia, _wrapMedia2).call(this, media); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3953
|
+
// @ts-ignore
|
|
3954
|
+
|
|
3955
|
+
this.state.medias = medias ? medias.map(function (m) {
|
|
3956
|
+
return _classPrivateMethodGet(_this8, _wrapMedia, _wrapMedia2).call(_this8, m);
|
|
3957
|
+
}).filter(function (el) {
|
|
3958
|
+
return el !== null;
|
|
3959
|
+
}) : media && !medias ? [_classPrivateMethodGet(this, _wrapMedia, _wrapMedia2).call(this, media, "media")].filter(function (el) {
|
|
3960
|
+
return el !== null;
|
|
3961
|
+
}) : null;
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3259
3964
|
_defineProperty__default["default"](Message, "updated", "updated");
|
|
3260
3965
|
|
|
3966
|
+
__decorate([deprecationDecorator.deprecated("getMediaByCategory", "getMediaByCategories"), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", Array)], Message.prototype, "getMediaByCategory", null);
|
|
3967
|
+
|
|
3261
3968
|
__decorate([declarativeTypeValidator.validateTypes([declarativeTypeValidator.nonEmptyString, "undefined"]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailBody", null);
|
|
3262
3969
|
|
|
3263
3970
|
__decorate([declarativeTypeValidator.validateTypes([declarativeTypeValidator.nonEmptyString, "undefined"]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Media)], Message.prototype, "getEmailHistory", null);
|
|
3264
3971
|
|
|
3265
3972
|
__decorate([declarativeTypeValidator.validateTypesAsync("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Message.prototype, "updateBody", null);
|
|
3266
3973
|
|
|
3267
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
|
3974
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Message.prototype, "updateAttributes", null);
|
|
3975
|
+
|
|
3976
|
+
__decorate([deprecationDecorator.deprecated("attachTemporaryUrlsFor", "getTemporaryContentUrlsForMedia"), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", Promise)], Message.prototype, "attachTemporaryUrlsFor", null);
|
|
3268
3977
|
|
|
3269
3978
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyArray("media", Media)), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", mcsClient.CancellablePromise)], Message.prototype, "getTemporaryContentUrlsForMedia", null);
|
|
3270
3979
|
|
|
3271
3980
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyArray("strings", "string")), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", mcsClient.CancellablePromise)], Message.prototype, "getTemporaryContentUrlsForMediaSids", null);
|
|
3272
3981
|
|
|
3273
|
-
function
|
|
3982
|
+
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; }
|
|
3274
3983
|
|
|
3275
|
-
function
|
|
3984
|
+
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; }
|
|
3276
3985
|
|
|
3277
|
-
function
|
|
3986
|
+
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; } } }; }
|
|
3278
3987
|
|
|
3279
|
-
function
|
|
3988
|
+
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); }
|
|
3280
3989
|
|
|
3281
|
-
function
|
|
3990
|
+
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; }
|
|
3991
|
+
|
|
3992
|
+
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); }; }
|
|
3993
|
+
|
|
3994
|
+
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
3995
|
var log$2 = Logger.scope("Messages");
|
|
3283
3996
|
/**
|
|
3284
3997
|
* Represents the collection of messages in a conversation
|
|
@@ -3287,7 +4000,7 @@ var log$2 = Logger.scope("Messages");
|
|
|
3287
4000
|
var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3288
4001
|
_inherits__default["default"](Messages, _ReplayEventEmitter);
|
|
3289
4002
|
|
|
3290
|
-
var _super = _createSuper$
|
|
4003
|
+
var _super = _createSuper$5(Messages);
|
|
3291
4004
|
|
|
3292
4005
|
function Messages(conversation, configuration, services) {
|
|
3293
4006
|
var _this;
|
|
@@ -3304,14 +4017,15 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3304
4017
|
}
|
|
3305
4018
|
/**
|
|
3306
4019
|
* Subscribe to the Messages Event Stream
|
|
3307
|
-
* @param
|
|
4020
|
+
* @param arg - Name of the Sync object, or the SyncList itself, that
|
|
4021
|
+
* represents the Messages resource.
|
|
3308
4022
|
*/
|
|
3309
4023
|
|
|
3310
4024
|
|
|
3311
4025
|
_createClass__default["default"](Messages, [{
|
|
3312
4026
|
key: "subscribe",
|
|
3313
4027
|
value: function () {
|
|
3314
|
-
var _subscribe = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(
|
|
4028
|
+
var _subscribe = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(arg) {
|
|
3315
4029
|
var _this2 = this;
|
|
3316
4030
|
|
|
3317
4031
|
var list;
|
|
@@ -3327,10 +4041,10 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3327
4041
|
return _context.abrupt("return", this.messagesListPromise);
|
|
3328
4042
|
|
|
3329
4043
|
case 2:
|
|
3330
|
-
this.messagesListPromise = this.services.syncClient.list({
|
|
3331
|
-
id:
|
|
4044
|
+
this.messagesListPromise = typeof arg === "string" ? this.services.syncClient.list({
|
|
4045
|
+
id: arg,
|
|
3332
4046
|
mode: "open_existing"
|
|
3333
|
-
});
|
|
4047
|
+
}) : Promise.resolve(arg);
|
|
3334
4048
|
_context.prev = 3;
|
|
3335
4049
|
_context.next = 6;
|
|
3336
4050
|
return this.messagesListPromise;
|
|
@@ -3481,7 +4195,7 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3481
4195
|
return request.cancel();
|
|
3482
4196
|
});
|
|
3483
4197
|
});
|
|
3484
|
-
_iterator = _createForOfIteratorHelper$
|
|
4198
|
+
_iterator = _createForOfIteratorHelper$4(message.mediaContent);
|
|
3485
4199
|
_context3.prev = 4;
|
|
3486
4200
|
|
|
3487
4201
|
_iterator.s();
|
|
@@ -3543,7 +4257,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
3543
4257
|
media_sids: media.map(function (m) {
|
|
3544
4258
|
return m.sid;
|
|
3545
4259
|
}),
|
|
3546
|
-
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined
|
|
4260
|
+
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined,
|
|
4261
|
+
content_sid: message.contentSid,
|
|
4262
|
+
content_variables: typeof message.contentVariables !== "undefined" ? JSON.stringify(message.contentVariables.reduce(function (accum, current) {
|
|
4263
|
+
return _objectSpread$3(_objectSpread$3({}, accum), {}, _defineProperty__default["default"]({}, current.name, current.value));
|
|
4264
|
+
}, {})) : undefined
|
|
3547
4265
|
});
|
|
3548
4266
|
_context3.prev = 34;
|
|
3549
4267
|
_context3.t4 = resolve;
|
|
@@ -4014,6 +4732,29 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
|
4014
4732
|
this.emailHistories.set(contentType, history);
|
|
4015
4733
|
return this;
|
|
4016
4734
|
}
|
|
4735
|
+
/**
|
|
4736
|
+
* Adds {@link ContentTemplate} SID for the message alongside optional
|
|
4737
|
+
* variables. When no variables provided, the default values will be used.
|
|
4738
|
+
*
|
|
4739
|
+
* Adding the content SID converts the message to a rich message. In this
|
|
4740
|
+
* case, other fields are ignored and the message is sent using the content
|
|
4741
|
+
* from the the {@link ContentTemplate}.
|
|
4742
|
+
*
|
|
4743
|
+
* Use {@link Client.getContentTemplates} to request all available
|
|
4744
|
+
* {@link ContentTemplate}s.
|
|
4745
|
+
*
|
|
4746
|
+
* @param contentSid SID of the {@link ContentTemplate}
|
|
4747
|
+
* @param variables Custom variables to resolve the template.
|
|
4748
|
+
*/
|
|
4749
|
+
|
|
4750
|
+
}, {
|
|
4751
|
+
key: "setContentTemplate",
|
|
4752
|
+
value: function setContentTemplate(contentSid) {
|
|
4753
|
+
var contentVariables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
4754
|
+
this.message.contentSid = contentSid;
|
|
4755
|
+
this.message.contentVariables = contentVariables;
|
|
4756
|
+
return this;
|
|
4757
|
+
}
|
|
4017
4758
|
/**
|
|
4018
4759
|
* Adds media to the message.
|
|
4019
4760
|
* @param payload Media to add.
|
|
@@ -4088,29 +4829,34 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
|
4088
4829
|
value: function buildAndSend() {
|
|
4089
4830
|
return this.build().send();
|
|
4090
4831
|
}
|
|
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
4832
|
}]);
|
|
4101
4833
|
|
|
4102
4834
|
return MessageBuilder;
|
|
4103
4835
|
}();
|
|
4104
4836
|
|
|
4105
|
-
|
|
4837
|
+
__decorate([declarativeTypeValidator.validateTypes("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setBody", null);
|
|
4106
4838
|
|
|
4107
|
-
|
|
4839
|
+
__decorate([declarativeTypeValidator.validateTypes("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setSubject", null);
|
|
4108
4840
|
|
|
4109
|
-
|
|
4841
|
+
__decorate([declarativeTypeValidator.validateTypes(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setAttributes", null);
|
|
4110
4842
|
|
|
4111
|
-
|
|
4843
|
+
__decorate([declarativeTypeValidator.validateTypes("string", [FormData, sendMediaOptions]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setEmailBody", null);
|
|
4112
4844
|
|
|
4113
|
-
|
|
4845
|
+
__decorate([declarativeTypeValidator.validateTypes("string", [FormData, sendMediaOptions]), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "setEmailHistory", null);
|
|
4846
|
+
|
|
4847
|
+
__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);
|
|
4848
|
+
|
|
4849
|
+
__decorate([declarativeTypeValidator.validateTypes([FormData, sendMediaOptions]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", MessageBuilder)], MessageBuilder.prototype, "addMedia", null);
|
|
4850
|
+
|
|
4851
|
+
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; } } }; }
|
|
4852
|
+
|
|
4853
|
+
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); }
|
|
4854
|
+
|
|
4855
|
+
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; }
|
|
4856
|
+
|
|
4857
|
+
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); }; }
|
|
4858
|
+
|
|
4859
|
+
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
4860
|
/**
|
|
4115
4861
|
* Map of the fields that will be processed with update messages.
|
|
4116
4862
|
*/
|
|
@@ -4138,7 +4884,7 @@ var fieldMappings = {
|
|
|
4138
4884
|
var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4139
4885
|
_inherits__default["default"](Conversation, _ReplayEventEmitter);
|
|
4140
4886
|
|
|
4141
|
-
var _super = _createSuper$
|
|
4887
|
+
var _super = _createSuper$4(Conversation);
|
|
4142
4888
|
|
|
4143
4889
|
/**
|
|
4144
4890
|
* Fired when a participant has joined the conversation.
|
|
@@ -4244,24 +4990,86 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
4244
4990
|
*/
|
|
4245
4991
|
|
|
4246
4992
|
/**
|
|
4247
|
-
*
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
*
|
|
4993
|
+
* Unique system identifier of the conversation.
|
|
4994
|
+
*/
|
|
4995
|
+
|
|
4996
|
+
/**
|
|
4997
|
+
* Conversation links for REST requests.
|
|
4252
4998
|
* @internal
|
|
4253
4999
|
*/
|
|
4254
|
-
function Conversation(descriptor, sid, links, configuration, services) {
|
|
4255
|
-
var _descriptor$attribute, _descriptor$bindings;
|
|
4256
5000
|
|
|
4257
|
-
|
|
5001
|
+
/**
|
|
5002
|
+
* Configuration of the client that the conversation belongs to.
|
|
5003
|
+
*/
|
|
4258
5004
|
|
|
4259
|
-
|
|
5005
|
+
/**
|
|
5006
|
+
* Conversation service objects.
|
|
5007
|
+
*/
|
|
4260
5008
|
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
5009
|
+
/**
|
|
5010
|
+
* Internal state of the conversation.
|
|
5011
|
+
*/
|
|
5012
|
+
|
|
5013
|
+
/**
|
|
5014
|
+
* Name of the conversation entity document.
|
|
5015
|
+
*/
|
|
5016
|
+
|
|
5017
|
+
/**
|
|
5018
|
+
* Messages entity.
|
|
5019
|
+
*/
|
|
5020
|
+
|
|
5021
|
+
/**
|
|
5022
|
+
* Sync list containing messages.
|
|
5023
|
+
*/
|
|
5024
|
+
|
|
5025
|
+
/**
|
|
5026
|
+
* Map of participants.
|
|
5027
|
+
* @internal
|
|
5028
|
+
*/
|
|
5029
|
+
|
|
5030
|
+
/**
|
|
5031
|
+
* Participants entity.
|
|
5032
|
+
*/
|
|
5033
|
+
|
|
5034
|
+
/**
|
|
5035
|
+
* Sync map containing participants.
|
|
5036
|
+
*/
|
|
5037
|
+
|
|
5038
|
+
/**
|
|
5039
|
+
* Source of the most recent update.
|
|
5040
|
+
*/
|
|
5041
|
+
|
|
5042
|
+
/**
|
|
5043
|
+
* Promise for the conversation entity document.
|
|
5044
|
+
*/
|
|
5045
|
+
|
|
5046
|
+
/**
|
|
5047
|
+
* Promise for the messages list.
|
|
5048
|
+
*/
|
|
5049
|
+
|
|
5050
|
+
/**
|
|
5051
|
+
* Conversation entity document.
|
|
5052
|
+
*/
|
|
5053
|
+
|
|
5054
|
+
/**
|
|
5055
|
+
* @param descriptor Conversation descriptor.
|
|
5056
|
+
* @param sid Conversation SID.
|
|
5057
|
+
* @param links Conversation links for REST requests.
|
|
5058
|
+
* @param configuration Client configuration.
|
|
5059
|
+
* @param services Conversation services.
|
|
5060
|
+
* @internal
|
|
5061
|
+
*/
|
|
5062
|
+
function Conversation(descriptor, sid, links, configuration, services) {
|
|
5063
|
+
var _descriptor$attribute, _descriptor$bindings;
|
|
5064
|
+
|
|
5065
|
+
var _this;
|
|
5066
|
+
|
|
5067
|
+
_classCallCheck__default["default"](this, Conversation);
|
|
5068
|
+
|
|
5069
|
+
_this = _super.call(this);
|
|
5070
|
+
_this.sid = sid;
|
|
5071
|
+
_this._links = links;
|
|
5072
|
+
_this._configuration = configuration;
|
|
4265
5073
|
_this._services = services;
|
|
4266
5074
|
_this._entityName = descriptor.channel;
|
|
4267
5075
|
_this._internalState = {
|
|
@@ -4284,32 +5092,39 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
4284
5092
|
participants: _this._links.participants
|
|
4285
5093
|
};
|
|
4286
5094
|
_this._participants = new Map();
|
|
4287
|
-
_this._participantsEntity = new Participants(_assertThisInitialized__default["default"](_this), _this._participants,
|
|
5095
|
+
_this._participantsEntity = new Participants(_assertThisInitialized__default["default"](_this), _this._participants, // state leak
|
|
5096
|
+
participantsLinks, _this._services);
|
|
4288
5097
|
|
|
4289
|
-
_this._participantsEntity.on(
|
|
4290
|
-
return
|
|
5098
|
+
_this._participantsEntity.on(Conversation.participantJoined, function (participant) {
|
|
5099
|
+
return (// @todo update participants map here??
|
|
5100
|
+
_this.emit(Conversation.participantJoined, participant)
|
|
5101
|
+
);
|
|
4291
5102
|
});
|
|
4292
5103
|
|
|
4293
|
-
_this._participantsEntity.on(
|
|
4294
|
-
return
|
|
5104
|
+
_this._participantsEntity.on(Conversation.participantLeft, function (participant) {
|
|
5105
|
+
return (// @todo update participants map here??
|
|
5106
|
+
_this.emit(Conversation.participantLeft, participant)
|
|
5107
|
+
);
|
|
4295
5108
|
});
|
|
4296
5109
|
|
|
4297
|
-
_this._participantsEntity.on(
|
|
4298
|
-
return
|
|
5110
|
+
_this._participantsEntity.on(Conversation.participantUpdated, function (args) {
|
|
5111
|
+
return (// @todo update participants map here??
|
|
5112
|
+
_this.emit(Conversation.participantUpdated, args)
|
|
5113
|
+
);
|
|
4299
5114
|
});
|
|
4300
5115
|
|
|
4301
5116
|
_this._messagesEntity = new Messages(_assertThisInitialized__default["default"](_this), configuration, services);
|
|
4302
5117
|
|
|
4303
|
-
_this._messagesEntity.on(
|
|
5118
|
+
_this._messagesEntity.on(Conversation.messageAdded, function (message) {
|
|
4304
5119
|
return _this._onMessageAdded(message);
|
|
4305
5120
|
});
|
|
4306
5121
|
|
|
4307
|
-
_this._messagesEntity.on(
|
|
4308
|
-
return _this.emit(
|
|
5122
|
+
_this._messagesEntity.on(Conversation.messageUpdated, function (args) {
|
|
5123
|
+
return _this.emit(Conversation.messageUpdated, args);
|
|
4309
5124
|
});
|
|
4310
5125
|
|
|
4311
|
-
_this._messagesEntity.on(
|
|
4312
|
-
return _this.emit(
|
|
5126
|
+
_this._messagesEntity.on(Conversation.messageRemoved, function (message) {
|
|
5127
|
+
return _this.emit(Conversation.messageRemoved, message);
|
|
4313
5128
|
});
|
|
4314
5129
|
|
|
4315
5130
|
return _this;
|
|
@@ -4412,7 +5227,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
4412
5227
|
return (_this$_internalState$3 = this._internalState.notificationLevel) !== null && _this$_internalState$3 !== void 0 ? _this$_internalState$3 : "default";
|
|
4413
5228
|
}
|
|
4414
5229
|
/**
|
|
4415
|
-
* Conversation bindings.
|
|
5230
|
+
* Conversation bindings. An undocumented feature (for now).
|
|
4416
5231
|
* @internal
|
|
4417
5232
|
*/
|
|
4418
5233
|
|
|
@@ -4868,7 +5683,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
4868
5683
|
return getMessagesCount;
|
|
4869
5684
|
}()
|
|
4870
5685
|
/**
|
|
4871
|
-
* Get unread messages
|
|
5686
|
+
* Get count of unread messages for the user if they are a participant of this
|
|
4872
5687
|
* conversation. Rejects if the user is not a participant of the conversation.
|
|
4873
5688
|
*
|
|
4874
5689
|
* Use this method to obtain the number of unread messages together with
|
|
@@ -4876,12 +5691,19 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
4876
5691
|
* message indices which may have gaps. See {@link Message.index} for details.
|
|
4877
5692
|
*
|
|
4878
5693
|
* 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
|
|
5694
|
+
* correct, but it will also be possibly incorrect for a few seconds. The
|
|
4880
5695
|
* Conversations system does not provide real time events for counter values
|
|
4881
5696
|
* changes.
|
|
4882
5697
|
*
|
|
4883
5698
|
* This is useful for any UI badges, but it is not recommended to build any
|
|
4884
5699
|
* core application logic based on these counters being accurate in real time.
|
|
5700
|
+
*
|
|
5701
|
+
* If the read horizon is not set, this function will return null. This could mean
|
|
5702
|
+
* that all messages in the conversation are unread, or that the read horizon system
|
|
5703
|
+
* is not being used. How to interpret this `null` value is up to the customer application.
|
|
5704
|
+
*
|
|
5705
|
+
* @return Number of unread messages based on the current read horizon set for
|
|
5706
|
+
* the user or `null` if the read horizon is not set.
|
|
4885
5707
|
*/
|
|
4886
5708
|
|
|
4887
5709
|
}, {
|
|
@@ -4986,7 +5808,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
4986
5808
|
}
|
|
4987
5809
|
|
|
4988
5810
|
_context14.next = 3;
|
|
4989
|
-
return this._services.commandExecutor.mutateResource("delete", "".concat(this._links.participants, "/").concat(this._configuration.userIdentity));
|
|
5811
|
+
return this._services.commandExecutor.mutateResource("delete", "".concat(this._links.participants, "/").concat(encodeURIComponent(this._configuration.userIdentity)));
|
|
4990
5812
|
|
|
4991
5813
|
case 3:
|
|
4992
5814
|
return _context14.abrupt("return", this);
|
|
@@ -5094,7 +5916,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5094
5916
|
}()
|
|
5095
5917
|
/**
|
|
5096
5918
|
* New interface to prepare for sending a message.
|
|
5097
|
-
* Use this instead of {@link
|
|
5919
|
+
* Use this instead of {@link Conversation.sendMessage}.
|
|
5098
5920
|
* @return A MessageBuilder to help set all message sending options.
|
|
5099
5921
|
*/
|
|
5100
5922
|
|
|
@@ -5154,7 +5976,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5154
5976
|
}()
|
|
5155
5977
|
/**
|
|
5156
5978
|
* Set all messages in the conversation unread.
|
|
5157
|
-
* @
|
|
5979
|
+
* @returns New count of unread messages after this update.
|
|
5158
5980
|
*/
|
|
5159
5981
|
|
|
5160
5982
|
}, {
|
|
@@ -5312,7 +6134,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5312
6134
|
* Set the last read message index to the current read horizon.
|
|
5313
6135
|
* @param index Message index to set as last read. If null is provided, then
|
|
5314
6136
|
* the behavior is identical to {@link Conversation.setAllMessagesUnread}.
|
|
5315
|
-
* @returns
|
|
6137
|
+
* @returns New count of unread messages after this update.
|
|
5316
6138
|
*/
|
|
5317
6139
|
|
|
5318
6140
|
}, {
|
|
@@ -5385,74 +6207,107 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5385
6207
|
|
|
5386
6208
|
return updateUniqueName;
|
|
5387
6209
|
}()
|
|
6210
|
+
/**
|
|
6211
|
+
* Get recipients of all messages in the conversation.
|
|
6212
|
+
* @param options Optional configuration, set pageSize to request a specific pagination page size. Page size specifies a number of messages to include in a single batch. Each message may include multiple recipients.
|
|
6213
|
+
*/
|
|
6214
|
+
|
|
6215
|
+
}, {
|
|
6216
|
+
key: "getMessageRecipients",
|
|
6217
|
+
value: function () {
|
|
6218
|
+
var _getMessageRecipients = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee24(options) {
|
|
6219
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee24$(_context24) {
|
|
6220
|
+
while (1) {
|
|
6221
|
+
switch (_context24.prev = _context24.next) {
|
|
6222
|
+
case 0:
|
|
6223
|
+
_context24.next = 2;
|
|
6224
|
+
return this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid, options);
|
|
6225
|
+
|
|
6226
|
+
case 2:
|
|
6227
|
+
return _context24.abrupt("return", _context24.sent);
|
|
6228
|
+
|
|
6229
|
+
case 3:
|
|
6230
|
+
case "end":
|
|
6231
|
+
return _context24.stop();
|
|
6232
|
+
}
|
|
6233
|
+
}
|
|
6234
|
+
}, _callee24, this);
|
|
6235
|
+
}));
|
|
6236
|
+
|
|
6237
|
+
function getMessageRecipients(_x19) {
|
|
6238
|
+
return _getMessageRecipients.apply(this, arguments);
|
|
6239
|
+
}
|
|
6240
|
+
|
|
6241
|
+
return getMessageRecipients;
|
|
6242
|
+
}()
|
|
5388
6243
|
/**
|
|
5389
6244
|
* Load and subscribe to this conversation and do not subscribe to its
|
|
5390
6245
|
* participants and messages. This or _subscribeStreams will need to be called
|
|
5391
|
-
* before any events
|
|
6246
|
+
* before any events in the conversation will fire.
|
|
5392
6247
|
* @internal
|
|
5393
6248
|
*/
|
|
5394
6249
|
|
|
5395
6250
|
}, {
|
|
5396
6251
|
key: "_subscribe",
|
|
5397
6252
|
value: function () {
|
|
5398
|
-
var _subscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
6253
|
+
var _subscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee25() {
|
|
5399
6254
|
var _this2 = this;
|
|
5400
6255
|
|
|
5401
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6256
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee25$(_context25) {
|
|
5402
6257
|
while (1) {
|
|
5403
|
-
switch (
|
|
6258
|
+
switch (_context25.prev = _context25.next) {
|
|
5404
6259
|
case 0:
|
|
5405
6260
|
if (!this._entityPromise) {
|
|
5406
|
-
|
|
6261
|
+
_context25.next = 2;
|
|
5407
6262
|
break;
|
|
5408
6263
|
}
|
|
5409
6264
|
|
|
5410
|
-
return
|
|
6265
|
+
return _context25.abrupt("return", this._entityPromise);
|
|
5411
6266
|
|
|
5412
6267
|
case 2:
|
|
5413
6268
|
this._entityPromise = this._services.syncClient.document({
|
|
5414
6269
|
id: this._entityName,
|
|
5415
6270
|
mode: "open_existing"
|
|
5416
6271
|
});
|
|
5417
|
-
|
|
5418
|
-
|
|
6272
|
+
_context25.prev = 3;
|
|
6273
|
+
_context25.next = 6;
|
|
5419
6274
|
return this._entityPromise;
|
|
5420
6275
|
|
|
5421
6276
|
case 6:
|
|
5422
|
-
this._entity =
|
|
6277
|
+
this._entity = _context25.sent;
|
|
5423
6278
|
|
|
5424
|
-
this._entity.on(
|
|
6279
|
+
this._entity.on(twilioSync.SyncDocument.updated, function (args) {
|
|
5425
6280
|
return _this2._update(args.data);
|
|
5426
6281
|
});
|
|
5427
6282
|
|
|
5428
|
-
this._entity.on(
|
|
5429
|
-
return _this2.emit(
|
|
6283
|
+
this._entity.on(twilioSync.SyncDocument.removed, function () {
|
|
6284
|
+
return _this2.emit(Conversation.removed, _this2);
|
|
5430
6285
|
});
|
|
5431
6286
|
|
|
5432
6287
|
this._update(this._entity.data);
|
|
5433
6288
|
|
|
5434
|
-
return
|
|
6289
|
+
return _context25.abrupt("return", this._entity);
|
|
5435
6290
|
|
|
5436
6291
|
case 13:
|
|
5437
|
-
|
|
5438
|
-
|
|
6292
|
+
_context25.prev = 13;
|
|
6293
|
+
_context25.t0 = _context25["catch"](3);
|
|
5439
6294
|
this._entity = null;
|
|
5440
6295
|
this._entityPromise = null;
|
|
5441
6296
|
|
|
5442
6297
|
if (this._services.syncClient.connectionState != "disconnected") {
|
|
5443
|
-
Conversation._logger.error("Failed to get conversation object",
|
|
6298
|
+
Conversation._logger.error("Failed to get conversation object", _context25.t0);
|
|
5444
6299
|
}
|
|
5445
6300
|
|
|
5446
|
-
Conversation._logger.debug("ERROR: Failed to get conversation object",
|
|
6301
|
+
Conversation._logger.debug("ERROR: Failed to get conversation object", _context25.t0);
|
|
5447
6302
|
|
|
5448
|
-
throw
|
|
6303
|
+
throw _context25.t0;
|
|
5449
6304
|
|
|
5450
6305
|
case 20:
|
|
5451
6306
|
case "end":
|
|
5452
|
-
return
|
|
6307
|
+
return _context25.stop();
|
|
5453
6308
|
}
|
|
5454
6309
|
}
|
|
5455
|
-
},
|
|
6310
|
+
}, _callee25, this, [[3, 13]]);
|
|
5456
6311
|
}));
|
|
5457
6312
|
|
|
5458
6313
|
function _subscribe() {
|
|
@@ -5461,6 +6316,116 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5461
6316
|
|
|
5462
6317
|
return _subscribe;
|
|
5463
6318
|
}()
|
|
6319
|
+
/**
|
|
6320
|
+
* Fetch participants and messages of the conversation. This method needs to
|
|
6321
|
+
* be called during conversation initialization to catch broken conversations
|
|
6322
|
+
* (broken conversations are conversations that have essential Sync entities
|
|
6323
|
+
* missing, i.e. the conversation document, the messages list or the
|
|
6324
|
+
* participant map). In case of this conversation being broken, the method
|
|
6325
|
+
* will throw an exception that will be caught and handled gracefully.
|
|
6326
|
+
* @internal
|
|
6327
|
+
*/
|
|
6328
|
+
|
|
6329
|
+
}, {
|
|
6330
|
+
key: "_fetchStreams",
|
|
6331
|
+
value: function () {
|
|
6332
|
+
var _fetchStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee27() {
|
|
6333
|
+
var _this3 = this;
|
|
6334
|
+
|
|
6335
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee27$(_context27) {
|
|
6336
|
+
while (1) {
|
|
6337
|
+
switch (_context27.prev = _context27.next) {
|
|
6338
|
+
case 0:
|
|
6339
|
+
if (!this._streamsPromise) {
|
|
6340
|
+
_context27.next = 2;
|
|
6341
|
+
break;
|
|
6342
|
+
}
|
|
6343
|
+
|
|
6344
|
+
return _context27.abrupt("return", this._streamsPromise);
|
|
6345
|
+
|
|
6346
|
+
case 2:
|
|
6347
|
+
this._streamsPromise = new Promise( /*#__PURE__*/function () {
|
|
6348
|
+
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee26(resolve, reject) {
|
|
6349
|
+
var _this3$_entity, _this3$_entity2;
|
|
6350
|
+
|
|
6351
|
+
var data, messagesPromise, participantsPromise;
|
|
6352
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee26$(_context26) {
|
|
6353
|
+
while (1) {
|
|
6354
|
+
switch (_context26.prev = _context26.next) {
|
|
6355
|
+
case 0:
|
|
6356
|
+
_context26.prev = 0;
|
|
6357
|
+
_context26.next = 3;
|
|
6358
|
+
return _this3._subscribe();
|
|
6359
|
+
|
|
6360
|
+
case 3:
|
|
6361
|
+
_context26.next = 9;
|
|
6362
|
+
break;
|
|
6363
|
+
|
|
6364
|
+
case 5:
|
|
6365
|
+
_context26.prev = 5;
|
|
6366
|
+
_context26.t0 = _context26["catch"](0);
|
|
6367
|
+
|
|
6368
|
+
Conversation._logger.trace("Failed to subscribe to conversation", _context26.t0);
|
|
6369
|
+
|
|
6370
|
+
return _context26.abrupt("return", reject(_context26.t0));
|
|
6371
|
+
|
|
6372
|
+
case 9:
|
|
6373
|
+
Conversation._logger.trace("_streamsAvailable, this.entity.data=", (_this3$_entity = _this3._entity) === null || _this3$_entity === void 0 ? void 0 : _this3$_entity.data);
|
|
6374
|
+
|
|
6375
|
+
data = (_this3$_entity2 = _this3._entity) === null || _this3$_entity2 === void 0 ? void 0 : _this3$_entity2.data;
|
|
6376
|
+
messagesPromise = _this3._services.syncClient.list({
|
|
6377
|
+
id: data.messages,
|
|
6378
|
+
mode: "open_existing"
|
|
6379
|
+
}).then(function (list) {
|
|
6380
|
+
_this3._messagesList = list;
|
|
6381
|
+
return list;
|
|
6382
|
+
});
|
|
6383
|
+
participantsPromise = _this3._services.syncClient.map({
|
|
6384
|
+
id: data.roster,
|
|
6385
|
+
mode: "open_existing"
|
|
6386
|
+
}).then(function (map) {
|
|
6387
|
+
_this3._participantsMap = map;
|
|
6388
|
+
return map;
|
|
6389
|
+
});
|
|
6390
|
+
Promise.all([messagesPromise, participantsPromise]).then(function () {
|
|
6391
|
+
return resolve(true);
|
|
6392
|
+
}).catch(function (err) {
|
|
6393
|
+
Conversation._logger.trace("Failed to fetch conversation streams for conversation", _this3.sid, err);
|
|
6394
|
+
|
|
6395
|
+
reject(err);
|
|
6396
|
+
});
|
|
6397
|
+
|
|
6398
|
+
case 14:
|
|
6399
|
+
case "end":
|
|
6400
|
+
return _context26.stop();
|
|
6401
|
+
}
|
|
6402
|
+
}
|
|
6403
|
+
}, _callee26, null, [[0, 5]]);
|
|
6404
|
+
}));
|
|
6405
|
+
|
|
6406
|
+
return function (_x20, _x21) {
|
|
6407
|
+
return _ref.apply(this, arguments);
|
|
6408
|
+
};
|
|
6409
|
+
}());
|
|
6410
|
+
return _context27.abrupt("return", this._streamsPromise.catch(function (err) {
|
|
6411
|
+
_this3._streamsPromise = null;
|
|
6412
|
+
throw err;
|
|
6413
|
+
}));
|
|
6414
|
+
|
|
6415
|
+
case 4:
|
|
6416
|
+
case "end":
|
|
6417
|
+
return _context27.stop();
|
|
6418
|
+
}
|
|
6419
|
+
}
|
|
6420
|
+
}, _callee27, this);
|
|
6421
|
+
}));
|
|
6422
|
+
|
|
6423
|
+
function _fetchStreams() {
|
|
6424
|
+
return _fetchStreams2.apply(this, arguments);
|
|
6425
|
+
}
|
|
6426
|
+
|
|
6427
|
+
return _fetchStreams;
|
|
6428
|
+
}()
|
|
5464
6429
|
/**
|
|
5465
6430
|
* Load the attributes of this conversation and instantiate its participants
|
|
5466
6431
|
* and messages. This or _subscribe will need to be called before any events
|
|
@@ -5472,16 +6437,16 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5472
6437
|
}, {
|
|
5473
6438
|
key: "_subscribeStreams",
|
|
5474
6439
|
value: function () {
|
|
5475
|
-
var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
5476
|
-
var _this$_entity, _this$_entity2, data, messagesObjectName, rosterObjectName;
|
|
6440
|
+
var _subscribeStreams2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee28() {
|
|
6441
|
+
var _this$_entity, _this$_entity2, _this$_messagesList, _this$_participantsMa, data, messagesObjectName, rosterObjectName;
|
|
5477
6442
|
|
|
5478
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6443
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee28$(_context28) {
|
|
5479
6444
|
while (1) {
|
|
5480
|
-
switch (
|
|
6445
|
+
switch (_context28.prev = _context28.next) {
|
|
5481
6446
|
case 0:
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
return this.
|
|
6447
|
+
_context28.prev = 0;
|
|
6448
|
+
_context28.next = 3;
|
|
6449
|
+
return this._fetchStreams();
|
|
5485
6450
|
|
|
5486
6451
|
case 3:
|
|
5487
6452
|
Conversation._logger.trace("_subscribeStreams, this.entity.data=", (_this$_entity = this._entity) === null || _this$_entity === void 0 ? void 0 : _this$_entity.data);
|
|
@@ -5489,31 +6454,31 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5489
6454
|
data = (_this$_entity2 = this._entity) === null || _this$_entity2 === void 0 ? void 0 : _this$_entity2.data;
|
|
5490
6455
|
messagesObjectName = data.messages;
|
|
5491
6456
|
rosterObjectName = data.roster;
|
|
5492
|
-
|
|
5493
|
-
return Promise.all([this._messagesEntity.subscribe(messagesObjectName), this._participantsEntity.subscribe(rosterObjectName)]);
|
|
6457
|
+
_context28.next = 9;
|
|
6458
|
+
return Promise.all([this._messagesEntity.subscribe((_this$_messagesList = this._messagesList) !== null && _this$_messagesList !== void 0 ? _this$_messagesList : messagesObjectName), this._participantsEntity.subscribe((_this$_participantsMa = this._participantsMap) !== null && _this$_participantsMa !== void 0 ? _this$_participantsMa : rosterObjectName)]);
|
|
5494
6459
|
|
|
5495
6460
|
case 9:
|
|
5496
|
-
|
|
6461
|
+
_context28.next = 16;
|
|
5497
6462
|
break;
|
|
5498
6463
|
|
|
5499
6464
|
case 11:
|
|
5500
|
-
|
|
5501
|
-
|
|
6465
|
+
_context28.prev = 11;
|
|
6466
|
+
_context28.t0 = _context28["catch"](0);
|
|
5502
6467
|
|
|
5503
6468
|
if (this._services.syncClient.connectionState !== "disconnected") {
|
|
5504
|
-
Conversation._logger.error("Failed to subscribe on conversation objects", this.sid,
|
|
6469
|
+
Conversation._logger.error("Failed to subscribe on conversation objects", this.sid, _context28.t0);
|
|
5505
6470
|
}
|
|
5506
6471
|
|
|
5507
|
-
Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid,
|
|
6472
|
+
Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context28.t0);
|
|
5508
6473
|
|
|
5509
|
-
throw
|
|
6474
|
+
throw _context28.t0;
|
|
5510
6475
|
|
|
5511
6476
|
case 16:
|
|
5512
6477
|
case "end":
|
|
5513
|
-
return
|
|
6478
|
+
return _context28.stop();
|
|
5514
6479
|
}
|
|
5515
6480
|
}
|
|
5516
|
-
},
|
|
6481
|
+
}, _callee28, this, [[0, 11]]);
|
|
5517
6482
|
}));
|
|
5518
6483
|
|
|
5519
6484
|
function _subscribeStreams() {
|
|
@@ -5530,32 +6495,26 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5530
6495
|
}, {
|
|
5531
6496
|
key: "_unsubscribe",
|
|
5532
6497
|
value: function () {
|
|
5533
|
-
var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
5534
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6498
|
+
var _unsubscribe2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee29() {
|
|
6499
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee29$(_context29) {
|
|
5535
6500
|
while (1) {
|
|
5536
|
-
switch (
|
|
6501
|
+
switch (_context29.prev = _context29.next) {
|
|
5537
6502
|
case 0:
|
|
5538
|
-
if (
|
|
5539
|
-
|
|
5540
|
-
break;
|
|
5541
|
-
}
|
|
5542
|
-
|
|
5543
|
-
_context26.next = 3;
|
|
5544
|
-
return this._entity.close();
|
|
6503
|
+
if (this._entity) {
|
|
6504
|
+
this._entity.close();
|
|
5545
6505
|
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
6506
|
+
this._entity = null;
|
|
6507
|
+
this._entityPromise = null;
|
|
6508
|
+
}
|
|
5549
6509
|
|
|
5550
|
-
|
|
5551
|
-
return _context26.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
|
|
6510
|
+
return _context29.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
|
|
5552
6511
|
|
|
5553
|
-
case
|
|
6512
|
+
case 2:
|
|
5554
6513
|
case "end":
|
|
5555
|
-
return
|
|
6514
|
+
return _context29.stop();
|
|
5556
6515
|
}
|
|
5557
6516
|
}
|
|
5558
|
-
},
|
|
6517
|
+
}, _callee29, this);
|
|
5559
6518
|
}));
|
|
5560
6519
|
|
|
5561
6520
|
function _unsubscribe() {
|
|
@@ -5572,7 +6531,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5572
6531
|
}, {
|
|
5573
6532
|
key: "_setStatus",
|
|
5574
6533
|
value: function _setStatus(status, source) {
|
|
5575
|
-
var
|
|
6534
|
+
var _this4 = this;
|
|
5576
6535
|
|
|
5577
6536
|
this._dataSource = source;
|
|
5578
6537
|
|
|
@@ -5586,7 +6545,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5586
6545
|
this._subscribeStreams().catch(function (err) {
|
|
5587
6546
|
Conversation._logger.debug("ERROR while setting conversation status " + status, err);
|
|
5588
6547
|
|
|
5589
|
-
if (
|
|
6548
|
+
if (_this4._services.syncClient.connectionState !== "disconnected") {
|
|
5590
6549
|
throw err;
|
|
5591
6550
|
}
|
|
5592
6551
|
});
|
|
@@ -5598,7 +6557,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5598
6557
|
this._unsubscribe().catch(function (err) {
|
|
5599
6558
|
Conversation._logger.debug("ERROR while setting conversation status " + status, err);
|
|
5600
6559
|
|
|
5601
|
-
if (
|
|
6560
|
+
if (_this4._services.syncClient.connectionState !== "disconnected") {
|
|
5602
6561
|
throw err;
|
|
5603
6562
|
}
|
|
5604
6563
|
});
|
|
@@ -5638,7 +6597,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5638
6597
|
break;
|
|
5639
6598
|
|
|
5640
6599
|
case fieldMappings.attributes:
|
|
5641
|
-
if (
|
|
6600
|
+
if (isEqual(this._internalState.attributes, update.attributes)) {
|
|
5642
6601
|
break;
|
|
5643
6602
|
}
|
|
5644
6603
|
|
|
@@ -5674,7 +6633,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5674
6633
|
updateReasons.add(localKey);
|
|
5675
6634
|
}
|
|
5676
6635
|
|
|
5677
|
-
if (
|
|
6636
|
+
if (isEqual(this._internalState.lastMessage, {})) {
|
|
5678
6637
|
delete this._internalState.lastMessage;
|
|
5679
6638
|
}
|
|
5680
6639
|
|
|
@@ -5687,7 +6646,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5687
6646
|
state.dateUpdated = new Date(state.dateUpdated);
|
|
5688
6647
|
}
|
|
5689
6648
|
|
|
5690
|
-
if (
|
|
6649
|
+
if (isEqual(this._internalState.state, state)) {
|
|
5691
6650
|
break;
|
|
5692
6651
|
}
|
|
5693
6652
|
|
|
@@ -5696,7 +6655,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5696
6655
|
break;
|
|
5697
6656
|
|
|
5698
6657
|
case fieldMappings.bindings:
|
|
5699
|
-
if (
|
|
6658
|
+
if (isEqual(this._internalState.bindings, update.bindings)) {
|
|
5700
6659
|
break;
|
|
5701
6660
|
}
|
|
5702
6661
|
|
|
@@ -5719,7 +6678,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5719
6678
|
}
|
|
5720
6679
|
|
|
5721
6680
|
if (updateReasons.size > 0) {
|
|
5722
|
-
this.emit(
|
|
6681
|
+
this.emit(Conversation.updated, {
|
|
5723
6682
|
conversation: this,
|
|
5724
6683
|
updateReasons: _toConsumableArray__default["default"](updateReasons)
|
|
5725
6684
|
});
|
|
@@ -5732,7 +6691,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5732
6691
|
}, {
|
|
5733
6692
|
key: "_onMessageAdded",
|
|
5734
6693
|
value: function _onMessageAdded(message) {
|
|
5735
|
-
var _iterator = _createForOfIteratorHelper$
|
|
6694
|
+
var _iterator = _createForOfIteratorHelper$3(this._participants.values()),
|
|
5736
6695
|
_step;
|
|
5737
6696
|
|
|
5738
6697
|
try {
|
|
@@ -5751,7 +6710,7 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5751
6710
|
_iterator.f();
|
|
5752
6711
|
}
|
|
5753
6712
|
|
|
5754
|
-
this.emit(
|
|
6713
|
+
this.emit(Conversation.messageAdded, message);
|
|
5755
6714
|
}
|
|
5756
6715
|
/**
|
|
5757
6716
|
* Set last read message index.
|
|
@@ -5761,30 +6720,30 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5761
6720
|
}, {
|
|
5762
6721
|
key: "_setLastReadMessageIndex",
|
|
5763
6722
|
value: function () {
|
|
5764
|
-
var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
6723
|
+
var _setLastReadMessageIndex2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee30(index) {
|
|
5765
6724
|
var result;
|
|
5766
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6725
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee30$(_context30) {
|
|
5767
6726
|
while (1) {
|
|
5768
|
-
switch (
|
|
6727
|
+
switch (_context30.prev = _context30.next) {
|
|
5769
6728
|
case 0:
|
|
5770
|
-
|
|
6729
|
+
_context30.next = 2;
|
|
5771
6730
|
return this._services.commandExecutor.mutateResource("post", "".concat(this._configuration.links.myConversations, "/").concat(this.sid), {
|
|
5772
6731
|
last_read_message_index: index
|
|
5773
6732
|
});
|
|
5774
6733
|
|
|
5775
6734
|
case 2:
|
|
5776
|
-
result =
|
|
5777
|
-
return
|
|
6735
|
+
result = _context30.sent;
|
|
6736
|
+
return _context30.abrupt("return", result.unread_messages_count);
|
|
5778
6737
|
|
|
5779
6738
|
case 4:
|
|
5780
6739
|
case "end":
|
|
5781
|
-
return
|
|
6740
|
+
return _context30.stop();
|
|
5782
6741
|
}
|
|
5783
6742
|
}
|
|
5784
|
-
},
|
|
6743
|
+
}, _callee30, this);
|
|
5785
6744
|
}));
|
|
5786
6745
|
|
|
5787
|
-
function _setLastReadMessageIndex(
|
|
6746
|
+
function _setLastReadMessageIndex(_x22) {
|
|
5788
6747
|
return _setLastReadMessageIndex2.apply(this, arguments);
|
|
5789
6748
|
}
|
|
5790
6749
|
|
|
@@ -5806,7 +6765,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5806
6765
|
}
|
|
5807
6766
|
|
|
5808
6767
|
try {
|
|
5809
|
-
|
|
6768
|
+
if (update.dateCreated) {
|
|
6769
|
+
update.dateCreated = new Date(update.dateCreated);
|
|
6770
|
+
}
|
|
5810
6771
|
} catch (e) {
|
|
5811
6772
|
Conversation._logger.warn("Retrieved malformed dateCreated from the server for conversation: " + conversationSid);
|
|
5812
6773
|
|
|
@@ -5814,7 +6775,9 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5814
6775
|
}
|
|
5815
6776
|
|
|
5816
6777
|
try {
|
|
5817
|
-
|
|
6778
|
+
if (update.dateUpdated) {
|
|
6779
|
+
update.dateUpdated = new Date(update.dateUpdated);
|
|
6780
|
+
}
|
|
5818
6781
|
} catch (e) {
|
|
5819
6782
|
Conversation._logger.warn("Retrieved malformed dateUpdated from the server for conversation: " + conversationSid);
|
|
5820
6783
|
|
|
@@ -5858,9 +6821,9 @@ _defineProperty__default["default"](Conversation, "removed", "removed");
|
|
|
5858
6821
|
|
|
5859
6822
|
_defineProperty__default["default"](Conversation, "_logger", Logger.scope("Conversation"));
|
|
5860
6823
|
|
|
5861
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString,
|
|
6824
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, optionalJson), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "add", null);
|
|
5862
6825
|
|
|
5863
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString,
|
|
6826
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString, optionalJson, optionalJson), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "addNonChatParticipant", null);
|
|
5864
6827
|
|
|
5865
6828
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonNegativeInteger), __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", Promise)], Conversation.prototype, "advanceLastReadMessageIndex", null);
|
|
5866
6829
|
|
|
@@ -5883,13 +6846,13 @@ __decorate([declarativeTypeValidator.validateTypesAsync(["string", FormData, dec
|
|
|
5883
6846
|
|
|
5884
6847
|
return [isValid, "a non-empty string, an instance of Buffer or an instance of Blob"];
|
|
5885
6848
|
})
|
|
5886
|
-
})],
|
|
6849
|
+
})], optionalJson, ["undefined", declarativeTypeValidator.literal(null), declarativeTypeValidator.objectSchema("email attributes", {
|
|
5887
6850
|
subject: [declarativeTypeValidator.nonEmptyString, "undefined"]
|
|
5888
6851
|
})]), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "sendMessage", null);
|
|
5889
6852
|
|
|
5890
6853
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("default", "muted")), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "setUserNotificationLevel", null);
|
|
5891
6854
|
|
|
5892
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(
|
|
6855
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(json), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateAttributes", null);
|
|
5893
6856
|
|
|
5894
6857
|
__decorate([declarativeTypeValidator.validateTypesAsync("string"), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], Conversation.prototype, "updateFriendlyName", null);
|
|
5895
6858
|
|
|
@@ -5936,19 +6899,19 @@ var Deferred = /*#__PURE__*/function () {
|
|
|
5936
6899
|
return Deferred;
|
|
5937
6900
|
}();
|
|
5938
6901
|
|
|
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; } } }; }
|
|
6902
|
+
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; } } }; }
|
|
5940
6903
|
|
|
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); }
|
|
6904
|
+
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); }
|
|
5942
6905
|
|
|
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; }
|
|
6906
|
+
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; }
|
|
5944
6907
|
|
|
5945
6908
|
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
6909
|
|
|
5947
6910
|
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
6911
|
|
|
5949
|
-
function _createSuper$
|
|
6912
|
+
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
6913
|
|
|
5951
|
-
function _isNativeReflectConstruct$
|
|
6914
|
+
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
6915
|
var log$1 = Logger.scope("Conversations");
|
|
5953
6916
|
/**
|
|
5954
6917
|
* Represents conversations collection
|
|
@@ -5958,7 +6921,7 @@ var log$1 = Logger.scope("Conversations");
|
|
|
5958
6921
|
var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5959
6922
|
_inherits__default["default"](Conversations, _ReplayEventEmitter);
|
|
5960
6923
|
|
|
5961
|
-
var _super = _createSuper$
|
|
6924
|
+
var _super = _createSuper$3(Conversations);
|
|
5962
6925
|
|
|
5963
6926
|
function Conversations(configuration, services) {
|
|
5964
6927
|
var _this;
|
|
@@ -5996,6 +6959,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
5996
6959
|
return this.services.commandExecutor.mutateResource("post", this.configuration.links.conversations, {
|
|
5997
6960
|
friendly_name: options.friendlyName,
|
|
5998
6961
|
unique_name: options.uniqueName,
|
|
6962
|
+
access: options.access,
|
|
5999
6963
|
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined
|
|
6000
6964
|
});
|
|
6001
6965
|
|
|
@@ -6057,7 +7021,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6057
7021
|
return addConversation;
|
|
6058
7022
|
}()
|
|
6059
7023
|
/**
|
|
6060
|
-
* Fetch conversations list and instantiate all necessary objects
|
|
7024
|
+
* Fetch conversations' list and instantiate all necessary objects
|
|
6061
7025
|
*/
|
|
6062
7026
|
|
|
6063
7027
|
}, {
|
|
@@ -6078,12 +7042,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6078
7042
|
|
|
6079
7043
|
case 3:
|
|
6080
7044
|
map = _context2.sent;
|
|
6081
|
-
map.on(
|
|
7045
|
+
map.on(twilioSync.SyncMap.itemAdded, function (args) {
|
|
6082
7046
|
log$1.debug("itemAdded: ".concat(args.item.key));
|
|
6083
7047
|
|
|
6084
7048
|
_this2._upsertConversation("sync", args.item.key, args.item.data);
|
|
6085
7049
|
});
|
|
6086
|
-
map.on(
|
|
7050
|
+
map.on(twilioSync.SyncMap.itemRemoved, function (args) {
|
|
6087
7051
|
log$1.debug("itemRemoved: ".concat(args.key));
|
|
6088
7052
|
var sid = args.key;
|
|
6089
7053
|
|
|
@@ -6109,7 +7073,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6109
7073
|
|
|
6110
7074
|
conversation.emit("removed", conversation);
|
|
6111
7075
|
});
|
|
6112
|
-
map.on(
|
|
7076
|
+
map.on(twilioSync.SyncMap.itemUpdated, function (args) {
|
|
6113
7077
|
log$1.debug("itemUpdated: ".concat(args.item.key));
|
|
6114
7078
|
|
|
6115
7079
|
_this2._upsertConversation("sync", args.item.key, args.item.data);
|
|
@@ -6120,7 +7084,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6120
7084
|
case 9:
|
|
6121
7085
|
myConversations = _context2.sent;
|
|
6122
7086
|
upserts = [];
|
|
6123
|
-
_iterator = _createForOfIteratorHelper(myConversations);
|
|
7087
|
+
_iterator = _createForOfIteratorHelper$2(myConversations);
|
|
6124
7088
|
|
|
6125
7089
|
try {
|
|
6126
7090
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -6280,6 +7244,8 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6280
7244
|
createdBy: body.created_by,
|
|
6281
7245
|
attributes: body.attributes,
|
|
6282
7246
|
channel: body.sync_objects.conversation,
|
|
7247
|
+
roster: body.sync_objects.participants,
|
|
7248
|
+
messages: body.sync_objects.messages,
|
|
6283
7249
|
notificationLevel: body === null || body === void 0 ? void 0 : body.notification_level,
|
|
6284
7250
|
sid: sid
|
|
6285
7251
|
};
|
|
@@ -6325,8 +7291,10 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6325
7291
|
uniqueName: body.unique_name,
|
|
6326
7292
|
createdBy: body.created_by,
|
|
6327
7293
|
attributes: body.attributes,
|
|
6328
|
-
channel: "".concat(sid, ".channel"),
|
|
6329
|
-
|
|
7294
|
+
channel: body.sync_objects.conversation || "".concat(sid, ".channel"),
|
|
7295
|
+
roster: body.sync_objects.participants,
|
|
7296
|
+
messages: body.sync_objects.messages,
|
|
7297
|
+
notificationLevel: body === null || body === void 0 ? void 0 : body.notification_level,
|
|
6330
7298
|
sid: sid
|
|
6331
7299
|
};
|
|
6332
7300
|
return _context6.abrupt("return", this._upsertConversation("sync", sid, data));
|
|
@@ -6393,7 +7361,9 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6393
7361
|
case 2:
|
|
6394
7362
|
items = _context8.sent;
|
|
6395
7363
|
return _context8.abrupt("return", {
|
|
6396
|
-
items: items
|
|
7364
|
+
items: items.filter(function (item) {
|
|
7365
|
+
return item !== null;
|
|
7366
|
+
}),
|
|
6397
7367
|
hasNextPage: page.hasNextPage,
|
|
6398
7368
|
hasPrevPage: page.hasPrevPage,
|
|
6399
7369
|
nextPage: function nextPage() {
|
|
@@ -6464,7 +7434,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6464
7434
|
updateData.lastConsumedMessageIndex = data.lastConsumedMessageIndex;
|
|
6465
7435
|
}
|
|
6466
7436
|
|
|
6467
|
-
if (!
|
|
7437
|
+
if (!isEqual(updateData, {})) {
|
|
6468
7438
|
conversation._update(updateData);
|
|
6469
7439
|
}
|
|
6470
7440
|
|
|
@@ -6555,7 +7525,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6555
7525
|
break;
|
|
6556
7526
|
}
|
|
6557
7527
|
|
|
6558
|
-
log$1.trace("upsertChannel: the
|
|
7528
|
+
log$1.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring", sid);
|
|
6559
7529
|
return _context10.abrupt("return", null);
|
|
6560
7530
|
|
|
6561
7531
|
case 12:
|
|
@@ -6569,10 +7539,40 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6569
7539
|
};
|
|
6570
7540
|
newConversation = new Conversation(data, sid, links, this.configuration, this.services);
|
|
6571
7541
|
this.conversations.set(sid, newConversation);
|
|
6572
|
-
_context10.
|
|
7542
|
+
_context10.prev = 17;
|
|
7543
|
+
_context10.next = 20;
|
|
6573
7544
|
return newConversation._subscribe();
|
|
6574
7545
|
|
|
6575
|
-
case
|
|
7546
|
+
case 20:
|
|
7547
|
+
if (!(data.status === "joined")) {
|
|
7548
|
+
_context10.next = 23;
|
|
7549
|
+
break;
|
|
7550
|
+
}
|
|
7551
|
+
|
|
7552
|
+
_context10.next = 23;
|
|
7553
|
+
return newConversation._fetchStreams();
|
|
7554
|
+
|
|
7555
|
+
case 23:
|
|
7556
|
+
_context10.next = 32;
|
|
7557
|
+
break;
|
|
7558
|
+
|
|
7559
|
+
case 25:
|
|
7560
|
+
_context10.prev = 25;
|
|
7561
|
+
_context10.t0 = _context10["catch"](17);
|
|
7562
|
+
|
|
7563
|
+
if (!(_context10.t0.name !== "SyncError")) {
|
|
7564
|
+
_context10.next = 29;
|
|
7565
|
+
break;
|
|
7566
|
+
}
|
|
7567
|
+
|
|
7568
|
+
throw _context10.t0;
|
|
7569
|
+
|
|
7570
|
+
case 29:
|
|
7571
|
+
log$1.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring", sid, _context10.t0);
|
|
7572
|
+
this.conversations.delete(sid);
|
|
7573
|
+
return _context10.abrupt("return", null);
|
|
7574
|
+
|
|
7575
|
+
case 32:
|
|
6576
7576
|
this._registerForEvents(newConversation);
|
|
6577
7577
|
|
|
6578
7578
|
this.emit("conversationAdded", newConversation);
|
|
@@ -6585,12 +7585,12 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6585
7585
|
|
|
6586
7586
|
return _context10.abrupt("return", newConversation);
|
|
6587
7587
|
|
|
6588
|
-
case
|
|
7588
|
+
case 36:
|
|
6589
7589
|
case "end":
|
|
6590
7590
|
return _context10.stop();
|
|
6591
7591
|
}
|
|
6592
7592
|
}
|
|
6593
|
-
}, _callee10, this);
|
|
7593
|
+
}, _callee10, this, [[17, 25]]);
|
|
6594
7594
|
}));
|
|
6595
7595
|
|
|
6596
7596
|
function _upsertConversation(_x10, _x11, _x12) {
|
|
@@ -6631,7 +7631,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6631
7631
|
status: conversationDescriptor.status,
|
|
6632
7632
|
channel: conversationDescriptor.sync_objects.conversation,
|
|
6633
7633
|
messages: conversationDescriptor.sync_objects.messages,
|
|
6634
|
-
roster: "".concat(conversationDescriptor.conversation_sid, ".roster"),
|
|
7634
|
+
roster: conversationDescriptor.sync_objects.participants || "".concat(conversationDescriptor.conversation_sid, ".roster"),
|
|
6635
7635
|
lastConsumedMessageIndex: conversationDescriptor.last_read_message_index,
|
|
6636
7636
|
notificationLevel: conversationDescriptor.notification_level
|
|
6637
7637
|
};
|
|
@@ -6713,9 +7713,9 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
|
6713
7713
|
return Conversations;
|
|
6714
7714
|
}(replayEventEmitter.ReplayEventEmitter);
|
|
6715
7715
|
|
|
6716
|
-
function _createSuper$
|
|
7716
|
+
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
7717
|
|
|
6718
|
-
function _isNativeReflectConstruct$
|
|
7718
|
+
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
7719
|
/**
|
|
6720
7720
|
* Container for known users
|
|
6721
7721
|
*/
|
|
@@ -6723,7 +7723,7 @@ function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !
|
|
|
6723
7723
|
var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6724
7724
|
_inherits__default["default"](Users, _ReplayEventEmitter);
|
|
6725
7725
|
|
|
6726
|
-
var _super = _createSuper$
|
|
7726
|
+
var _super = _createSuper$2(Users);
|
|
6727
7727
|
|
|
6728
7728
|
function Users(myself, configuration, services) {
|
|
6729
7729
|
var _this;
|
|
@@ -7054,7 +8054,7 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
|
7054
8054
|
}
|
|
7055
8055
|
|
|
7056
8056
|
conversation._participants.forEach(function (participant) {
|
|
7057
|
-
if (participant.identity !== message.identity) {
|
|
8057
|
+
if (participant.identity !== message.identity && participant.type !== "apple") {
|
|
7058
8058
|
return;
|
|
7059
8059
|
}
|
|
7060
8060
|
|
|
@@ -7170,12 +8170,25 @@ function PushNotification(data) {
|
|
|
7170
8170
|
this.data = data.data || {};
|
|
7171
8171
|
});
|
|
7172
8172
|
|
|
7173
|
-
var version = "3.0.
|
|
8173
|
+
var version = "3.0.1-rc.0";
|
|
8174
|
+
|
|
8175
|
+
/**
|
|
8176
|
+
* Generate a random UUID using the Web Crypto API.
|
|
8177
|
+
* Available in Node.js 14.17+, modern browsers, and React Native.
|
|
8178
|
+
*/
|
|
8179
|
+
var randomUUID = function randomUUID() {
|
|
8180
|
+
return crypto.randomUUID();
|
|
8181
|
+
};
|
|
7174
8182
|
|
|
7175
8183
|
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7176
8184
|
|
|
7177
8185
|
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
8186
|
|
|
8187
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
|
|
8188
|
+
|
|
8189
|
+
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
8190
|
+
var uuidv4 = randomUUID;
|
|
8191
|
+
|
|
7179
8192
|
var trimSlashes = function trimSlashes(url) {
|
|
7180
8193
|
return url.replace(/(^\/+|\/+$)/g, "");
|
|
7181
8194
|
};
|
|
@@ -7184,6 +8197,20 @@ var isMutationConflictResponse = function isMutationConflictResponse(response) {
|
|
|
7184
8197
|
return response.status.code === 202;
|
|
7185
8198
|
};
|
|
7186
8199
|
|
|
8200
|
+
var ChannelMetadataNotFoundError = /*#__PURE__*/function (_Error) {
|
|
8201
|
+
_inherits__default["default"](ChannelMetadataNotFoundError, _Error);
|
|
8202
|
+
|
|
8203
|
+
var _super = _createSuper$1(ChannelMetadataNotFoundError);
|
|
8204
|
+
|
|
8205
|
+
function ChannelMetadataNotFoundError(message) {
|
|
8206
|
+
_classCallCheck__default["default"](this, ChannelMetadataNotFoundError);
|
|
8207
|
+
|
|
8208
|
+
return _super.call(this, message);
|
|
8209
|
+
}
|
|
8210
|
+
|
|
8211
|
+
return _createClass__default["default"](ChannelMetadataNotFoundError);
|
|
8212
|
+
}( /*#__PURE__*/_wrapNativeSuper__default["default"](Error));
|
|
8213
|
+
|
|
7187
8214
|
var CommandExecutor = /*#__PURE__*/function () {
|
|
7188
8215
|
function CommandExecutor(_serviceUrl, _services, _productId) {
|
|
7189
8216
|
_classCallCheck__default["default"](this, CommandExecutor);
|
|
@@ -7230,147 +8257,1001 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
|
7230
8257
|
}).join("&");
|
|
7231
8258
|
}
|
|
7232
8259
|
|
|
7233
|
-
_context.next = 9;
|
|
7234
|
-
return this._services.transport.get(getUrl, finalHeaders, this._productId);
|
|
8260
|
+
_context.next = 9;
|
|
8261
|
+
return this._services.transport.get(getUrl, finalHeaders, this._productId);
|
|
8262
|
+
|
|
8263
|
+
case 9:
|
|
8264
|
+
response = _context.sent;
|
|
8265
|
+
return _context.abrupt("break", 19);
|
|
8266
|
+
|
|
8267
|
+
case 11:
|
|
8268
|
+
_context.next = 13;
|
|
8269
|
+
return this._services.transport.post(preProcessedUrl, finalHeaders, JSON.stringify(requestBody), this._productId);
|
|
8270
|
+
|
|
8271
|
+
case 13:
|
|
8272
|
+
response = _context.sent;
|
|
8273
|
+
return _context.abrupt("break", 19);
|
|
8274
|
+
|
|
8275
|
+
case 15:
|
|
8276
|
+
_context.next = 17;
|
|
8277
|
+
return this._services.transport.delete(preProcessedUrl, finalHeaders, {}, this._productId);
|
|
8278
|
+
|
|
8279
|
+
case 17:
|
|
8280
|
+
response = _context.sent;
|
|
8281
|
+
return _context.abrupt("break", 19);
|
|
8282
|
+
|
|
8283
|
+
case 19:
|
|
8284
|
+
if (!(response.status.code < 200 || response.status.code >= 300)) {
|
|
8285
|
+
_context.next = 21;
|
|
8286
|
+
break;
|
|
8287
|
+
}
|
|
8288
|
+
|
|
8289
|
+
throw new Error("Request responded with a non-success code ".concat(response.status.code));
|
|
8290
|
+
|
|
8291
|
+
case 21:
|
|
8292
|
+
return _context.abrupt("return", response);
|
|
8293
|
+
|
|
8294
|
+
case 22:
|
|
8295
|
+
case "end":
|
|
8296
|
+
return _context.stop();
|
|
8297
|
+
}
|
|
8298
|
+
}
|
|
8299
|
+
}, _callee, this);
|
|
8300
|
+
}));
|
|
8301
|
+
|
|
8302
|
+
function _makeRequest(_x, _x2, _x3, _x4) {
|
|
8303
|
+
return _makeRequest2.apply(this, arguments);
|
|
8304
|
+
}
|
|
8305
|
+
|
|
8306
|
+
return _makeRequest;
|
|
8307
|
+
}()
|
|
8308
|
+
}, {
|
|
8309
|
+
key: "fetchResource",
|
|
8310
|
+
value: function () {
|
|
8311
|
+
var _fetchResource = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(url, requestBody) {
|
|
8312
|
+
var _this = this;
|
|
8313
|
+
|
|
8314
|
+
var maxAttemptsCount, retrier, resolution;
|
|
8315
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
|
8316
|
+
while (1) {
|
|
8317
|
+
switch (_context3.prev = _context3.next) {
|
|
8318
|
+
case 0:
|
|
8319
|
+
maxAttemptsCount = 6;
|
|
8320
|
+
retrier = new operationRetrier.AsyncRetrier({
|
|
8321
|
+
min: 50,
|
|
8322
|
+
max: 1600,
|
|
8323
|
+
maxAttemptsCount: maxAttemptsCount
|
|
8324
|
+
});
|
|
8325
|
+
_context3.prev = 2;
|
|
8326
|
+
_context3.next = 5;
|
|
8327
|
+
return retrier.run( /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
|
|
8328
|
+
var response, _e$body, _e$body2;
|
|
8329
|
+
|
|
8330
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
8331
|
+
while (1) {
|
|
8332
|
+
switch (_context2.prev = _context2.next) {
|
|
8333
|
+
case 0:
|
|
8334
|
+
_context2.prev = 0;
|
|
8335
|
+
_context2.next = 3;
|
|
8336
|
+
return _this._makeRequest("get", url, requestBody);
|
|
8337
|
+
|
|
8338
|
+
case 3:
|
|
8339
|
+
response = _context2.sent;
|
|
8340
|
+
return _context2.abrupt("return", {
|
|
8341
|
+
type: "success",
|
|
8342
|
+
data: response.body
|
|
8343
|
+
});
|
|
8344
|
+
|
|
8345
|
+
case 7:
|
|
8346
|
+
_context2.prev = 7;
|
|
8347
|
+
_context2.t0 = _context2["catch"](0);
|
|
8348
|
+
|
|
8349
|
+
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)) {
|
|
8350
|
+
_context2.next = 11;
|
|
8351
|
+
break;
|
|
8352
|
+
}
|
|
8353
|
+
|
|
8354
|
+
return _context2.abrupt("return", {
|
|
8355
|
+
type: "noMetadata"
|
|
8356
|
+
});
|
|
8357
|
+
|
|
8358
|
+
case 11:
|
|
8359
|
+
throw _context2.t0;
|
|
8360
|
+
|
|
8361
|
+
case 12:
|
|
8362
|
+
case "end":
|
|
8363
|
+
return _context2.stop();
|
|
8364
|
+
}
|
|
8365
|
+
}
|
|
8366
|
+
}, _callee2, null, [[0, 7]]);
|
|
8367
|
+
})));
|
|
8368
|
+
|
|
8369
|
+
case 5:
|
|
8370
|
+
resolution = _context3.sent;
|
|
8371
|
+
_context3.next = 11;
|
|
8372
|
+
break;
|
|
8373
|
+
|
|
8374
|
+
case 8:
|
|
8375
|
+
_context3.prev = 8;
|
|
8376
|
+
_context3.t0 = _context3["catch"](2);
|
|
8377
|
+
throw new Error("Fetch resource from \"".concat(url, "\" failed."));
|
|
8378
|
+
|
|
8379
|
+
case 11:
|
|
8380
|
+
if (!(resolution.type === "noMetadata")) {
|
|
8381
|
+
_context3.next = 13;
|
|
8382
|
+
break;
|
|
8383
|
+
}
|
|
8384
|
+
|
|
8385
|
+
throw new ChannelMetadataNotFoundError("No metadata found.");
|
|
8386
|
+
|
|
8387
|
+
case 13:
|
|
8388
|
+
return _context3.abrupt("return", resolution.data);
|
|
8389
|
+
|
|
8390
|
+
case 14:
|
|
8391
|
+
case "end":
|
|
8392
|
+
return _context3.stop();
|
|
8393
|
+
}
|
|
8394
|
+
}
|
|
8395
|
+
}, _callee3, null, [[2, 8]]);
|
|
8396
|
+
}));
|
|
8397
|
+
|
|
8398
|
+
function fetchResource(_x5, _x6) {
|
|
8399
|
+
return _fetchResource.apply(this, arguments);
|
|
8400
|
+
}
|
|
8401
|
+
|
|
8402
|
+
return fetchResource;
|
|
8403
|
+
}()
|
|
8404
|
+
}, {
|
|
8405
|
+
key: "mutateResource",
|
|
8406
|
+
value: function () {
|
|
8407
|
+
var _mutateResource = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(method, url, requestBody) {
|
|
8408
|
+
var result;
|
|
8409
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
|
|
8410
|
+
while (1) {
|
|
8411
|
+
switch (_context4.prev = _context4.next) {
|
|
8412
|
+
case 0:
|
|
8413
|
+
_context4.next = 2;
|
|
8414
|
+
return this._makeRequest(method, url, requestBody, {
|
|
8415
|
+
"X-Twilio-Mutation-Id": uuidv4()
|
|
8416
|
+
});
|
|
8417
|
+
|
|
8418
|
+
case 2:
|
|
8419
|
+
result = _context4.sent;
|
|
8420
|
+
|
|
8421
|
+
if (!isMutationConflictResponse(result)) {
|
|
8422
|
+
_context4.next = 7;
|
|
8423
|
+
break;
|
|
8424
|
+
}
|
|
8425
|
+
|
|
8426
|
+
_context4.next = 6;
|
|
8427
|
+
return this.fetchResource(result.body.resource_url);
|
|
8428
|
+
|
|
8429
|
+
case 6:
|
|
8430
|
+
return _context4.abrupt("return", _context4.sent);
|
|
8431
|
+
|
|
8432
|
+
case 7:
|
|
8433
|
+
return _context4.abrupt("return", result.body);
|
|
8434
|
+
|
|
8435
|
+
case 8:
|
|
8436
|
+
case "end":
|
|
8437
|
+
return _context4.stop();
|
|
8438
|
+
}
|
|
8439
|
+
}
|
|
8440
|
+
}, _callee4, this);
|
|
8441
|
+
}));
|
|
8442
|
+
|
|
8443
|
+
function mutateResource(_x7, _x8, _x9) {
|
|
8444
|
+
return _mutateResource.apply(this, arguments);
|
|
8445
|
+
}
|
|
8446
|
+
|
|
8447
|
+
return mutateResource;
|
|
8448
|
+
}()
|
|
8449
|
+
}]);
|
|
8450
|
+
|
|
8451
|
+
return CommandExecutor;
|
|
8452
|
+
}();
|
|
8453
|
+
|
|
8454
|
+
var ContentClient = /*#__PURE__*/function () {
|
|
8455
|
+
function ContentClient(_services) {
|
|
8456
|
+
var _pageSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
|
|
8457
|
+
|
|
8458
|
+
var _cacheTtlMs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5000;
|
|
8459
|
+
|
|
8460
|
+
_classCallCheck__default["default"](this, ContentClient);
|
|
8461
|
+
|
|
8462
|
+
_defineProperty__default["default"](this, "_cachedTemplates", null);
|
|
8463
|
+
|
|
8464
|
+
this._services = _services;
|
|
8465
|
+
this._pageSize = _pageSize;
|
|
8466
|
+
this._cacheTtlMs = _cacheTtlMs;
|
|
8467
|
+
}
|
|
8468
|
+
|
|
8469
|
+
_createClass__default["default"](ContentClient, [{
|
|
8470
|
+
key: "getContentTemplates",
|
|
8471
|
+
value: function () {
|
|
8472
|
+
var _getContentTemplates = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
8473
|
+
var _this = this;
|
|
8474
|
+
|
|
8475
|
+
var _yield$this$_fetchCon, _yield$this$_fetchCon2, templatesPage, nextToken, templates, _yield$this$_fetchCon3, _yield$this$_fetchCon4;
|
|
8476
|
+
|
|
8477
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
8478
|
+
while (1) {
|
|
8479
|
+
switch (_context.prev = _context.next) {
|
|
8480
|
+
case 0:
|
|
8481
|
+
if (!(this._cachedTemplates !== null)) {
|
|
8482
|
+
_context.next = 2;
|
|
8483
|
+
break;
|
|
8484
|
+
}
|
|
8485
|
+
|
|
8486
|
+
return _context.abrupt("return", this._cachedTemplates);
|
|
8487
|
+
|
|
8488
|
+
case 2:
|
|
8489
|
+
_context.next = 4;
|
|
8490
|
+
return this._fetchContentTemplates();
|
|
8491
|
+
|
|
8492
|
+
case 4:
|
|
8493
|
+
_yield$this$_fetchCon = _context.sent;
|
|
8494
|
+
_yield$this$_fetchCon2 = _slicedToArray__default["default"](_yield$this$_fetchCon, 2);
|
|
8495
|
+
templatesPage = _yield$this$_fetchCon2[0];
|
|
8496
|
+
nextToken = _yield$this$_fetchCon2[1];
|
|
8497
|
+
templates = templatesPage;
|
|
8498
|
+
|
|
8499
|
+
case 9:
|
|
8500
|
+
if (!(nextToken !== null)) {
|
|
8501
|
+
_context.next = 19;
|
|
8502
|
+
break;
|
|
8503
|
+
}
|
|
8504
|
+
|
|
8505
|
+
_context.next = 12;
|
|
8506
|
+
return this._fetchContentTemplates(nextToken);
|
|
8507
|
+
|
|
8508
|
+
case 12:
|
|
8509
|
+
_yield$this$_fetchCon3 = _context.sent;
|
|
8510
|
+
_yield$this$_fetchCon4 = _slicedToArray__default["default"](_yield$this$_fetchCon3, 2);
|
|
8511
|
+
templatesPage = _yield$this$_fetchCon4[0];
|
|
8512
|
+
nextToken = _yield$this$_fetchCon4[1];
|
|
8513
|
+
templates = [].concat(_toConsumableArray__default["default"](templates), _toConsumableArray__default["default"](templatesPage));
|
|
8514
|
+
_context.next = 9;
|
|
8515
|
+
break;
|
|
8516
|
+
|
|
8517
|
+
case 19:
|
|
8518
|
+
this._cachedTemplates = Object.freeze(templates);
|
|
8519
|
+
setTimeout(function () {
|
|
8520
|
+
_this._cachedTemplates = null;
|
|
8521
|
+
}, this._cacheTtlMs);
|
|
8522
|
+
return _context.abrupt("return", templates);
|
|
8523
|
+
|
|
8524
|
+
case 22:
|
|
8525
|
+
case "end":
|
|
8526
|
+
return _context.stop();
|
|
8527
|
+
}
|
|
8528
|
+
}
|
|
8529
|
+
}, _callee, this);
|
|
8530
|
+
}));
|
|
8531
|
+
|
|
8532
|
+
function getContentTemplates() {
|
|
8533
|
+
return _getContentTemplates.apply(this, arguments);
|
|
8534
|
+
}
|
|
8535
|
+
|
|
8536
|
+
return getContentTemplates;
|
|
8537
|
+
}()
|
|
8538
|
+
}, {
|
|
8539
|
+
key: "_fetchContentTemplates",
|
|
8540
|
+
value: function () {
|
|
8541
|
+
var _fetchContentTemplates2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(pageToken) {
|
|
8542
|
+
var contentTemplatesUrl, url, response;
|
|
8543
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
8544
|
+
while (1) {
|
|
8545
|
+
switch (_context2.prev = _context2.next) {
|
|
8546
|
+
case 0:
|
|
8547
|
+
contentTemplatesUrl = "Client/v2/ContentTemplates";
|
|
8548
|
+
url = new UriBuilder(contentTemplatesUrl);
|
|
8549
|
+
url.arg("PageSize", this._pageSize);
|
|
8550
|
+
|
|
8551
|
+
if (pageToken !== undefined) {
|
|
8552
|
+
url.arg("PageToken", pageToken);
|
|
8553
|
+
}
|
|
8554
|
+
|
|
8555
|
+
_context2.next = 6;
|
|
8556
|
+
return this._services.commandExecutor.fetchResource(url.build());
|
|
8557
|
+
|
|
8558
|
+
case 6:
|
|
8559
|
+
response = _context2.sent;
|
|
8560
|
+
return _context2.abrupt("return", [response.templates.map(function (template) {
|
|
8561
|
+
return new ContentTemplate(template);
|
|
8562
|
+
}), response.meta.next_token]);
|
|
8563
|
+
|
|
8564
|
+
case 8:
|
|
8565
|
+
case "end":
|
|
8566
|
+
return _context2.stop();
|
|
8567
|
+
}
|
|
8568
|
+
}
|
|
8569
|
+
}, _callee2, this);
|
|
8570
|
+
}));
|
|
8571
|
+
|
|
8572
|
+
function _fetchContentTemplates(_x) {
|
|
8573
|
+
return _fetchContentTemplates2.apply(this, arguments);
|
|
8574
|
+
}
|
|
8575
|
+
|
|
8576
|
+
return _fetchContentTemplates;
|
|
8577
|
+
}()
|
|
8578
|
+
}]);
|
|
8579
|
+
|
|
8580
|
+
return ContentClient;
|
|
8581
|
+
}();
|
|
8582
|
+
|
|
8583
|
+
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; } } }; }
|
|
8584
|
+
|
|
8585
|
+
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); }
|
|
8586
|
+
|
|
8587
|
+
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; }
|
|
8588
|
+
|
|
8589
|
+
var QuickLRU = /*#__PURE__*/function (_Symbol$iterator) {
|
|
8590
|
+
function QuickLRU() {
|
|
8591
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8592
|
+
|
|
8593
|
+
_classCallCheck__default["default"](this, QuickLRU);
|
|
8594
|
+
|
|
8595
|
+
if (!(options.maxSize && options.maxSize > 0)) {
|
|
8596
|
+
throw new TypeError('`maxSize` must be a number greater than 0');
|
|
8597
|
+
}
|
|
8598
|
+
|
|
8599
|
+
this.maxSize = options.maxSize;
|
|
8600
|
+
this.onEviction = options.onEviction;
|
|
8601
|
+
this.cache = new Map();
|
|
8602
|
+
this.oldCache = new Map();
|
|
8603
|
+
this._size = 0;
|
|
8604
|
+
}
|
|
8605
|
+
|
|
8606
|
+
_createClass__default["default"](QuickLRU, [{
|
|
8607
|
+
key: "_set",
|
|
8608
|
+
value: function _set(key, value) {
|
|
8609
|
+
this.cache.set(key, value);
|
|
8610
|
+
this._size++;
|
|
8611
|
+
|
|
8612
|
+
if (this._size >= this.maxSize) {
|
|
8613
|
+
this._size = 0;
|
|
8614
|
+
|
|
8615
|
+
if (typeof this.onEviction === 'function') {
|
|
8616
|
+
var _iterator = _createForOfIteratorHelper$1(this.oldCache.entries()),
|
|
8617
|
+
_step;
|
|
8618
|
+
|
|
8619
|
+
try {
|
|
8620
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
8621
|
+
var _step$value = _slicedToArray__default["default"](_step.value, 2),
|
|
8622
|
+
_key = _step$value[0],
|
|
8623
|
+
_value = _step$value[1];
|
|
8624
|
+
|
|
8625
|
+
this.onEviction(_key, _value);
|
|
8626
|
+
}
|
|
8627
|
+
} catch (err) {
|
|
8628
|
+
_iterator.e(err);
|
|
8629
|
+
} finally {
|
|
8630
|
+
_iterator.f();
|
|
8631
|
+
}
|
|
8632
|
+
}
|
|
8633
|
+
|
|
8634
|
+
this.oldCache = this.cache;
|
|
8635
|
+
this.cache = new Map();
|
|
8636
|
+
}
|
|
8637
|
+
}
|
|
8638
|
+
}, {
|
|
8639
|
+
key: "get",
|
|
8640
|
+
value: function get(key) {
|
|
8641
|
+
if (this.cache.has(key)) {
|
|
8642
|
+
return this.cache.get(key);
|
|
8643
|
+
}
|
|
8644
|
+
|
|
8645
|
+
if (this.oldCache.has(key)) {
|
|
8646
|
+
var value = this.oldCache.get(key);
|
|
8647
|
+
this.oldCache.delete(key);
|
|
8648
|
+
|
|
8649
|
+
this._set(key, value);
|
|
8650
|
+
|
|
8651
|
+
return value;
|
|
8652
|
+
}
|
|
8653
|
+
}
|
|
8654
|
+
}, {
|
|
8655
|
+
key: "set",
|
|
8656
|
+
value: function set(key, value) {
|
|
8657
|
+
if (this.cache.has(key)) {
|
|
8658
|
+
this.cache.set(key, value);
|
|
8659
|
+
} else {
|
|
8660
|
+
this._set(key, value);
|
|
8661
|
+
}
|
|
8662
|
+
|
|
8663
|
+
return this;
|
|
8664
|
+
}
|
|
8665
|
+
}, {
|
|
8666
|
+
key: "has",
|
|
8667
|
+
value: function has(key) {
|
|
8668
|
+
return this.cache.has(key) || this.oldCache.has(key);
|
|
8669
|
+
}
|
|
8670
|
+
}, {
|
|
8671
|
+
key: "peek",
|
|
8672
|
+
value: function peek(key) {
|
|
8673
|
+
if (this.cache.has(key)) {
|
|
8674
|
+
return this.cache.get(key);
|
|
8675
|
+
}
|
|
8676
|
+
|
|
8677
|
+
if (this.oldCache.has(key)) {
|
|
8678
|
+
return this.oldCache.get(key);
|
|
8679
|
+
}
|
|
8680
|
+
}
|
|
8681
|
+
}, {
|
|
8682
|
+
key: "delete",
|
|
8683
|
+
value: function _delete(key) {
|
|
8684
|
+
var deleted = this.cache.delete(key);
|
|
8685
|
+
|
|
8686
|
+
if (deleted) {
|
|
8687
|
+
this._size--;
|
|
8688
|
+
}
|
|
8689
|
+
|
|
8690
|
+
return this.oldCache.delete(key) || deleted;
|
|
8691
|
+
}
|
|
8692
|
+
}, {
|
|
8693
|
+
key: "clear",
|
|
8694
|
+
value: function clear() {
|
|
8695
|
+
this.cache.clear();
|
|
8696
|
+
this.oldCache.clear();
|
|
8697
|
+
this._size = 0;
|
|
8698
|
+
}
|
|
8699
|
+
}, {
|
|
8700
|
+
key: "keys",
|
|
8701
|
+
value: /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function keys() {
|
|
8702
|
+
var _iterator2, _step2, _step2$value, key;
|
|
8703
|
+
|
|
8704
|
+
return _regeneratorRuntime__default["default"].wrap(function keys$(_context) {
|
|
8705
|
+
while (1) {
|
|
8706
|
+
switch (_context.prev = _context.next) {
|
|
8707
|
+
case 0:
|
|
8708
|
+
_iterator2 = _createForOfIteratorHelper$1(this);
|
|
8709
|
+
_context.prev = 1;
|
|
8710
|
+
|
|
8711
|
+
_iterator2.s();
|
|
8712
|
+
|
|
8713
|
+
case 3:
|
|
8714
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
8715
|
+
_context.next = 9;
|
|
8716
|
+
break;
|
|
8717
|
+
}
|
|
8718
|
+
|
|
8719
|
+
_step2$value = _slicedToArray__default["default"](_step2.value, 1), key = _step2$value[0];
|
|
8720
|
+
_context.next = 7;
|
|
8721
|
+
return key;
|
|
8722
|
+
|
|
8723
|
+
case 7:
|
|
8724
|
+
_context.next = 3;
|
|
8725
|
+
break;
|
|
8726
|
+
|
|
8727
|
+
case 9:
|
|
8728
|
+
_context.next = 14;
|
|
8729
|
+
break;
|
|
8730
|
+
|
|
8731
|
+
case 11:
|
|
8732
|
+
_context.prev = 11;
|
|
8733
|
+
_context.t0 = _context["catch"](1);
|
|
8734
|
+
|
|
8735
|
+
_iterator2.e(_context.t0);
|
|
8736
|
+
|
|
8737
|
+
case 14:
|
|
8738
|
+
_context.prev = 14;
|
|
8739
|
+
|
|
8740
|
+
_iterator2.f();
|
|
8741
|
+
|
|
8742
|
+
return _context.finish(14);
|
|
8743
|
+
|
|
8744
|
+
case 17:
|
|
8745
|
+
case "end":
|
|
8746
|
+
return _context.stop();
|
|
8747
|
+
}
|
|
8748
|
+
}
|
|
8749
|
+
}, keys, this, [[1, 11, 14, 17]]);
|
|
8750
|
+
})
|
|
8751
|
+
}, {
|
|
8752
|
+
key: "values",
|
|
8753
|
+
value: /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function values() {
|
|
8754
|
+
var _iterator3, _step3, _step3$value, value;
|
|
8755
|
+
|
|
8756
|
+
return _regeneratorRuntime__default["default"].wrap(function values$(_context2) {
|
|
8757
|
+
while (1) {
|
|
8758
|
+
switch (_context2.prev = _context2.next) {
|
|
8759
|
+
case 0:
|
|
8760
|
+
_iterator3 = _createForOfIteratorHelper$1(this);
|
|
8761
|
+
_context2.prev = 1;
|
|
8762
|
+
|
|
8763
|
+
_iterator3.s();
|
|
8764
|
+
|
|
8765
|
+
case 3:
|
|
8766
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
8767
|
+
_context2.next = 9;
|
|
8768
|
+
break;
|
|
8769
|
+
}
|
|
8770
|
+
|
|
8771
|
+
_step3$value = _slicedToArray__default["default"](_step3.value, 2), value = _step3$value[1];
|
|
8772
|
+
_context2.next = 7;
|
|
8773
|
+
return value;
|
|
8774
|
+
|
|
8775
|
+
case 7:
|
|
8776
|
+
_context2.next = 3;
|
|
8777
|
+
break;
|
|
8778
|
+
|
|
8779
|
+
case 9:
|
|
8780
|
+
_context2.next = 14;
|
|
8781
|
+
break;
|
|
8782
|
+
|
|
8783
|
+
case 11:
|
|
8784
|
+
_context2.prev = 11;
|
|
8785
|
+
_context2.t0 = _context2["catch"](1);
|
|
8786
|
+
|
|
8787
|
+
_iterator3.e(_context2.t0);
|
|
8788
|
+
|
|
8789
|
+
case 14:
|
|
8790
|
+
_context2.prev = 14;
|
|
8791
|
+
|
|
8792
|
+
_iterator3.f();
|
|
8793
|
+
|
|
8794
|
+
return _context2.finish(14);
|
|
8795
|
+
|
|
8796
|
+
case 17:
|
|
8797
|
+
case "end":
|
|
8798
|
+
return _context2.stop();
|
|
8799
|
+
}
|
|
8800
|
+
}
|
|
8801
|
+
}, values, this, [[1, 11, 14, 17]]);
|
|
8802
|
+
})
|
|
8803
|
+
}, {
|
|
8804
|
+
key: _Symbol$iterator,
|
|
8805
|
+
value: /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function value() {
|
|
8806
|
+
var _iterator4, _step4, item, _iterator5, _step5, _item, _item2, key;
|
|
8807
|
+
|
|
8808
|
+
return _regeneratorRuntime__default["default"].wrap(function value$(_context3) {
|
|
8809
|
+
while (1) {
|
|
8810
|
+
switch (_context3.prev = _context3.next) {
|
|
8811
|
+
case 0:
|
|
8812
|
+
_iterator4 = _createForOfIteratorHelper$1(this.cache);
|
|
8813
|
+
_context3.prev = 1;
|
|
8814
|
+
|
|
8815
|
+
_iterator4.s();
|
|
8816
|
+
|
|
8817
|
+
case 3:
|
|
8818
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
8819
|
+
_context3.next = 9;
|
|
8820
|
+
break;
|
|
8821
|
+
}
|
|
8822
|
+
|
|
8823
|
+
item = _step4.value;
|
|
8824
|
+
_context3.next = 7;
|
|
8825
|
+
return item;
|
|
8826
|
+
|
|
8827
|
+
case 7:
|
|
8828
|
+
_context3.next = 3;
|
|
8829
|
+
break;
|
|
8830
|
+
|
|
8831
|
+
case 9:
|
|
8832
|
+
_context3.next = 14;
|
|
8833
|
+
break;
|
|
8834
|
+
|
|
8835
|
+
case 11:
|
|
8836
|
+
_context3.prev = 11;
|
|
8837
|
+
_context3.t0 = _context3["catch"](1);
|
|
8838
|
+
|
|
8839
|
+
_iterator4.e(_context3.t0);
|
|
8840
|
+
|
|
8841
|
+
case 14:
|
|
8842
|
+
_context3.prev = 14;
|
|
8843
|
+
|
|
8844
|
+
_iterator4.f();
|
|
8845
|
+
|
|
8846
|
+
return _context3.finish(14);
|
|
8847
|
+
|
|
8848
|
+
case 17:
|
|
8849
|
+
_iterator5 = _createForOfIteratorHelper$1(this.oldCache);
|
|
8850
|
+
_context3.prev = 18;
|
|
8851
|
+
|
|
8852
|
+
_iterator5.s();
|
|
8853
|
+
|
|
8854
|
+
case 20:
|
|
8855
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
8856
|
+
_context3.next = 28;
|
|
8857
|
+
break;
|
|
8858
|
+
}
|
|
8859
|
+
|
|
8860
|
+
_item = _step5.value;
|
|
8861
|
+
_item2 = _slicedToArray__default["default"](_item, 1), key = _item2[0];
|
|
8862
|
+
|
|
8863
|
+
if (this.cache.has(key)) {
|
|
8864
|
+
_context3.next = 26;
|
|
8865
|
+
break;
|
|
8866
|
+
}
|
|
8867
|
+
|
|
8868
|
+
_context3.next = 26;
|
|
8869
|
+
return _item;
|
|
8870
|
+
|
|
8871
|
+
case 26:
|
|
8872
|
+
_context3.next = 20;
|
|
8873
|
+
break;
|
|
8874
|
+
|
|
8875
|
+
case 28:
|
|
8876
|
+
_context3.next = 33;
|
|
8877
|
+
break;
|
|
8878
|
+
|
|
8879
|
+
case 30:
|
|
8880
|
+
_context3.prev = 30;
|
|
8881
|
+
_context3.t1 = _context3["catch"](18);
|
|
8882
|
+
|
|
8883
|
+
_iterator5.e(_context3.t1);
|
|
8884
|
+
|
|
8885
|
+
case 33:
|
|
8886
|
+
_context3.prev = 33;
|
|
8887
|
+
|
|
8888
|
+
_iterator5.f();
|
|
8889
|
+
|
|
8890
|
+
return _context3.finish(33);
|
|
8891
|
+
|
|
8892
|
+
case 36:
|
|
8893
|
+
case "end":
|
|
8894
|
+
return _context3.stop();
|
|
8895
|
+
}
|
|
8896
|
+
}
|
|
8897
|
+
}, value, this, [[1, 11, 14, 17], [18, 30, 33, 36]]);
|
|
8898
|
+
})
|
|
8899
|
+
}, {
|
|
8900
|
+
key: "size",
|
|
8901
|
+
get: function get() {
|
|
8902
|
+
var oldCacheSize = 0;
|
|
8903
|
+
|
|
8904
|
+
var _iterator6 = _createForOfIteratorHelper$1(this.oldCache.keys()),
|
|
8905
|
+
_step6;
|
|
8906
|
+
|
|
8907
|
+
try {
|
|
8908
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
8909
|
+
var key = _step6.value;
|
|
8910
|
+
|
|
8911
|
+
if (!this.cache.has(key)) {
|
|
8912
|
+
oldCacheSize++;
|
|
8913
|
+
}
|
|
8914
|
+
}
|
|
8915
|
+
} catch (err) {
|
|
8916
|
+
_iterator6.e(err);
|
|
8917
|
+
} finally {
|
|
8918
|
+
_iterator6.f();
|
|
8919
|
+
}
|
|
8920
|
+
|
|
8921
|
+
return Math.min(this._size + oldCacheSize, this.maxSize);
|
|
8922
|
+
}
|
|
8923
|
+
}]);
|
|
8924
|
+
|
|
8925
|
+
return QuickLRU;
|
|
8926
|
+
}(Symbol.iterator);
|
|
8927
|
+
|
|
8928
|
+
var quickLru = QuickLRU;
|
|
8929
|
+
|
|
8930
|
+
/**
|
|
8931
|
+
* Represents channel metadata.
|
|
8932
|
+
*/
|
|
8933
|
+
|
|
8934
|
+
var ChannelMetadata = /*#__PURE__*/_createClass__default["default"](
|
|
8935
|
+
/**
|
|
8936
|
+
* Communication channel type.
|
|
8937
|
+
*/
|
|
8938
|
+
|
|
8939
|
+
/**
|
|
8940
|
+
* The actual metadata.
|
|
8941
|
+
*/
|
|
8942
|
+
|
|
8943
|
+
/**
|
|
8944
|
+
* @internal
|
|
8945
|
+
*/
|
|
8946
|
+
function ChannelMetadata(type, data) {
|
|
8947
|
+
_classCallCheck__default["default"](this, ChannelMetadata);
|
|
8948
|
+
|
|
8949
|
+
this.type = type;
|
|
8950
|
+
this.data = data;
|
|
8951
|
+
Object.freeze(data);
|
|
8952
|
+
});
|
|
8953
|
+
|
|
8954
|
+
var ChannelMetadataClient = /*#__PURE__*/function () {
|
|
8955
|
+
function ChannelMetadataClient(services, configuration) {
|
|
8956
|
+
_classCallCheck__default["default"](this, ChannelMetadataClient);
|
|
8957
|
+
|
|
8958
|
+
this._services = services;
|
|
8959
|
+
this._configuration = configuration;
|
|
8960
|
+
this._cache = new quickLru({
|
|
8961
|
+
maxSize: configuration.channelMetadataCacheCapacity
|
|
8962
|
+
});
|
|
8963
|
+
}
|
|
8964
|
+
|
|
8965
|
+
_createClass__default["default"](ChannelMetadataClient, [{
|
|
8966
|
+
key: "getChannelMetadata",
|
|
8967
|
+
value: function () {
|
|
8968
|
+
var _getChannelMetadata = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(conversationSid, messageSid) {
|
|
8969
|
+
var key, cachedItem, url, metadataResponse, metadata;
|
|
8970
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
8971
|
+
while (1) {
|
|
8972
|
+
switch (_context.prev = _context.next) {
|
|
8973
|
+
case 0:
|
|
8974
|
+
key = "".concat(conversationSid, ",").concat(messageSid);
|
|
8975
|
+
cachedItem = this._cache.get(key);
|
|
8976
|
+
|
|
8977
|
+
if (!cachedItem) {
|
|
8978
|
+
_context.next = 4;
|
|
8979
|
+
break;
|
|
8980
|
+
}
|
|
8981
|
+
|
|
8982
|
+
return _context.abrupt("return", cachedItem.item);
|
|
8983
|
+
|
|
8984
|
+
case 4:
|
|
8985
|
+
url = "".concat(this._configuration.links.conversations, "/").concat(conversationSid, "/Messages/").concat(messageSid, "/ChannelMetadata");
|
|
8986
|
+
_context.prev = 5;
|
|
8987
|
+
_context.next = 8;
|
|
8988
|
+
return this._services.commandExecutor.fetchResource(url);
|
|
8989
|
+
|
|
8990
|
+
case 8:
|
|
8991
|
+
metadataResponse = _context.sent;
|
|
8992
|
+
_context.next = 17;
|
|
8993
|
+
break;
|
|
8994
|
+
|
|
8995
|
+
case 11:
|
|
8996
|
+
_context.prev = 11;
|
|
8997
|
+
_context.t0 = _context["catch"](5);
|
|
8998
|
+
|
|
8999
|
+
if (!(_context.t0 instanceof ChannelMetadataNotFoundError)) {
|
|
9000
|
+
_context.next = 16;
|
|
9001
|
+
break;
|
|
9002
|
+
}
|
|
9003
|
+
|
|
9004
|
+
this._cache.set(key, {
|
|
9005
|
+
item: null
|
|
9006
|
+
});
|
|
9007
|
+
|
|
9008
|
+
return _context.abrupt("return", null);
|
|
9009
|
+
|
|
9010
|
+
case 16:
|
|
9011
|
+
throw new Error(_context.t0);
|
|
9012
|
+
|
|
9013
|
+
case 17:
|
|
9014
|
+
metadata = new ChannelMetadata(metadataResponse.type, metadataResponse.data);
|
|
9015
|
+
|
|
9016
|
+
this._cache.set(key, {
|
|
9017
|
+
item: metadata
|
|
9018
|
+
});
|
|
9019
|
+
|
|
9020
|
+
return _context.abrupt("return", metadata);
|
|
9021
|
+
|
|
9022
|
+
case 20:
|
|
9023
|
+
case "end":
|
|
9024
|
+
return _context.stop();
|
|
9025
|
+
}
|
|
9026
|
+
}
|
|
9027
|
+
}, _callee, this, [[5, 11]]);
|
|
9028
|
+
}));
|
|
9029
|
+
|
|
9030
|
+
function getChannelMetadata(_x, _x2) {
|
|
9031
|
+
return _getChannelMetadata.apply(this, arguments);
|
|
9032
|
+
}
|
|
9033
|
+
|
|
9034
|
+
return getChannelMetadata;
|
|
9035
|
+
}()
|
|
9036
|
+
}]);
|
|
9037
|
+
|
|
9038
|
+
return ChannelMetadataClient;
|
|
9039
|
+
}();
|
|
9040
|
+
|
|
9041
|
+
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; } } }; }
|
|
9042
|
+
|
|
9043
|
+
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); }
|
|
9044
|
+
|
|
9045
|
+
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; }
|
|
9046
|
+
/**
|
|
9047
|
+
* Email recipient descriptor.
|
|
9048
|
+
*/
|
|
9049
|
+
|
|
9050
|
+
var EmailRecipientDescriptor = /*#__PURE__*/_createClass__default["default"](
|
|
9051
|
+
/**
|
|
9052
|
+
* Type of recipient.
|
|
9053
|
+
*/
|
|
9054
|
+
|
|
9055
|
+
/**
|
|
9056
|
+
* Sid of the message that this recipient belongs to.
|
|
9057
|
+
*/
|
|
9058
|
+
|
|
9059
|
+
/**
|
|
9060
|
+
* Email recipient level.
|
|
9061
|
+
*/
|
|
9062
|
+
|
|
9063
|
+
/**
|
|
9064
|
+
* Name of the recipient.
|
|
9065
|
+
*/
|
|
9066
|
+
|
|
9067
|
+
/**
|
|
9068
|
+
* Address of the recipient.
|
|
9069
|
+
*/
|
|
9070
|
+
|
|
9071
|
+
/**
|
|
9072
|
+
* @internal
|
|
9073
|
+
*/
|
|
9074
|
+
function EmailRecipientDescriptor(recipient) {
|
|
9075
|
+
_classCallCheck__default["default"](this, EmailRecipientDescriptor);
|
|
7235
9076
|
|
|
7236
|
-
|
|
7237
|
-
response = _context.sent;
|
|
7238
|
-
return _context.abrupt("break", 19);
|
|
9077
|
+
_defineProperty__default["default"](this, "type", "email");
|
|
7239
9078
|
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
9079
|
+
this.messageSid = recipient.message_sid;
|
|
9080
|
+
this.level = recipient.level;
|
|
9081
|
+
this.name = recipient.name;
|
|
9082
|
+
this.address = recipient.address;
|
|
9083
|
+
});
|
|
9084
|
+
/**
|
|
9085
|
+
* Unknown recipient descriptor. Used to be able to handle recipient types that
|
|
9086
|
+
* are not supported by the current version of the SDK.
|
|
9087
|
+
*/
|
|
7243
9088
|
|
|
7244
|
-
case 13:
|
|
7245
|
-
response = _context.sent;
|
|
7246
|
-
return _context.abrupt("break", 19);
|
|
7247
9089
|
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
9090
|
+
var UnknownRecipientDescriptor = /*#__PURE__*/_createClass__default["default"](
|
|
9091
|
+
/**
|
|
9092
|
+
* Type of recipient.
|
|
9093
|
+
*/
|
|
7251
9094
|
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
9095
|
+
/**
|
|
9096
|
+
* Sid of the message that this recipient belongs to.
|
|
9097
|
+
*/
|
|
7255
9098
|
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
break;
|
|
7260
|
-
}
|
|
9099
|
+
/**
|
|
9100
|
+
* Recipient data as a JSON string.
|
|
9101
|
+
*/
|
|
7261
9102
|
|
|
7262
|
-
|
|
9103
|
+
/**
|
|
9104
|
+
* @internal
|
|
9105
|
+
*/
|
|
9106
|
+
function UnknownRecipientDescriptor(recipient) {
|
|
9107
|
+
_classCallCheck__default["default"](this, UnknownRecipientDescriptor);
|
|
7263
9108
|
|
|
7264
|
-
|
|
7265
|
-
|
|
9109
|
+
this.type = recipient.type;
|
|
9110
|
+
this.messageSid = recipient.message_sid;
|
|
9111
|
+
this.rawData = JSON.stringify(recipient);
|
|
9112
|
+
});
|
|
7266
9113
|
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
}
|
|
7271
|
-
}
|
|
7272
|
-
}, _callee, this);
|
|
7273
|
-
}));
|
|
9114
|
+
var MessageRecipientsClient = /*#__PURE__*/function () {
|
|
9115
|
+
function MessageRecipientsClient(services, configuration) {
|
|
9116
|
+
_classCallCheck__default["default"](this, MessageRecipientsClient);
|
|
7274
9117
|
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
9118
|
+
this._services = services;
|
|
9119
|
+
this._configuration = configuration;
|
|
9120
|
+
this._cache = new quickLru({
|
|
9121
|
+
maxSize: configuration.messageRecipientsCacheCapacity
|
|
9122
|
+
});
|
|
9123
|
+
}
|
|
7278
9124
|
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
}, {
|
|
7282
|
-
key: "fetchResource",
|
|
9125
|
+
_createClass__default["default"](MessageRecipientsClient, [{
|
|
9126
|
+
key: "getRecipientsFromMessage",
|
|
7283
9127
|
value: function () {
|
|
7284
|
-
var
|
|
9128
|
+
var _getRecipientsFromMessage = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(conversationSid, messageSid) {
|
|
7285
9129
|
var _this = this;
|
|
7286
9130
|
|
|
7287
|
-
var
|
|
7288
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
9131
|
+
var key, cachedItem, url, recipientsResponse, recipients;
|
|
9132
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
7289
9133
|
while (1) {
|
|
7290
|
-
switch (
|
|
9134
|
+
switch (_context.prev = _context.next) {
|
|
7291
9135
|
case 0:
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
});
|
|
9136
|
+
key = "".concat(conversationSid, ",").concat(messageSid);
|
|
9137
|
+
cachedItem = this._cache.get(key);
|
|
9138
|
+
|
|
9139
|
+
if (!cachedItem) {
|
|
9140
|
+
_context.next = 4;
|
|
9141
|
+
break;
|
|
9142
|
+
}
|
|
9143
|
+
|
|
9144
|
+
return _context.abrupt("return", cachedItem.item);
|
|
7302
9145
|
|
|
7303
9146
|
case 4:
|
|
7304
|
-
|
|
7305
|
-
|
|
9147
|
+
url = new UriBuilder(this._configuration.links.conversations).path(conversationSid).path("MessageRecipients").arg("MessageSid", messageSid).build();
|
|
9148
|
+
_context.next = 7;
|
|
9149
|
+
return this._services.commandExecutor.fetchResource(url);
|
|
7306
9150
|
|
|
7307
|
-
case
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
9151
|
+
case 7:
|
|
9152
|
+
recipientsResponse = _context.sent;
|
|
9153
|
+
recipients = recipientsResponse.message_recipients.map(function (recipient) {
|
|
9154
|
+
return _this._wrapResponse(recipient);
|
|
9155
|
+
});
|
|
9156
|
+
|
|
9157
|
+
if (recipients.length > 0) {
|
|
9158
|
+
this._cache.set(key, {
|
|
9159
|
+
item: recipients
|
|
9160
|
+
});
|
|
9161
|
+
}
|
|
9162
|
+
|
|
9163
|
+
return _context.abrupt("return", recipients);
|
|
7311
9164
|
|
|
7312
9165
|
case 11:
|
|
7313
9166
|
case "end":
|
|
7314
|
-
return
|
|
9167
|
+
return _context.stop();
|
|
7315
9168
|
}
|
|
7316
9169
|
}
|
|
7317
|
-
},
|
|
9170
|
+
}, _callee, this);
|
|
7318
9171
|
}));
|
|
7319
9172
|
|
|
7320
|
-
function
|
|
7321
|
-
return
|
|
9173
|
+
function getRecipientsFromMessage(_x, _x2) {
|
|
9174
|
+
return _getRecipientsFromMessage.apply(this, arguments);
|
|
7322
9175
|
}
|
|
7323
9176
|
|
|
7324
|
-
return
|
|
9177
|
+
return getRecipientsFromMessage;
|
|
7325
9178
|
}()
|
|
7326
9179
|
}, {
|
|
7327
|
-
key: "
|
|
9180
|
+
key: "getRecipientsFromConversation",
|
|
7328
9181
|
value: function () {
|
|
7329
|
-
var
|
|
7330
|
-
var
|
|
7331
|
-
|
|
9182
|
+
var _getRecipientsFromConversation = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(conversationSid, paginatorOptions) {
|
|
9183
|
+
var _paginatorOptions$pag,
|
|
9184
|
+
_paginatorOptions$pag2,
|
|
9185
|
+
_this2 = this;
|
|
9186
|
+
|
|
9187
|
+
var url, recipientsResponse, allRecipients, _iterator, _step, _this$_cache$get$item, _this$_cache$get, recipient, key, existingMessageRecipients;
|
|
9188
|
+
|
|
9189
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
7332
9190
|
while (1) {
|
|
7333
|
-
switch (
|
|
9191
|
+
switch (_context2.prev = _context2.next) {
|
|
7334
9192
|
case 0:
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
9193
|
+
url = new UriBuilder(this._configuration.links.conversations).path(conversationSid).path("MessageRecipients").arg("PageToken", (_paginatorOptions$pag = paginatorOptions === null || paginatorOptions === void 0 ? void 0 : paginatorOptions.pageToken) !== null && _paginatorOptions$pag !== void 0 ? _paginatorOptions$pag : undefined).arg("PageSize", (_paginatorOptions$pag2 = paginatorOptions === null || paginatorOptions === void 0 ? void 0 : paginatorOptions.pageSize) !== null && _paginatorOptions$pag2 !== void 0 ? _paginatorOptions$pag2 : undefined).build();
|
|
9194
|
+
_context2.next = 3;
|
|
9195
|
+
return this._services.commandExecutor.fetchResource(url);
|
|
9196
|
+
|
|
9197
|
+
case 3:
|
|
9198
|
+
recipientsResponse = _context2.sent;
|
|
9199
|
+
allRecipients = recipientsResponse.message_recipients.map(function (recipient) {
|
|
9200
|
+
return _this2._wrapResponse(recipient);
|
|
7338
9201
|
});
|
|
9202
|
+
_iterator = _createForOfIteratorHelper(allRecipients);
|
|
7339
9203
|
|
|
7340
|
-
|
|
7341
|
-
|
|
9204
|
+
try {
|
|
9205
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
9206
|
+
recipient = _step.value;
|
|
9207
|
+
key = "".concat(conversationSid, ",").concat(recipient.messageSid);
|
|
9208
|
+
existingMessageRecipients = (_this$_cache$get$item = (_this$_cache$get = this._cache.get(key)) === null || _this$_cache$get === void 0 ? void 0 : _this$_cache$get.item) !== null && _this$_cache$get$item !== void 0 ? _this$_cache$get$item : [];
|
|
7342
9209
|
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
9210
|
+
this._cache.set(key, {
|
|
9211
|
+
item: [].concat(_toConsumableArray__default["default"](existingMessageRecipients), [recipient])
|
|
9212
|
+
});
|
|
9213
|
+
}
|
|
9214
|
+
} catch (err) {
|
|
9215
|
+
_iterator.e(err);
|
|
9216
|
+
} finally {
|
|
9217
|
+
_iterator.f();
|
|
7346
9218
|
}
|
|
7347
9219
|
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
case 7:
|
|
7355
|
-
return _context3.abrupt("return", result.body);
|
|
9220
|
+
return _context2.abrupt("return", new RestPaginator(allRecipients, function (pageToken, pageSize) {
|
|
9221
|
+
return _this2.getRecipientsFromConversation(conversationSid, {
|
|
9222
|
+
pageToken: pageToken,
|
|
9223
|
+
pageSize: pageSize
|
|
9224
|
+
});
|
|
9225
|
+
}, recipientsResponse.meta.previous_token, recipientsResponse.meta.next_token));
|
|
7356
9226
|
|
|
7357
9227
|
case 8:
|
|
7358
9228
|
case "end":
|
|
7359
|
-
return
|
|
9229
|
+
return _context2.stop();
|
|
7360
9230
|
}
|
|
7361
9231
|
}
|
|
7362
|
-
},
|
|
9232
|
+
}, _callee2, this);
|
|
7363
9233
|
}));
|
|
7364
9234
|
|
|
7365
|
-
function
|
|
7366
|
-
return
|
|
9235
|
+
function getRecipientsFromConversation(_x3, _x4) {
|
|
9236
|
+
return _getRecipientsFromConversation.apply(this, arguments);
|
|
7367
9237
|
}
|
|
7368
9238
|
|
|
7369
|
-
return
|
|
9239
|
+
return getRecipientsFromConversation;
|
|
7370
9240
|
}()
|
|
9241
|
+
}, {
|
|
9242
|
+
key: "_wrapResponse",
|
|
9243
|
+
value: function _wrapResponse(recipient) {
|
|
9244
|
+
switch (recipient.type) {
|
|
9245
|
+
case "email":
|
|
9246
|
+
return new EmailRecipientDescriptor(recipient);
|
|
9247
|
+
|
|
9248
|
+
default:
|
|
9249
|
+
return new UnknownRecipientDescriptor(recipient);
|
|
9250
|
+
}
|
|
9251
|
+
}
|
|
7371
9252
|
}]);
|
|
7372
9253
|
|
|
7373
|
-
return
|
|
9254
|
+
return MessageRecipientsClient;
|
|
7374
9255
|
}();
|
|
7375
9256
|
|
|
7376
9257
|
var _class;
|
|
@@ -7572,12 +9453,25 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
7572
9453
|
*/
|
|
7573
9454
|
|
|
7574
9455
|
/**
|
|
9456
|
+
* @deprecated Use initialized or initFailed events instead
|
|
7575
9457
|
* Fired when the state of the client has been changed.
|
|
7576
9458
|
*
|
|
7577
9459
|
* Parameters:
|
|
9460
|
+
* 1. {@link State} `state` - the new client state
|
|
9461
|
+
* @event
|
|
9462
|
+
*/
|
|
9463
|
+
|
|
9464
|
+
/**
|
|
9465
|
+
* Fired when the client has completed initialization successfully.
|
|
9466
|
+
* @event
|
|
9467
|
+
*/
|
|
9468
|
+
|
|
9469
|
+
/**
|
|
9470
|
+
* Fired when the client initialization failed.
|
|
9471
|
+
*
|
|
9472
|
+
* Parameters:
|
|
7578
9473
|
* 1. object `data` - info object provided with the event. It has the
|
|
7579
|
-
* following
|
|
7580
|
-
* * {@link State} `state` - the new client state
|
|
9474
|
+
* following property:
|
|
7581
9475
|
* * Error? `error` - the initialization error if present
|
|
7582
9476
|
* @event
|
|
7583
9477
|
*/
|
|
@@ -7628,7 +9522,47 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
7628
9522
|
*/
|
|
7629
9523
|
|
|
7630
9524
|
/**
|
|
7631
|
-
*
|
|
9525
|
+
* Promise that resolves on successful initialization.
|
|
9526
|
+
*/
|
|
9527
|
+
|
|
9528
|
+
/**
|
|
9529
|
+
* Options passed to the client.
|
|
9530
|
+
*/
|
|
9531
|
+
|
|
9532
|
+
/**
|
|
9533
|
+
* Client service objects.
|
|
9534
|
+
*/
|
|
9535
|
+
|
|
9536
|
+
/**
|
|
9537
|
+
* The user of the client.
|
|
9538
|
+
*/
|
|
9539
|
+
|
|
9540
|
+
/**
|
|
9541
|
+
* Resolves the {@link Client._ensureReady} promise.
|
|
9542
|
+
*/
|
|
9543
|
+
|
|
9544
|
+
/**
|
|
9545
|
+
* Rejects the {@link Client._ensureReady} promise.
|
|
9546
|
+
*/
|
|
9547
|
+
|
|
9548
|
+
/**
|
|
9549
|
+
* The current token of the client.
|
|
9550
|
+
*/
|
|
9551
|
+
|
|
9552
|
+
/**
|
|
9553
|
+
* The constructed configuration object.
|
|
9554
|
+
*/
|
|
9555
|
+
|
|
9556
|
+
/**
|
|
9557
|
+
* The Conversations entity.
|
|
9558
|
+
*/
|
|
9559
|
+
|
|
9560
|
+
/**
|
|
9561
|
+
* Promise that resolves when initial conversations are fetched.
|
|
9562
|
+
*/
|
|
9563
|
+
|
|
9564
|
+
/**
|
|
9565
|
+
* Returned Conversations Client instance is not yet fully initialized. Calling any
|
|
7632
9566
|
* operations will block until it is. Use connection events to monitor when
|
|
7633
9567
|
* client becomes fully available (connectionStateChanged with state
|
|
7634
9568
|
* 'connected') or not available (connectionStateChange with state 'denied',
|
|
@@ -7718,16 +9652,16 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
7718
9652
|
|
|
7719
9653
|
_this._services.twilsockClient = _this._options.twilsockClient = (_this$_options$twilso = _this._options.twilsockClient) !== null && _this$_options$twilso !== void 0 ? _this$_options$twilso : new twilsock.TwilsockClient(fpaToken, productId, _this._options);
|
|
7720
9654
|
|
|
7721
|
-
_this._services.twilsockClient.on(
|
|
7722
|
-
return _this.emit(
|
|
9655
|
+
_this._services.twilsockClient.on(Client_1.tokenAboutToExpire, function () {
|
|
9656
|
+
return _this.emit(Client_1.tokenAboutToExpire);
|
|
7723
9657
|
});
|
|
7724
9658
|
|
|
7725
|
-
_this._services.twilsockClient.on(
|
|
7726
|
-
return _this.emit(
|
|
9659
|
+
_this._services.twilsockClient.on(Client_1.tokenExpired, function () {
|
|
9660
|
+
return _this.emit(Client_1.tokenExpired);
|
|
7727
9661
|
});
|
|
7728
9662
|
|
|
7729
|
-
_this._services.twilsockClient.on(
|
|
7730
|
-
return _this.emit(
|
|
9663
|
+
_this._services.twilsockClient.on(Client_1.connectionError, function (error) {
|
|
9664
|
+
return _this.emit(Client_1.connectionError, error);
|
|
7731
9665
|
});
|
|
7732
9666
|
|
|
7733
9667
|
_this._services.twilsockClient.on("stateChanged", function (state) {
|
|
@@ -7736,7 +9670,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
7736
9670
|
if (state !== _this.connectionState) {
|
|
7737
9671
|
_this.connectionState = state;
|
|
7738
9672
|
|
|
7739
|
-
_this.emit(
|
|
9673
|
+
_this.emit(Client_1.connectionStateChanged, _this.connectionState);
|
|
7740
9674
|
}
|
|
7741
9675
|
});
|
|
7742
9676
|
|
|
@@ -7749,12 +9683,14 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
7749
9683
|
_this._services.commandExecutor = new CommandExecutor(baseUrl, {
|
|
7750
9684
|
transport: _this._options.transport
|
|
7751
9685
|
}, productId);
|
|
9686
|
+
_this._services.contentClient = new ContentClient(_this._services);
|
|
7752
9687
|
|
|
7753
9688
|
var emitFailed = function emitFailed(error) {
|
|
7754
9689
|
_this._rejectEnsureReady(error);
|
|
7755
9690
|
|
|
7756
|
-
_this.emit(
|
|
7757
|
-
|
|
9691
|
+
_this.emit(Client_1.stateChanged, "failed");
|
|
9692
|
+
|
|
9693
|
+
_this.emit(Client_1.initFailed, {
|
|
7758
9694
|
error: error
|
|
7759
9695
|
});
|
|
7760
9696
|
};
|
|
@@ -7764,13 +9700,15 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
7764
9700
|
terminal: true,
|
|
7765
9701
|
message: "Twilsock has disconnected."
|
|
7766
9702
|
});
|
|
9703
|
+
|
|
9704
|
+
_this._initializeEnsureReady((options === null || options === void 0 ? void 0 : options.throwErrorsAlways) || false);
|
|
7767
9705
|
};
|
|
7768
9706
|
|
|
7769
|
-
_this._services.twilsockClient.
|
|
9707
|
+
_this._services.twilsockClient.once("connectionError", emitFailed);
|
|
7770
9708
|
|
|
7771
|
-
_this._services.twilsockClient.
|
|
9709
|
+
_this._services.twilsockClient.once("disconnected", emitDisconnected);
|
|
7772
9710
|
|
|
7773
|
-
_this._services.twilsockClient.
|
|
9711
|
+
_this._services.twilsockClient.once("connected", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
7774
9712
|
var startupEvent, connectionError;
|
|
7775
9713
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
7776
9714
|
while (1) {
|
|
@@ -7793,7 +9731,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
7793
9731
|
case 8:
|
|
7794
9732
|
_this._services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription("", "", new Date()), startupEvent, twilsock.TelemetryPoint.End);
|
|
7795
9733
|
|
|
7796
|
-
_context.next =
|
|
9734
|
+
_context.next = 17;
|
|
7797
9735
|
break;
|
|
7798
9736
|
|
|
7799
9737
|
case 11:
|
|
@@ -7807,12 +9745,13 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
7807
9745
|
|
|
7808
9746
|
_this._rejectEnsureReady(connectionError);
|
|
7809
9747
|
|
|
7810
|
-
_this.emit(
|
|
7811
|
-
|
|
9748
|
+
_this.emit(Client_1.stateChanged, "failed");
|
|
9749
|
+
|
|
9750
|
+
_this.emit(Client_1.initFailed, {
|
|
7812
9751
|
error: connectionError
|
|
7813
9752
|
});
|
|
7814
9753
|
|
|
7815
|
-
case
|
|
9754
|
+
case 17:
|
|
7816
9755
|
case "end":
|
|
7817
9756
|
return _context.stop();
|
|
7818
9757
|
}
|
|
@@ -7820,12 +9759,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
7820
9759
|
}, _callee, null, [[3, 11]]);
|
|
7821
9760
|
})));
|
|
7822
9761
|
|
|
7823
|
-
_this.
|
|
7824
|
-
_this._resolveEnsureReady = resolve;
|
|
7825
|
-
_this._rejectEnsureReady = reject;
|
|
7826
|
-
}).catch(function () {
|
|
7827
|
-
return void 0;
|
|
7828
|
-
}); // @todo How to process unhandled rejection here?
|
|
9762
|
+
_this._initializeEnsureReady((options === null || options === void 0 ? void 0 : options.throwErrorsAlways) || false);
|
|
7829
9763
|
|
|
7830
9764
|
if (startTwilsock) {
|
|
7831
9765
|
_this._services.twilsockClient.connect();
|
|
@@ -7859,6 +9793,17 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
7859
9793
|
|
|
7860
9794
|
return this._configuration.reachabilityEnabled;
|
|
7861
9795
|
}
|
|
9796
|
+
/**
|
|
9797
|
+
* @deprecated
|
|
9798
|
+
* Current token.
|
|
9799
|
+
* @internal
|
|
9800
|
+
*/
|
|
9801
|
+
|
|
9802
|
+
}, {
|
|
9803
|
+
key: "token",
|
|
9804
|
+
get: function get() {
|
|
9805
|
+
return this._fpaToken;
|
|
9806
|
+
}
|
|
7862
9807
|
/**
|
|
7863
9808
|
* @deprecated Call constructor directly.
|
|
7864
9809
|
*
|
|
@@ -7997,16 +9942,32 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
7997
9942
|
conversation = _context4.sent;
|
|
7998
9943
|
|
|
7999
9944
|
if (conversation) {
|
|
8000
|
-
_context4.next =
|
|
9945
|
+
_context4.next = 12;
|
|
9946
|
+
break;
|
|
9947
|
+
}
|
|
9948
|
+
|
|
9949
|
+
_context4.next = 10;
|
|
9950
|
+
return this.peekConversationBySid(conversationSid);
|
|
9951
|
+
|
|
9952
|
+
case 10:
|
|
9953
|
+
conversation = _context4.sent;
|
|
9954
|
+
|
|
9955
|
+
if (conversation) {
|
|
9956
|
+
deprecationDecorator.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");
|
|
9957
|
+
}
|
|
9958
|
+
|
|
9959
|
+
case 12:
|
|
9960
|
+
if (conversation) {
|
|
9961
|
+
_context4.next = 14;
|
|
8001
9962
|
break;
|
|
8002
9963
|
}
|
|
8003
9964
|
|
|
8004
9965
|
throw new Error("Conversation with SID ".concat(conversationSid, " was not found."));
|
|
8005
9966
|
|
|
8006
|
-
case
|
|
9967
|
+
case 14:
|
|
8007
9968
|
return _context4.abrupt("return", conversation);
|
|
8008
9969
|
|
|
8009
|
-
case
|
|
9970
|
+
case 15:
|
|
8010
9971
|
case "end":
|
|
8011
9972
|
return _context4.stop();
|
|
8012
9973
|
}
|
|
@@ -8023,7 +9984,6 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
8023
9984
|
/**
|
|
8024
9985
|
* Peek a conversation by its SID.
|
|
8025
9986
|
* @param conversationSid Conversation sid
|
|
8026
|
-
* @internal
|
|
8027
9987
|
*/
|
|
8028
9988
|
|
|
8029
9989
|
}, {
|
|
@@ -8309,7 +10269,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
8309
10269
|
return removePushRegistrations;
|
|
8310
10270
|
}()
|
|
8311
10271
|
/**
|
|
8312
|
-
*
|
|
10272
|
+
* Parse a push notification payload.
|
|
8313
10273
|
*/
|
|
8314
10274
|
|
|
8315
10275
|
}, {
|
|
@@ -8492,6 +10452,43 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
8492
10452
|
});
|
|
8493
10453
|
return this.getTemporaryContentUrlsForMediaSids(sids);
|
|
8494
10454
|
}
|
|
10455
|
+
/**
|
|
10456
|
+
* Returns rich content templates belonging to the account. Rich content
|
|
10457
|
+
* templates can be created via the Twilio console or the REST API.
|
|
10458
|
+
*/
|
|
10459
|
+
|
|
10460
|
+
}, {
|
|
10461
|
+
key: "getContentTemplates",
|
|
10462
|
+
value: function () {
|
|
10463
|
+
var _getContentTemplates = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee16() {
|
|
10464
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee16$(_context16) {
|
|
10465
|
+
while (1) {
|
|
10466
|
+
switch (_context16.prev = _context16.next) {
|
|
10467
|
+
case 0:
|
|
10468
|
+
_context16.next = 2;
|
|
10469
|
+
return this._ensureReady;
|
|
10470
|
+
|
|
10471
|
+
case 2:
|
|
10472
|
+
_context16.next = 4;
|
|
10473
|
+
return this._services.contentClient.getContentTemplates();
|
|
10474
|
+
|
|
10475
|
+
case 4:
|
|
10476
|
+
return _context16.abrupt("return", _context16.sent);
|
|
10477
|
+
|
|
10478
|
+
case 5:
|
|
10479
|
+
case "end":
|
|
10480
|
+
return _context16.stop();
|
|
10481
|
+
}
|
|
10482
|
+
}
|
|
10483
|
+
}, _callee16, this);
|
|
10484
|
+
}));
|
|
10485
|
+
|
|
10486
|
+
function getContentTemplates() {
|
|
10487
|
+
return _getContentTemplates.apply(this, arguments);
|
|
10488
|
+
}
|
|
10489
|
+
|
|
10490
|
+
return getContentTemplates;
|
|
10491
|
+
}()
|
|
8495
10492
|
/**
|
|
8496
10493
|
* Initialize the client.
|
|
8497
10494
|
*/
|
|
@@ -8499,20 +10496,22 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
8499
10496
|
}, {
|
|
8500
10497
|
key: "_initialize",
|
|
8501
10498
|
value: function () {
|
|
8502
|
-
var _initialize2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
10499
|
+
var _initialize2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee17() {
|
|
8503
10500
|
var _this3 = this;
|
|
8504
10501
|
|
|
8505
10502
|
var configurationResponse;
|
|
8506
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
10503
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee17$(_context17) {
|
|
8507
10504
|
while (1) {
|
|
8508
|
-
switch (
|
|
10505
|
+
switch (_context17.prev = _context17.next) {
|
|
8509
10506
|
case 0:
|
|
8510
|
-
|
|
10507
|
+
_context17.next = 2;
|
|
8511
10508
|
return this._services.commandExecutor.fetchResource("Client/v2/Configuration");
|
|
8512
10509
|
|
|
8513
10510
|
case 2:
|
|
8514
|
-
configurationResponse =
|
|
10511
|
+
configurationResponse = _context17.sent;
|
|
8515
10512
|
this._configuration = new Configuration(this._options, configurationResponse, Client_1._logger);
|
|
10513
|
+
this._services.channelMetadataClient = new ChannelMetadataClient(this._services, this._configuration);
|
|
10514
|
+
this._services.messageRecipientsClient = new MessageRecipientsClient(this._services, this._configuration);
|
|
8516
10515
|
|
|
8517
10516
|
this._myself._resolveInitialization(this._configuration, this._configuration.userIdentity, this._configuration.userInfo, true);
|
|
8518
10517
|
|
|
@@ -8589,12 +10588,13 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
8589
10588
|
this._conversationsPromise = this._conversationsEntity.fetchConversations().then(function () {
|
|
8590
10589
|
return _this3._conversationsEntity;
|
|
8591
10590
|
}).catch(function (error) {
|
|
10591
|
+
console.error("Failed to fetch conversations _conversationsPromise -> client.ts", error);
|
|
8592
10592
|
throw error;
|
|
8593
10593
|
});
|
|
8594
|
-
|
|
10594
|
+
_context17.next = 30;
|
|
8595
10595
|
return this._services.users.myself._ensureFetched();
|
|
8596
10596
|
|
|
8597
|
-
case
|
|
10597
|
+
case 30:
|
|
8598
10598
|
Client_1._supportedPushChannels.forEach(function (channelType) {
|
|
8599
10599
|
return _this3._subscribeToPushNotifications(channelType);
|
|
8600
10600
|
});
|
|
@@ -8607,16 +10607,15 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
8607
10607
|
|
|
8608
10608
|
this._resolveEnsureReady();
|
|
8609
10609
|
|
|
8610
|
-
this.emit(
|
|
8611
|
-
|
|
8612
|
-
});
|
|
10610
|
+
this.emit(Client_1.stateChanged, "initialized");
|
|
10611
|
+
this.emit(Client_1.initialized);
|
|
8613
10612
|
|
|
8614
|
-
case
|
|
10613
|
+
case 36:
|
|
8615
10614
|
case "end":
|
|
8616
|
-
return
|
|
10615
|
+
return _context17.stop();
|
|
8617
10616
|
}
|
|
8618
10617
|
}
|
|
8619
|
-
},
|
|
10618
|
+
}, _callee17, this);
|
|
8620
10619
|
}));
|
|
8621
10620
|
|
|
8622
10621
|
function _initialize() {
|
|
@@ -8653,17 +10652,37 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
8653
10652
|
_this5._services.notificationClient.unsubscribe(channelType, messageType);
|
|
8654
10653
|
});
|
|
8655
10654
|
}
|
|
10655
|
+
/**
|
|
10656
|
+
* Initialize the ensureReady promise.
|
|
10657
|
+
*/
|
|
10658
|
+
|
|
10659
|
+
}, {
|
|
10660
|
+
key: "_initializeEnsureReady",
|
|
10661
|
+
value: function _initializeEnsureReady(throwErrorsAlways) {
|
|
10662
|
+
var _this6 = this;
|
|
10663
|
+
|
|
10664
|
+
this._ensureReady = new Promise(function (resolve, reject) {
|
|
10665
|
+
_this6._resolveEnsureReady = resolve;
|
|
10666
|
+
_this6._rejectEnsureReady = reject;
|
|
10667
|
+
}).catch(function (error) {
|
|
10668
|
+
if (throwErrorsAlways) {
|
|
10669
|
+
throw error;
|
|
10670
|
+
} else {
|
|
10671
|
+
return void 0;
|
|
10672
|
+
}
|
|
10673
|
+
});
|
|
10674
|
+
}
|
|
8656
10675
|
}], [{
|
|
8657
10676
|
key: "create",
|
|
8658
10677
|
value: function () {
|
|
8659
|
-
var _create = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
10678
|
+
var _create = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee18(token, options) {
|
|
8660
10679
|
var client;
|
|
8661
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
10680
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee18$(_context18) {
|
|
8662
10681
|
while (1) {
|
|
8663
|
-
switch (
|
|
10682
|
+
switch (_context18.prev = _context18.next) {
|
|
8664
10683
|
case 0:
|
|
8665
10684
|
if (!(options !== null && options !== void 0 && options.twilsockClient)) {
|
|
8666
|
-
|
|
10685
|
+
_context18.next = 2;
|
|
8667
10686
|
break;
|
|
8668
10687
|
}
|
|
8669
10688
|
|
|
@@ -8671,18 +10690,18 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
8671
10690
|
|
|
8672
10691
|
case 2:
|
|
8673
10692
|
client = new Client_1(token, options);
|
|
8674
|
-
|
|
10693
|
+
_context18.next = 5;
|
|
8675
10694
|
return client._ensureReady;
|
|
8676
10695
|
|
|
8677
10696
|
case 5:
|
|
8678
|
-
return
|
|
10697
|
+
return _context18.abrupt("return", client);
|
|
8679
10698
|
|
|
8680
10699
|
case 6:
|
|
8681
10700
|
case "end":
|
|
8682
|
-
return
|
|
10701
|
+
return _context18.stop();
|
|
8683
10702
|
}
|
|
8684
10703
|
}
|
|
8685
|
-
},
|
|
10704
|
+
}, _callee18);
|
|
8686
10705
|
}));
|
|
8687
10706
|
|
|
8688
10707
|
function create(_x16, _x17) {
|
|
@@ -8815,7 +10834,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
8815
10834
|
}]);
|
|
8816
10835
|
|
|
8817
10836
|
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", {
|
|
10837
|
+
}(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
10838
|
conversation_sid: "conversationSid",
|
|
8820
10839
|
conversation_title: "conversationTitle",
|
|
8821
10840
|
message_sid: "messageSid",
|
|
@@ -8825,6 +10844,8 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
|
8825
10844
|
|
|
8826
10845
|
}), _class);
|
|
8827
10846
|
|
|
10847
|
+
__decorate([deprecationDecorator.deprecated("token"), __metadata("design:type", String), __metadata("design:paramtypes", [])], exports.Client.prototype, "token", null);
|
|
10848
|
+
|
|
8828
10849
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "updateToken", null);
|
|
8829
10850
|
|
|
8830
10851
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise)], exports.Client.prototype, "getConversationBySid", null);
|
|
@@ -8853,7 +10874,7 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
|
|
|
8853
10874
|
|
|
8854
10875
|
__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
10876
|
|
|
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);
|
|
10877
|
+
__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
10878
|
|
|
8858
10879
|
__decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.pureObject), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", PushNotification)], exports.Client, "parsePushNotification", null);
|
|
8859
10880
|
|
|
@@ -8864,8 +10885,12 @@ Object.defineProperty(exports, 'CancellablePromise', {
|
|
|
8864
10885
|
get: function () { return mcsClient.CancellablePromise; }
|
|
8865
10886
|
});
|
|
8866
10887
|
exports.AggregatedDeliveryReceipt = AggregatedDeliveryReceipt;
|
|
10888
|
+
exports.ChannelMetadata = ChannelMetadata;
|
|
10889
|
+
exports.ContentTemplate = ContentTemplate;
|
|
10890
|
+
exports.ContentTemplateVariable = ContentTemplateVariable;
|
|
8867
10891
|
exports.Conversation = Conversation;
|
|
8868
10892
|
exports.DetailedDeliveryReceipt = DetailedDeliveryReceipt;
|
|
10893
|
+
exports.EmailRecipientDescriptor = EmailRecipientDescriptor;
|
|
8869
10894
|
exports.Media = Media;
|
|
8870
10895
|
exports.Message = Message;
|
|
8871
10896
|
exports.MessageBuilder = MessageBuilder;
|
|
@@ -8873,6 +10898,7 @@ exports.NotificationTypes = NotificationTypes;
|
|
|
8873
10898
|
exports.Participant = Participant;
|
|
8874
10899
|
exports.PushNotification = PushNotification;
|
|
8875
10900
|
exports.RestPaginator = RestPaginator;
|
|
10901
|
+
exports.UnknownRecipientDescriptor = UnknownRecipientDescriptor;
|
|
8876
10902
|
exports.UnsentMessage = UnsentMessage;
|
|
8877
10903
|
exports.User = User;
|
|
8878
10904
|
//# sourceMappingURL=browser.js.map
|