@twilio/conversations 2.2.2 → 2.3.0-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/builds/browser.js +606 -25
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +501 -3
- package/builds/lib.js +606 -25
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +864 -267
- package/builds/twilio-conversations.min.js +1 -1
- package/dist/client.js +10 -0
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js.map +1 -1
- package/dist/content-client.js +175 -0
- package/dist/content-client.js.map +1 -0
- package/dist/content-template.js +301 -0
- package/dist/content-template.js.map +1 -0
- package/dist/data/messages.js +4 -0
- package/dist/data/messages.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/message-builder.js +19 -0
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +70 -0
- package/dist/message.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/unsent-message.js.map +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/classes/Client.html +24 -0
- package/docs/classes/ContentTemplate.html +3116 -0
- package/docs/classes/ContentTemplateVariable.html +3116 -0
- package/docs/classes/Message.html +47 -0
- package/docs/classes/MessageBuilder.html +41 -0
- package/docs/index.html +813 -0
- package/docs/modules.html +813 -0
- package/package.json +7 -7
package/builds/browser.js
CHANGED
@@ -211,11 +211,13 @@ require('core-js/modules/es.array-buffer.constructor.js');
|
|
211
211
|
require('isomorphic-form-data');
|
212
212
|
require('core-js/modules/es.array.sort.js');
|
213
213
|
require('core-js/modules/es.string.includes.js');
|
214
|
+
require('core-js/modules/es.string.starts-with.js');
|
214
215
|
var deprecationDecorator = require('@twilio/deprecation-decorator');
|
216
|
+
require('core-js/modules/es.object.entries.js');
|
215
217
|
require('core-js/modules/es.array.find.js');
|
216
218
|
require('core-js/modules/es.array.splice.js');
|
217
|
-
require('core-js/modules/es.object.entries.js');
|
218
219
|
var uuid = require('uuid');
|
220
|
+
require('core-js/modules/es.object.freeze.js');
|
219
221
|
|
220
222
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
221
223
|
|
@@ -390,9 +392,9 @@ var Logger = /*#__PURE__*/function () {
|
|
390
392
|
return Logger;
|
391
393
|
}();
|
392
394
|
|
393
|
-
function ownKeys$
|
395
|
+
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; }
|
394
396
|
|
395
|
-
function _objectSpread$
|
397
|
+
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; }
|
396
398
|
var TYPING_TIMEOUT = 5;
|
397
399
|
var HTTP_CACHE_LIFETIME = "PT5S";
|
398
400
|
var CONSUMPTION_HORIZON_SENDING_INTERVAL = "PT5S";
|
@@ -433,7 +435,7 @@ var Configuration = /*#__PURE__*/_createClass__default["default"](function Confi
|
|
433
435
|
emailBodiesAllowedContentTypes: configurationResponse.options.email_bodies_allowed_mime_types
|
434
436
|
};
|
435
437
|
this.typingIndicatorTimeoutOverride = constructorOptions.typingIndicatorTimeoutOverride;
|
436
|
-
this.backoffConfiguration = _objectSpread$
|
438
|
+
this.backoffConfiguration = _objectSpread$5({
|
437
439
|
min: MINIMUM_RETRY_DELAY,
|
438
440
|
max: MAXIMUM_RETRY_DELAY,
|
439
441
|
maxAttemptsCount: MAXIMUM_ATTEMPTS_COUNT
|
@@ -2547,9 +2549,247 @@ function DetailedDeliveryReceipt(descriptor) {
|
|
2547
2549
|
this.dateUpdated = descriptor.date_updated;
|
2548
2550
|
});
|
2549
2551
|
|
2550
|
-
|
2552
|
+
var collectActions = function collectActions(actions) {
|
2553
|
+
return actions.map(function (action) {
|
2554
|
+
var _action$id, _action$index, _action$phone, _action$url;
|
2551
2555
|
|
2552
|
-
|
2556
|
+
var rawData = JSON.stringify(action);
|
2557
|
+
|
2558
|
+
switch (action.type) {
|
2559
|
+
case "QUICK_REPLY":
|
2560
|
+
return {
|
2561
|
+
type: "reply",
|
2562
|
+
title: action.title,
|
2563
|
+
id: (_action$id = action.id) !== null && _action$id !== void 0 ? _action$id : "",
|
2564
|
+
index: (_action$index = action.index) !== null && _action$index !== void 0 ? _action$index : 0,
|
2565
|
+
rawData: rawData
|
2566
|
+
};
|
2567
|
+
|
2568
|
+
case "PHONE_NUMBER":
|
2569
|
+
return {
|
2570
|
+
type: "phone",
|
2571
|
+
title: action.title,
|
2572
|
+
phone: (_action$phone = action.phone) !== null && _action$phone !== void 0 ? _action$phone : "",
|
2573
|
+
rawData: rawData
|
2574
|
+
};
|
2575
|
+
|
2576
|
+
case "URL":
|
2577
|
+
return {
|
2578
|
+
type: "url",
|
2579
|
+
title: action.title,
|
2580
|
+
url: (_action$url = action.url) !== null && _action$url !== void 0 ? _action$url : "",
|
2581
|
+
rawData: rawData
|
2582
|
+
};
|
2583
|
+
|
2584
|
+
default:
|
2585
|
+
return {
|
2586
|
+
type: "other",
|
2587
|
+
rawData: rawData
|
2588
|
+
};
|
2589
|
+
}
|
2590
|
+
});
|
2591
|
+
};
|
2592
|
+
|
2593
|
+
var parseVariant = function parseVariant(type, data) {
|
2594
|
+
var rawData = JSON.stringify(data);
|
2595
|
+
|
2596
|
+
switch (type) {
|
2597
|
+
case "twilio/text":
|
2598
|
+
{
|
2599
|
+
var variant = data;
|
2600
|
+
return {
|
2601
|
+
type: "text",
|
2602
|
+
body: variant.body,
|
2603
|
+
rawData: rawData
|
2604
|
+
};
|
2605
|
+
}
|
2606
|
+
|
2607
|
+
case "twilio/media":
|
2608
|
+
{
|
2609
|
+
var _variant = data;
|
2610
|
+
return {
|
2611
|
+
type: "media",
|
2612
|
+
body: _variant.body,
|
2613
|
+
media: _variant.media,
|
2614
|
+
rawData: rawData
|
2615
|
+
};
|
2616
|
+
}
|
2617
|
+
|
2618
|
+
case "twilio/location":
|
2619
|
+
{
|
2620
|
+
var _variant2 = data;
|
2621
|
+
return {
|
2622
|
+
type: "location",
|
2623
|
+
longitude: _variant2.longitude,
|
2624
|
+
latitude: _variant2.latitude,
|
2625
|
+
label: _variant2.label,
|
2626
|
+
rawData: rawData
|
2627
|
+
};
|
2628
|
+
}
|
2629
|
+
|
2630
|
+
case "twilio/quick-reply":
|
2631
|
+
{
|
2632
|
+
var _variant3 = data;
|
2633
|
+
return {
|
2634
|
+
type: "quickReply",
|
2635
|
+
body: _variant3.body,
|
2636
|
+
replies: _variant3.actions,
|
2637
|
+
rawData: rawData
|
2638
|
+
};
|
2639
|
+
}
|
2640
|
+
|
2641
|
+
case "twilio/call-to-action":
|
2642
|
+
{
|
2643
|
+
var _variant4 = data;
|
2644
|
+
return {
|
2645
|
+
type: "callToAction",
|
2646
|
+
body: _variant4.body,
|
2647
|
+
actions: collectActions(_variant4.actions),
|
2648
|
+
rawData: rawData
|
2649
|
+
};
|
2650
|
+
}
|
2651
|
+
|
2652
|
+
case "twilio/list-picker":
|
2653
|
+
{
|
2654
|
+
var _variant5 = data;
|
2655
|
+
return {
|
2656
|
+
type: "listPicker",
|
2657
|
+
body: _variant5.body,
|
2658
|
+
button: _variant5.button,
|
2659
|
+
items: _variant5.items,
|
2660
|
+
rawData: rawData
|
2661
|
+
};
|
2662
|
+
}
|
2663
|
+
|
2664
|
+
case "twilio/card":
|
2665
|
+
{
|
2666
|
+
var _variant6$media, _variant6$actions;
|
2667
|
+
|
2668
|
+
var _variant6 = data;
|
2669
|
+
return {
|
2670
|
+
type: "card",
|
2671
|
+
title: _variant6.title,
|
2672
|
+
subtitle: _variant6.subtitle,
|
2673
|
+
media: (_variant6$media = _variant6.media) !== null && _variant6$media !== void 0 ? _variant6$media : [],
|
2674
|
+
actions: collectActions((_variant6$actions = _variant6.actions) !== null && _variant6$actions !== void 0 ? _variant6$actions : []),
|
2675
|
+
rawData: rawData
|
2676
|
+
};
|
2677
|
+
}
|
2678
|
+
|
2679
|
+
default:
|
2680
|
+
return {
|
2681
|
+
type: "other",
|
2682
|
+
rawData: rawData
|
2683
|
+
};
|
2684
|
+
}
|
2685
|
+
};
|
2686
|
+
|
2687
|
+
var collectVariants = function collectVariants(variants) {
|
2688
|
+
var variantsMap = new Map();
|
2689
|
+
|
2690
|
+
for (var _i = 0, _Object$entries = Object.entries(variants); _i < _Object$entries.length; _i++) {
|
2691
|
+
var _Object$entries$_i = _slicedToArray__default["default"](_Object$entries[_i], 2),
|
2692
|
+
key = _Object$entries$_i[0],
|
2693
|
+
value = _Object$entries$_i[1];
|
2694
|
+
|
2695
|
+
variantsMap.set(key, parseVariant(key, value));
|
2696
|
+
}
|
2697
|
+
|
2698
|
+
return variantsMap;
|
2699
|
+
};
|
2700
|
+
/**
|
2701
|
+
* Represents a variable for a content template. See
|
2702
|
+
* {@link ContentTemplate.variables}.
|
2703
|
+
*/
|
2704
|
+
|
2705
|
+
|
2706
|
+
var ContentTemplateVariable = /*#__PURE__*/function () {
|
2707
|
+
function ContentTemplateVariable(
|
2708
|
+
/**
|
2709
|
+
* Name of the variable.
|
2710
|
+
*/
|
2711
|
+
name,
|
2712
|
+
/**
|
2713
|
+
* Key of the variable
|
2714
|
+
*/
|
2715
|
+
value) {
|
2716
|
+
_classCallCheck__default["default"](this, ContentTemplateVariable);
|
2717
|
+
|
2718
|
+
this.name = name;
|
2719
|
+
this.value = value;
|
2720
|
+
}
|
2721
|
+
/**
|
2722
|
+
* Copies the variable with a new value.
|
2723
|
+
*
|
2724
|
+
* @param value The new value for the variable.
|
2725
|
+
*/
|
2726
|
+
|
2727
|
+
|
2728
|
+
_createClass__default["default"](ContentTemplateVariable, [{
|
2729
|
+
key: "copyWithValue",
|
2730
|
+
value: function copyWithValue(value) {
|
2731
|
+
return new ContentTemplateVariable(this.name, value);
|
2732
|
+
}
|
2733
|
+
}]);
|
2734
|
+
|
2735
|
+
return ContentTemplateVariable;
|
2736
|
+
}();
|
2737
|
+
/**
|
2738
|
+
* A rich content template.
|
2739
|
+
*
|
2740
|
+
* Use {@Link Client.getContentTemplates} to request all the templates available
|
2741
|
+
* for the current account.
|
2742
|
+
*/
|
2743
|
+
|
2744
|
+
|
2745
|
+
var ContentTemplate = /*#__PURE__*/_createClass__default["default"](
|
2746
|
+
/**
|
2747
|
+
* The server-assigned unique identifier for the template.
|
2748
|
+
*/
|
2749
|
+
|
2750
|
+
/**
|
2751
|
+
* Friendly name used to describe the content. Not visible to the recipient.
|
2752
|
+
*/
|
2753
|
+
|
2754
|
+
/**
|
2755
|
+
* Variables used by this template.
|
2756
|
+
*/
|
2757
|
+
|
2758
|
+
/**
|
2759
|
+
* Variants of the content. See @{link ContentData}.
|
2760
|
+
*/
|
2761
|
+
|
2762
|
+
/**
|
2763
|
+
* Date of creation.
|
2764
|
+
*/
|
2765
|
+
|
2766
|
+
/**
|
2767
|
+
* Date of the last update.
|
2768
|
+
*/
|
2769
|
+
|
2770
|
+
/**
|
2771
|
+
* @internal
|
2772
|
+
*/
|
2773
|
+
function ContentTemplate(contentTemplateResponse) {
|
2774
|
+
_classCallCheck__default["default"](this, ContentTemplate);
|
2775
|
+
|
2776
|
+
this.sid = contentTemplateResponse.sid;
|
2777
|
+
this.friendlyName = contentTemplateResponse.friendly_name;
|
2778
|
+
this.variables = Object.entries(JSON.parse(contentTemplateResponse.variables)).map(function (_ref) {
|
2779
|
+
var _ref2 = _slicedToArray__default["default"](_ref, 2),
|
2780
|
+
key = _ref2[0],
|
2781
|
+
value = _ref2[1];
|
2782
|
+
|
2783
|
+
return new ContentTemplateVariable(key, value);
|
2784
|
+
});
|
2785
|
+
this.variants = collectVariants(contentTemplateResponse.variants);
|
2786
|
+
this.dateCreated = new Date(contentTemplateResponse.date_created);
|
2787
|
+
this.dateUpdated = new Date(contentTemplateResponse.date_updated);
|
2788
|
+
});
|
2789
|
+
|
2790
|
+
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; }
|
2791
|
+
|
2792
|
+
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; }
|
2553
2793
|
|
2554
2794
|
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); }; }
|
2555
2795
|
|
@@ -2588,6 +2828,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2588
2828
|
index: index,
|
2589
2829
|
author: data.author,
|
2590
2830
|
subject: data.subject,
|
2831
|
+
contentSid: data.contentSid,
|
2591
2832
|
body: (_data$text = data.text) !== null && _data$text !== void 0 ? _data$text : null,
|
2592
2833
|
timestamp: data.timestamp ? new Date(data.timestamp) : null,
|
2593
2834
|
dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,
|
@@ -2597,7 +2838,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2597
2838
|
media: data.type === "media" && data.media ? new Media(data.media, _this.services) : null,
|
2598
2839
|
medias: data.type === "media" && data.medias ? data.medias.map(function (m) {
|
2599
2840
|
return new Media(m, _this.services);
|
2600
|
-
}) : data.type === "media" && data.media && !data.medias ? [new Media(_objectSpread$
|
2841
|
+
}) : data.type === "media" && data.media && !data.medias ? [new Media(_objectSpread$4(_objectSpread$4({}, data.media), {}, {
|
2601
2842
|
category: "media"
|
2602
2843
|
}), _this.services)] : null,
|
2603
2844
|
participantSid: (_data$memberSid = data.memberSid) !== null && _data$memberSid !== void 0 ? _data$memberSid : null,
|
@@ -2642,6 +2883,15 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2642
2883
|
get: function get() {
|
2643
2884
|
return this.state.subject;
|
2644
2885
|
}
|
2886
|
+
/**
|
2887
|
+
* Unique identifier of {@link ContentTemplate} for this message.
|
2888
|
+
*/
|
2889
|
+
|
2890
|
+
}, {
|
2891
|
+
key: "contentSid",
|
2892
|
+
get: function get() {
|
2893
|
+
return this.state.contentSid;
|
2894
|
+
}
|
2645
2895
|
/**
|
2646
2896
|
* Body of the message.
|
2647
2897
|
*/
|
@@ -3303,6 +3553,137 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3303
3553
|
|
3304
3554
|
return _getDetailedDeliveryReceiptsPaginator;
|
3305
3555
|
}()
|
3556
|
+
/**
|
3557
|
+
* Get the {@link ContentData} for this message. Resolves to `null` when
|
3558
|
+
* {@link Message.contentSid} is null.
|
3559
|
+
*/
|
3560
|
+
|
3561
|
+
}, {
|
3562
|
+
key: "getContentData",
|
3563
|
+
value: function getContentData() {
|
3564
|
+
var _this6 = this;
|
3565
|
+
|
3566
|
+
return new mcsClient.CancellablePromise( /*#__PURE__*/function () {
|
3567
|
+
var _ref2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9(resolve, reject, onCancel) {
|
3568
|
+
var bodies, twilioPrefix, filteredMedias, contentMedia, urlPromise, url, abortController, responsePromise, json, response, blob, text, dataType;
|
3569
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context9) {
|
3570
|
+
while (1) {
|
3571
|
+
switch (_context9.prev = _context9.next) {
|
3572
|
+
case 0:
|
3573
|
+
if (!(_this6.state.contentSid === null)) {
|
3574
|
+
_context9.next = 3;
|
3575
|
+
break;
|
3576
|
+
}
|
3577
|
+
|
3578
|
+
resolve(null);
|
3579
|
+
return _context9.abrupt("return");
|
3580
|
+
|
3581
|
+
case 3:
|
3582
|
+
bodies = _this6.getMediaByCategories(["body"]);
|
3583
|
+
|
3584
|
+
if (!(bodies === null)) {
|
3585
|
+
_context9.next = 7;
|
3586
|
+
break;
|
3587
|
+
}
|
3588
|
+
|
3589
|
+
resolve(null);
|
3590
|
+
return _context9.abrupt("return");
|
3591
|
+
|
3592
|
+
case 7:
|
3593
|
+
twilioPrefix = "application/x-vnd.com.twilio.rich.";
|
3594
|
+
filteredMedias = bodies.filter(function (media) {
|
3595
|
+
return media.contentType.startsWith(twilioPrefix);
|
3596
|
+
});
|
3597
|
+
|
3598
|
+
if (!(filteredMedias.length === 0)) {
|
3599
|
+
_context9.next = 12;
|
3600
|
+
break;
|
3601
|
+
}
|
3602
|
+
|
3603
|
+
resolve(null);
|
3604
|
+
return _context9.abrupt("return");
|
3605
|
+
|
3606
|
+
case 12:
|
3607
|
+
contentMedia = filteredMedias[0];
|
3608
|
+
urlPromise = contentMedia.getContentTemporaryUrl();
|
3609
|
+
onCancel(function () {
|
3610
|
+
urlPromise.cancel();
|
3611
|
+
});
|
3612
|
+
_context9.prev = 15;
|
3613
|
+
_context9.next = 18;
|
3614
|
+
return urlPromise;
|
3615
|
+
|
3616
|
+
case 18:
|
3617
|
+
url = _context9.sent;
|
3618
|
+
_context9.next = 25;
|
3619
|
+
break;
|
3620
|
+
|
3621
|
+
case 21:
|
3622
|
+
_context9.prev = 21;
|
3623
|
+
_context9.t0 = _context9["catch"](15);
|
3624
|
+
reject(_context9.t0);
|
3625
|
+
return _context9.abrupt("return");
|
3626
|
+
|
3627
|
+
case 25:
|
3628
|
+
if (!(url === null)) {
|
3629
|
+
_context9.next = 28;
|
3630
|
+
break;
|
3631
|
+
}
|
3632
|
+
|
3633
|
+
resolve(null);
|
3634
|
+
return _context9.abrupt("return");
|
3635
|
+
|
3636
|
+
case 28:
|
3637
|
+
abortController = new AbortController();
|
3638
|
+
responsePromise = fetch(url, {
|
3639
|
+
signal: abortController.signal
|
3640
|
+
});
|
3641
|
+
onCancel(function () {
|
3642
|
+
abortController.abort();
|
3643
|
+
});
|
3644
|
+
_context9.prev = 31;
|
3645
|
+
_context9.next = 34;
|
3646
|
+
return responsePromise;
|
3647
|
+
|
3648
|
+
case 34:
|
3649
|
+
response = _context9.sent;
|
3650
|
+
_context9.next = 37;
|
3651
|
+
return response.blob();
|
3652
|
+
|
3653
|
+
case 37:
|
3654
|
+
blob = _context9.sent;
|
3655
|
+
_context9.next = 40;
|
3656
|
+
return blob.text();
|
3657
|
+
|
3658
|
+
case 40:
|
3659
|
+
text = _context9.sent;
|
3660
|
+
json = JSON.parse(text);
|
3661
|
+
_context9.next = 48;
|
3662
|
+
break;
|
3663
|
+
|
3664
|
+
case 44:
|
3665
|
+
_context9.prev = 44;
|
3666
|
+
_context9.t1 = _context9["catch"](31);
|
3667
|
+
reject(_context9.t1);
|
3668
|
+
return _context9.abrupt("return");
|
3669
|
+
|
3670
|
+
case 48:
|
3671
|
+
dataType = contentMedia.contentType.replace(twilioPrefix, "").replace(".", "/");
|
3672
|
+
resolve(parseVariant(dataType, json.data));
|
3673
|
+
|
3674
|
+
case 50:
|
3675
|
+
case "end":
|
3676
|
+
return _context9.stop();
|
3677
|
+
}
|
3678
|
+
}
|
3679
|
+
}, _callee9, null, [[15, 21], [31, 44]]);
|
3680
|
+
}));
|
3681
|
+
|
3682
|
+
return function (_x8, _x9, _x10) {
|
3683
|
+
return _ref2.apply(this, arguments);
|
3684
|
+
};
|
3685
|
+
}());
|
3686
|
+
}
|
3306
3687
|
}]);
|
3307
3688
|
|
3308
3689
|
return Message;
|
@@ -3326,6 +3707,10 @@ __decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator
|
|
3326
3707
|
|
3327
3708
|
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyArray("strings", "string")), __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", mcsClient.CancellablePromise)], Message.prototype, "getTemporaryContentUrlsForMediaSids", null);
|
3328
3709
|
|
3710
|
+
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; }
|
3711
|
+
|
3712
|
+
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; }
|
3713
|
+
|
3329
3714
|
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; } } }; }
|
3330
3715
|
|
3331
3716
|
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); }
|
@@ -3600,7 +3985,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3600
3985
|
media_sids: media.map(function (m) {
|
3601
3986
|
return m.sid;
|
3602
3987
|
}),
|
3603
|
-
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined
|
3988
|
+
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined,
|
3989
|
+
content_sid: message.contentSid,
|
3990
|
+
content_variables: typeof message.contentVariables !== "undefined" ? JSON.stringify(message.contentVariables.reduce(function (accum, current) {
|
3991
|
+
return _objectSpread$3(_objectSpread$3({}, accum), {}, _defineProperty__default["default"]({}, current.name, current.value));
|
3992
|
+
}, {})) : undefined
|
3604
3993
|
});
|
3605
3994
|
_context3.prev = 34;
|
3606
3995
|
_context3.t4 = resolve;
|
@@ -4071,6 +4460,29 @@ var MessageBuilder = /*#__PURE__*/function () {
|
|
4071
4460
|
this.emailHistories.set(contentType, history);
|
4072
4461
|
return this;
|
4073
4462
|
}
|
4463
|
+
/**
|
4464
|
+
* Adds {@link ContentTemplate} SID for the message alongside optional
|
4465
|
+
* variables. When no variables provided, the default values will be used.
|
4466
|
+
*
|
4467
|
+
* Adding the content SID converts the message to a rich message. In this
|
4468
|
+
* case, other fields are ignored and the message is sent using the content
|
4469
|
+
* from the the {@link ContentTemplate}.
|
4470
|
+
*
|
4471
|
+
* Use {@link Client.getContentTemplates} to request all available
|
4472
|
+
* {@link ContentTemplate}s.
|
4473
|
+
*
|
4474
|
+
* @param contentSid SID of the {@link ContentTemplate}
|
4475
|
+
* @param variables Custom variables to resolve the template.
|
4476
|
+
*/
|
4477
|
+
|
4478
|
+
}, {
|
4479
|
+
key: "setContentTemplate",
|
4480
|
+
value: function setContentTemplate(contentSid) {
|
4481
|
+
var contentVariables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
4482
|
+
this.message.contentSid = contentSid;
|
4483
|
+
this.message.contentVariables = contentVariables;
|
4484
|
+
return this;
|
4485
|
+
}
|
4074
4486
|
/**
|
4075
4487
|
* Adds media to the message.
|
4076
4488
|
* @param payload Media to add.
|
@@ -7329,7 +7741,7 @@ function PushNotification(data) {
|
|
7329
7741
|
this.data = data.data || {};
|
7330
7742
|
});
|
7331
7743
|
|
7332
|
-
var version = "2.
|
7744
|
+
var version = "2.3.0-rc.0";
|
7333
7745
|
|
7334
7746
|
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; }
|
7335
7747
|
|
@@ -7532,6 +7944,135 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
7532
7944
|
return CommandExecutor;
|
7533
7945
|
}();
|
7534
7946
|
|
7947
|
+
var ContentClient = /*#__PURE__*/function () {
|
7948
|
+
function ContentClient(_services) {
|
7949
|
+
var _pageSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
|
7950
|
+
|
7951
|
+
var _cacheTtlMs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5000;
|
7952
|
+
|
7953
|
+
_classCallCheck__default["default"](this, ContentClient);
|
7954
|
+
|
7955
|
+
_defineProperty__default["default"](this, "_cachedTemplates", null);
|
7956
|
+
|
7957
|
+
this._services = _services;
|
7958
|
+
this._pageSize = _pageSize;
|
7959
|
+
this._cacheTtlMs = _cacheTtlMs;
|
7960
|
+
}
|
7961
|
+
|
7962
|
+
_createClass__default["default"](ContentClient, [{
|
7963
|
+
key: "getContentTemplates",
|
7964
|
+
value: function () {
|
7965
|
+
var _getContentTemplates = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
7966
|
+
var _this = this;
|
7967
|
+
|
7968
|
+
var _yield$this$_fetchCon, _yield$this$_fetchCon2, templatesPage, nextToken, templates, _yield$this$_fetchCon3, _yield$this$_fetchCon4;
|
7969
|
+
|
7970
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
7971
|
+
while (1) {
|
7972
|
+
switch (_context.prev = _context.next) {
|
7973
|
+
case 0:
|
7974
|
+
if (!(this._cachedTemplates !== null)) {
|
7975
|
+
_context.next = 2;
|
7976
|
+
break;
|
7977
|
+
}
|
7978
|
+
|
7979
|
+
return _context.abrupt("return", this._cachedTemplates);
|
7980
|
+
|
7981
|
+
case 2:
|
7982
|
+
_context.next = 4;
|
7983
|
+
return this._fetchContentTemplates();
|
7984
|
+
|
7985
|
+
case 4:
|
7986
|
+
_yield$this$_fetchCon = _context.sent;
|
7987
|
+
_yield$this$_fetchCon2 = _slicedToArray__default["default"](_yield$this$_fetchCon, 2);
|
7988
|
+
templatesPage = _yield$this$_fetchCon2[0];
|
7989
|
+
nextToken = _yield$this$_fetchCon2[1];
|
7990
|
+
templates = templatesPage;
|
7991
|
+
|
7992
|
+
case 9:
|
7993
|
+
if (!(nextToken !== null)) {
|
7994
|
+
_context.next = 19;
|
7995
|
+
break;
|
7996
|
+
}
|
7997
|
+
|
7998
|
+
_context.next = 12;
|
7999
|
+
return this._fetchContentTemplates(nextToken);
|
8000
|
+
|
8001
|
+
case 12:
|
8002
|
+
_yield$this$_fetchCon3 = _context.sent;
|
8003
|
+
_yield$this$_fetchCon4 = _slicedToArray__default["default"](_yield$this$_fetchCon3, 2);
|
8004
|
+
templatesPage = _yield$this$_fetchCon4[0];
|
8005
|
+
nextToken = _yield$this$_fetchCon4[1];
|
8006
|
+
templates = [].concat(_toConsumableArray__default["default"](templates), _toConsumableArray__default["default"](templatesPage));
|
8007
|
+
_context.next = 9;
|
8008
|
+
break;
|
8009
|
+
|
8010
|
+
case 19:
|
8011
|
+
this._cachedTemplates = Object.freeze(templates);
|
8012
|
+
setTimeout(function () {
|
8013
|
+
_this._cachedTemplates = null;
|
8014
|
+
}, this._cacheTtlMs);
|
8015
|
+
return _context.abrupt("return", templates);
|
8016
|
+
|
8017
|
+
case 22:
|
8018
|
+
case "end":
|
8019
|
+
return _context.stop();
|
8020
|
+
}
|
8021
|
+
}
|
8022
|
+
}, _callee, this);
|
8023
|
+
}));
|
8024
|
+
|
8025
|
+
function getContentTemplates() {
|
8026
|
+
return _getContentTemplates.apply(this, arguments);
|
8027
|
+
}
|
8028
|
+
|
8029
|
+
return getContentTemplates;
|
8030
|
+
}()
|
8031
|
+
}, {
|
8032
|
+
key: "_fetchContentTemplates",
|
8033
|
+
value: function () {
|
8034
|
+
var _fetchContentTemplates2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(pageToken) {
|
8035
|
+
var contentTemplatesUrl, url, response;
|
8036
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
8037
|
+
while (1) {
|
8038
|
+
switch (_context2.prev = _context2.next) {
|
8039
|
+
case 0:
|
8040
|
+
contentTemplatesUrl = "Client/v2/ContentTemplates";
|
8041
|
+
url = new UriBuilder(contentTemplatesUrl);
|
8042
|
+
url.arg("PageSize", this._pageSize);
|
8043
|
+
|
8044
|
+
if (pageToken !== undefined) {
|
8045
|
+
url.arg("PageToken", pageToken);
|
8046
|
+
}
|
8047
|
+
|
8048
|
+
_context2.next = 6;
|
8049
|
+
return this._services.commandExecutor.fetchResource(url.build());
|
8050
|
+
|
8051
|
+
case 6:
|
8052
|
+
response = _context2.sent;
|
8053
|
+
return _context2.abrupt("return", [response.templates.map(function (template) {
|
8054
|
+
return new ContentTemplate(template);
|
8055
|
+
}), response.meta.next_token]);
|
8056
|
+
|
8057
|
+
case 8:
|
8058
|
+
case "end":
|
8059
|
+
return _context2.stop();
|
8060
|
+
}
|
8061
|
+
}
|
8062
|
+
}, _callee2, this);
|
8063
|
+
}));
|
8064
|
+
|
8065
|
+
function _fetchContentTemplates(_x) {
|
8066
|
+
return _fetchContentTemplates2.apply(this, arguments);
|
8067
|
+
}
|
8068
|
+
|
8069
|
+
return _fetchContentTemplates;
|
8070
|
+
}()
|
8071
|
+
}]);
|
8072
|
+
|
8073
|
+
return ContentClient;
|
8074
|
+
}();
|
8075
|
+
|
7535
8076
|
var _class;
|
7536
8077
|
|
7537
8078
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
@@ -7921,6 +8462,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7921
8462
|
_this._services.commandExecutor = new CommandExecutor(baseUrl, {
|
7922
8463
|
transport: _this._options.transport
|
7923
8464
|
}, productId);
|
8465
|
+
_this._services.contentClient = new ContentClient(_this._services);
|
7924
8466
|
|
7925
8467
|
var emitFailed = function emitFailed(error) {
|
7926
8468
|
_this._rejectEnsureReady(error);
|
@@ -8693,6 +9235,43 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8693
9235
|
});
|
8694
9236
|
return this.getTemporaryContentUrlsForMediaSids(sids);
|
8695
9237
|
}
|
9238
|
+
/**
|
9239
|
+
* Returns rich content templates belonging to the account. Rich content
|
9240
|
+
* templates can be created via the Twilio console or the REST API.
|
9241
|
+
*/
|
9242
|
+
|
9243
|
+
}, {
|
9244
|
+
key: "getContentTemplates",
|
9245
|
+
value: function () {
|
9246
|
+
var _getContentTemplates = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee16() {
|
9247
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee16$(_context16) {
|
9248
|
+
while (1) {
|
9249
|
+
switch (_context16.prev = _context16.next) {
|
9250
|
+
case 0:
|
9251
|
+
_context16.next = 2;
|
9252
|
+
return this._ensureReady;
|
9253
|
+
|
9254
|
+
case 2:
|
9255
|
+
_context16.next = 4;
|
9256
|
+
return this._services.contentClient.getContentTemplates();
|
9257
|
+
|
9258
|
+
case 4:
|
9259
|
+
return _context16.abrupt("return", _context16.sent);
|
9260
|
+
|
9261
|
+
case 5:
|
9262
|
+
case "end":
|
9263
|
+
return _context16.stop();
|
9264
|
+
}
|
9265
|
+
}
|
9266
|
+
}, _callee16, this);
|
9267
|
+
}));
|
9268
|
+
|
9269
|
+
function getContentTemplates() {
|
9270
|
+
return _getContentTemplates.apply(this, arguments);
|
9271
|
+
}
|
9272
|
+
|
9273
|
+
return getContentTemplates;
|
9274
|
+
}()
|
8696
9275
|
/**
|
8697
9276
|
* Initialize the client.
|
8698
9277
|
*/
|
@@ -8700,19 +9279,19 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8700
9279
|
}, {
|
8701
9280
|
key: "_initialize",
|
8702
9281
|
value: function () {
|
8703
|
-
var _initialize2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
9282
|
+
var _initialize2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee17() {
|
8704
9283
|
var _this3 = this;
|
8705
9284
|
|
8706
9285
|
var configurationResponse;
|
8707
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
9286
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee17$(_context17) {
|
8708
9287
|
while (1) {
|
8709
|
-
switch (
|
9288
|
+
switch (_context17.prev = _context17.next) {
|
8710
9289
|
case 0:
|
8711
|
-
|
9290
|
+
_context17.next = 2;
|
8712
9291
|
return this._services.commandExecutor.fetchResource("Client/v2/Configuration");
|
8713
9292
|
|
8714
9293
|
case 2:
|
8715
|
-
configurationResponse =
|
9294
|
+
configurationResponse = _context17.sent;
|
8716
9295
|
this._configuration = new Configuration(this._options, configurationResponse, Client_1._logger);
|
8717
9296
|
|
8718
9297
|
this._myself._resolveInitialization(this._configuration, this._configuration.userIdentity, this._configuration.userInfo, true);
|
@@ -8792,7 +9371,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8792
9371
|
}).catch(function (error) {
|
8793
9372
|
throw error;
|
8794
9373
|
});
|
8795
|
-
|
9374
|
+
_context17.next = 28;
|
8796
9375
|
return this._services.users.myself._ensureFetched();
|
8797
9376
|
|
8798
9377
|
case 28:
|
@@ -8813,10 +9392,10 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8813
9392
|
|
8814
9393
|
case 34:
|
8815
9394
|
case "end":
|
8816
|
-
return
|
9395
|
+
return _context17.stop();
|
8817
9396
|
}
|
8818
9397
|
}
|
8819
|
-
},
|
9398
|
+
}, _callee17, this);
|
8820
9399
|
}));
|
8821
9400
|
|
8822
9401
|
function _initialize() {
|
@@ -8856,14 +9435,14 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8856
9435
|
}], [{
|
8857
9436
|
key: "create",
|
8858
9437
|
value: function () {
|
8859
|
-
var _create = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
9438
|
+
var _create = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee18(token, options) {
|
8860
9439
|
var client;
|
8861
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
9440
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee18$(_context18) {
|
8862
9441
|
while (1) {
|
8863
|
-
switch (
|
9442
|
+
switch (_context18.prev = _context18.next) {
|
8864
9443
|
case 0:
|
8865
9444
|
if (!(options !== null && options !== void 0 && options.twilsockClient)) {
|
8866
|
-
|
9445
|
+
_context18.next = 2;
|
8867
9446
|
break;
|
8868
9447
|
}
|
8869
9448
|
|
@@ -8871,18 +9450,18 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
8871
9450
|
|
8872
9451
|
case 2:
|
8873
9452
|
client = new Client_1(token, options);
|
8874
|
-
|
9453
|
+
_context18.next = 5;
|
8875
9454
|
return client._ensureReady;
|
8876
9455
|
|
8877
9456
|
case 5:
|
8878
|
-
return
|
9457
|
+
return _context18.abrupt("return", client);
|
8879
9458
|
|
8880
9459
|
case 6:
|
8881
9460
|
case "end":
|
8882
|
-
return
|
9461
|
+
return _context18.stop();
|
8883
9462
|
}
|
8884
9463
|
}
|
8885
|
-
},
|
9464
|
+
}, _callee18);
|
8886
9465
|
}));
|
8887
9466
|
|
8888
9467
|
function create(_x16, _x17) {
|
@@ -9066,6 +9645,8 @@ Object.defineProperty(exports, 'CancellablePromise', {
|
|
9066
9645
|
get: function () { return mcsClient.CancellablePromise; }
|
9067
9646
|
});
|
9068
9647
|
exports.AggregatedDeliveryReceipt = AggregatedDeliveryReceipt;
|
9648
|
+
exports.ContentTemplate = ContentTemplate;
|
9649
|
+
exports.ContentTemplateVariable = ContentTemplateVariable;
|
9069
9650
|
exports.Conversation = Conversation;
|
9070
9651
|
exports.DetailedDeliveryReceipt = DetailedDeliveryReceipt;
|
9071
9652
|
exports.Media = Media;
|