@twilio/conversations 2.1.0 → 3.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/builds/browser.js +1193 -690
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +248 -130
- package/builds/lib.js +1193 -690
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +1903 -1215
- package/builds/twilio-conversations.min.js +2 -2
- package/dist/client.js +403 -279
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +2 -2
- package/dist/configuration.js.map +1 -1
- package/dist/data/messages.js +39 -19
- package/dist/data/messages.js.map +1 -1
- package/dist/media.js +36 -25
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +24 -18
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +46 -19
- package/dist/message.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/unsent-message.js +13 -3
- package/dist/unsent-message.js.map +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/classes/Client.html +205 -33
- package/docs/classes/Media.html +2 -28
- package/docs/classes/Message.html +94 -39
- package/docs/classes/MessageBuilder.html +31 -8
- package/docs/classes/UnsentMessage.html +2 -2
- package/docs/index.html +4 -2
- package/docs/interfaces/ConversationLimits.html +12 -12
- package/docs/modules.html +4 -2
- package/package.json +4 -3
@@ -2784,6 +2784,21 @@ this.Twilio.Conversations = (function (exports) {
|
|
2784
2784
|
}
|
2785
2785
|
});
|
2786
2786
|
|
2787
|
+
var $$n = _export;
|
2788
|
+
var $map$1 = arrayIteration.map;
|
2789
|
+
var arrayMethodHasSpeciesSupport$3 = arrayMethodHasSpeciesSupport$5;
|
2790
|
+
|
2791
|
+
var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport$3('map');
|
2792
|
+
|
2793
|
+
// `Array.prototype.map` method
|
2794
|
+
// https://tc39.es/ecma262/#sec-array.prototype.map
|
2795
|
+
// with adding support of @@species
|
2796
|
+
$$n({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$2 }, {
|
2797
|
+
map: function map(callbackfn /* , thisArg */) {
|
2798
|
+
return $map$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
2799
|
+
}
|
2800
|
+
});
|
2801
|
+
|
2787
2802
|
// iterable DOM collections
|
2788
2803
|
// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
|
2789
2804
|
var domIterables = {
|
@@ -2871,140 +2886,6 @@ this.Twilio.Conversations = (function (exports) {
|
|
2871
2886
|
|
2872
2887
|
handlePrototype$1(DOMTokenListPrototype$1);
|
2873
2888
|
|
2874
|
-
var isObject$a = isObject$n;
|
2875
|
-
var setPrototypeOf$5 = objectSetPrototypeOf;
|
2876
|
-
|
2877
|
-
// makes subclassing work correct for wrapped built-ins
|
2878
|
-
var inheritIfRequired$3 = function ($this, dummy, Wrapper) {
|
2879
|
-
var NewTarget, NewTargetPrototype;
|
2880
|
-
if (
|
2881
|
-
// it can work only with native `setPrototypeOf`
|
2882
|
-
setPrototypeOf$5 &&
|
2883
|
-
// we haven't completely correct pre-ES6 way for getting `new.target`, so use this
|
2884
|
-
typeof (NewTarget = dummy.constructor) == 'function' &&
|
2885
|
-
NewTarget !== Wrapper &&
|
2886
|
-
isObject$a(NewTargetPrototype = NewTarget.prototype) &&
|
2887
|
-
NewTargetPrototype !== Wrapper.prototype
|
2888
|
-
) setPrototypeOf$5($this, NewTargetPrototype);
|
2889
|
-
return $this;
|
2890
|
-
};
|
2891
|
-
|
2892
|
-
// a string of all valid unicode whitespaces
|
2893
|
-
var whitespaces$1 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
|
2894
|
-
'\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
|
2895
|
-
|
2896
|
-
var requireObjectCoercible$7 = requireObjectCoercible$a;
|
2897
|
-
var toString$a = toString$d;
|
2898
|
-
var whitespaces = whitespaces$1;
|
2899
|
-
|
2900
|
-
var whitespace = '[' + whitespaces + ']';
|
2901
|
-
var ltrim = RegExp('^' + whitespace + whitespace + '*');
|
2902
|
-
var rtrim = RegExp(whitespace + whitespace + '*$');
|
2903
|
-
|
2904
|
-
// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
|
2905
|
-
var createMethod$3 = function (TYPE) {
|
2906
|
-
return function ($this) {
|
2907
|
-
var string = toString$a(requireObjectCoercible$7($this));
|
2908
|
-
if (TYPE & 1) string = string.replace(ltrim, '');
|
2909
|
-
if (TYPE & 2) string = string.replace(rtrim, '');
|
2910
|
-
return string;
|
2911
|
-
};
|
2912
|
-
};
|
2913
|
-
|
2914
|
-
var stringTrim = {
|
2915
|
-
// `String.prototype.{ trimLeft, trimStart }` methods
|
2916
|
-
// https://tc39.es/ecma262/#sec-string.prototype.trimstart
|
2917
|
-
start: createMethod$3(1),
|
2918
|
-
// `String.prototype.{ trimRight, trimEnd }` methods
|
2919
|
-
// https://tc39.es/ecma262/#sec-string.prototype.trimend
|
2920
|
-
end: createMethod$3(2),
|
2921
|
-
// `String.prototype.trim` method
|
2922
|
-
// https://tc39.es/ecma262/#sec-string.prototype.trim
|
2923
|
-
trim: createMethod$3(3)
|
2924
|
-
};
|
2925
|
-
|
2926
|
-
var DESCRIPTORS$9 = descriptors;
|
2927
|
-
var global$h = global$C;
|
2928
|
-
var isForced$1 = isForced_1;
|
2929
|
-
var redefine$7 = redefine$d.exports;
|
2930
|
-
var has$6 = has$g;
|
2931
|
-
var classof$5 = classofRaw$1;
|
2932
|
-
var inheritIfRequired$2 = inheritIfRequired$3;
|
2933
|
-
var isSymbol$1 = isSymbol$6;
|
2934
|
-
var toPrimitive = toPrimitive$2;
|
2935
|
-
var fails$m = fails$z;
|
2936
|
-
var create$6 = objectCreate;
|
2937
|
-
var getOwnPropertyNames$2 = objectGetOwnPropertyNames.f;
|
2938
|
-
var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
|
2939
|
-
var defineProperty$8 = objectDefineProperty.f;
|
2940
|
-
var trim = stringTrim.trim;
|
2941
|
-
|
2942
|
-
var NUMBER = 'Number';
|
2943
|
-
var NativeNumber = global$h[NUMBER];
|
2944
|
-
var NumberPrototype = NativeNumber.prototype;
|
2945
|
-
|
2946
|
-
// Opera ~12 has broken Object#toString
|
2947
|
-
var BROKEN_CLASSOF = classof$5(create$6(NumberPrototype)) == NUMBER;
|
2948
|
-
|
2949
|
-
// `ToNumber` abstract operation
|
2950
|
-
// https://tc39.es/ecma262/#sec-tonumber
|
2951
|
-
var toNumber = function (argument) {
|
2952
|
-
if (isSymbol$1(argument)) throw TypeError('Cannot convert a Symbol value to a number');
|
2953
|
-
var it = toPrimitive(argument, 'number');
|
2954
|
-
var first, third, radix, maxCode, digits, length, index, code;
|
2955
|
-
if (typeof it == 'string' && it.length > 2) {
|
2956
|
-
it = trim(it);
|
2957
|
-
first = it.charCodeAt(0);
|
2958
|
-
if (first === 43 || first === 45) {
|
2959
|
-
third = it.charCodeAt(2);
|
2960
|
-
if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
|
2961
|
-
} else if (first === 48) {
|
2962
|
-
switch (it.charCodeAt(1)) {
|
2963
|
-
case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
|
2964
|
-
case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
|
2965
|
-
default: return +it;
|
2966
|
-
}
|
2967
|
-
digits = it.slice(2);
|
2968
|
-
length = digits.length;
|
2969
|
-
for (index = 0; index < length; index++) {
|
2970
|
-
code = digits.charCodeAt(index);
|
2971
|
-
// parseInt parses a string to a first unavailable symbol
|
2972
|
-
// but ToNumber should return NaN if a string contains unavailable symbols
|
2973
|
-
if (code < 48 || code > maxCode) return NaN;
|
2974
|
-
} return parseInt(digits, radix);
|
2975
|
-
}
|
2976
|
-
} return +it;
|
2977
|
-
};
|
2978
|
-
|
2979
|
-
// `Number` constructor
|
2980
|
-
// https://tc39.es/ecma262/#sec-number-constructor
|
2981
|
-
if (isForced$1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {
|
2982
|
-
var NumberWrapper = function Number(value) {
|
2983
|
-
var it = arguments.length < 1 ? 0 : value;
|
2984
|
-
var dummy = this;
|
2985
|
-
return dummy instanceof NumberWrapper
|
2986
|
-
// check on 1..constructor(foo) case
|
2987
|
-
&& (BROKEN_CLASSOF ? fails$m(function () { NumberPrototype.valueOf.call(dummy); }) : classof$5(dummy) != NUMBER)
|
2988
|
-
? inheritIfRequired$2(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it);
|
2989
|
-
};
|
2990
|
-
for (var keys$2 = DESCRIPTORS$9 ? getOwnPropertyNames$2(NativeNumber) : (
|
2991
|
-
// ES3:
|
2992
|
-
'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
|
2993
|
-
// ES2015 (in case, if modules with ES2015 Number statics required before):
|
2994
|
-
'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
|
2995
|
-
'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,' +
|
2996
|
-
// ESNext
|
2997
|
-
'fromString,range'
|
2998
|
-
).split(','), j$1 = 0, key$1; keys$2.length > j$1; j$1++) {
|
2999
|
-
if (has$6(NativeNumber, key$1 = keys$2[j$1]) && !has$6(NumberWrapper, key$1)) {
|
3000
|
-
defineProperty$8(NumberWrapper, key$1, getOwnPropertyDescriptor$1(NativeNumber, key$1));
|
3001
|
-
}
|
3002
|
-
}
|
3003
|
-
NumberWrapper.prototype = NumberPrototype;
|
3004
|
-
NumberPrototype.constructor = NumberWrapper;
|
3005
|
-
redefine$7(global$h, NUMBER, NumberWrapper);
|
3006
|
-
}
|
3007
|
-
|
3008
2889
|
/**
|
3009
2890
|
* Copyright (c) 2014-present, Facebook, Inc.
|
3010
2891
|
*
|
@@ -3421,7 +3302,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
3421
3302
|
this.reset(true);
|
3422
3303
|
}
|
3423
3304
|
|
3424
|
-
function keys$
|
3305
|
+
function keys$2(object) {
|
3425
3306
|
var keys = [];
|
3426
3307
|
|
3427
3308
|
for (var key in object) {
|
@@ -3686,7 +3567,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
3686
3567
|
mark: mark,
|
3687
3568
|
awrap: awrap,
|
3688
3569
|
async: async,
|
3689
|
-
keys: keys$
|
3570
|
+
keys: keys$2,
|
3690
3571
|
values: values
|
3691
3572
|
};
|
3692
3573
|
|
@@ -3708,15 +3589,15 @@ this.Twilio.Conversations = (function (exports) {
|
|
3708
3589
|
if ((typeof Reflect === "undefined" ? "undefined" : _typeof$3(Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
3709
3590
|
}
|
3710
3591
|
|
3711
|
-
var $$
|
3712
|
-
var fails$
|
3592
|
+
var $$m = _export;
|
3593
|
+
var fails$m = fails$z;
|
3713
3594
|
var isArray$1 = isArray$4;
|
3714
|
-
var isObject$
|
3595
|
+
var isObject$a = isObject$n;
|
3715
3596
|
var toObject$b = toObject$g;
|
3716
3597
|
var toLength$j = toLength$n;
|
3717
3598
|
var createProperty$3 = createProperty$5;
|
3718
3599
|
var arraySpeciesCreate$1 = arraySpeciesCreate$3;
|
3719
|
-
var arrayMethodHasSpeciesSupport$
|
3600
|
+
var arrayMethodHasSpeciesSupport$2 = arrayMethodHasSpeciesSupport$5;
|
3720
3601
|
var wellKnownSymbol$d = wellKnownSymbol$s;
|
3721
3602
|
var V8_VERSION = engineV8Version;
|
3722
3603
|
|
@@ -3727,16 +3608,16 @@ this.Twilio.Conversations = (function (exports) {
|
|
3727
3608
|
// We can't use this feature detection in V8 since it causes
|
3728
3609
|
// deoptimization and serious performance degradation
|
3729
3610
|
// https://github.com/zloirock/core-js/issues/679
|
3730
|
-
var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails$
|
3611
|
+
var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails$m(function () {
|
3731
3612
|
var array = [];
|
3732
3613
|
array[IS_CONCAT_SPREADABLE] = false;
|
3733
3614
|
return array.concat()[0] !== array;
|
3734
3615
|
});
|
3735
3616
|
|
3736
|
-
var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport$
|
3617
|
+
var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport$2('concat');
|
3737
3618
|
|
3738
3619
|
var isConcatSpreadable = function (O) {
|
3739
|
-
if (!isObject$
|
3620
|
+
if (!isObject$a(O)) return false;
|
3740
3621
|
var spreadable = O[IS_CONCAT_SPREADABLE];
|
3741
3622
|
return spreadable !== undefined ? !!spreadable : isArray$1(O);
|
3742
3623
|
};
|
@@ -3746,7 +3627,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
3746
3627
|
// `Array.prototype.concat` method
|
3747
3628
|
// https://tc39.es/ecma262/#sec-array.prototype.concat
|
3748
3629
|
// with adding support of @@isConcatSpreadable and @@species
|
3749
|
-
$$
|
3630
|
+
$$m({ target: 'Array', proto: true, forced: FORCED$5 }, {
|
3750
3631
|
// eslint-disable-next-line no-unused-vars -- required for `.length`
|
3751
3632
|
concat: function concat(arg) {
|
3752
3633
|
var O = toObject$b(this);
|
@@ -3823,7 +3704,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
3823
3704
|
return result;
|
3824
3705
|
};
|
3825
3706
|
|
3826
|
-
var $$
|
3707
|
+
var $$l = _export;
|
3827
3708
|
var from = arrayFrom$1;
|
3828
3709
|
var checkCorrectnessOfIteration$2 = checkCorrectnessOfIteration$4;
|
3829
3710
|
|
@@ -3834,18 +3715,18 @@ this.Twilio.Conversations = (function (exports) {
|
|
3834
3715
|
|
3835
3716
|
// `Array.from` method
|
3836
3717
|
// https://tc39.es/ecma262/#sec-array.from
|
3837
|
-
$$
|
3718
|
+
$$l({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
|
3838
3719
|
from: from
|
3839
3720
|
});
|
3840
3721
|
|
3841
3722
|
var toInteger$6 = toInteger$9;
|
3842
|
-
var toString$
|
3843
|
-
var requireObjectCoercible$
|
3723
|
+
var toString$a = toString$d;
|
3724
|
+
var requireObjectCoercible$7 = requireObjectCoercible$a;
|
3844
3725
|
|
3845
3726
|
// `String.prototype.codePointAt` methods implementation
|
3846
|
-
var createMethod$
|
3727
|
+
var createMethod$3 = function (CONVERT_TO_STRING) {
|
3847
3728
|
return function ($this, pos) {
|
3848
|
-
var S = toString$
|
3729
|
+
var S = toString$a(requireObjectCoercible$7($this));
|
3849
3730
|
var position = toInteger$6(pos);
|
3850
3731
|
var size = S.length;
|
3851
3732
|
var first, second;
|
@@ -3861,22 +3742,22 @@ this.Twilio.Conversations = (function (exports) {
|
|
3861
3742
|
var stringMultibyte = {
|
3862
3743
|
// `String.prototype.codePointAt` method
|
3863
3744
|
// https://tc39.es/ecma262/#sec-string.prototype.codepointat
|
3864
|
-
codeAt: createMethod$
|
3745
|
+
codeAt: createMethod$3(false),
|
3865
3746
|
// `String.prototype.at` method
|
3866
3747
|
// https://github.com/mathiasbynens/String.prototype.at
|
3867
|
-
charAt: createMethod$
|
3748
|
+
charAt: createMethod$3(true)
|
3868
3749
|
};
|
3869
3750
|
|
3870
|
-
var fails$
|
3751
|
+
var fails$l = fails$z;
|
3871
3752
|
|
3872
|
-
var correctPrototypeGetter = !fails$
|
3753
|
+
var correctPrototypeGetter = !fails$l(function () {
|
3873
3754
|
function F() { /* empty */ }
|
3874
3755
|
F.prototype.constructor = null;
|
3875
3756
|
// eslint-disable-next-line es/no-object-getprototypeof -- required for testing
|
3876
3757
|
return Object.getPrototypeOf(new F()) !== F.prototype;
|
3877
3758
|
});
|
3878
3759
|
|
3879
|
-
var has$
|
3760
|
+
var has$6 = has$g;
|
3880
3761
|
var toObject$9 = toObject$g;
|
3881
3762
|
var sharedKey = sharedKey$4;
|
3882
3763
|
var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
|
@@ -3889,13 +3770,13 @@ this.Twilio.Conversations = (function (exports) {
|
|
3889
3770
|
// eslint-disable-next-line es/no-object-getprototypeof -- safe
|
3890
3771
|
var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
|
3891
3772
|
O = toObject$9(O);
|
3892
|
-
if (has$
|
3773
|
+
if (has$6(O, IE_PROTO)) return O[IE_PROTO];
|
3893
3774
|
if (typeof O.constructor == 'function' && O instanceof O.constructor) {
|
3894
3775
|
return O.constructor.prototype;
|
3895
3776
|
} return O instanceof Object ? ObjectPrototype$2 : null;
|
3896
3777
|
};
|
3897
3778
|
|
3898
|
-
var fails$
|
3779
|
+
var fails$k = fails$z;
|
3899
3780
|
var getPrototypeOf$4 = objectGetPrototypeOf;
|
3900
3781
|
var createNonEnumerableProperty$6 = createNonEnumerableProperty$c;
|
3901
3782
|
var wellKnownSymbol$c = wellKnownSymbol$s;
|
@@ -3918,7 +3799,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
3918
3799
|
}
|
3919
3800
|
}
|
3920
3801
|
|
3921
|
-
var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$2 == undefined || fails$
|
3802
|
+
var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$2 == undefined || fails$k(function () {
|
3922
3803
|
var test = {};
|
3923
3804
|
// FF44- legacy iterators case
|
3924
3805
|
return IteratorPrototype$2[ITERATOR$5].call(test) !== test;
|
@@ -3940,7 +3821,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
3940
3821
|
};
|
3941
3822
|
|
3942
3823
|
var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
|
3943
|
-
var create$
|
3824
|
+
var create$6 = objectCreate;
|
3944
3825
|
var createPropertyDescriptor$2 = createPropertyDescriptor$7;
|
3945
3826
|
var setToStringTag$5 = setToStringTag$8;
|
3946
3827
|
var Iterators$2 = iterators;
|
@@ -3949,19 +3830,19 @@ this.Twilio.Conversations = (function (exports) {
|
|
3949
3830
|
|
3950
3831
|
var createIteratorConstructor$2 = function (IteratorConstructor, NAME, next) {
|
3951
3832
|
var TO_STRING_TAG = NAME + ' Iterator';
|
3952
|
-
IteratorConstructor.prototype = create$
|
3833
|
+
IteratorConstructor.prototype = create$6(IteratorPrototype$1, { next: createPropertyDescriptor$2(1, next) });
|
3953
3834
|
setToStringTag$5(IteratorConstructor, TO_STRING_TAG, false);
|
3954
3835
|
Iterators$2[TO_STRING_TAG] = returnThis$1;
|
3955
3836
|
return IteratorConstructor;
|
3956
3837
|
};
|
3957
3838
|
|
3958
|
-
var $$
|
3839
|
+
var $$k = _export;
|
3959
3840
|
var createIteratorConstructor$1 = createIteratorConstructor$2;
|
3960
3841
|
var getPrototypeOf$3 = objectGetPrototypeOf;
|
3961
|
-
var setPrototypeOf$
|
3842
|
+
var setPrototypeOf$5 = objectSetPrototypeOf;
|
3962
3843
|
var setToStringTag$4 = setToStringTag$8;
|
3963
3844
|
var createNonEnumerableProperty$5 = createNonEnumerableProperty$c;
|
3964
|
-
var redefine$
|
3845
|
+
var redefine$7 = redefine$d.exports;
|
3965
3846
|
var wellKnownSymbol$b = wellKnownSymbol$s;
|
3966
3847
|
var Iterators$1 = iterators;
|
3967
3848
|
var IteratorsCore = iteratorsCore;
|
@@ -4003,8 +3884,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
4003
3884
|
CurrentIteratorPrototype = getPrototypeOf$3(anyNativeIterator.call(new Iterable()));
|
4004
3885
|
if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
|
4005
3886
|
if (getPrototypeOf$3(CurrentIteratorPrototype) !== IteratorPrototype) {
|
4006
|
-
if (setPrototypeOf$
|
4007
|
-
setPrototypeOf$
|
3887
|
+
if (setPrototypeOf$5) {
|
3888
|
+
setPrototypeOf$5(CurrentIteratorPrototype, IteratorPrototype);
|
4008
3889
|
} else if (typeof CurrentIteratorPrototype[ITERATOR$4] != 'function') {
|
4009
3890
|
createNonEnumerableProperty$5(CurrentIteratorPrototype, ITERATOR$4, returnThis);
|
4010
3891
|
}
|
@@ -4035,16 +3916,16 @@ this.Twilio.Conversations = (function (exports) {
|
|
4035
3916
|
};
|
4036
3917
|
if (FORCED) for (KEY in methods) {
|
4037
3918
|
if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
|
4038
|
-
redefine$
|
3919
|
+
redefine$7(IterablePrototype, KEY, methods[KEY]);
|
4039
3920
|
}
|
4040
|
-
} else $$
|
3921
|
+
} else $$k({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
|
4041
3922
|
}
|
4042
3923
|
|
4043
3924
|
return methods;
|
4044
3925
|
};
|
4045
3926
|
|
4046
3927
|
var charAt$1 = stringMultibyte.charAt;
|
4047
|
-
var toString$
|
3928
|
+
var toString$9 = toString$d;
|
4048
3929
|
var InternalStateModule$6 = internalState;
|
4049
3930
|
var defineIterator$2 = defineIterator$3;
|
4050
3931
|
|
@@ -4057,7 +3938,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4057
3938
|
defineIterator$2(String, 'String', function (iterated) {
|
4058
3939
|
setInternalState$6(this, {
|
4059
3940
|
type: STRING_ITERATOR,
|
4060
|
-
string: toString$
|
3941
|
+
string: toString$9(iterated),
|
4061
3942
|
index: 0
|
4062
3943
|
});
|
4063
3944
|
// `%StringIteratorPrototype%.next` method
|
@@ -4342,7 +4223,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4342
4223
|
return ["".concat(new Date().toISOString(), " Conversations ").concat(prefix, ":")].concat(Array.from(args));
|
4343
4224
|
}
|
4344
4225
|
|
4345
|
-
var log$
|
4226
|
+
var log$a = loglevel.exports.getLogger("twilio-conversations"); // twilio-conversations is used by Flex SDK. Please DO NOT change
|
4346
4227
|
|
4347
4228
|
var Logger = /*#__PURE__*/function () {
|
4348
4229
|
function Logger(prefix) {
|
@@ -4356,7 +4237,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4356
4237
|
_createClass$3(Logger, [{
|
4357
4238
|
key: "setLevel",
|
4358
4239
|
value: function setLevel(level) {
|
4359
|
-
log$
|
4240
|
+
log$a.setLevel(level);
|
4360
4241
|
}
|
4361
4242
|
}, {
|
4362
4243
|
key: "trace",
|
@@ -4365,7 +4246,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4365
4246
|
args[_key] = arguments[_key];
|
4366
4247
|
}
|
4367
4248
|
|
4368
|
-
log$
|
4249
|
+
log$a.trace.apply(null, prepareLine$1(this.prefix + "T", args));
|
4369
4250
|
}
|
4370
4251
|
}, {
|
4371
4252
|
key: "debug",
|
@@ -4374,7 +4255,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4374
4255
|
args[_key2] = arguments[_key2];
|
4375
4256
|
}
|
4376
4257
|
|
4377
|
-
log$
|
4258
|
+
log$a.debug.apply(null, prepareLine$1(this.prefix + "D", args));
|
4378
4259
|
}
|
4379
4260
|
}, {
|
4380
4261
|
key: "info",
|
@@ -4383,7 +4264,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4383
4264
|
args[_key3] = arguments[_key3];
|
4384
4265
|
}
|
4385
4266
|
|
4386
|
-
log$
|
4267
|
+
log$a.info.apply(null, prepareLine$1(this.prefix + "I", args));
|
4387
4268
|
}
|
4388
4269
|
}, {
|
4389
4270
|
key: "warn",
|
@@ -4392,7 +4273,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4392
4273
|
args[_key4] = arguments[_key4];
|
4393
4274
|
}
|
4394
4275
|
|
4395
|
-
log$
|
4276
|
+
log$a.warn.apply(null, prepareLine$1(this.prefix + "W", args));
|
4396
4277
|
}
|
4397
4278
|
}, {
|
4398
4279
|
key: "error",
|
@@ -4401,7 +4282,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4401
4282
|
args[_key5] = arguments[_key5];
|
4402
4283
|
}
|
4403
4284
|
|
4404
|
-
log$
|
4285
|
+
log$a.error.apply(null, prepareLine$1(this.prefix + "E", args));
|
4405
4286
|
}
|
4406
4287
|
}], [{
|
4407
4288
|
key: "scope",
|
@@ -4411,7 +4292,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4411
4292
|
}, {
|
4412
4293
|
key: "setLevel",
|
4413
4294
|
value: function setLevel(level) {
|
4414
|
-
log$
|
4295
|
+
log$a.setLevel(level);
|
4415
4296
|
}
|
4416
4297
|
}, {
|
4417
4298
|
key: "trace",
|
@@ -4420,7 +4301,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4420
4301
|
args[_key6] = arguments[_key6];
|
4421
4302
|
}
|
4422
4303
|
|
4423
|
-
log$
|
4304
|
+
log$a.trace.apply(null, prepareLine$1("T", args));
|
4424
4305
|
}
|
4425
4306
|
}, {
|
4426
4307
|
key: "debug",
|
@@ -4429,7 +4310,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4429
4310
|
args[_key7] = arguments[_key7];
|
4430
4311
|
}
|
4431
4312
|
|
4432
|
-
log$
|
4313
|
+
log$a.debug.apply(null, prepareLine$1("D", args));
|
4433
4314
|
}
|
4434
4315
|
}, {
|
4435
4316
|
key: "info",
|
@@ -4438,7 +4319,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4438
4319
|
args[_key8] = arguments[_key8];
|
4439
4320
|
}
|
4440
4321
|
|
4441
|
-
log$
|
4322
|
+
log$a.info.apply(null, prepareLine$1("I", args));
|
4442
4323
|
}
|
4443
4324
|
}, {
|
4444
4325
|
key: "warn",
|
@@ -4447,7 +4328,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4447
4328
|
args[_key9] = arguments[_key9];
|
4448
4329
|
}
|
4449
4330
|
|
4450
|
-
log$
|
4331
|
+
log$a.warn.apply(null, prepareLine$1("W", args));
|
4451
4332
|
}
|
4452
4333
|
}, {
|
4453
4334
|
key: "error",
|
@@ -4456,7 +4337,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4456
4337
|
args[_key10] = arguments[_key10];
|
4457
4338
|
}
|
4458
4339
|
|
4459
|
-
log$
|
4340
|
+
log$a.error.apply(null, prepareLine$1("E", args));
|
4460
4341
|
}
|
4461
4342
|
}]);
|
4462
4343
|
|
@@ -4591,8 +4472,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
4591
4472
|
mediaAttachmentsCountLimit: configurationResponse.options.media_attachments_count_limit,
|
4592
4473
|
mediaAttachmentSizeLimitInMb: configurationResponse.options.media_attachment_size_limit_in_mb,
|
4593
4474
|
mediaAttachmentsTotalSizeLimitInMb: configurationResponse.options.media_attachments_total_size_limit_in_mb,
|
4594
|
-
|
4595
|
-
|
4475
|
+
emailHistoriesAllowedContentTypes: configurationResponse.options.email_histories_allowed_mime_types,
|
4476
|
+
emailBodiesAllowedContentTypes: configurationResponse.options.email_bodies_allowed_mime_types
|
4596
4477
|
};
|
4597
4478
|
this.typingIndicatorTimeoutOverride = constructorOptions.typingIndicatorTimeoutOverride;
|
4598
4479
|
this.backoffConfiguration = _objectSpread$4({
|
@@ -4625,23 +4506,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
4625
4506
|
}
|
4626
4507
|
};
|
4627
4508
|
|
4628
|
-
var $$k = _export;
|
4629
|
-
var $map$1 = arrayIteration.map;
|
4630
|
-
var arrayMethodHasSpeciesSupport$2 = arrayMethodHasSpeciesSupport$5;
|
4631
|
-
|
4632
|
-
var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport$2('map');
|
4633
|
-
|
4634
|
-
// `Array.prototype.map` method
|
4635
|
-
// https://tc39.es/ecma262/#sec-array.prototype.map
|
4636
|
-
// with adding support of @@species
|
4637
|
-
$$k({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$2 }, {
|
4638
|
-
map: function map(callbackfn /* , thisArg */) {
|
4639
|
-
return $map$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
4640
|
-
}
|
4641
|
-
});
|
4642
|
-
|
4643
4509
|
var wellKnownSymbol$a = wellKnownSymbol$s;
|
4644
|
-
var create$
|
4510
|
+
var create$5 = objectCreate;
|
4645
4511
|
var definePropertyModule$1 = objectDefineProperty;
|
4646
4512
|
|
4647
4513
|
var UNSCOPABLES = wellKnownSymbol$a('unscopables');
|
@@ -4652,7 +4518,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4652
4518
|
if (ArrayPrototype[UNSCOPABLES] == undefined) {
|
4653
4519
|
definePropertyModule$1.f(ArrayPrototype, UNSCOPABLES, {
|
4654
4520
|
configurable: true,
|
4655
|
-
value: create$
|
4521
|
+
value: create$5(null)
|
4656
4522
|
});
|
4657
4523
|
}
|
4658
4524
|
|
@@ -4714,7 +4580,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
4714
4580
|
addToUnscopables$2('values');
|
4715
4581
|
addToUnscopables$2('entries');
|
4716
4582
|
|
4717
|
-
var global$
|
4583
|
+
var global$h = global$C;
|
4718
4584
|
var DOMIterables = domIterables;
|
4719
4585
|
var DOMTokenListPrototype = domTokenListPrototype;
|
4720
4586
|
var ArrayIteratorMethods = es_array_iterator;
|
@@ -4748,11 +4614,145 @@ this.Twilio.Conversations = (function (exports) {
|
|
4748
4614
|
};
|
4749
4615
|
|
4750
4616
|
for (var COLLECTION_NAME in DOMIterables) {
|
4751
|
-
handlePrototype(global$
|
4617
|
+
handlePrototype(global$h[COLLECTION_NAME] && global$h[COLLECTION_NAME].prototype, COLLECTION_NAME);
|
4752
4618
|
}
|
4753
4619
|
|
4754
4620
|
handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
|
4755
4621
|
|
4622
|
+
var isObject$9 = isObject$n;
|
4623
|
+
var setPrototypeOf$4 = objectSetPrototypeOf;
|
4624
|
+
|
4625
|
+
// makes subclassing work correct for wrapped built-ins
|
4626
|
+
var inheritIfRequired$3 = function ($this, dummy, Wrapper) {
|
4627
|
+
var NewTarget, NewTargetPrototype;
|
4628
|
+
if (
|
4629
|
+
// it can work only with native `setPrototypeOf`
|
4630
|
+
setPrototypeOf$4 &&
|
4631
|
+
// we haven't completely correct pre-ES6 way for getting `new.target`, so use this
|
4632
|
+
typeof (NewTarget = dummy.constructor) == 'function' &&
|
4633
|
+
NewTarget !== Wrapper &&
|
4634
|
+
isObject$9(NewTargetPrototype = NewTarget.prototype) &&
|
4635
|
+
NewTargetPrototype !== Wrapper.prototype
|
4636
|
+
) setPrototypeOf$4($this, NewTargetPrototype);
|
4637
|
+
return $this;
|
4638
|
+
};
|
4639
|
+
|
4640
|
+
// a string of all valid unicode whitespaces
|
4641
|
+
var whitespaces$1 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
|
4642
|
+
'\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
|
4643
|
+
|
4644
|
+
var requireObjectCoercible$6 = requireObjectCoercible$a;
|
4645
|
+
var toString$8 = toString$d;
|
4646
|
+
var whitespaces = whitespaces$1;
|
4647
|
+
|
4648
|
+
var whitespace = '[' + whitespaces + ']';
|
4649
|
+
var ltrim = RegExp('^' + whitespace + whitespace + '*');
|
4650
|
+
var rtrim = RegExp(whitespace + whitespace + '*$');
|
4651
|
+
|
4652
|
+
// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
|
4653
|
+
var createMethod$2 = function (TYPE) {
|
4654
|
+
return function ($this) {
|
4655
|
+
var string = toString$8(requireObjectCoercible$6($this));
|
4656
|
+
if (TYPE & 1) string = string.replace(ltrim, '');
|
4657
|
+
if (TYPE & 2) string = string.replace(rtrim, '');
|
4658
|
+
return string;
|
4659
|
+
};
|
4660
|
+
};
|
4661
|
+
|
4662
|
+
var stringTrim = {
|
4663
|
+
// `String.prototype.{ trimLeft, trimStart }` methods
|
4664
|
+
// https://tc39.es/ecma262/#sec-string.prototype.trimstart
|
4665
|
+
start: createMethod$2(1),
|
4666
|
+
// `String.prototype.{ trimRight, trimEnd }` methods
|
4667
|
+
// https://tc39.es/ecma262/#sec-string.prototype.trimend
|
4668
|
+
end: createMethod$2(2),
|
4669
|
+
// `String.prototype.trim` method
|
4670
|
+
// https://tc39.es/ecma262/#sec-string.prototype.trim
|
4671
|
+
trim: createMethod$2(3)
|
4672
|
+
};
|
4673
|
+
|
4674
|
+
var DESCRIPTORS$9 = descriptors;
|
4675
|
+
var global$g = global$C;
|
4676
|
+
var isForced$1 = isForced_1;
|
4677
|
+
var redefine$6 = redefine$d.exports;
|
4678
|
+
var has$5 = has$g;
|
4679
|
+
var classof$5 = classofRaw$1;
|
4680
|
+
var inheritIfRequired$2 = inheritIfRequired$3;
|
4681
|
+
var isSymbol$1 = isSymbol$6;
|
4682
|
+
var toPrimitive = toPrimitive$2;
|
4683
|
+
var fails$j = fails$z;
|
4684
|
+
var create$4 = objectCreate;
|
4685
|
+
var getOwnPropertyNames$2 = objectGetOwnPropertyNames.f;
|
4686
|
+
var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
|
4687
|
+
var defineProperty$8 = objectDefineProperty.f;
|
4688
|
+
var trim = stringTrim.trim;
|
4689
|
+
|
4690
|
+
var NUMBER = 'Number';
|
4691
|
+
var NativeNumber = global$g[NUMBER];
|
4692
|
+
var NumberPrototype = NativeNumber.prototype;
|
4693
|
+
|
4694
|
+
// Opera ~12 has broken Object#toString
|
4695
|
+
var BROKEN_CLASSOF = classof$5(create$4(NumberPrototype)) == NUMBER;
|
4696
|
+
|
4697
|
+
// `ToNumber` abstract operation
|
4698
|
+
// https://tc39.es/ecma262/#sec-tonumber
|
4699
|
+
var toNumber = function (argument) {
|
4700
|
+
if (isSymbol$1(argument)) throw TypeError('Cannot convert a Symbol value to a number');
|
4701
|
+
var it = toPrimitive(argument, 'number');
|
4702
|
+
var first, third, radix, maxCode, digits, length, index, code;
|
4703
|
+
if (typeof it == 'string' && it.length > 2) {
|
4704
|
+
it = trim(it);
|
4705
|
+
first = it.charCodeAt(0);
|
4706
|
+
if (first === 43 || first === 45) {
|
4707
|
+
third = it.charCodeAt(2);
|
4708
|
+
if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
|
4709
|
+
} else if (first === 48) {
|
4710
|
+
switch (it.charCodeAt(1)) {
|
4711
|
+
case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
|
4712
|
+
case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
|
4713
|
+
default: return +it;
|
4714
|
+
}
|
4715
|
+
digits = it.slice(2);
|
4716
|
+
length = digits.length;
|
4717
|
+
for (index = 0; index < length; index++) {
|
4718
|
+
code = digits.charCodeAt(index);
|
4719
|
+
// parseInt parses a string to a first unavailable symbol
|
4720
|
+
// but ToNumber should return NaN if a string contains unavailable symbols
|
4721
|
+
if (code < 48 || code > maxCode) return NaN;
|
4722
|
+
} return parseInt(digits, radix);
|
4723
|
+
}
|
4724
|
+
} return +it;
|
4725
|
+
};
|
4726
|
+
|
4727
|
+
// `Number` constructor
|
4728
|
+
// https://tc39.es/ecma262/#sec-number-constructor
|
4729
|
+
if (isForced$1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {
|
4730
|
+
var NumberWrapper = function Number(value) {
|
4731
|
+
var it = arguments.length < 1 ? 0 : value;
|
4732
|
+
var dummy = this;
|
4733
|
+
return dummy instanceof NumberWrapper
|
4734
|
+
// check on 1..constructor(foo) case
|
4735
|
+
&& (BROKEN_CLASSOF ? fails$j(function () { NumberPrototype.valueOf.call(dummy); }) : classof$5(dummy) != NUMBER)
|
4736
|
+
? inheritIfRequired$2(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it);
|
4737
|
+
};
|
4738
|
+
for (var keys$1 = DESCRIPTORS$9 ? getOwnPropertyNames$2(NativeNumber) : (
|
4739
|
+
// ES3:
|
4740
|
+
'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
|
4741
|
+
// ES2015 (in case, if modules with ES2015 Number statics required before):
|
4742
|
+
'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
|
4743
|
+
'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,' +
|
4744
|
+
// ESNext
|
4745
|
+
'fromString,range'
|
4746
|
+
).split(','), j$1 = 0, key$1; keys$1.length > j$1; j$1++) {
|
4747
|
+
if (has$5(NativeNumber, key$1 = keys$1[j$1]) && !has$5(NumberWrapper, key$1)) {
|
4748
|
+
defineProperty$8(NumberWrapper, key$1, getOwnPropertyDescriptor$1(NativeNumber, key$1));
|
4749
|
+
}
|
4750
|
+
}
|
4751
|
+
NumberWrapper.prototype = NumberPrototype;
|
4752
|
+
NumberPrototype.constructor = NumberWrapper;
|
4753
|
+
redefine$6(global$g, NUMBER, NumberWrapper);
|
4754
|
+
}
|
4755
|
+
|
4756
4756
|
var anObject$6 = anObject$k;
|
4757
4757
|
|
4758
4758
|
// `RegExp.prototype.flags` getter implementation
|
@@ -9214,7 +9214,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
9214
9214
|
function _createSuper$b(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$c(); return function _createSuperInternal() { var Super = _getPrototypeOf$4(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$4(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$4(this, result); }; }
|
9215
9215
|
|
9216
9216
|
function _isNativeReflectConstruct$c() { 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; } }
|
9217
|
-
var log$
|
9217
|
+
var log$9 = Logger.scope("User");
|
9218
9218
|
/**
|
9219
9219
|
* Extended user information.
|
9220
9220
|
* Note that `isOnline` and `isNotifiable` properties are eligible
|
@@ -9356,7 +9356,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
9356
9356
|
|
9357
9357
|
case 2:
|
9358
9358
|
updateReasons = [];
|
9359
|
-
log$
|
9359
|
+
log$9.debug("User for", this.state.identity, "updated:", key, value);
|
9360
9360
|
_context.t0 = key;
|
9361
9361
|
_context.next = _context.t0 === "friendlyName" ? 7 : _context.t0 === "attributes" ? 9 : _context.t0 === "reachability" ? 12 : 15;
|
9362
9362
|
break;
|
@@ -9370,7 +9370,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
9370
9370
|
return _context.abrupt("break", 16);
|
9371
9371
|
|
9372
9372
|
case 9:
|
9373
|
-
updateAttributes = parseAttributes(value.value, "Retrieved malformed attributes from the server for user: ".concat(this.state.identity), log$
|
9373
|
+
updateAttributes = parseAttributes(value.value, "Retrieved malformed attributes from the server for user: ".concat(this.state.identity), log$9);
|
9374
9374
|
|
9375
9375
|
if (!isEqual(this.state.attributes, updateAttributes)) {
|
9376
9376
|
this.state.attributes = updateAttributes;
|
@@ -9441,7 +9441,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
9441
9441
|
|
9442
9442
|
case 4:
|
9443
9443
|
return _context2.abrupt("return", map.get("reachability").then(update).catch(function (err) {
|
9444
|
-
log$
|
9444
|
+
log$9.warn("Failed to get reachability info for ", _this2.state.identity, err);
|
9445
9445
|
}));
|
9446
9446
|
|
9447
9447
|
case 5:
|
@@ -9488,7 +9488,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
9488
9488
|
}).then(function (map) {
|
9489
9489
|
_this3.entity = map;
|
9490
9490
|
map.on("itemUpdated", function (args) {
|
9491
|
-
log$
|
9491
|
+
log$9.debug(_this3.state.entityName + " (" + _this3.state.identity + ") itemUpdated: " + args.item.key);
|
9492
9492
|
return _this3._update(args.item.key, args.item.data);
|
9493
9493
|
});
|
9494
9494
|
return Promise.all([map.get("friendlyName").then(function (item) {
|
@@ -9499,7 +9499,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
9499
9499
|
return _this3._update(item.key, item.data);
|
9500
9500
|
})]);
|
9501
9501
|
}).then(function () {
|
9502
|
-
log$
|
9502
|
+
log$9.debug("Fetched for", _this3.identity);
|
9503
9503
|
_this3.subscribed = "subscribed";
|
9504
9504
|
|
9505
9505
|
_this3.emit("userSubscribed", _this3);
|
@@ -12505,7 +12505,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
12505
12505
|
var abs = Math.abs;
|
12506
12506
|
var pow$1 = Math.pow;
|
12507
12507
|
var floor$4 = Math.floor;
|
12508
|
-
var log$
|
12508
|
+
var log$8 = Math.log;
|
12509
12509
|
var LN2 = Math.LN2;
|
12510
12510
|
|
12511
12511
|
var pack = function (number, mantissaLength, bytes) {
|
@@ -12524,7 +12524,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
12524
12524
|
mantissa = number != number ? 1 : 0;
|
12525
12525
|
exponent = eMax;
|
12526
12526
|
} else {
|
12527
|
-
exponent = floor$4(log$
|
12527
|
+
exponent = floor$4(log$8(number) / LN2);
|
12528
12528
|
if (number * (c = pow$1(2, -exponent)) < 1) {
|
12529
12529
|
exponent--;
|
12530
12530
|
c *= 2;
|
@@ -22303,7 +22303,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
22303
22303
|
return isInteger(number) && number > 0;
|
22304
22304
|
}
|
22305
22305
|
|
22306
|
-
var log$
|
22306
|
+
var log$7 = loglevelLog__namespace.getLogger('twilio-sync'); // twilio-sync is used by Flex SDK. Please DO NOT change
|
22307
22307
|
|
22308
22308
|
function prepareLine(prefix, args) {
|
22309
22309
|
return ["".concat(new Date().toISOString(), " Sync ").concat(prefix, ":")].concat(Array.from(args));
|
@@ -22311,42 +22311,42 @@ this.Twilio.Conversations = (function (exports) {
|
|
22311
22311
|
|
22312
22312
|
var log$1$1 = {
|
22313
22313
|
setLevel: function setLevel(level) {
|
22314
|
-
log$
|
22314
|
+
log$7.setLevel(level);
|
22315
22315
|
},
|
22316
22316
|
trace: function trace() {
|
22317
22317
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
22318
22318
|
args[_key] = arguments[_key];
|
22319
22319
|
}
|
22320
22320
|
|
22321
|
-
log$
|
22321
|
+
log$7.trace.apply(null, prepareLine('T', args));
|
22322
22322
|
},
|
22323
22323
|
debug: function debug() {
|
22324
22324
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
22325
22325
|
args[_key2] = arguments[_key2];
|
22326
22326
|
}
|
22327
22327
|
|
22328
|
-
log$
|
22328
|
+
log$7.debug.apply(null, prepareLine('D', args));
|
22329
22329
|
},
|
22330
22330
|
info: function info() {
|
22331
22331
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
22332
22332
|
args[_key3] = arguments[_key3];
|
22333
22333
|
}
|
22334
22334
|
|
22335
|
-
log$
|
22335
|
+
log$7.info.apply(null, prepareLine('I', args));
|
22336
22336
|
},
|
22337
22337
|
warn: function warn() {
|
22338
22338
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
22339
22339
|
args[_key4] = arguments[_key4];
|
22340
22340
|
}
|
22341
22341
|
|
22342
|
-
log$
|
22342
|
+
log$7.warn.apply(null, prepareLine('W', args));
|
22343
22343
|
},
|
22344
22344
|
error: function error() {
|
22345
22345
|
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
22346
22346
|
args[_key5] = arguments[_key5];
|
22347
22347
|
}
|
22348
22348
|
|
22349
|
-
log$
|
22349
|
+
log$7.error.apply(null, prepareLine('E', args));
|
22350
22350
|
}
|
22351
22351
|
};
|
22352
22352
|
var SUBSCRIPTIONS_PATH = '/v4/Subscriptions';
|
@@ -30430,7 +30430,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
30430
30430
|
|
30431
30431
|
__decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0)], InstantQuery.prototype, "updateIndexName", null);
|
30432
30432
|
|
30433
|
-
var version$1 = "3.1.
|
30433
|
+
var version$1 = "3.1.1-rc.1";
|
30434
30434
|
|
30435
30435
|
function _createSuper$9(Derived) {
|
30436
30436
|
var hasNativeReflectConstruct = _isNativeReflectConstruct$a();
|
@@ -30503,7 +30503,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
30503
30503
|
}
|
30504
30504
|
|
30505
30505
|
var SYNC_PRODUCT_ID = 'data_sync';
|
30506
|
-
var SDK_VERSION
|
30506
|
+
var SDK_VERSION = version$1;
|
30507
30507
|
|
30508
30508
|
function decompose(arg) {
|
30509
30509
|
if (!arg) {
|
@@ -30580,7 +30580,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
30580
30580
|
|
30581
30581
|
if (!options.clientMetadata.hasOwnProperty('sdk')) {
|
30582
30582
|
options.clientMetadata.sdk = 'JS';
|
30583
|
-
options.clientMetadata.sdkv = SDK_VERSION
|
30583
|
+
options.clientMetadata.sdkv = SDK_VERSION;
|
30584
30584
|
}
|
30585
30585
|
|
30586
30586
|
var startTwilsock = !options.twilsockClient; // Create default init registrations if none were provided.
|
@@ -30616,7 +30616,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
30616
30616
|
return _this._routeMessage(messageType, payload);
|
30617
30617
|
});
|
30618
30618
|
var config = new Configuration(options);
|
30619
|
-
var network = new NetworkService(new ClientInfo(SDK_VERSION
|
30619
|
+
var network = new NetworkService(new ClientInfo(SDK_VERSION), config, twilsock$1);
|
30620
30620
|
var storage = new SessionStorage(config);
|
30621
30621
|
_this.services = {
|
30622
30622
|
config: config,
|
@@ -31802,7 +31802,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
31802
31802
|
}, {
|
31803
31803
|
key: "version",
|
31804
31804
|
get: function get() {
|
31805
|
-
return SDK_VERSION
|
31805
|
+
return SDK_VERSION;
|
31806
31806
|
}
|
31807
31807
|
}]);
|
31808
31808
|
|
@@ -33642,6 +33642,80 @@ this.Twilio.Conversations = (function (exports) {
|
|
33642
33642
|
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
33643
33643
|
|
33644
33644
|
var log__namespace = /*#__PURE__*/_interopNamespace(log$2);
|
33645
|
+
/**
|
33646
|
+
* Cancellable promise. Extends the functionality of the native Promise to include the cancel method.
|
33647
|
+
*
|
33648
|
+
* Example:
|
33649
|
+
*
|
33650
|
+
* ```ts
|
33651
|
+
*
|
33652
|
+
* const cancellableFetchPromise = new CancellablePromise(async (resolve, reject, onCancel) => {
|
33653
|
+
* const request = fetch("https://example.com/");
|
33654
|
+
*
|
33655
|
+
* onCancel(() => request.cancel());
|
33656
|
+
*
|
33657
|
+
* try {
|
33658
|
+
* const response = await request;
|
33659
|
+
* resolve(response);
|
33660
|
+
* } catch (err) {
|
33661
|
+
* reject(err);
|
33662
|
+
* }
|
33663
|
+
* });
|
33664
|
+
*
|
33665
|
+
* cancellableFetchPromise.cancel();
|
33666
|
+
* ```
|
33667
|
+
*/
|
33668
|
+
|
33669
|
+
|
33670
|
+
var CancellablePromise = /*#__PURE__*/function (_Promise) {
|
33671
|
+
_inherits$4(CancellablePromise, _Promise);
|
33672
|
+
|
33673
|
+
var _super = _createSuper$8(CancellablePromise);
|
33674
|
+
|
33675
|
+
/**
|
33676
|
+
* Creates a new CancellablePromise.
|
33677
|
+
* @param executor A callback used to initialize the promise. This callback is passed three arguments:
|
33678
|
+
* a resolve callback used to resolve the promise with a value or the result of another promise,
|
33679
|
+
* a reject callback used to reject the promise with a provided reason or error,
|
33680
|
+
* and an onCancel callback used to define behavior of cancellation.
|
33681
|
+
*/
|
33682
|
+
function CancellablePromise(executor) {
|
33683
|
+
var _this6;
|
33684
|
+
|
33685
|
+
_classCallCheck$4(this, CancellablePromise);
|
33686
|
+
|
33687
|
+
var outerCancellationFunction;
|
33688
|
+
var outerRejectPromise;
|
33689
|
+
_this6 = _super.call(this, function (resolve, reject) {
|
33690
|
+
outerRejectPromise = reject;
|
33691
|
+
return executor(resolve, reject, function (cancellationFunction) {
|
33692
|
+
outerCancellationFunction = cancellationFunction;
|
33693
|
+
});
|
33694
|
+
});
|
33695
|
+
_this6.cancel = outerCancellationFunction;
|
33696
|
+
_this6.rejectPromise = outerRejectPromise;
|
33697
|
+
return _this6;
|
33698
|
+
}
|
33699
|
+
/**
|
33700
|
+
* Cancels the promise and invokes the cancellation callback if it was defined during instantiation. Cancellation will result in the promise being rejected.
|
33701
|
+
*/
|
33702
|
+
|
33703
|
+
|
33704
|
+
_createClass$3(CancellablePromise, [{
|
33705
|
+
key: "cancel",
|
33706
|
+
value: function cancel() {
|
33707
|
+
if (this.onCancel) {
|
33708
|
+
this.onCancel();
|
33709
|
+
}
|
33710
|
+
|
33711
|
+
if (this.rejectPromise) {
|
33712
|
+
this.rejectPromise(new Error("Promise was cancelled"));
|
33713
|
+
}
|
33714
|
+
}
|
33715
|
+
}]);
|
33716
|
+
|
33717
|
+
return CancellablePromise;
|
33718
|
+
}( /*#__PURE__*/_wrapNativeSuper(Promise));
|
33645
33719
|
/*! *****************************************************************************
|
33646
33720
|
Copyright (c) Microsoft Corporation.
|
33647
33721
|
|
@@ -33929,8 +34003,6 @@ this.Twilio.Conversations = (function (exports) {
|
|
33929
34003
|
*
|
33930
34004
|
* It is reasonable to build your own refresh logic upon these two functions: as soon as URL returned
|
33931
34005
|
* by getCachedContentUrl() returns 40x status you should call getContentUrl() to refresh it.
|
33932
|
-
*
|
33933
|
-
* @returns {Promise<string>}
|
33934
34006
|
*/
|
33935
34007
|
|
33936
34008
|
}, {
|
@@ -33938,72 +34010,47 @@ this.Twilio.Conversations = (function (exports) {
|
|
33938
34010
|
value: function getContentUrl() {
|
33939
34011
|
var _this = this;
|
33940
34012
|
|
33941
|
-
return
|
33942
|
-
var
|
33943
|
-
|
33944
|
-
|
33945
|
-
|
33946
|
-
|
33947
|
-
|
33948
|
-
|
33949
|
-
|
33950
|
-
|
33951
|
-
|
33952
|
-
|
33953
|
-
|
33954
|
-
|
33955
|
-
return _context.abrupt("return", Promise.resolve(_this.state.contentDirectUrl));
|
34013
|
+
return new CancellablePromise( /*#__PURE__*/function () {
|
34014
|
+
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(resolve, reject, onCancel) {
|
34015
|
+
var request, response;
|
34016
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
34017
|
+
while (1) {
|
34018
|
+
switch (_context.prev = _context.next) {
|
34019
|
+
case 0:
|
34020
|
+
request = _this.network.get("".concat(_this.config.mediaUrl, "/").concat(_this.sid));
|
34021
|
+
onCancel(function () {
|
34022
|
+
return request.cancel();
|
34023
|
+
});
|
34024
|
+
_context.prev = 2;
|
34025
|
+
_context.next = 5;
|
34026
|
+
return request;
|
33956
34027
|
|
33957
|
-
|
33958
|
-
|
33959
|
-
return _context.stop();
|
33960
|
-
}
|
33961
|
-
}
|
33962
|
-
}, _callee);
|
33963
|
-
}))();
|
33964
|
-
}
|
33965
|
-
/**
|
33966
|
-
* Returns direct content URL to uploaded binary. This URL will expire after some time.
|
33967
|
-
* This function does not support getting a new URL however. Once set it will remain the same.
|
33968
|
-
* Use getContentUrl() to query a new one.
|
33969
|
-
*
|
33970
|
-
* It is reasonable to build your own refresh logic upon these two functions: as soon as URL returned
|
33971
|
-
* by getCachedContentUrl() returns 40x status you should call getContentUrl() to refresh it.
|
33972
|
-
*
|
33973
|
-
* @returns {Promise<string>}
|
33974
|
-
*/
|
34028
|
+
case 5:
|
34029
|
+
response = _context.sent;
|
33975
34030
|
|
33976
|
-
|
33977
|
-
key: "getCachedContentUrl",
|
33978
|
-
value: function getCachedContentUrl() {
|
33979
|
-
var _this2 = this;
|
34031
|
+
_this._update(response.body);
|
33980
34032
|
|
33981
|
-
|
33982
|
-
|
33983
|
-
while (1) {
|
33984
|
-
switch (_context2.prev = _context2.next) {
|
33985
|
-
case 0:
|
33986
|
-
if (!_this2.state.contentDirectUrl) {
|
33987
|
-
_context2.next = 2;
|
34033
|
+
resolve(_this.state.contentDirectUrl);
|
34034
|
+
_context.next = 13;
|
33988
34035
|
break;
|
33989
|
-
}
|
33990
34036
|
|
33991
|
-
|
34037
|
+
case 10:
|
34038
|
+
_context.prev = 10;
|
34039
|
+
_context.t0 = _context["catch"](2);
|
34040
|
+
reject(_context.t0);
|
33992
34041
|
|
33993
|
-
|
33994
|
-
|
33995
|
-
|
33996
|
-
|
33997
|
-
case 4:
|
33998
|
-
return _context2.abrupt("return", _context2.sent);
|
33999
|
-
|
34000
|
-
case 5:
|
34001
|
-
case "end":
|
34002
|
-
return _context2.stop();
|
34042
|
+
case 13:
|
34043
|
+
case "end":
|
34044
|
+
return _context.stop();
|
34045
|
+
}
|
34003
34046
|
}
|
34004
|
-
}
|
34005
|
-
}
|
34006
|
-
|
34047
|
+
}, _callee, null, [[2, 10]]);
|
34048
|
+
}));
|
34049
|
+
|
34050
|
+
return function (_x, _x2, _x3) {
|
34051
|
+
return _ref.apply(this, arguments);
|
34052
|
+
};
|
34053
|
+
}());
|
34007
34054
|
}
|
34008
34055
|
}, {
|
34009
34056
|
key: "_update",
|
@@ -34037,19 +34084,19 @@ this.Twilio.Conversations = (function (exports) {
|
|
34037
34084
|
var TransportError = /*#__PURE__*/function (_Error) {
|
34038
34085
|
_inherits$4(TransportError, _Error);
|
34039
34086
|
|
34040
|
-
var
|
34087
|
+
var _super2 = _createSuper$8(TransportError);
|
34041
34088
|
|
34042
34089
|
function TransportError(message, code, body, status, headers) {
|
34043
|
-
var
|
34090
|
+
var _this7;
|
34044
34091
|
|
34045
34092
|
_classCallCheck$4(this, TransportError);
|
34046
34093
|
|
34047
|
-
|
34048
|
-
|
34049
|
-
|
34050
|
-
|
34051
|
-
|
34052
|
-
return
|
34094
|
+
_this7 = _super2.call(this, message);
|
34095
|
+
_this7.code = code;
|
34096
|
+
_this7.body = body;
|
34097
|
+
_this7.status = status;
|
34098
|
+
_this7.headers = headers;
|
34099
|
+
return _this7;
|
34053
34100
|
}
|
34054
34101
|
|
34055
34102
|
return TransportError;
|
@@ -34102,20 +34149,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
34102
34149
|
* Make a GET request by given URL
|
34103
34150
|
*/
|
34104
34151
|
function get(url, headers) {
|
34105
|
-
return
|
34106
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
34107
|
-
while (1) {
|
34108
|
-
switch (_context2.prev = _context2.next) {
|
34109
|
-
case 0:
|
34110
|
-
return _context2.abrupt("return", Transport.request("GET", url, headers));
|
34111
|
-
|
34112
|
-
case 1:
|
34113
|
-
case "end":
|
34114
|
-
return _context2.stop();
|
34115
|
-
}
|
34116
|
-
}
|
34117
|
-
}, _callee2);
|
34118
|
-
}))();
|
34152
|
+
return Transport.request("GET", url, headers);
|
34119
34153
|
}
|
34120
34154
|
/**
|
34121
34155
|
* Make a POST request by given URL
|
@@ -34124,82 +34158,61 @@ this.Twilio.Conversations = (function (exports) {
|
|
34124
34158
|
}, {
|
34125
34159
|
key: "post",
|
34126
34160
|
value: function post(url, headers, body) {
|
34127
|
-
return
|
34128
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
34129
|
-
while (1) {
|
34130
|
-
switch (_context3.prev = _context3.next) {
|
34131
|
-
case 0:
|
34132
|
-
return _context3.abrupt("return", Transport.request("POST", url, headers, body));
|
34133
|
-
|
34134
|
-
case 1:
|
34135
|
-
case "end":
|
34136
|
-
return _context3.stop();
|
34137
|
-
}
|
34138
|
-
}
|
34139
|
-
}, _callee3);
|
34140
|
-
}))();
|
34161
|
+
return Transport.request("POST", url, headers, body);
|
34141
34162
|
}
|
34142
34163
|
}], [{
|
34143
34164
|
key: "request",
|
34144
34165
|
value: function request(method, url, headers, body) {
|
34145
|
-
return
|
34146
|
-
|
34147
|
-
|
34148
|
-
|
34149
|
-
|
34150
|
-
|
34151
|
-
|
34152
|
-
|
34153
|
-
|
34154
|
-
xhr.onreadystatechange = function onreadystatechange() {
|
34155
|
-
if (xhr.readyState !== 4) {
|
34156
|
-
return;
|
34157
|
-
}
|
34158
|
-
|
34159
|
-
var headers = parseResponseHeaders(xhr.getAllResponseHeaders());
|
34160
|
-
var body = extractBody(xhr);
|
34166
|
+
return new CancellablePromise(function (resolve, reject, onCancel) {
|
34167
|
+
var xhr = new XHR();
|
34168
|
+
var isCancelled = false;
|
34169
|
+
onCancel(function () {
|
34170
|
+
xhr.abort();
|
34171
|
+
isCancelled = true;
|
34172
|
+
});
|
34173
|
+
xhr.open(method, url, true);
|
34161
34174
|
|
34162
|
-
|
34163
|
-
|
34164
|
-
|
34165
|
-
|
34166
|
-
body: body
|
34167
|
-
});
|
34168
|
-
} else {
|
34169
|
-
var _xhr$statusText;
|
34175
|
+
xhr.onreadystatechange = function onreadystatechange() {
|
34176
|
+
if (xhr.readyState !== 4 || isCancelled) {
|
34177
|
+
return;
|
34178
|
+
}
|
34170
34179
|
|
34171
|
-
|
34172
|
-
|
34180
|
+
var headers = parseResponseHeaders(xhr.getAllResponseHeaders());
|
34181
|
+
var body = extractBody(xhr);
|
34173
34182
|
|
34174
|
-
|
34175
|
-
|
34176
|
-
|
34177
|
-
|
34178
|
-
|
34183
|
+
if (200 <= xhr.status && xhr.status < 300) {
|
34184
|
+
resolve({
|
34185
|
+
status: xhr.status,
|
34186
|
+
headers: headers,
|
34187
|
+
body: body
|
34188
|
+
});
|
34189
|
+
} else {
|
34190
|
+
var _xhr$statusText;
|
34179
34191
|
|
34180
|
-
|
34181
|
-
|
34182
|
-
}
|
34183
|
-
};
|
34192
|
+
var status = (_xhr$statusText = xhr.statusText) !== null && _xhr$statusText !== void 0 ? _xhr$statusText : "NONE";
|
34193
|
+
var bodyRepresentation;
|
34184
34194
|
|
34185
|
-
|
34186
|
-
|
34195
|
+
if (typeof body === "string") {
|
34196
|
+
bodyRepresentation = body && body.split("\n", 2).length === 1 ? body : "";
|
34197
|
+
} else {
|
34198
|
+
bodyRepresentation = JSON.stringify(body);
|
34199
|
+
}
|
34187
34200
|
|
34188
|
-
|
34189
|
-
|
34190
|
-
|
34191
|
-
|
34201
|
+
var message = "".concat(xhr.status, ": [").concat(status, "] ").concat(bodyRepresentation);
|
34202
|
+
reject(new TransportError(message, xhr.status, body, status, headers));
|
34203
|
+
}
|
34204
|
+
};
|
34192
34205
|
|
34193
|
-
|
34194
|
-
|
34206
|
+
for (var headerName in headers) {
|
34207
|
+
xhr.setRequestHeader(headerName, headers[headerName]);
|
34195
34208
|
|
34196
|
-
|
34197
|
-
|
34198
|
-
return _context.stop();
|
34199
|
-
}
|
34209
|
+
if (headerName === "Content-Type" && headers[headerName] === "application/json") {
|
34210
|
+
body = JSON.stringify(body);
|
34200
34211
|
}
|
34201
|
-
}
|
34202
|
-
|
34212
|
+
}
|
34213
|
+
|
34214
|
+
xhr.send(body);
|
34215
|
+
});
|
34203
34216
|
}
|
34204
34217
|
}]);
|
34205
34218
|
|
@@ -34233,19 +34246,25 @@ this.Twilio.Conversations = (function (exports) {
|
|
34233
34246
|
value: function executeWithRetry(request, retryWhenThrottled) {
|
34234
34247
|
var _this = this;
|
34235
34248
|
|
34236
|
-
return
|
34237
|
-
|
34238
|
-
|
34239
|
-
|
34240
|
-
|
34241
|
-
|
34242
|
-
|
34249
|
+
return new CancellablePromise( /*#__PURE__*/function () {
|
34250
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(resolve, reject, onCancel) {
|
34251
|
+
var retrier, codesToRetryOn;
|
34252
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
34253
|
+
while (1) {
|
34254
|
+
switch (_context2.prev = _context2.next) {
|
34255
|
+
case 0:
|
34256
|
+
retrier = new operationRetrier.Retrier(_this.backoffConfig());
|
34257
|
+
onCancel(function () {
|
34258
|
+
request.cancel();
|
34259
|
+
retrier.removeAllListeners();
|
34260
|
+
retrier.cancel();
|
34261
|
+
});
|
34262
|
+
codesToRetryOn = [502, 503, 504];
|
34243
34263
|
|
34244
34264
|
if (retryWhenThrottled) {
|
34245
34265
|
codesToRetryOn.push(429);
|
34246
34266
|
}
|
34247
34267
|
|
34248
|
-
var retrier = new operationRetrier.Retrier(_this.backoffConfig());
|
34249
34268
|
retrier.on("attempt", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
34250
34269
|
var result;
|
34251
34270
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
@@ -34295,130 +34314,158 @@ this.Twilio.Conversations = (function (exports) {
|
|
34295
34314
|
return reject(err);
|
34296
34315
|
});
|
34297
34316
|
retrier.start();
|
34298
|
-
}));
|
34299
34317
|
|
34300
|
-
|
34301
|
-
|
34302
|
-
|
34318
|
+
case 9:
|
34319
|
+
case "end":
|
34320
|
+
return _context2.stop();
|
34321
|
+
}
|
34303
34322
|
}
|
34304
|
-
}
|
34305
|
-
}
|
34306
|
-
|
34323
|
+
}, _callee2);
|
34324
|
+
}));
|
34325
|
+
|
34326
|
+
return function (_x, _x2, _x3) {
|
34327
|
+
return _ref2.apply(this, arguments);
|
34328
|
+
};
|
34329
|
+
}());
|
34307
34330
|
}
|
34308
34331
|
}, {
|
34309
34332
|
key: "get",
|
34310
34333
|
value: function get(url) {
|
34311
34334
|
var _this2 = this;
|
34312
34335
|
|
34313
|
-
return
|
34314
|
-
var
|
34315
|
-
|
34316
|
-
|
34317
|
-
|
34318
|
-
|
34319
|
-
|
34320
|
-
|
34321
|
-
|
34322
|
-
|
34323
|
-
|
34324
|
-
|
34325
|
-
|
34326
|
-
|
34327
|
-
|
34328
|
-
|
34329
|
-
|
34330
|
-
|
34331
|
-
|
34332
|
-
|
34336
|
+
return new CancellablePromise( /*#__PURE__*/function () {
|
34337
|
+
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(resolve, reject, onCancel) {
|
34338
|
+
var headers, request, response;
|
34339
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
34340
|
+
while (1) {
|
34341
|
+
switch (_context3.prev = _context3.next) {
|
34342
|
+
case 0:
|
34343
|
+
headers = {
|
34344
|
+
"X-Twilio-Token": _this2.config.token
|
34345
|
+
};
|
34346
|
+
request = _this2.executeWithRetry(function () {
|
34347
|
+
return _this2.transport.get(url, headers);
|
34348
|
+
}, _this2.retryWhenThrottled());
|
34349
|
+
log$1.trace("sending GET request to ", url, " headers ", headers);
|
34350
|
+
onCancel(function () {
|
34351
|
+
return request.cancel();
|
34352
|
+
});
|
34353
|
+
_context3.prev = 4;
|
34354
|
+
_context3.next = 7;
|
34355
|
+
return request;
|
34356
|
+
|
34357
|
+
case 7:
|
34358
|
+
response = _context3.sent;
|
34359
|
+
log$1.trace("response", response);
|
34360
|
+
resolve(response);
|
34361
|
+
_context3.next = 16;
|
34362
|
+
break;
|
34333
34363
|
|
34334
|
-
|
34335
|
-
|
34336
|
-
|
34337
|
-
|
34338
|
-
|
34364
|
+
case 12:
|
34365
|
+
_context3.prev = 12;
|
34366
|
+
_context3.t0 = _context3["catch"](4);
|
34367
|
+
log$1.debug("get() error ".concat(_context3.t0));
|
34368
|
+
reject(_context3.t0);
|
34339
34369
|
|
34340
|
-
|
34341
|
-
|
34342
|
-
|
34370
|
+
case 16:
|
34371
|
+
case "end":
|
34372
|
+
return _context3.stop();
|
34373
|
+
}
|
34343
34374
|
}
|
34344
|
-
}
|
34345
|
-
}
|
34346
|
-
|
34375
|
+
}, _callee3, null, [[4, 12]]);
|
34376
|
+
}));
|
34377
|
+
|
34378
|
+
return function (_x4, _x5, _x6) {
|
34379
|
+
return _ref4.apply(this, arguments);
|
34380
|
+
};
|
34381
|
+
}());
|
34347
34382
|
}
|
34348
34383
|
}, {
|
34349
34384
|
key: "post",
|
34350
34385
|
value: function post(url, category, media, contentType, filename) {
|
34351
34386
|
var _this3 = this;
|
34352
34387
|
|
34353
|
-
|
34354
|
-
|
34355
|
-
|
34356
|
-
while (1) {
|
34357
|
-
switch (_context4.prev = _context4.next) {
|
34358
|
-
case 0:
|
34359
|
-
headers = {
|
34360
|
-
"X-Twilio-Token": _this3.config.token
|
34361
|
-
};
|
34362
|
-
|
34363
|
-
if ((typeof FormData === "undefined" || !(media instanceof FormData)) && contentType) {
|
34364
|
-
Object.assign(headers, {
|
34365
|
-
"Content-Type": contentType
|
34366
|
-
});
|
34367
|
-
}
|
34388
|
+
var headers = {
|
34389
|
+
"X-Twilio-Token": this.config.token
|
34390
|
+
};
|
34368
34391
|
|
34369
|
-
|
34392
|
+
if ((typeof FormData === "undefined" || !(media instanceof FormData)) && contentType) {
|
34393
|
+
Object.assign(headers, {
|
34394
|
+
"Content-Type": contentType
|
34395
|
+
});
|
34396
|
+
}
|
34370
34397
|
|
34371
|
-
|
34372
|
-
fullUrl.searchParams.append("Category", category);
|
34373
|
-
}
|
34398
|
+
var fullUrl = new URL(url);
|
34374
34399
|
|
34375
|
-
|
34376
|
-
|
34377
|
-
|
34400
|
+
if (category) {
|
34401
|
+
fullUrl.searchParams.append("Category", category);
|
34402
|
+
}
|
34378
34403
|
|
34379
|
-
|
34380
|
-
|
34381
|
-
|
34382
|
-
return _this3.transport.post(fullUrl.href, headers, media);
|
34404
|
+
if (filename) {
|
34405
|
+
fullUrl.searchParams.append("Filename", filename);
|
34406
|
+
}
|
34383
34407
|
|
34384
|
-
|
34385
|
-
|
34386
|
-
|
34387
|
-
|
34408
|
+
return new CancellablePromise( /*#__PURE__*/function () {
|
34409
|
+
var _ref5 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(resolve, reject, onCancel) {
|
34410
|
+
var request, response;
|
34411
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
34412
|
+
while (1) {
|
34413
|
+
switch (_context4.prev = _context4.next) {
|
34414
|
+
case 0:
|
34415
|
+
request = _this3.transport.post(fullUrl.href, headers, media);
|
34416
|
+
onCancel(function () {
|
34417
|
+
return request.cancel();
|
34418
|
+
});
|
34419
|
+
log$1.trace("sending POST request to ".concat(url, " with headers ").concat(headers));
|
34420
|
+
_context4.prev = 3;
|
34421
|
+
_context4.next = 6;
|
34422
|
+
return request;
|
34423
|
+
|
34424
|
+
case 6:
|
34425
|
+
response = _context4.sent;
|
34426
|
+
_context4.next = 17;
|
34427
|
+
break;
|
34388
34428
|
|
34389
|
-
|
34390
|
-
|
34391
|
-
|
34429
|
+
case 9:
|
34430
|
+
_context4.prev = 9;
|
34431
|
+
_context4.t0 = _context4["catch"](3);
|
34392
34432
|
|
34393
|
-
|
34394
|
-
|
34395
|
-
|
34396
|
-
|
34433
|
+
if (!(global["XMLHttpRequest"] === undefined && media instanceof FormData)) {
|
34434
|
+
_context4.next = 14;
|
34435
|
+
break;
|
34436
|
+
}
|
34397
34437
|
|
34398
|
-
|
34438
|
+
reject(new TypeError("Posting FormData supported only with browser engine's FormData"));
|
34439
|
+
return _context4.abrupt("return");
|
34399
34440
|
|
34400
|
-
|
34401
|
-
|
34402
|
-
|
34441
|
+
case 14:
|
34442
|
+
log$1.debug("post() error ".concat(_context4.t0));
|
34443
|
+
reject(_context4.t0);
|
34444
|
+
return _context4.abrupt("return");
|
34403
34445
|
|
34404
|
-
|
34405
|
-
|
34406
|
-
|
34446
|
+
case 17:
|
34447
|
+
log$1.trace("response", response);
|
34448
|
+
resolve(response);
|
34407
34449
|
|
34408
|
-
|
34409
|
-
|
34410
|
-
|
34450
|
+
case 19:
|
34451
|
+
case "end":
|
34452
|
+
return _context4.stop();
|
34453
|
+
}
|
34411
34454
|
}
|
34412
|
-
}
|
34413
|
-
}
|
34414
|
-
|
34455
|
+
}, _callee4, null, [[3, 9]]);
|
34456
|
+
}));
|
34457
|
+
|
34458
|
+
return function (_x7, _x8, _x9) {
|
34459
|
+
return _ref5.apply(this, arguments);
|
34460
|
+
};
|
34461
|
+
}());
|
34415
34462
|
}
|
34416
34463
|
}]);
|
34417
34464
|
|
34418
34465
|
return Network;
|
34419
34466
|
}();
|
34420
34467
|
|
34421
|
-
var version = "0.
|
34468
|
+
var version = "0.6.0-rc.1";
|
34422
34469
|
|
34423
34470
|
var _class, _temp;
|
34424
34471
|
|
@@ -34476,7 +34523,6 @@ this.Twilio.Conversations = (function (exports) {
|
|
34476
34523
|
/**
|
34477
34524
|
* Gets media from media service
|
34478
34525
|
* @param {String} sid - Media's SID
|
34479
|
-
* @returns {Promise<Media>}
|
34480
34526
|
*/
|
34481
34527
|
|
34482
34528
|
}, {
|
@@ -34484,33 +34530,50 @@ this.Twilio.Conversations = (function (exports) {
|
|
34484
34530
|
value: function get(sid) {
|
34485
34531
|
var _this = this;
|
34486
34532
|
|
34487
|
-
return
|
34488
|
-
var
|
34489
|
-
|
34490
|
-
|
34491
|
-
|
34492
|
-
|
34493
|
-
|
34494
|
-
|
34533
|
+
return new CancellablePromise( /*#__PURE__*/function () {
|
34534
|
+
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(resolve, reject, onCancel) {
|
34535
|
+
var request, response;
|
34536
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
34537
|
+
while (1) {
|
34538
|
+
switch (_context.prev = _context.next) {
|
34539
|
+
case 0:
|
34540
|
+
request = _this.network.get("".concat(_this.config.mediaUrl, "/").concat(sid));
|
34541
|
+
onCancel(function () {
|
34542
|
+
return request.cancel();
|
34543
|
+
});
|
34544
|
+
_context.prev = 2;
|
34545
|
+
_context.next = 5;
|
34546
|
+
return request;
|
34547
|
+
|
34548
|
+
case 5:
|
34549
|
+
response = _context.sent;
|
34550
|
+
resolve(new Media(_this.config, _this.network, response.body));
|
34551
|
+
_context.next = 12;
|
34552
|
+
break;
|
34495
34553
|
|
34496
|
-
|
34497
|
-
|
34498
|
-
|
34554
|
+
case 9:
|
34555
|
+
_context.prev = 9;
|
34556
|
+
_context.t0 = _context["catch"](2);
|
34557
|
+
reject(_context.t0);
|
34499
34558
|
|
34500
|
-
|
34501
|
-
|
34502
|
-
|
34559
|
+
case 12:
|
34560
|
+
case "end":
|
34561
|
+
return _context.stop();
|
34562
|
+
}
|
34503
34563
|
}
|
34504
|
-
}
|
34505
|
-
}
|
34506
|
-
|
34564
|
+
}, _callee, null, [[2, 9]]);
|
34565
|
+
}));
|
34566
|
+
|
34567
|
+
return function (_x, _x2, _x3) {
|
34568
|
+
return _ref.apply(this, arguments);
|
34569
|
+
};
|
34570
|
+
}());
|
34507
34571
|
}
|
34508
34572
|
/**
|
34509
34573
|
* Posts raw content to media service
|
34510
34574
|
* @param {String} contentType - content type of media
|
34511
34575
|
* @param {String|Buffer|Blob} media - content to post
|
34512
34576
|
* @param {MediaCategory|null} category - category for the media
|
34513
|
-
* @returns {Promise<Media>}
|
34514
34577
|
*/
|
34515
34578
|
|
34516
34579
|
}, {
|
@@ -34518,26 +34581,44 @@ this.Twilio.Conversations = (function (exports) {
|
|
34518
34581
|
value: function post(contentType, media, category, filename) {
|
34519
34582
|
var _this2 = this;
|
34520
34583
|
|
34521
|
-
return
|
34522
|
-
var
|
34523
|
-
|
34524
|
-
|
34525
|
-
|
34526
|
-
|
34527
|
-
|
34528
|
-
|
34584
|
+
return new CancellablePromise( /*#__PURE__*/function () {
|
34585
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(resolve, reject, onCancel) {
|
34586
|
+
var request, response;
|
34587
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
34588
|
+
while (1) {
|
34589
|
+
switch (_context2.prev = _context2.next) {
|
34590
|
+
case 0:
|
34591
|
+
request = _this2.network.post(_this2.config.mediaUrl, category !== null && category !== void 0 ? category : "media", media, contentType, filename);
|
34592
|
+
onCancel(function () {
|
34593
|
+
return request.cancel();
|
34594
|
+
});
|
34595
|
+
_context2.prev = 2;
|
34596
|
+
_context2.next = 5;
|
34597
|
+
return request;
|
34598
|
+
|
34599
|
+
case 5:
|
34600
|
+
response = _context2.sent;
|
34601
|
+
resolve(new Media(_this2.config, _this2.network, response.body));
|
34602
|
+
_context2.next = 12;
|
34603
|
+
break;
|
34529
34604
|
|
34530
|
-
|
34531
|
-
|
34532
|
-
|
34605
|
+
case 9:
|
34606
|
+
_context2.prev = 9;
|
34607
|
+
_context2.t0 = _context2["catch"](2);
|
34608
|
+
reject(_context2.t0);
|
34533
34609
|
|
34534
|
-
|
34535
|
-
|
34536
|
-
|
34610
|
+
case 12:
|
34611
|
+
case "end":
|
34612
|
+
return _context2.stop();
|
34613
|
+
}
|
34537
34614
|
}
|
34538
|
-
}
|
34539
|
-
}
|
34540
|
-
|
34615
|
+
}, _callee2, null, [[2, 9]]);
|
34616
|
+
}));
|
34617
|
+
|
34618
|
+
return function (_x4, _x5, _x6) {
|
34619
|
+
return _ref2.apply(this, arguments);
|
34620
|
+
};
|
34621
|
+
}());
|
34541
34622
|
}
|
34542
34623
|
/**
|
34543
34624
|
* Posts FormData to media service. Can be used only with browser engine's FormData.
|
@@ -34545,7 +34626,6 @@ this.Twilio.Conversations = (function (exports) {
|
|
34545
34626
|
* new TypeError("Posting FormData supported only with browser engine's FormData")
|
34546
34627
|
* @param {FormData} formData - form data to post
|
34547
34628
|
* @param {MediaCategory|null} category - category for the media
|
34548
|
-
* @returns {Promise<Media>}
|
34549
34629
|
*/
|
34550
34630
|
|
34551
34631
|
}, {
|
@@ -34553,26 +34633,44 @@ this.Twilio.Conversations = (function (exports) {
|
|
34553
34633
|
value: function postFormData(formData, category) {
|
34554
34634
|
var _this3 = this;
|
34555
34635
|
|
34556
|
-
return
|
34557
|
-
var
|
34558
|
-
|
34559
|
-
|
34560
|
-
|
34561
|
-
|
34562
|
-
|
34563
|
-
|
34636
|
+
return new CancellablePromise( /*#__PURE__*/function () {
|
34637
|
+
var _ref3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(resolve, reject, onCancel) {
|
34638
|
+
var request, response;
|
34639
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
34640
|
+
while (1) {
|
34641
|
+
switch (_context3.prev = _context3.next) {
|
34642
|
+
case 0:
|
34643
|
+
request = _this3.network.post(_this3.config.mediaUrl, category !== null && category !== void 0 ? category : "media", formData);
|
34644
|
+
onCancel(function () {
|
34645
|
+
return request.cancel();
|
34646
|
+
});
|
34647
|
+
_context3.prev = 2;
|
34648
|
+
_context3.next = 5;
|
34649
|
+
return request;
|
34650
|
+
|
34651
|
+
case 5:
|
34652
|
+
response = _context3.sent;
|
34653
|
+
resolve(new Media(_this3.config, _this3.network, response.body));
|
34654
|
+
_context3.next = 12;
|
34655
|
+
break;
|
34564
34656
|
|
34565
|
-
|
34566
|
-
|
34567
|
-
|
34657
|
+
case 9:
|
34658
|
+
_context3.prev = 9;
|
34659
|
+
_context3.t0 = _context3["catch"](2);
|
34660
|
+
reject(_context3.t0);
|
34568
34661
|
|
34569
|
-
|
34570
|
-
|
34571
|
-
|
34662
|
+
case 12:
|
34663
|
+
case "end":
|
34664
|
+
return _context3.stop();
|
34665
|
+
}
|
34572
34666
|
}
|
34573
|
-
}
|
34574
|
-
}
|
34575
|
-
|
34667
|
+
}, _callee3, null, [[2, 9]]);
|
34668
|
+
}));
|
34669
|
+
|
34670
|
+
return function (_x7, _x8, _x9) {
|
34671
|
+
return _ref3.apply(this, arguments);
|
34672
|
+
};
|
34673
|
+
}());
|
34576
34674
|
}
|
34577
34675
|
/**
|
34578
34676
|
* Retrieve information about multiple media SIDs at the same time.
|
@@ -34584,40 +34682,126 @@ this.Twilio.Conversations = (function (exports) {
|
|
34584
34682
|
value: function mediaSetGet(mediaSids) {
|
34585
34683
|
var _this4 = this;
|
34586
34684
|
|
34587
|
-
return
|
34588
|
-
var
|
34589
|
-
|
34590
|
-
|
34591
|
-
|
34592
|
-
|
34593
|
-
|
34594
|
-
|
34595
|
-
|
34596
|
-
|
34597
|
-
|
34598
|
-
|
34599
|
-
|
34600
|
-
|
34601
|
-
|
34602
|
-
|
34685
|
+
return new CancellablePromise( /*#__PURE__*/function () {
|
34686
|
+
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(resolve, reject, onCancel) {
|
34687
|
+
var query, request, response, media;
|
34688
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
34689
|
+
while (1) {
|
34690
|
+
switch (_context4.prev = _context4.next) {
|
34691
|
+
case 0:
|
34692
|
+
query = {
|
34693
|
+
command: "get",
|
34694
|
+
list: mediaSids.map(function (sid) {
|
34695
|
+
return {
|
34696
|
+
media_sid: sid
|
34697
|
+
};
|
34698
|
+
})
|
34699
|
+
};
|
34700
|
+
request = _this4.network.post("".concat(_this4.config.mediaSetUrl), null, query, "application/json");
|
34701
|
+
onCancel(function () {
|
34702
|
+
return request.cancel();
|
34703
|
+
});
|
34704
|
+
_context4.prev = 3;
|
34705
|
+
_context4.next = 6;
|
34706
|
+
return request;
|
34707
|
+
|
34708
|
+
case 6:
|
34709
|
+
response = _context4.sent;
|
34710
|
+
media = response.body.map(function (item) {
|
34711
|
+
if (item.code !== 200) {
|
34712
|
+
reject("Failed to obtain detailed information about Media items (failed SID ".concat(item.media_record.sid, ")"));
|
34713
|
+
return;
|
34714
|
+
}
|
34603
34715
|
|
34604
|
-
|
34605
|
-
|
34606
|
-
|
34607
|
-
|
34608
|
-
|
34609
|
-
}
|
34716
|
+
return new Media(_this4.config, _this4.network, item.media_record);
|
34717
|
+
});
|
34718
|
+
resolve(media);
|
34719
|
+
_context4.next = 14;
|
34720
|
+
break;
|
34610
34721
|
|
34611
|
-
|
34612
|
-
|
34722
|
+
case 11:
|
34723
|
+
_context4.prev = 11;
|
34724
|
+
_context4.t0 = _context4["catch"](3);
|
34725
|
+
reject(_context4.t0);
|
34613
34726
|
|
34614
|
-
|
34615
|
-
|
34616
|
-
|
34727
|
+
case 14:
|
34728
|
+
case "end":
|
34729
|
+
return _context4.stop();
|
34730
|
+
}
|
34617
34731
|
}
|
34618
|
-
}
|
34619
|
-
}
|
34620
|
-
|
34732
|
+
}, _callee4, null, [[3, 11]]);
|
34733
|
+
}));
|
34734
|
+
|
34735
|
+
return function (_x10, _x11, _x12) {
|
34736
|
+
return _ref4.apply(this, arguments);
|
34737
|
+
};
|
34738
|
+
}());
|
34739
|
+
}
|
34740
|
+
/**
|
34741
|
+
* Retrieve temporary URLs for a set of media SIDs.
|
34742
|
+
* @param mediaSids array of the media SIDs to get URLs from.
|
34743
|
+
*/
|
34744
|
+
|
34745
|
+
}, {
|
34746
|
+
key: "mediaSetGetContentUrls",
|
34747
|
+
value: function mediaSetGetContentUrls(mediaSids) {
|
34748
|
+
var _this5 = this;
|
34749
|
+
|
34750
|
+
return new CancellablePromise( /*#__PURE__*/function () {
|
34751
|
+
var _ref5 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(resolve, reject, onCancel) {
|
34752
|
+
var query, request, response, urls;
|
34753
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
34754
|
+
while (1) {
|
34755
|
+
switch (_context5.prev = _context5.next) {
|
34756
|
+
case 0:
|
34757
|
+
query = {
|
34758
|
+
command: "get",
|
34759
|
+
list: mediaSids.map(function (sid) {
|
34760
|
+
return {
|
34761
|
+
media_sid: sid
|
34762
|
+
};
|
34763
|
+
})
|
34764
|
+
};
|
34765
|
+
request = _this5.network.post("".concat(_this5.config.mediaSetUrl), null, query, "application/json");
|
34766
|
+
onCancel(function () {
|
34767
|
+
return request.cancel();
|
34768
|
+
});
|
34769
|
+
_context5.prev = 3;
|
34770
|
+
_context5.next = 6;
|
34771
|
+
return request;
|
34772
|
+
|
34773
|
+
case 6:
|
34774
|
+
response = _context5.sent;
|
34775
|
+
urls = new Map();
|
34776
|
+
response.body.forEach(function (item) {
|
34777
|
+
if (item.code !== 200) {
|
34778
|
+
reject("Failed to obtain detailed information about Media items (failed SID ".concat(item.media_record.sid, ")"));
|
34779
|
+
return;
|
34780
|
+
}
|
34781
|
+
|
34782
|
+
urls.set(item.media_record.sid, item.media_record.links.content_direct_temporary);
|
34783
|
+
});
|
34784
|
+
resolve(urls);
|
34785
|
+
_context5.next = 15;
|
34786
|
+
break;
|
34787
|
+
|
34788
|
+
case 12:
|
34789
|
+
_context5.prev = 12;
|
34790
|
+
_context5.t0 = _context5["catch"](3);
|
34791
|
+
reject(_context5.t0);
|
34792
|
+
|
34793
|
+
case 15:
|
34794
|
+
case "end":
|
34795
|
+
return _context5.stop();
|
34796
|
+
}
|
34797
|
+
}
|
34798
|
+
}, _callee5, null, [[3, 12]]);
|
34799
|
+
}));
|
34800
|
+
|
34801
|
+
return function (_x13, _x14, _x15) {
|
34802
|
+
return _ref5.apply(this, arguments);
|
34803
|
+
};
|
34804
|
+
}());
|
34621
34805
|
}
|
34622
34806
|
}]);
|
34623
34807
|
|
@@ -34626,10 +34810,11 @@ this.Twilio.Conversations = (function (exports) {
|
|
34626
34810
|
|
34627
34811
|
__decorate([declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0)], exports['default'].prototype, "updateToken", null);
|
34628
34812
|
|
34629
|
-
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype",
|
34813
|
+
__decorate([declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", CancellablePromise)], exports['default'].prototype, "get", null);
|
34630
34814
|
|
34631
34815
|
exports['default'] = __decorate([declarativeTypeValidator.validateConstructorTypes(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString, [declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.literal(null)], [declarativeTypeValidator.pureObject, "undefined"]), __metadata("design:paramtypes", [String, String, Object, Object])], exports['default']); // Proper renames should happen in index.ts,
|
34632
34816
|
|
34817
|
+
exports.CancellablePromise = CancellablePromise;
|
34633
34818
|
exports.Client = exports['default'];
|
34634
34819
|
exports.McsClient = exports['default'];
|
34635
34820
|
exports.McsMedia = Media;
|
@@ -34673,7 +34858,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
34673
34858
|
function _createSuper$7(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$7(); return function _createSuperInternal() { var Super = _getPrototypeOf$4(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$4(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$4(this, result); }; }
|
34674
34859
|
|
34675
34860
|
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; } }
|
34676
|
-
var log$
|
34861
|
+
var log$6 = Logger.scope("Participant");
|
34677
34862
|
/**
|
34678
34863
|
* A participant represents a remote client in a conversation.
|
34679
34864
|
*/
|
@@ -34698,7 +34883,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
34698
34883
|
_this.links = links;
|
34699
34884
|
_this.services = services;
|
34700
34885
|
_this.state = {
|
34701
|
-
attributes: parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + sid, log$
|
34886
|
+
attributes: parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + sid, log$6),
|
34702
34887
|
dateCreated: data.dateCreated ? parseTime$1(data.dateCreated) : null,
|
34703
34888
|
dateUpdated: data.dateCreated ? parseTime$1(data.dateUpdated) : null,
|
34704
34889
|
sid: sid,
|
@@ -34887,7 +35072,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
34887
35072
|
key: "_update",
|
34888
35073
|
value: function _update(data) {
|
34889
35074
|
var updateReasons = [];
|
34890
|
-
var updateAttributes = parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + this.state.sid, log$
|
35075
|
+
var updateAttributes = parseAttributes(data.attributes, "Retrieved malformed attributes from the server for participant: " + this.state.sid, log$6);
|
34891
35076
|
|
34892
35077
|
if (data.attributes && !isEqual(this.state.attributes, updateAttributes)) {
|
34893
35078
|
this.state.attributes = updateAttributes;
|
@@ -35056,7 +35241,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
35056
35241
|
function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf$4(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$4(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$4(this, result); }; }
|
35057
35242
|
|
35058
35243
|
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; } }
|
35059
|
-
var log$
|
35244
|
+
var log$5 = Logger.scope("Participants");
|
35060
35245
|
/**
|
35061
35246
|
* @classdesc Represents the collection of participants for the conversation
|
35062
35247
|
* @fires Participants#participantJoined
|
@@ -35132,14 +35317,14 @@ this.Twilio.Conversations = (function (exports) {
|
|
35132
35317
|
mode: "open_existing"
|
35133
35318
|
}).then(function (rosterMap) {
|
35134
35319
|
rosterMap.on("itemAdded", function (args) {
|
35135
|
-
log$
|
35320
|
+
log$5.debug(_this2.conversation.sid + " itemAdded: " + args.item.key);
|
35136
35321
|
|
35137
35322
|
_this2.upsertParticipant(args.item.key, args.item.data).then(function (participant) {
|
35138
35323
|
_this2.emit("participantJoined", participant);
|
35139
35324
|
});
|
35140
35325
|
});
|
35141
35326
|
rosterMap.on("itemRemoved", function (args) {
|
35142
|
-
log$
|
35327
|
+
log$5.debug(_this2.conversation.sid + " itemRemoved: " + args.key);
|
35143
35328
|
var participantSid = args.key;
|
35144
35329
|
|
35145
35330
|
if (!_this2.participants.has(participantSid)) {
|
@@ -35157,7 +35342,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
35157
35342
|
_this2.emit("participantLeft", leftParticipant);
|
35158
35343
|
});
|
35159
35344
|
rosterMap.on("itemUpdated", function (args) {
|
35160
|
-
log$
|
35345
|
+
log$5.debug(_this2.conversation.sid + " itemUpdated: " + args.item.key);
|
35161
35346
|
|
35162
35347
|
_this2.upsertParticipant(args.item.key, args.item.data);
|
35163
35348
|
});
|
@@ -35179,10 +35364,10 @@ this.Twilio.Conversations = (function (exports) {
|
|
35179
35364
|
_this2.rosterEntityPromise = null;
|
35180
35365
|
|
35181
35366
|
if (_this2.services.syncClient.connectionState != "disconnected") {
|
35182
|
-
log$
|
35367
|
+
log$5.error("Failed to get roster object for conversation", _this2.conversation.sid, err);
|
35183
35368
|
}
|
35184
35369
|
|
35185
|
-
log$
|
35370
|
+
log$5.debug("ERROR: Failed to get roster object for conversation", _this2.conversation.sid, err);
|
35186
35371
|
throw err;
|
35187
35372
|
});
|
35188
35373
|
}
|
@@ -35649,117 +35834,140 @@ this.Twilio.Conversations = (function (exports) {
|
|
35649
35834
|
|
35650
35835
|
}, {
|
35651
35836
|
key: "getContentTemporaryUrl",
|
35652
|
-
value: function () {
|
35653
|
-
var
|
35654
|
-
var _this$mcsMedia$getCon, _this$mcsMedia;
|
35837
|
+
value: function getContentTemporaryUrl() {
|
35838
|
+
var _this = this;
|
35655
35839
|
|
35656
|
-
|
35657
|
-
|
35658
|
-
|
35659
|
-
case 0:
|
35660
|
-
_context.next = 2;
|
35661
|
-
return this._fetchMcsMedia();
|
35840
|
+
return new browser.CancellablePromise( /*#__PURE__*/function () {
|
35841
|
+
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(resolve, reject, onCancel) {
|
35842
|
+
var _this$mcsMedia;
|
35662
35843
|
|
35663
|
-
|
35664
|
-
|
35844
|
+
var fetchMediaRequest, contentUrlRequest, mcsMedia;
|
35845
|
+
return _regeneratorRuntime$1.wrap(function _callee$(_context) {
|
35846
|
+
while (1) {
|
35847
|
+
switch (_context.prev = _context.next) {
|
35848
|
+
case 0:
|
35849
|
+
fetchMediaRequest = _this._fetchMcsMedia();
|
35850
|
+
contentUrlRequest = (_this$mcsMedia = _this.mcsMedia) === null || _this$mcsMedia === void 0 ? void 0 : _this$mcsMedia.getContentUrl();
|
35851
|
+
onCancel(function () {
|
35852
|
+
fetchMediaRequest.cancel();
|
35665
35853
|
|
35666
|
-
|
35667
|
-
|
35668
|
-
|
35669
|
-
|
35670
|
-
|
35671
|
-
}, _callee, this);
|
35672
|
-
}));
|
35854
|
+
if (contentUrlRequest) {
|
35855
|
+
contentUrlRequest.cancel();
|
35856
|
+
}
|
35857
|
+
});
|
35858
|
+
_context.prev = 3;
|
35673
35859
|
|
35674
|
-
|
35675
|
-
|
35676
|
-
|
35860
|
+
if (_this.mcsMedia) {
|
35861
|
+
_context.next = 9;
|
35862
|
+
break;
|
35863
|
+
}
|
35677
35864
|
|
35678
|
-
|
35679
|
-
|
35680
|
-
/**
|
35681
|
-
* Returns cached direct content URL for the media.
|
35682
|
-
*
|
35683
|
-
* This URL will expire in several minutes. This function does not refresh the URL and can be used to query it several times
|
35684
|
-
* without causing network traffic.
|
35685
|
-
* If the URL becomes expired, you need to request a new one using getContentTemporaryUrl().
|
35686
|
-
*
|
35687
|
-
* @returns {Promise<String>}
|
35688
|
-
*/
|
35865
|
+
_context.next = 7;
|
35866
|
+
return fetchMediaRequest;
|
35689
35867
|
|
35690
|
-
|
35691
|
-
|
35692
|
-
|
35693
|
-
var _getCachedTemporaryUrl = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2() {
|
35694
|
-
var _this$mcsMedia$getCac, _this$mcsMedia2;
|
35868
|
+
case 7:
|
35869
|
+
mcsMedia = _context.sent;
|
35870
|
+
contentUrlRequest = mcsMedia.getContentUrl();
|
35695
35871
|
|
35696
|
-
|
35697
|
-
|
35698
|
-
switch (_context2.prev = _context2.next) {
|
35699
|
-
case 0:
|
35700
|
-
_context2.next = 2;
|
35701
|
-
return this._fetchMcsMedia();
|
35872
|
+
case 9:
|
35873
|
+
_context.t0 = resolve;
|
35702
35874
|
|
35703
|
-
|
35704
|
-
|
35875
|
+
if (!contentUrlRequest) {
|
35876
|
+
_context.next = 16;
|
35877
|
+
break;
|
35878
|
+
}
|
35705
35879
|
|
35706
|
-
|
35707
|
-
|
35708
|
-
return _context2.stop();
|
35709
|
-
}
|
35710
|
-
}
|
35711
|
-
}, _callee2, this);
|
35712
|
-
}));
|
35880
|
+
_context.next = 13;
|
35881
|
+
return contentUrlRequest;
|
35713
35882
|
|
35714
|
-
|
35715
|
-
|
35716
|
-
|
35883
|
+
case 13:
|
35884
|
+
_context.t1 = _context.sent;
|
35885
|
+
_context.next = 17;
|
35886
|
+
break;
|
35717
35887
|
|
35718
|
-
|
35719
|
-
|
35888
|
+
case 16:
|
35889
|
+
_context.t1 = null;
|
35890
|
+
|
35891
|
+
case 17:
|
35892
|
+
_context.t2 = _context.t1;
|
35893
|
+
(0, _context.t0)(_context.t2);
|
35894
|
+
_context.next = 24;
|
35895
|
+
break;
|
35896
|
+
|
35897
|
+
case 21:
|
35898
|
+
_context.prev = 21;
|
35899
|
+
_context.t3 = _context["catch"](3);
|
35900
|
+
reject(_context.t3);
|
35901
|
+
|
35902
|
+
case 24:
|
35903
|
+
case "end":
|
35904
|
+
return _context.stop();
|
35905
|
+
}
|
35906
|
+
}
|
35907
|
+
}, _callee, null, [[3, 21]]);
|
35908
|
+
}));
|
35909
|
+
|
35910
|
+
return function (_x, _x2, _x3) {
|
35911
|
+
return _ref.apply(this, arguments);
|
35912
|
+
};
|
35913
|
+
}());
|
35914
|
+
}
|
35720
35915
|
}, {
|
35721
35916
|
key: "_fetchMcsMedia",
|
35722
|
-
value: function () {
|
35723
|
-
var
|
35724
|
-
return _regeneratorRuntime$1.wrap(function _callee3$(_context3) {
|
35725
|
-
while (1) {
|
35726
|
-
switch (_context3.prev = _context3.next) {
|
35727
|
-
case 0:
|
35728
|
-
if (this.mcsMedia) {
|
35729
|
-
_context3.next = 8;
|
35730
|
-
break;
|
35731
|
-
}
|
35917
|
+
value: function _fetchMcsMedia() {
|
35918
|
+
var _this2 = this;
|
35732
35919
|
|
35733
|
-
|
35734
|
-
|
35920
|
+
return new browser.CancellablePromise( /*#__PURE__*/function () {
|
35921
|
+
var _ref2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(resolve, reject, onCancel) {
|
35922
|
+
var request;
|
35923
|
+
return _regeneratorRuntime$1.wrap(function _callee2$(_context2) {
|
35924
|
+
while (1) {
|
35925
|
+
switch (_context2.prev = _context2.next) {
|
35926
|
+
case 0:
|
35927
|
+
request = _this2.services.mcsClient.get(_this2.state.sid);
|
35928
|
+
|
35929
|
+
if (!_this2.services.mcsClient) {
|
35930
|
+
_context2.next = 14;
|
35931
|
+
break;
|
35932
|
+
}
|
35933
|
+
|
35934
|
+
onCancel(function () {
|
35935
|
+
return request.cancel();
|
35936
|
+
});
|
35937
|
+
_context2.prev = 3;
|
35938
|
+
_context2.next = 6;
|
35939
|
+
return request;
|
35940
|
+
|
35941
|
+
case 6:
|
35942
|
+
_this2.mcsMedia = _context2.sent;
|
35943
|
+
resolve(_this2.mcsMedia);
|
35944
|
+
_context2.next = 13;
|
35735
35945
|
break;
|
35736
|
-
}
|
35737
35946
|
|
35738
|
-
|
35739
|
-
|
35947
|
+
case 10:
|
35948
|
+
_context2.prev = 10;
|
35949
|
+
_context2.t0 = _context2["catch"](3);
|
35950
|
+
reject(_context2.t0);
|
35740
35951
|
|
35741
|
-
|
35742
|
-
|
35743
|
-
_context3.next = 8;
|
35744
|
-
break;
|
35952
|
+
case 13:
|
35953
|
+
return _context2.abrupt("return");
|
35745
35954
|
|
35746
|
-
|
35747
|
-
|
35955
|
+
case 14:
|
35956
|
+
reject(new Error("Media Content Service is unavailable"));
|
35748
35957
|
|
35749
|
-
|
35750
|
-
|
35751
|
-
|
35958
|
+
case 15:
|
35959
|
+
case "end":
|
35960
|
+
return _context2.stop();
|
35961
|
+
}
|
35752
35962
|
}
|
35753
|
-
}
|
35754
|
-
}
|
35755
|
-
}));
|
35756
|
-
|
35757
|
-
function _fetchMcsMedia() {
|
35758
|
-
return _fetchMcsMedia2.apply(this, arguments);
|
35759
|
-
}
|
35963
|
+
}, _callee2, null, [[3, 10]]);
|
35964
|
+
}));
|
35760
35965
|
|
35761
|
-
|
35762
|
-
|
35966
|
+
return function (_x4, _x5, _x6) {
|
35967
|
+
return _ref2.apply(this, arguments);
|
35968
|
+
};
|
35969
|
+
}());
|
35970
|
+
}
|
35763
35971
|
}]);
|
35764
35972
|
|
35765
35973
|
return Media;
|
@@ -36015,7 +36223,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36015
36223
|
function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf$4(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$4(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$4(this, result); }; }
|
36016
36224
|
|
36017
36225
|
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; } }
|
36018
|
-
var log$
|
36226
|
+
var log$4 = Logger.scope("Message");
|
36019
36227
|
/**
|
36020
36228
|
* A message in a conversation.
|
36021
36229
|
*/
|
@@ -36053,7 +36261,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36053
36261
|
timestamp: data.timestamp ? new Date(data.timestamp) : null,
|
36054
36262
|
dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,
|
36055
36263
|
lastUpdatedBy: (_data$lastUpdatedBy = data.lastUpdatedBy) !== null && _data$lastUpdatedBy !== void 0 ? _data$lastUpdatedBy : null,
|
36056
|
-
attributes: parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(data.sid), log$
|
36264
|
+
attributes: parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(data.sid), log$4),
|
36057
36265
|
type: (_data$type = data.type) !== null && _data$type !== void 0 ? _data$type : "text",
|
36058
36266
|
media: data.type && data.type === "media" && data.media ? new Media(data.media, _this.services) : null,
|
36059
36267
|
medias: data.type && data.type === "media" && data.medias ? data.medias.map(function (m) {
|
@@ -36189,7 +36397,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36189
36397
|
}, {
|
36190
36398
|
key: "attachedMedia",
|
36191
36399
|
get: function get() {
|
36192
|
-
return this.
|
36400
|
+
return this.getMediaByCategories(["media"]);
|
36193
36401
|
}
|
36194
36402
|
/**
|
36195
36403
|
* The server-assigned unique identifier of the authoring participant.
|
@@ -36217,8 +36425,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
36217
36425
|
*/
|
36218
36426
|
|
36219
36427
|
}, {
|
36220
|
-
key: "
|
36221
|
-
value: function
|
36428
|
+
key: "getMediaByCategories",
|
36429
|
+
value: function getMediaByCategories(categories) {
|
36222
36430
|
var _this$state$medias;
|
36223
36431
|
|
36224
36432
|
return ((_this$state$medias = this.state.medias) !== null && _this$state$medias !== void 0 ? _this$state$medias : []).filter(function (m) {
|
@@ -36227,7 +36435,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36227
36435
|
}
|
36228
36436
|
/**
|
36229
36437
|
* Get a media descriptor for an email body attachment of a provided type.
|
36230
|
-
* Allowed body types are returned in the Conversation.limits().
|
36438
|
+
* Allowed body types are returned in the Conversation.limits().emailBodiesAllowedContentTypes array.
|
36231
36439
|
* @param type Type of email body to request, defaults to `text/plain`.
|
36232
36440
|
*/
|
36233
36441
|
|
@@ -36237,13 +36445,13 @@ this.Twilio.Conversations = (function (exports) {
|
|
36237
36445
|
var _this$getMediaByCateg, _this$getMediaByCateg2;
|
36238
36446
|
|
36239
36447
|
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "text/plain";
|
36240
|
-
return (_this$getMediaByCateg = (_this$getMediaByCateg2 = this.
|
36448
|
+
return (_this$getMediaByCateg = (_this$getMediaByCateg2 = this.getMediaByCategories(["body"])) === null || _this$getMediaByCateg2 === void 0 ? void 0 : _this$getMediaByCateg2.filter(function (m) {
|
36241
36449
|
return m.contentType == type;
|
36242
36450
|
}).shift()) !== null && _this$getMediaByCateg !== void 0 ? _this$getMediaByCateg : null;
|
36243
36451
|
}
|
36244
36452
|
/**
|
36245
36453
|
* Get a media descriptor for an email history attachment of a provided type.
|
36246
|
-
* Allowed body types are returned in the Conversation.limits().
|
36454
|
+
* Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedContentTypes array.
|
36247
36455
|
* @param type Type of email history to request, defaults to `text/plain`.
|
36248
36456
|
*/
|
36249
36457
|
|
@@ -36253,7 +36461,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36253
36461
|
var _this$getMediaByCateg3, _this$getMediaByCateg4;
|
36254
36462
|
|
36255
36463
|
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "text/plain";
|
36256
|
-
return (_this$getMediaByCateg3 = (_this$getMediaByCateg4 = this.
|
36464
|
+
return (_this$getMediaByCateg3 = (_this$getMediaByCateg4 = this.getMediaByCategories(["history"])) === null || _this$getMediaByCateg4 === void 0 ? void 0 : _this$getMediaByCateg4.filter(function (m) {
|
36257
36465
|
return m.contentType == type;
|
36258
36466
|
}).shift()) !== null && _this$getMediaByCateg3 !== void 0 ? _this$getMediaByCateg3 : null;
|
36259
36467
|
}
|
@@ -36292,7 +36500,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36292
36500
|
updateReasons.push("dateCreated");
|
36293
36501
|
}
|
36294
36502
|
|
36295
|
-
var updatedAttributes = parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(this.sid), log$
|
36503
|
+
var updatedAttributes = parseAttributes(data.attributes, "Got malformed attributes for the message ".concat(this.sid), log$4);
|
36296
36504
|
|
36297
36505
|
if (!isEqual(this.state.attributes, updatedAttributes)) {
|
36298
36506
|
this.state.attributes = updatedAttributes;
|
@@ -36345,7 +36553,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36345
36553
|
|
36346
36554
|
_context.next = 4;
|
36347
36555
|
return this.conversation.getParticipantBySid(this.state.participantSid).catch(function () {
|
36348
|
-
log$
|
36556
|
+
log$4.debug("Participant with sid \"".concat(_this2.participantSid, "\" not found for message ").concat(_this2.sid));
|
36349
36557
|
return null;
|
36350
36558
|
});
|
36351
36559
|
|
@@ -36360,7 +36568,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36360
36568
|
|
36361
36569
|
_context.next = 8;
|
36362
36570
|
return this.conversation.getParticipantByIdentity(this.state.author).catch(function () {
|
36363
|
-
log$
|
36571
|
+
log$4.debug("Participant with identity \"".concat(_this2.author, "\" not found for message ").concat(_this2.sid));
|
36364
36572
|
return null;
|
36365
36573
|
});
|
36366
36574
|
|
@@ -36571,57 +36779,96 @@ this.Twilio.Conversations = (function (exports) {
|
|
36571
36779
|
return updateAttributes;
|
36572
36780
|
}()
|
36573
36781
|
/**
|
36574
|
-
* Get content URLs for all media attachments in the given set using single operation.
|
36575
|
-
* @param contentSet Set of media attachments to query
|
36782
|
+
* Get content URLs for all media attachments in the given set using a single operation.
|
36783
|
+
* @param contentSet Set of media attachments to query content URLs.
|
36576
36784
|
*/
|
36577
36785
|
|
36578
36786
|
}, {
|
36579
|
-
key: "
|
36580
|
-
value: function () {
|
36581
|
-
var
|
36582
|
-
var _this3 = this;
|
36787
|
+
key: "getTemporaryContentUrlsForMedia",
|
36788
|
+
value: function getTemporaryContentUrlsForMedia(contentSet) {
|
36789
|
+
var _contentSet$map;
|
36583
36790
|
|
36584
|
-
|
36585
|
-
|
36586
|
-
|
36587
|
-
|
36588
|
-
|
36589
|
-
|
36590
|
-
|
36591
|
-
|
36592
|
-
|
36593
|
-
|
36791
|
+
// We ignore existing mcsMedia members of each of the media entries.
|
36792
|
+
// Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.
|
36793
|
+
var sids = (_contentSet$map = contentSet === null || contentSet === void 0 ? void 0 : contentSet.map(function (m) {
|
36794
|
+
return m.sid;
|
36795
|
+
})) !== null && _contentSet$map !== void 0 ? _contentSet$map : [];
|
36796
|
+
return this.getTemporaryContentUrlsForMediaSids(sids);
|
36797
|
+
}
|
36798
|
+
/**
|
36799
|
+
* Get content URLs for all media attachments in the given set of media sids using a single operation.
|
36800
|
+
* @param mediaSids Set of media sids to query for the content URL.
|
36801
|
+
*/
|
36594
36802
|
|
36595
|
-
|
36596
|
-
|
36597
|
-
|
36598
|
-
|
36803
|
+
}, {
|
36804
|
+
key: "getTemporaryContentUrlsForMediaSids",
|
36805
|
+
value: function getTemporaryContentUrlsForMediaSids(mediaSids) {
|
36806
|
+
var _this3 = this;
|
36599
36807
|
|
36600
|
-
|
36601
|
-
|
36808
|
+
return new browser.CancellablePromise( /*#__PURE__*/function () {
|
36809
|
+
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(resolve, reject, onCancel) {
|
36810
|
+
var mediaGetRequest, urls;
|
36811
|
+
return _regeneratorRuntime$1.wrap(function _callee6$(_context6) {
|
36812
|
+
while (1) {
|
36813
|
+
switch (_context6.prev = _context6.next) {
|
36814
|
+
case 0:
|
36815
|
+
mediaGetRequest = _this3.services.mcsClient.mediaSetGetContentUrls(mediaSids !== null && mediaSids !== void 0 ? mediaSids : []);
|
36602
36816
|
|
36603
|
-
|
36604
|
-
|
36605
|
-
|
36606
|
-
|
36817
|
+
if (!(!_this3.services.mcsClient || !mediaSids)) {
|
36818
|
+
_context6.next = 4;
|
36819
|
+
break;
|
36820
|
+
}
|
36607
36821
|
|
36608
|
-
|
36609
|
-
|
36822
|
+
reject(new Error("Media Content Service is unavailable"));
|
36823
|
+
return _context6.abrupt("return");
|
36610
36824
|
|
36611
|
-
|
36612
|
-
|
36613
|
-
|
36825
|
+
case 4:
|
36826
|
+
onCancel(function () {
|
36827
|
+
mediaGetRequest.cancel();
|
36828
|
+
});
|
36829
|
+
_context6.prev = 5;
|
36830
|
+
_context6.next = 8;
|
36831
|
+
return mediaGetRequest;
|
36832
|
+
|
36833
|
+
case 8:
|
36834
|
+
urls = _context6.sent;
|
36835
|
+
resolve(urls);
|
36836
|
+
_context6.next = 15;
|
36837
|
+
break;
|
36838
|
+
|
36839
|
+
case 12:
|
36840
|
+
_context6.prev = 12;
|
36841
|
+
_context6.t0 = _context6["catch"](5);
|
36842
|
+
reject(_context6.t0);
|
36843
|
+
|
36844
|
+
case 15:
|
36845
|
+
case "end":
|
36846
|
+
return _context6.stop();
|
36847
|
+
}
|
36614
36848
|
}
|
36615
|
-
}
|
36616
|
-
}
|
36617
|
-
}));
|
36849
|
+
}, _callee6, null, [[5, 12]]);
|
36850
|
+
}));
|
36618
36851
|
|
36619
|
-
|
36620
|
-
|
36621
|
-
|
36852
|
+
return function (_x3, _x4, _x5) {
|
36853
|
+
return _ref.apply(this, arguments);
|
36854
|
+
};
|
36855
|
+
}());
|
36856
|
+
}
|
36857
|
+
/**
|
36858
|
+
* Get content URLs for all media attached to the message.
|
36859
|
+
*/
|
36622
36860
|
|
36623
|
-
|
36624
|
-
|
36861
|
+
}, {
|
36862
|
+
key: "getTemporaryContentUrlsForAttachedMedia",
|
36863
|
+
value: function getTemporaryContentUrlsForAttachedMedia() {
|
36864
|
+
var _media$map;
|
36865
|
+
|
36866
|
+
var media = this.attachedMedia;
|
36867
|
+
var sids = (_media$map = media === null || media === void 0 ? void 0 : media.map(function (m) {
|
36868
|
+
return m.sid;
|
36869
|
+
})) !== null && _media$map !== void 0 ? _media$map : [];
|
36870
|
+
return this.getTemporaryContentUrlsForMediaSids(sids);
|
36871
|
+
}
|
36625
36872
|
}, {
|
36626
36873
|
key: "_getDetailedDeliveryReceiptsPaginator",
|
36627
36874
|
value: function () {
|
@@ -36657,7 +36904,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36657
36904
|
}, _callee7, this);
|
36658
36905
|
}));
|
36659
36906
|
|
36660
|
-
function _getDetailedDeliveryReceiptsPaginator(
|
36907
|
+
function _getDetailedDeliveryReceiptsPaginator(_x6) {
|
36661
36908
|
return _getDetailedDeliveryReceiptsPaginator2.apply(this, arguments);
|
36662
36909
|
}
|
36663
36910
|
|
@@ -36682,7 +36929,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36682
36929
|
return [value instanceof Array && value.length > 0 && value.reduce(function (a, c) {
|
36683
36930
|
return a && c instanceof Media;
|
36684
36931
|
}, true), "a non-empty array of Media"];
|
36685
|
-
})), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [Array]), __metadata$1("design:returntype",
|
36932
|
+
})), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [Array]), __metadata$1("design:returntype", browser.CancellablePromise)], Message.prototype, "getTemporaryContentUrlsForMedia", null);
|
36686
36933
|
|
36687
36934
|
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; } } }; }
|
36688
36935
|
|
@@ -36693,7 +36940,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36693
36940
|
function _createSuper$4(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$4(); return function _createSuperInternal() { var Super = _getPrototypeOf$4(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$4(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$4(this, result); }; }
|
36694
36941
|
|
36695
36942
|
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; } }
|
36696
|
-
var log$
|
36943
|
+
var log$3 = Logger.scope("Messages");
|
36697
36944
|
/**
|
36698
36945
|
* Represents the collection of messages in a conversation
|
36699
36946
|
*/
|
@@ -36752,7 +36999,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36752
36999
|
case 6:
|
36753
37000
|
list = _context.sent;
|
36754
37001
|
list.on("itemAdded", function (args) {
|
36755
|
-
log$
|
37002
|
+
log$3.debug("".concat(_this2.conversation.sid, " itemAdded: ").concat(args.item.index));
|
36756
37003
|
var links = {
|
36757
37004
|
self: "".concat(_this2.conversation.links.messages, "/").concat(args.item.data.sid),
|
36758
37005
|
conversation: _this2.conversation.links.self,
|
@@ -36761,7 +37008,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36761
37008
|
var message = new Message(args.item.index, args.item.data, _this2.conversation, links, _this2.configuration, _this2.services);
|
36762
37009
|
|
36763
37010
|
if (_this2.messagesByIndex.has(message.index)) {
|
36764
|
-
log$
|
37011
|
+
log$3.debug("Message arrived, but is already known and ignored", _this2.conversation.sid, message.index);
|
36765
37012
|
return;
|
36766
37013
|
}
|
36767
37014
|
|
@@ -36774,7 +37021,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36774
37021
|
_this2.emit("messageAdded", message);
|
36775
37022
|
});
|
36776
37023
|
list.on("itemRemoved", function (args) {
|
36777
|
-
log$
|
37024
|
+
log$3.debug("#{this.conversation.sid} itemRemoved: ".concat(args.index));
|
36778
37025
|
var index = args.index;
|
36779
37026
|
|
36780
37027
|
if (_this2.messagesByIndex.has(index)) {
|
@@ -36792,7 +37039,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36792
37039
|
}
|
36793
37040
|
});
|
36794
37041
|
list.on("itemUpdated", function (args) {
|
36795
|
-
log$
|
37042
|
+
log$3.debug("".concat(_this2.conversation.sid, " itemUpdated: ").concat(args.item.index));
|
36796
37043
|
|
36797
37044
|
var message = _this2.messagesByIndex.get(args.item.index);
|
36798
37045
|
|
@@ -36808,10 +37055,10 @@ this.Twilio.Conversations = (function (exports) {
|
|
36808
37055
|
this.messagesListPromise = null;
|
36809
37056
|
|
36810
37057
|
if (this.services.syncClient.connectionState !== "disconnected") {
|
36811
|
-
log$
|
37058
|
+
log$3.error("Failed to get messages object for conversation", this.conversation.sid, _context.t0);
|
36812
37059
|
}
|
36813
37060
|
|
36814
|
-
log$
|
37061
|
+
log$3.debug("ERROR: Failed to get messages object for conversation", this.conversation.sid, _context.t0);
|
36815
37062
|
throw _context.t0;
|
36816
37063
|
|
36817
37064
|
case 19:
|
@@ -36868,114 +37115,126 @@ this.Twilio.Conversations = (function (exports) {
|
|
36868
37115
|
return unsubscribe;
|
36869
37116
|
}()
|
36870
37117
|
/**
|
36871
|
-
* Send
|
37118
|
+
* Send a message to the conversation. The message could include text and multiple media attachments.
|
36872
37119
|
* @param message Message to post
|
36873
|
-
* @returns Returns a promise which can fail
|
36874
37120
|
*/
|
36875
37121
|
|
36876
37122
|
}, {
|
36877
37123
|
key: "sendV2",
|
36878
|
-
value: function () {
|
36879
|
-
var
|
36880
|
-
var _message$emailOptions;
|
37124
|
+
value: function sendV2(message) {
|
37125
|
+
var _this3 = this;
|
36881
37126
|
|
36882
|
-
|
37127
|
+
log$3.debug("Sending message V2", message.mediaContent, message.attributes, message.emailOptions);
|
37128
|
+
return new browser.CancellablePromise( /*#__PURE__*/function () {
|
37129
|
+
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(resolve, reject, onCancel) {
|
37130
|
+
var _message$emailOptions;
|
36883
37131
|
|
36884
|
-
|
36885
|
-
while (1) {
|
36886
|
-
switch (_context3.prev = _context3.next) {
|
36887
|
-
case 0:
|
36888
|
-
log$4.debug("Sending message V2", message.mediaContent, message.attributes, message.emailOptions);
|
36889
|
-
media = [];
|
36890
|
-
_iterator = _createForOfIteratorHelper$2(message.mediaContent);
|
36891
|
-
_context3.prev = 3;
|
37132
|
+
var media, requests, _iterator, _step, _step$value, category, mediaContent, _mediaContent$content, _mediaContent$media, request, messagesPostRequest;
|
36892
37133
|
|
36893
|
-
|
37134
|
+
return _regeneratorRuntime$1.wrap(function _callee3$(_context3) {
|
37135
|
+
while (1) {
|
37136
|
+
switch (_context3.prev = _context3.next) {
|
37137
|
+
case 0:
|
37138
|
+
media = [];
|
37139
|
+
requests = [];
|
37140
|
+
onCancel(function () {
|
37141
|
+
requests.forEach(function (request) {
|
37142
|
+
return request.cancel();
|
37143
|
+
});
|
37144
|
+
});
|
37145
|
+
_iterator = _createForOfIteratorHelper$2(message.mediaContent);
|
37146
|
+
_context3.prev = 4;
|
36894
37147
|
|
36895
|
-
|
36896
|
-
if ((_step = _iterator.n()).done) {
|
36897
|
-
_context3.next = 22;
|
36898
|
-
break;
|
36899
|
-
}
|
37148
|
+
_iterator.s();
|
36900
37149
|
|
36901
|
-
|
36902
|
-
|
36903
|
-
|
37150
|
+
case 6:
|
37151
|
+
if ((_step = _iterator.n()).done) {
|
37152
|
+
_context3.next = 25;
|
37153
|
+
break;
|
37154
|
+
}
|
36904
37155
|
|
36905
|
-
|
37156
|
+
_step$value = _slicedToArray$1(_step.value, 2), category = _step$value[0], mediaContent = _step$value[1];
|
37157
|
+
_context3.prev = 8;
|
37158
|
+
log$3.debug("Adding media to a message as ".concat(mediaContent instanceof FormData ? "FormData" : "SendMediaOptions"), mediaContent);
|
37159
|
+
request = mediaContent instanceof FormData ? _this3.services.mcsClient.postFormData(mediaContent, category) : _this3.services.mcsClient.post((_mediaContent$content = mediaContent.contentType) !== null && _mediaContent$content !== void 0 ? _mediaContent$content : "", (_mediaContent$media = mediaContent.media) !== null && _mediaContent$media !== void 0 ? _mediaContent$media : "", category, mediaContent.filename);
|
37160
|
+
requests.push(request);
|
37161
|
+
_context3.t0 = media;
|
36906
37162
|
_context3.next = 15;
|
36907
|
-
|
36908
|
-
}
|
36909
|
-
|
36910
|
-
_context3.next = 12;
|
36911
|
-
return this.services.mcsClient.postFormData(mediaContent, category);
|
37163
|
+
return request;
|
36912
37164
|
|
36913
|
-
|
36914
|
-
|
36915
|
-
_context3.next = 18;
|
36916
|
-
break;
|
37165
|
+
case 15:
|
37166
|
+
_context3.t1 = _context3.sent;
|
36917
37167
|
|
36918
|
-
|
36919
|
-
_context3.next = 17;
|
36920
|
-
return this.services.mcsClient.post((_mediaContent$content = mediaContent.contentType) !== null && _mediaContent$content !== void 0 ? _mediaContent$content : "", (_mediaContent$media = mediaContent.media) !== null && _mediaContent$media !== void 0 ? _mediaContent$media : "", category, mediaContent.filename);
|
37168
|
+
_context3.t0.push.call(_context3.t0, _context3.t1);
|
36921
37169
|
|
36922
|
-
|
36923
|
-
|
37170
|
+
_context3.next = 23;
|
37171
|
+
break;
|
36924
37172
|
|
36925
|
-
|
36926
|
-
|
37173
|
+
case 19:
|
37174
|
+
_context3.prev = 19;
|
37175
|
+
_context3.t2 = _context3["catch"](8);
|
37176
|
+
reject(_context3.t2);
|
37177
|
+
return _context3.abrupt("return");
|
36927
37178
|
|
36928
|
-
|
37179
|
+
case 23:
|
37180
|
+
_context3.next = 6;
|
37181
|
+
break;
|
36929
37182
|
|
36930
|
-
|
36931
|
-
|
36932
|
-
|
37183
|
+
case 25:
|
37184
|
+
_context3.next = 30;
|
37185
|
+
break;
|
36933
37186
|
|
36934
|
-
|
36935
|
-
|
36936
|
-
|
37187
|
+
case 27:
|
37188
|
+
_context3.prev = 27;
|
37189
|
+
_context3.t3 = _context3["catch"](4);
|
36937
37190
|
|
36938
|
-
|
36939
|
-
_context3.prev = 24;
|
36940
|
-
_context3.t3 = _context3["catch"](3);
|
37191
|
+
_iterator.e(_context3.t3);
|
36941
37192
|
|
36942
|
-
|
37193
|
+
case 30:
|
37194
|
+
_context3.prev = 30;
|
36943
37195
|
|
36944
|
-
|
36945
|
-
_context3.prev = 27;
|
37196
|
+
_iterator.f();
|
36946
37197
|
|
36947
|
-
|
37198
|
+
return _context3.finish(30);
|
36948
37199
|
|
36949
|
-
|
37200
|
+
case 33:
|
37201
|
+
messagesPostRequest = _this3.services.commandExecutor.mutateResource("post", _this3.conversation.links.messages, {
|
37202
|
+
body: message.text,
|
37203
|
+
subject: (_message$emailOptions = message.emailOptions) === null || _message$emailOptions === void 0 ? void 0 : _message$emailOptions.subject,
|
37204
|
+
media_sids: media.map(function (m) {
|
37205
|
+
return m.sid;
|
37206
|
+
}),
|
37207
|
+
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined
|
37208
|
+
});
|
37209
|
+
_context3.prev = 34;
|
37210
|
+
_context3.t4 = resolve;
|
37211
|
+
_context3.next = 38;
|
37212
|
+
return messagesPostRequest;
|
36950
37213
|
|
36951
|
-
|
36952
|
-
|
36953
|
-
|
36954
|
-
|
36955
|
-
|
36956
|
-
media_sids: media.map(function (m) {
|
36957
|
-
return m.sid;
|
36958
|
-
}),
|
36959
|
-
attributes: typeof message.attributes !== "undefined" ? JSON.stringify(message.attributes) : undefined
|
36960
|
-
});
|
37214
|
+
case 38:
|
37215
|
+
_context3.t5 = _context3.sent;
|
37216
|
+
(0, _context3.t4)(_context3.t5);
|
37217
|
+
_context3.next = 45;
|
37218
|
+
break;
|
36961
37219
|
|
36962
|
-
|
36963
|
-
|
37220
|
+
case 42:
|
37221
|
+
_context3.prev = 42;
|
37222
|
+
_context3.t6 = _context3["catch"](34);
|
37223
|
+
reject(_context3.t6);
|
36964
37224
|
|
36965
|
-
|
36966
|
-
|
36967
|
-
|
37225
|
+
case 45:
|
37226
|
+
case "end":
|
37227
|
+
return _context3.stop();
|
37228
|
+
}
|
36968
37229
|
}
|
36969
|
-
}
|
36970
|
-
}
|
36971
|
-
}));
|
36972
|
-
|
36973
|
-
function sendV2(_x2) {
|
36974
|
-
return _sendV.apply(this, arguments);
|
36975
|
-
}
|
37230
|
+
}, _callee3, null, [[4, 27, 30, 33], [8, 19], [34, 42]]);
|
37231
|
+
}));
|
36976
37232
|
|
36977
|
-
|
36978
|
-
|
37233
|
+
return function (_x2, _x3, _x4) {
|
37234
|
+
return _ref.apply(this, arguments);
|
37235
|
+
};
|
37236
|
+
}());
|
37237
|
+
}
|
36979
37238
|
/**
|
36980
37239
|
* Send Message to the conversation
|
36981
37240
|
* @param message Message to post
|
@@ -36997,18 +37256,14 @@ this.Twilio.Conversations = (function (exports) {
|
|
36997
37256
|
case 0:
|
36998
37257
|
attributes = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
36999
37258
|
emailOptions = _args4.length > 2 ? _args4[2] : undefined;
|
37000
|
-
log$
|
37001
|
-
_context4.
|
37002
|
-
return this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
|
37259
|
+
log$3.debug("Sending text message", message, attributes, emailOptions);
|
37260
|
+
return _context4.abrupt("return", this.services.commandExecutor.mutateResource("post", this.conversation.links.messages, {
|
37003
37261
|
body: message !== null && message !== void 0 ? message : "",
|
37004
37262
|
attributes: typeof attributes !== "undefined" ? JSON.stringify(attributes) : undefined,
|
37005
37263
|
subject: emailOptions === null || emailOptions === void 0 ? void 0 : emailOptions.subject
|
37006
|
-
});
|
37007
|
-
|
37008
|
-
case 5:
|
37009
|
-
return _context4.abrupt("return", _context4.sent);
|
37264
|
+
}));
|
37010
37265
|
|
37011
|
-
case
|
37266
|
+
case 4:
|
37012
37267
|
case "end":
|
37013
37268
|
return _context4.stop();
|
37014
37269
|
}
|
@@ -37016,7 +37271,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37016
37271
|
}, _callee4, this);
|
37017
37272
|
}));
|
37018
37273
|
|
37019
|
-
function send(
|
37274
|
+
function send(_x5) {
|
37020
37275
|
return _send.apply(this, arguments);
|
37021
37276
|
}
|
37022
37277
|
|
@@ -37046,8 +37301,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
37046
37301
|
case 0:
|
37047
37302
|
attributes = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
37048
37303
|
emailOptions = _args5.length > 2 ? _args5[2] : undefined;
|
37049
|
-
log$
|
37050
|
-
log$
|
37304
|
+
log$3.debug("Sending media message", mediaContent, attributes, emailOptions);
|
37305
|
+
log$3.debug("Sending media message as ".concat(mediaContent instanceof FormData ? "FormData" : "SendMediaOptions"), mediaContent, attributes);
|
37051
37306
|
|
37052
37307
|
if (!(mediaContent instanceof FormData)) {
|
37053
37308
|
_context5.next = 10;
|
@@ -37088,7 +37343,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37088
37343
|
}, _callee5, this);
|
37089
37344
|
}));
|
37090
37345
|
|
37091
|
-
function sendMedia(
|
37346
|
+
function sendMedia(_x6) {
|
37092
37347
|
return _sendMedia.apply(this, arguments);
|
37093
37348
|
}
|
37094
37349
|
|
@@ -37123,7 +37378,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37123
37378
|
}, _callee6, this);
|
37124
37379
|
}));
|
37125
37380
|
|
37126
|
-
function getMessages(
|
37381
|
+
function getMessages(_x7, _x8) {
|
37127
37382
|
return _getMessages2.apply(this, arguments);
|
37128
37383
|
}
|
37129
37384
|
|
@@ -37132,7 +37387,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37132
37387
|
}, {
|
37133
37388
|
key: "_wrapPaginator",
|
37134
37389
|
value: function _wrapPaginator(order, page, op) {
|
37135
|
-
var
|
37390
|
+
var _this4 = this;
|
37136
37391
|
|
37137
37392
|
// Due to an inconsistency between Sync and Chat conventions, next and
|
37138
37393
|
// previous pages should be swapped.
|
@@ -37140,13 +37395,13 @@ this.Twilio.Conversations = (function (exports) {
|
|
37140
37395
|
|
37141
37396
|
var nextPage = function nextPage() {
|
37142
37397
|
return page.nextPage().then(function (page) {
|
37143
|
-
return
|
37398
|
+
return _this4._wrapPaginator(order, page, op);
|
37144
37399
|
});
|
37145
37400
|
};
|
37146
37401
|
|
37147
37402
|
var previousPage = function previousPage() {
|
37148
37403
|
return page.prevPage().then(function (page) {
|
37149
|
-
return
|
37404
|
+
return _this4._wrapPaginator(order, page, op);
|
37150
37405
|
});
|
37151
37406
|
};
|
37152
37407
|
|
@@ -37165,7 +37420,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37165
37420
|
}, {
|
37166
37421
|
key: "_upsertMessage",
|
37167
37422
|
value: function _upsertMessage(index, value) {
|
37168
|
-
var
|
37423
|
+
var _this5 = this;
|
37169
37424
|
|
37170
37425
|
var cachedMessage = this.messagesByIndex.get(index);
|
37171
37426
|
|
@@ -37181,7 +37436,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37181
37436
|
var message = new Message(index, value, this.conversation, links, this.configuration, this.services);
|
37182
37437
|
this.messagesByIndex.set(message.index, message);
|
37183
37438
|
message.on("updated", function (args) {
|
37184
|
-
return
|
37439
|
+
return _this5.emit("messageUpdated", args);
|
37185
37440
|
});
|
37186
37441
|
return message;
|
37187
37442
|
}
|
@@ -37198,7 +37453,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37198
37453
|
key: "_getMessages",
|
37199
37454
|
value: function () {
|
37200
37455
|
var _getMessages3 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee7() {
|
37201
|
-
var
|
37456
|
+
var _this6 = this;
|
37202
37457
|
|
37203
37458
|
var pageSize,
|
37204
37459
|
anchor,
|
@@ -37234,7 +37489,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37234
37489
|
_context7.next = 12;
|
37235
37490
|
return this._wrapPaginator(order, page, function (items) {
|
37236
37491
|
return Promise.all(items.map(function (item) {
|
37237
|
-
return
|
37492
|
+
return _this6._upsertMessage(item.index, item.data);
|
37238
37493
|
}));
|
37239
37494
|
});
|
37240
37495
|
|
@@ -37287,34 +37542,48 @@ this.Twilio.Conversations = (function (exports) {
|
|
37287
37542
|
|
37288
37543
|
_createClass$3(UnsentMessage, [{
|
37289
37544
|
key: "send",
|
37290
|
-
value: function () {
|
37291
|
-
var
|
37292
|
-
var response;
|
37293
|
-
return _regeneratorRuntime$1.wrap(function _callee$(_context) {
|
37294
|
-
while (1) {
|
37295
|
-
switch (_context.prev = _context.next) {
|
37296
|
-
case 0:
|
37297
|
-
_context.next = 2;
|
37298
|
-
return this.messagesEntity.sendV2(this);
|
37545
|
+
value: function send() {
|
37546
|
+
var _this = this;
|
37299
37547
|
|
37300
|
-
|
37301
|
-
|
37302
|
-
|
37548
|
+
return new browser.CancellablePromise( /*#__PURE__*/function () {
|
37549
|
+
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(resolve, reject, onCancel) {
|
37550
|
+
var request, response;
|
37551
|
+
return _regeneratorRuntime$1.wrap(function _callee$(_context) {
|
37552
|
+
while (1) {
|
37553
|
+
switch (_context.prev = _context.next) {
|
37554
|
+
case 0:
|
37555
|
+
request = _this.messagesEntity.sendV2(_this);
|
37556
|
+
onCancel(function () {
|
37557
|
+
return request.cancel();
|
37558
|
+
});
|
37559
|
+
_context.prev = 2;
|
37560
|
+
_context.next = 5;
|
37561
|
+
return request;
|
37303
37562
|
|
37304
|
-
|
37305
|
-
|
37306
|
-
|
37307
|
-
|
37308
|
-
|
37309
|
-
}, _callee, this);
|
37310
|
-
}));
|
37563
|
+
case 5:
|
37564
|
+
response = _context.sent;
|
37565
|
+
resolve(parseToNumber(response.index));
|
37566
|
+
_context.next = 12;
|
37567
|
+
break;
|
37311
37568
|
|
37312
|
-
|
37313
|
-
|
37314
|
-
|
37569
|
+
case 9:
|
37570
|
+
_context.prev = 9;
|
37571
|
+
_context.t0 = _context["catch"](2);
|
37572
|
+
reject(_context.t0);
|
37315
37573
|
|
37316
|
-
|
37317
|
-
|
37574
|
+
case 12:
|
37575
|
+
case "end":
|
37576
|
+
return _context.stop();
|
37577
|
+
}
|
37578
|
+
}
|
37579
|
+
}, _callee, null, [[2, 9]]);
|
37580
|
+
}));
|
37581
|
+
|
37582
|
+
return function (_x, _x2, _x3) {
|
37583
|
+
return _ref.apply(this, arguments);
|
37584
|
+
};
|
37585
|
+
}());
|
37586
|
+
}
|
37318
37587
|
}]);
|
37319
37588
|
|
37320
37589
|
return UnsentMessage;
|
@@ -37383,27 +37652,27 @@ this.Twilio.Conversations = (function (exports) {
|
|
37383
37652
|
return this;
|
37384
37653
|
}
|
37385
37654
|
/**
|
37386
|
-
* Set email body with given
|
37387
|
-
* @param
|
37388
|
-
* @param body Body payload in selected format.
|
37655
|
+
* Set the email body with a given content type.
|
37656
|
+
* @param contentType Format of the body to set (text/plain or text/html).
|
37657
|
+
* @param body Body payload in the selected format.
|
37389
37658
|
*/
|
37390
37659
|
|
37391
37660
|
}, {
|
37392
37661
|
key: "setEmailBody",
|
37393
|
-
value: function setEmailBody(
|
37394
|
-
this.emailBodies.set(
|
37662
|
+
value: function setEmailBody(contentType, body) {
|
37663
|
+
this.emailBodies.set(contentType, body);
|
37395
37664
|
return this;
|
37396
37665
|
}
|
37397
37666
|
/**
|
37398
|
-
* Set email history with given
|
37399
|
-
* @param
|
37400
|
-
* @param history History payload in selected format.
|
37667
|
+
* Set the email history with a given content type.
|
37668
|
+
* @param contentType Format of the history to set (text/plain or text/html).
|
37669
|
+
* @param history History payload in the selected format.
|
37401
37670
|
*/
|
37402
37671
|
|
37403
37672
|
}, {
|
37404
37673
|
key: "setEmailHistory",
|
37405
|
-
value: function setEmailHistory(
|
37406
|
-
this.emailHistories.set(
|
37674
|
+
value: function setEmailHistory(contentType, history) {
|
37675
|
+
this.emailHistories.set(contentType, history);
|
37407
37676
|
return this;
|
37408
37677
|
}
|
37409
37678
|
/**
|
@@ -37439,22 +37708,22 @@ this.Twilio.Conversations = (function (exports) {
|
|
37439
37708
|
var _this = this;
|
37440
37709
|
|
37441
37710
|
this.emailBodies.forEach(function (_, key) {
|
37442
|
-
if (!_this.limits.
|
37443
|
-
throw new Error("Unsupported email body
|
37711
|
+
if (!_this.limits.emailBodiesAllowedContentTypes.includes(key)) {
|
37712
|
+
throw new Error("Unsupported email body content type ".concat(key));
|
37444
37713
|
}
|
37445
37714
|
});
|
37446
37715
|
this.emailHistories.forEach(function (_, key) {
|
37447
|
-
if (!_this.limits.
|
37448
|
-
throw new Error("Unsupported email history
|
37716
|
+
if (!_this.limits.emailHistoriesAllowedContentTypes.includes(key)) {
|
37717
|
+
throw new Error("Unsupported email history content type ".concat(key));
|
37449
37718
|
}
|
37450
37719
|
});
|
37451
37720
|
|
37452
|
-
if (this.emailBodies.size > this.limits.
|
37453
|
-
throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size, " > ").concat(this.limits.
|
37721
|
+
if (this.emailBodies.size > this.limits.emailBodiesAllowedContentTypes.length) {
|
37722
|
+
throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size, " > ").concat(this.limits.emailBodiesAllowedContentTypes.length, ")"));
|
37454
37723
|
}
|
37455
37724
|
|
37456
|
-
if (this.emailHistories.size > this.limits.
|
37457
|
-
throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size, " > ").concat(this.limits.
|
37725
|
+
if (this.emailHistories.size > this.limits.emailHistoriesAllowedContentTypes.length) {
|
37726
|
+
throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size, " > ").concat(this.limits.emailHistoriesAllowedContentTypes.length, ")"));
|
37458
37727
|
}
|
37459
37728
|
|
37460
37729
|
if (this.message.mediaContent.length > this.limits.mediaAttachmentsCountLimit) {
|
@@ -37471,6 +37740,15 @@ this.Twilio.Conversations = (function (exports) {
|
|
37471
37740
|
});
|
37472
37741
|
return this.message;
|
37473
37742
|
}
|
37743
|
+
/**
|
37744
|
+
* Prepares a message and sends it to the conversation.
|
37745
|
+
*/
|
37746
|
+
|
37747
|
+
}, {
|
37748
|
+
key: "buildAndSend",
|
37749
|
+
value: function buildAndSend() {
|
37750
|
+
return this.build().send();
|
37751
|
+
}
|
37474
37752
|
}, {
|
37475
37753
|
key: "getPayloadContentType",
|
37476
37754
|
value: function getPayloadContentType(payload) {
|
@@ -37494,7 +37772,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37494
37772
|
function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf$4(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$4(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$4(this, result); }; }
|
37495
37773
|
|
37496
37774
|
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; } }
|
37497
|
-
var log$
|
37775
|
+
var log$2 = Logger.scope("Conversation");
|
37498
37776
|
var fieldMappings = {
|
37499
37777
|
lastMessage: "lastMessage",
|
37500
37778
|
attributes: "attributes",
|
@@ -37774,10 +38052,10 @@ this.Twilio.Conversations = (function (exports) {
|
|
37774
38052
|
_this2.entityPromise = null;
|
37775
38053
|
|
37776
38054
|
if (_this2.services.syncClient.connectionState != "disconnected") {
|
37777
|
-
log$
|
38055
|
+
log$2.error("Failed to get conversation object", err);
|
37778
38056
|
}
|
37779
38057
|
|
37780
|
-
log$
|
38058
|
+
log$2.debug("ERROR: Failed to get conversation object", err);
|
37781
38059
|
throw err;
|
37782
38060
|
});
|
37783
38061
|
}
|
@@ -37803,7 +38081,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37803
38081
|
return this._subscribe();
|
37804
38082
|
|
37805
38083
|
case 3:
|
37806
|
-
log$
|
38084
|
+
log$2.trace("_subscribeStreams, this.entity.data=", (_this$entity = this.entity) === null || _this$entity === void 0 ? void 0 : _this$entity.data);
|
37807
38085
|
messagesObjectName = (_this$entity2 = this.entity) === null || _this$entity2 === void 0 ? void 0 : _this$entity2.data.messages;
|
37808
38086
|
rosterObjectName = (_this$entity3 = this.entity) === null || _this$entity3 === void 0 ? void 0 : _this$entity3.data.roster;
|
37809
38087
|
_context.next = 8;
|
@@ -37818,10 +38096,10 @@ this.Twilio.Conversations = (function (exports) {
|
|
37818
38096
|
_context.t0 = _context["catch"](0);
|
37819
38097
|
|
37820
38098
|
if (this.services.syncClient.connectionState !== "disconnected") {
|
37821
|
-
log$
|
38099
|
+
log$2.error("Failed to subscribe on conversation objects", this.sid, _context.t0);
|
37822
38100
|
}
|
37823
38101
|
|
37824
|
-
log$
|
38102
|
+
log$2.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context.t0);
|
37825
38103
|
throw _context.t0;
|
37826
38104
|
|
37827
38105
|
case 15:
|
@@ -37900,7 +38178,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37900
38178
|
|
37901
38179
|
if (status === "joined") {
|
37902
38180
|
this._subscribeStreams().catch(function (err) {
|
37903
|
-
log$
|
38181
|
+
log$2.debug("ERROR while setting conversation status " + status, err);
|
37904
38182
|
|
37905
38183
|
if (_this3.services.syncClient.connectionState !== "disconnected") {
|
37906
38184
|
throw err;
|
@@ -37908,7 +38186,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37908
38186
|
});
|
37909
38187
|
} else if (this.entityPromise) {
|
37910
38188
|
this._unsubscribe().catch(function (err) {
|
37911
|
-
log$
|
38189
|
+
log$2.debug("ERROR while setting conversation status " + status, err);
|
37912
38190
|
|
37913
38191
|
if (_this3.services.syncClient.connectionState !== "disconnected") {
|
37914
38192
|
throw err;
|
@@ -37936,7 +38214,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
37936
38214
|
function _update(update) {
|
37937
38215
|
var _update$lastMessage, _update$lastMessage2, _this$channelState$la2, _this$channelState$la3, _this$channelState$lo;
|
37938
38216
|
|
37939
|
-
log$
|
38217
|
+
log$2.trace("_update", update);
|
37940
38218
|
Conversation.preprocessUpdate(update, this.sid);
|
37941
38219
|
var updateReasons = new Set();
|
37942
38220
|
|
@@ -39035,7 +39313,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
39035
39313
|
JSON.stringify(update.attributes);
|
39036
39314
|
}
|
39037
39315
|
} catch (e) {
|
39038
|
-
log$
|
39316
|
+
log$2.warn("Retrieved malformed attributes from the server for conversation: " + conversationSid);
|
39039
39317
|
update.attributes = {};
|
39040
39318
|
}
|
39041
39319
|
|
@@ -39044,7 +39322,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
39044
39322
|
update.dateCreated = new Date(update.dateCreated);
|
39045
39323
|
}
|
39046
39324
|
} catch (e) {
|
39047
|
-
log$
|
39325
|
+
log$2.warn("Retrieved malformed dateCreated from the server for conversation: " + conversationSid);
|
39048
39326
|
delete update.dateCreated;
|
39049
39327
|
}
|
39050
39328
|
|
@@ -39053,7 +39331,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
39053
39331
|
update.dateUpdated = new Date(update.dateUpdated);
|
39054
39332
|
}
|
39055
39333
|
} catch (e) {
|
39056
|
-
log$
|
39334
|
+
log$2.warn("Retrieved malformed dateUpdated from the server for conversation: " + conversationSid);
|
39057
39335
|
delete update.dateUpdated;
|
39058
39336
|
}
|
39059
39337
|
|
@@ -39062,7 +39340,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
39062
39340
|
update.lastMessage.timestamp = new Date(update.lastMessage.timestamp);
|
39063
39341
|
}
|
39064
39342
|
} catch (e) {
|
39065
|
-
log$
|
39343
|
+
log$2.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: " + conversationSid);
|
39066
39344
|
delete update.lastMessage.timestamp;
|
39067
39345
|
}
|
39068
39346
|
}
|
@@ -39185,7 +39463,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
39185
39463
|
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf$4(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$4(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$4(this, result); }; }
|
39186
39464
|
|
39187
39465
|
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; } }
|
39188
|
-
var log$
|
39466
|
+
var log$1 = Logger.scope("Conversations");
|
39189
39467
|
/**
|
39190
39468
|
* Represents conversations collection
|
39191
39469
|
* {@see Conversation}
|
@@ -39315,12 +39593,12 @@ this.Twilio.Conversations = (function (exports) {
|
|
39315
39593
|
case 3:
|
39316
39594
|
map = _context2.sent;
|
39317
39595
|
map.on("itemAdded", function (args) {
|
39318
|
-
log$
|
39596
|
+
log$1.debug("itemAdded: ".concat(args.item.key));
|
39319
39597
|
|
39320
39598
|
_this2._upsertConversation("sync", args.item.key, args.item.data);
|
39321
39599
|
});
|
39322
39600
|
map.on("itemRemoved", function (args) {
|
39323
|
-
log$
|
39601
|
+
log$1.debug("itemRemoved: ".concat(args.key));
|
39324
39602
|
var sid = args.key;
|
39325
39603
|
|
39326
39604
|
if (!_this2.myConversationsFetched) {
|
@@ -39346,7 +39624,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
39346
39624
|
conversation.emit("removed", conversation);
|
39347
39625
|
});
|
39348
39626
|
map.on("itemUpdated", function (args) {
|
39349
|
-
log$
|
39627
|
+
log$1.debug("itemUpdated: ".concat(args.item.key));
|
39350
39628
|
|
39351
39629
|
_this2._upsertConversation("sync", args.item.key, args.item.data);
|
39352
39630
|
});
|
@@ -39376,7 +39654,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
39376
39654
|
case 16:
|
39377
39655
|
this.myConversationsFetched = true;
|
39378
39656
|
this.tombstones.clear();
|
39379
|
-
log$
|
39657
|
+
log$1.debug("The conversations list has been successfully fetched");
|
39380
39658
|
return _context2.abrupt("return", this);
|
39381
39659
|
|
39382
39660
|
case 22:
|
@@ -39385,10 +39663,10 @@ this.Twilio.Conversations = (function (exports) {
|
|
39385
39663
|
errorMessage = "Failed to fetch the conversations list";
|
39386
39664
|
|
39387
39665
|
if (this.services.syncClient.connectionState !== "disconnected") {
|
39388
|
-
log$
|
39666
|
+
log$1.error(errorMessage, _context2.t0);
|
39389
39667
|
}
|
39390
39668
|
|
39391
|
-
log$
|
39669
|
+
log$1.debug("ERROR: ".concat(errorMessage), _context2.t0);
|
39392
39670
|
throw _context2.t0;
|
39393
39671
|
|
39394
39672
|
case 28:
|
@@ -39677,7 +39955,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
39677
39955
|
break;
|
39678
39956
|
}
|
39679
39957
|
|
39680
|
-
log$
|
39958
|
+
log$1.trace("upsertConversation: conversation is known from sync and came from chat, ignoring", {
|
39681
39959
|
sid: conversation.sid,
|
39682
39960
|
data: data.status,
|
39683
39961
|
conversation: conversation.status
|
@@ -39767,7 +40045,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
39767
40045
|
while (1) {
|
39768
40046
|
switch (_context10.prev = _context10.next) {
|
39769
40047
|
case 0:
|
39770
|
-
log$
|
40048
|
+
log$1.trace("upsertConversation called for ".concat(sid), data);
|
39771
40049
|
conversation = this.conversations.get(sid); // If the channel is known, update it
|
39772
40050
|
|
39773
40051
|
if (!conversation) {
|
@@ -39775,7 +40053,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
39775
40053
|
break;
|
39776
40054
|
}
|
39777
40055
|
|
39778
|
-
log$
|
40056
|
+
log$1.trace("upsertConversation: the conversation ".concat(conversation.sid, " is known;") + "its status is known from the source ".concat(conversation._statusSource(), " ") + "and the update came from the source ".concat(source), conversation);
|
39779
40057
|
_context10.next = 6;
|
39780
40058
|
return this._updateConversation(source, conversation, data);
|
39781
40059
|
|
@@ -39792,12 +40070,12 @@ this.Twilio.Conversations = (function (exports) {
|
|
39792
40070
|
break;
|
39793
40071
|
}
|
39794
40072
|
|
39795
|
-
log$
|
40073
|
+
log$1.trace("upsertChannel: the channel is deleted but reappeared again from chat, ignoring", sid);
|
39796
40074
|
return _context10.abrupt("return", null);
|
39797
40075
|
|
39798
40076
|
case 12:
|
39799
40077
|
// If the conversation is unknown, fetch it
|
39800
|
-
log$
|
40078
|
+
log$1.trace("upsertConversation: creating a local conversation object with sid " + sid, data);
|
39801
40079
|
baseLink = "".concat(this.configuration.links.conversations, "/").concat(sid);
|
39802
40080
|
links = {
|
39803
40081
|
self: baseLink,
|
@@ -40222,7 +40500,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
40222
40500
|
return Users;
|
40223
40501
|
}(ReplayEventEmitter_1);
|
40224
40502
|
|
40225
|
-
var log
|
40503
|
+
var log = Logger.scope("TypingIndicator");
|
40226
40504
|
/**
|
40227
40505
|
* An important note in regards to typing timeout timers. There are two places that the SDK can get the "typing_timeout" attribute from. The first
|
40228
40506
|
* place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the
|
@@ -40310,7 +40588,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
40310
40588
|
while (1) {
|
40311
40589
|
switch (_context2.prev = _context2.next) {
|
40312
40590
|
case 0:
|
40313
|
-
log
|
40591
|
+
log.trace("Got new typing indicator ", message);
|
40314
40592
|
this.getConversation(message.channel_sid).then(function (conversation) {
|
40315
40593
|
if (!conversation) {
|
40316
40594
|
return;
|
@@ -40326,7 +40604,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
40326
40604
|
participant._startTyping(timeout);
|
40327
40605
|
});
|
40328
40606
|
}).catch(function (err) {
|
40329
|
-
log
|
40607
|
+
log.error(err);
|
40330
40608
|
throw err;
|
40331
40609
|
});
|
40332
40610
|
|
@@ -40366,7 +40644,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
40366
40644
|
value: function _send(conversationSid) {
|
40367
40645
|
var _this3 = this;
|
40368
40646
|
|
40369
|
-
log
|
40647
|
+
log.trace("Sending typing indicator");
|
40370
40648
|
var url = this.configuration.links.typing;
|
40371
40649
|
var headers = {
|
40372
40650
|
"Content-Type": "application/x-www-form-urlencoded"
|
@@ -40377,7 +40655,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
40377
40655
|
_this3.serviceTypingTimeout = response.body.typing_timeout * 1000;
|
40378
40656
|
}
|
40379
40657
|
}).catch(function (err) {
|
40380
|
-
log
|
40658
|
+
log.error("Failed to send typing indicator:", err);
|
40381
40659
|
throw err;
|
40382
40660
|
});
|
40383
40661
|
}
|
@@ -40433,7 +40711,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
40433
40711
|
this.data = data.data || {};
|
40434
40712
|
};
|
40435
40713
|
|
40436
|
-
var version = "
|
40714
|
+
var version = "3.0.0-rc.1";
|
40437
40715
|
|
40438
40716
|
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
40439
40717
|
|
@@ -40647,8 +40925,9 @@ this.Twilio.Conversations = (function (exports) {
|
|
40647
40925
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
40648
40926
|
|
40649
40927
|
var Client_1;
|
40650
|
-
|
40651
|
-
|
40928
|
+
/**
|
40929
|
+
* Client services.
|
40930
|
+
*/
|
40652
40931
|
|
40653
40932
|
var ClientServices = function ClientServices() {
|
40654
40933
|
_classCallCheck$4(this, ClientServices);
|
@@ -40664,28 +40943,246 @@ this.Twilio.Conversations = (function (exports) {
|
|
40664
40943
|
var _super = _createSuper(Client);
|
40665
40944
|
|
40666
40945
|
/**
|
40667
|
-
*
|
40946
|
+
* Fired when a conversation becomes visible to the client. The event is also
|
40947
|
+
* triggered when the client creates a new conversation.
|
40948
|
+
* Fired for all conversations that the client has joined.
|
40949
|
+
*
|
40950
|
+
* Parameters:
|
40951
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
40952
|
+
* @event
|
40953
|
+
*/
|
40954
|
+
|
40955
|
+
/**
|
40956
|
+
* Fired when the client joins a conversation.
|
40957
|
+
*
|
40958
|
+
* Parameters:
|
40959
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
40960
|
+
* @event
|
40961
|
+
*/
|
40962
|
+
|
40963
|
+
/**
|
40964
|
+
* Fired when the client leaves a conversation.
|
40965
|
+
*
|
40966
|
+
* Parameters:
|
40967
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
40968
|
+
* @event
|
40969
|
+
*/
|
40970
|
+
|
40971
|
+
/**
|
40972
|
+
* Fired when a conversation is no longer visible to the client.
|
40973
|
+
*
|
40974
|
+
* Parameters:
|
40975
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
40976
|
+
* @event
|
40977
|
+
*/
|
40978
|
+
|
40979
|
+
/**
|
40980
|
+
* Fired when the attributes or the metadata of a conversation have been
|
40981
|
+
* updated. During conversation's creation and initialization, this event
|
40982
|
+
* might be fired multiple times for same joined or created conversation as
|
40983
|
+
* new data is arriving from different sources.
|
40984
|
+
*
|
40985
|
+
* Parameters:
|
40986
|
+
* 1. object `data` - info object provided with the event. It has the
|
40987
|
+
* following properties:
|
40988
|
+
* * {@link Conversation} `conversation` - the conversation in question
|
40989
|
+
* * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
|
40990
|
+
* for the update
|
40991
|
+
* @event
|
40992
|
+
*/
|
40993
|
+
|
40994
|
+
/**
|
40995
|
+
* Fired when a participant has joined a conversation.
|
40996
|
+
*
|
40997
|
+
* Parameters:
|
40998
|
+
* 1. {@link Participant} `participant` - the participant in question
|
40999
|
+
* @event
|
41000
|
+
*/
|
41001
|
+
|
41002
|
+
/**
|
41003
|
+
* Fired when a participant has left a conversation.
|
41004
|
+
*
|
41005
|
+
* Parameters:
|
41006
|
+
* 1. {@link Participant} `participant` - the participant in question
|
41007
|
+
* @event
|
41008
|
+
*/
|
41009
|
+
|
41010
|
+
/**
|
41011
|
+
* Fired when a participant's fields have been updated.
|
41012
|
+
*
|
41013
|
+
* Parameters:
|
41014
|
+
* 1. object `data` - info object provided with the event. It has the
|
41015
|
+
* following properties:
|
41016
|
+
* * {@link Participant} `participant` - the participant in question
|
41017
|
+
* * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
|
41018
|
+
* for the update
|
41019
|
+
* @event
|
41020
|
+
*/
|
41021
|
+
|
41022
|
+
/**
|
41023
|
+
* Fired when a new message has been added to the conversation on the server.
|
41024
|
+
*
|
41025
|
+
* Parameters:
|
41026
|
+
* 1. {@link Message} `message` - the message in question
|
41027
|
+
* @event
|
41028
|
+
*/
|
41029
|
+
|
41030
|
+
/**
|
41031
|
+
* Fired when a message is removed from the message list of a conversation.
|
41032
|
+
*
|
41033
|
+
* Parameters:
|
41034
|
+
* 1. {@link Message} `message` - the message in question
|
41035
|
+
* @event
|
41036
|
+
*/
|
41037
|
+
|
41038
|
+
/**
|
41039
|
+
* Fired when the fields of an existing message are updated with new values.
|
41040
|
+
*
|
41041
|
+
* Parameters:
|
41042
|
+
* 1. object `data` - info object provided with the event. It has the
|
41043
|
+
* following properties:
|
41044
|
+
* * {@link Message} `message` - the message in question
|
41045
|
+
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
|
41046
|
+
* the update
|
41047
|
+
* @event
|
41048
|
+
*/
|
41049
|
+
|
41050
|
+
/**
|
41051
|
+
* Fired when the token is about to expire and needs to be updated.
|
41052
|
+
* * Parameters:
|
41053
|
+
* 1. number `message` - token's time to live
|
41054
|
+
* @event
|
41055
|
+
*/
|
41056
|
+
|
41057
|
+
/**
|
41058
|
+
* Fired when the token has expired.
|
41059
|
+
* @event
|
41060
|
+
*/
|
41061
|
+
|
41062
|
+
/**
|
41063
|
+
* Fired when a participant has stopped typing.
|
41064
|
+
*
|
41065
|
+
* Parameters:
|
41066
|
+
* 1. {@link Participant} `participant` - the participant in question
|
41067
|
+
* @event
|
41068
|
+
*/
|
41069
|
+
|
41070
|
+
/**
|
41071
|
+
* Fired when a participant has started typing.
|
41072
|
+
*
|
41073
|
+
* Parameters:
|
41074
|
+
* 1. {@link Participant} `participant` - the participant in question
|
41075
|
+
* @event
|
41076
|
+
*/
|
41077
|
+
|
41078
|
+
/**
|
41079
|
+
* Fired when the client has received (and parsed) a push notification via one
|
41080
|
+
* of the push channels (apn or fcm).
|
41081
|
+
*
|
41082
|
+
* Parameters:
|
41083
|
+
* 1. {@link PushNotification} `pushNotification` - the push notification in
|
41084
|
+
* question
|
41085
|
+
* @event
|
41086
|
+
*/
|
41087
|
+
|
41088
|
+
/**
|
41089
|
+
* Fired when the client has subscribed to a user.
|
41090
|
+
*
|
41091
|
+
* Parameters:
|
41092
|
+
* 1. {@link User} `user` - the user in question
|
41093
|
+
* @event
|
41094
|
+
*/
|
41095
|
+
|
41096
|
+
/**
|
41097
|
+
* Fired when the client has unsubscribed from a user.
|
41098
|
+
*
|
41099
|
+
* Parameters:
|
41100
|
+
* 1. {@link User} `user` - the user in question
|
41101
|
+
* @event
|
41102
|
+
*/
|
41103
|
+
|
41104
|
+
/**
|
41105
|
+
* Fired when the properties or the reachability status of a user have been
|
41106
|
+
* updated.
|
41107
|
+
*
|
41108
|
+
* Parameters:
|
41109
|
+
* 1. object `data` - info object provided with the event. It has the
|
41110
|
+
* following properties:
|
41111
|
+
* * {@link User} `user` - the user in question
|
41112
|
+
* * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the
|
41113
|
+
* update
|
41114
|
+
* @event
|
41115
|
+
*/
|
41116
|
+
|
41117
|
+
/**
|
41118
|
+
* Fired when the state of the client has been changed.
|
41119
|
+
*
|
41120
|
+
* Parameters:
|
41121
|
+
* 1. object `data` - info object provided with the event. It has the
|
41122
|
+
* following properties:
|
41123
|
+
* * {@link State} `state` - the new client state
|
41124
|
+
* * Error? `error` - the initialization error if present
|
41125
|
+
* @event
|
41126
|
+
*/
|
41127
|
+
|
41128
|
+
/**
|
41129
|
+
* Fired when the connection state of the client has been changed.
|
41130
|
+
*
|
41131
|
+
* Parameters:
|
41132
|
+
* 1. {@link ConnectionState} `state` - the new connection state
|
41133
|
+
* @event
|
41134
|
+
*/
|
41135
|
+
|
41136
|
+
/**
|
41137
|
+
* Fired when the connection is interrupted for an unexpected reason.
|
41138
|
+
*
|
41139
|
+
* Parameters:
|
41140
|
+
* 1. object `data` - info object provided with the event. It has the
|
41141
|
+
* following properties:
|
41142
|
+
* * boolean `terminal` - Twilsock will stop connection attempts if true
|
41143
|
+
* * string `message` - the error message of the root cause
|
41144
|
+
* * number? `httpStatusCode` - http status code if available
|
41145
|
+
* * number? `errorCode` - Twilio public error code if available
|
41146
|
+
* @event
|
40668
41147
|
*/
|
40669
41148
|
|
40670
41149
|
/**
|
40671
41150
|
* Current version of the Conversations client.
|
40672
41151
|
*/
|
40673
41152
|
|
41153
|
+
/**
|
41154
|
+
* Logger instance.
|
41155
|
+
*/
|
41156
|
+
|
41157
|
+
/**
|
41158
|
+
* Supported push notification channels.
|
41159
|
+
*/
|
41160
|
+
|
41161
|
+
/**
|
41162
|
+
* Supported push data fields.
|
41163
|
+
*/
|
41164
|
+
|
40674
41165
|
/**
|
40675
41166
|
* Current version of the Conversations client.
|
40676
41167
|
*/
|
40677
41168
|
|
40678
41169
|
/**
|
40679
|
-
*
|
40680
|
-
|
40681
|
-
|
41170
|
+
* Client connection state.
|
41171
|
+
*/
|
41172
|
+
|
41173
|
+
/**
|
41174
|
+
* Returned Conversations instance is not yet fully initialized. Calling any
|
41175
|
+
* operations will block until it is. Use connection events to monitor when
|
41176
|
+
* client becomes fully available (connectionStateChanged with state
|
41177
|
+
* 'connected') or not available (connectionStateChange with state 'denied',
|
41178
|
+
* event tokenExpired, event connectionError).
|
40682
41179
|
*
|
40683
41180
|
* @param fpaToken Access token
|
40684
41181
|
* @param options Options to customize the Client
|
40685
41182
|
* @returns A not yet fully-initialized client.
|
40686
41183
|
*/
|
40687
41184
|
function Client(fpaToken) {
|
40688
|
-
var _this$
|
41185
|
+
var _this$_options$logLev, _this$_options$twilso, _this$_options$transp, _this$_options$notifi, _this$_options$syncCl;
|
40689
41186
|
|
40690
41187
|
var _this;
|
40691
41188
|
|
@@ -40695,87 +41192,89 @@ this.Twilio.Conversations = (function (exports) {
|
|
40695
41192
|
|
40696
41193
|
_this = _super.call(this);
|
40697
41194
|
|
40698
|
-
_defineProperty$3(_assertThisInitialized$3(_this), "
|
41195
|
+
_defineProperty$3(_assertThisInitialized$3(_this), "version", version);
|
40699
41196
|
|
40700
|
-
_defineProperty$3(_assertThisInitialized$3(_this), "
|
41197
|
+
_defineProperty$3(_assertThisInitialized$3(_this), "connectionState", "unknown");
|
40701
41198
|
|
40702
41199
|
_defineProperty$3(_assertThisInitialized$3(_this), "parsePushNotification", Client_1.parsePushNotification);
|
40703
41200
|
|
40704
|
-
_this.
|
40705
|
-
_this.
|
41201
|
+
_this._fpaToken = fpaToken !== null && fpaToken !== void 0 ? fpaToken : "";
|
41202
|
+
_this._options = options !== null && options !== void 0 ? options : {};
|
40706
41203
|
|
40707
|
-
if (!_this.
|
40708
|
-
var _options = _objectSpread(_objectSpread({}, _this.
|
41204
|
+
if (!_this._options.disableDeepClone) {
|
41205
|
+
var _options = _objectSpread(_objectSpread({}, _this._options), {}, {
|
40709
41206
|
transport: undefined,
|
40710
41207
|
twilsockClient: undefined
|
40711
41208
|
});
|
40712
41209
|
|
40713
41210
|
_options = deepClone$1(_options);
|
40714
|
-
_options.transport = _this.
|
40715
|
-
_options.twilsockClient = _this.
|
40716
|
-
_this.
|
41211
|
+
_options.transport = _this._options.transport;
|
41212
|
+
_options.twilsockClient = _this._options.twilsockClient;
|
41213
|
+
_this._options = _options;
|
40717
41214
|
}
|
40718
41215
|
|
40719
|
-
_this.
|
40720
|
-
|
40721
|
-
|
41216
|
+
_this._options.logLevel = (_this$_options$logLev = _this._options.logLevel) !== null && _this$_options$logLev !== void 0 ? _this$_options$logLev : "silent";
|
41217
|
+
|
41218
|
+
Client_1._logger.setLevel(_this._options.logLevel);
|
40722
41219
|
|
40723
|
-
|
41220
|
+
var productId = _this._options.productId = "ip_messaging"; // Filling ClientMetadata
|
40724
41221
|
|
40725
|
-
|
40726
|
-
|
41222
|
+
_this._options.clientMetadata = _this._options.clientMetadata || {};
|
41223
|
+
|
41224
|
+
if (!_this._options.clientMetadata.hasOwnProperty("type")) {
|
41225
|
+
_this._options.clientMetadata.type = "conversations";
|
40727
41226
|
}
|
40728
41227
|
|
40729
|
-
if (!_this.
|
40730
|
-
_this.
|
40731
|
-
_this.
|
41228
|
+
if (!_this._options.clientMetadata.hasOwnProperty("sdk")) {
|
41229
|
+
_this._options.clientMetadata.sdk = "JS";
|
41230
|
+
_this._options.clientMetadata.sdkv = version;
|
40732
41231
|
} // Enable session local storage for Sync
|
40733
41232
|
|
40734
41233
|
|
40735
|
-
_this.
|
41234
|
+
_this._options.Sync = _this._options.Sync || {};
|
40736
41235
|
|
40737
|
-
if (typeof _this.
|
40738
|
-
_this.
|
41236
|
+
if (typeof _this._options.Sync.enableSessionStorage === "undefined") {
|
41237
|
+
_this._options.Sync.enableSessionStorage = true;
|
40739
41238
|
}
|
40740
41239
|
|
40741
|
-
if (_this.
|
40742
|
-
_this.
|
41240
|
+
if (_this._options.region) {
|
41241
|
+
_this._options.Sync.region = _this._options.region;
|
40743
41242
|
}
|
40744
41243
|
|
40745
41244
|
if (!fpaToken) {
|
40746
41245
|
throw new Error("A valid Twilio token should be provided");
|
40747
41246
|
}
|
40748
41247
|
|
40749
|
-
_this.
|
40750
|
-
_this._myself = new User("", "", null, _this.
|
40751
|
-
var startTwilsock = !_this.
|
41248
|
+
_this._services = new ClientServices();
|
41249
|
+
_this._myself = new User("", "", null, _this._services);
|
41250
|
+
var startTwilsock = !_this._options.twilsockClient; // Create default init registrations if none were provided.
|
40752
41251
|
// Otherwise, the outside party have to list all the init registrations they
|
40753
41252
|
// need.
|
40754
41253
|
// Init registrations passed to the Conversations client will be passed down
|
40755
41254
|
// to the Sync client as well.
|
40756
41255
|
|
40757
|
-
if (!_this.
|
41256
|
+
if (!_this._options.initRegistrations) {
|
40758
41257
|
var initRegistration = new browser$3.InitRegistration(productId);
|
40759
41258
|
Client_1.populateInitRegistrations(initRegistration);
|
40760
|
-
_this.
|
41259
|
+
_this._options.initRegistrations = [initRegistration];
|
40761
41260
|
}
|
40762
41261
|
|
40763
|
-
_this.
|
41262
|
+
_this._services.twilsockClient = _this._options.twilsockClient = (_this$_options$twilso = _this._options.twilsockClient) !== null && _this$_options$twilso !== void 0 ? _this$_options$twilso : new browser$3.TwilsockClient(fpaToken, productId, _this._options);
|
40764
41263
|
|
40765
|
-
_this.
|
41264
|
+
_this._services.twilsockClient.on("tokenAboutToExpire", function (ttl) {
|
40766
41265
|
return _this.emit("tokenAboutToExpire", ttl);
|
40767
41266
|
});
|
40768
41267
|
|
40769
|
-
_this.
|
41268
|
+
_this._services.twilsockClient.on("tokenExpired", function () {
|
40770
41269
|
return _this.emit("tokenExpired");
|
40771
41270
|
});
|
40772
41271
|
|
40773
|
-
_this.
|
41272
|
+
_this._services.twilsockClient.on("connectionError", function (error) {
|
40774
41273
|
return _this.emit("connectionError", error);
|
40775
41274
|
});
|
40776
41275
|
|
40777
|
-
_this.
|
40778
|
-
|
41276
|
+
_this._services.twilsockClient.on("stateChanged", function (state) {
|
41277
|
+
Client_1._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(state));
|
40779
41278
|
|
40780
41279
|
if (state !== _this.connectionState) {
|
40781
41280
|
_this.connectionState = state;
|
@@ -40784,49 +41283,52 @@ this.Twilio.Conversations = (function (exports) {
|
|
40784
41283
|
}
|
40785
41284
|
});
|
40786
41285
|
|
40787
|
-
_this.
|
40788
|
-
_this.
|
40789
|
-
_this.
|
41286
|
+
_this._services.transport = _this._options.transport = (_this$_options$transp = _this._options.transport) !== null && _this$_options$transp !== void 0 ? _this$_options$transp : _this._options.twilsockClient;
|
41287
|
+
_this._services.notificationClient = _this._options.notificationsClient = (_this$_options$notifi = _this._options.notificationsClient) !== null && _this$_options$notifi !== void 0 ? _this$_options$notifi : new browser$2.Notifications(fpaToken, _this._options);
|
41288
|
+
_this._services.syncClient = _this._options.syncClient = (_this$_options$syncCl = _this._options.syncClient) !== null && _this$_options$syncCl !== void 0 ? _this$_options$syncCl : new SyncClient(fpaToken, _this._options);
|
40790
41289
|
var configurationOptions = (options === null || options === void 0 ? void 0 : options.Chat) || (options === null || options === void 0 ? void 0 : options.IPMessaging) || options || {};
|
40791
41290
|
var region = configurationOptions.region || (options === null || options === void 0 ? void 0 : options.region);
|
40792
41291
|
var baseUrl = configurationOptions.apiUri || configurationOptions.typingUri || "https://aim.".concat(region || "us1", ".twilio.com");
|
40793
|
-
_this.
|
40794
|
-
transport: _this.
|
41292
|
+
_this._services.commandExecutor = new CommandExecutor(baseUrl, {
|
41293
|
+
transport: _this._options.transport
|
40795
41294
|
}, productId);
|
40796
41295
|
|
40797
|
-
var emitFailed = function emitFailed(
|
40798
|
-
_this._rejectEnsureReady(
|
41296
|
+
var emitFailed = function emitFailed(error) {
|
41297
|
+
_this._rejectEnsureReady(error);
|
40799
41298
|
|
40800
|
-
_this.emit("stateChanged",
|
41299
|
+
_this.emit("stateChanged", {
|
41300
|
+
state: "failed",
|
41301
|
+
error: error
|
41302
|
+
});
|
40801
41303
|
};
|
40802
41304
|
|
40803
|
-
_this.
|
41305
|
+
_this._services.twilsockClient.once("connectionError", emitFailed);
|
40804
41306
|
|
40805
|
-
_this.
|
41307
|
+
_this._services.twilsockClient.once("disconnected", emitFailed); // The client will be able to initialize only after Twilsock is connected
|
40806
41308
|
|
40807
41309
|
|
40808
|
-
_this.
|
41310
|
+
_this._services.twilsockClient.once("connected", /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee() {
|
40809
41311
|
var startupEvent;
|
40810
41312
|
return _regeneratorRuntime$1.wrap(function _callee$(_context) {
|
40811
41313
|
while (1) {
|
40812
41314
|
switch (_context.prev = _context.next) {
|
40813
41315
|
case 0:
|
40814
|
-
|
41316
|
+
Client_1._logger.debug("ConversationsClient started INITIALIZING");
|
40815
41317
|
|
40816
|
-
_this.
|
41318
|
+
_this._services.twilsockClient.off("connectionError", emitFailed);
|
40817
41319
|
|
40818
|
-
_this.
|
41320
|
+
_this._services.twilsockClient.off("disconnected", emitFailed);
|
40819
41321
|
|
40820
41322
|
_context.prev = 3;
|
40821
41323
|
startupEvent = "conversations.client.startup";
|
40822
41324
|
|
40823
|
-
_this.
|
41325
|
+
_this._services.twilsockClient.addPartialTelemetryEvent(new browser$3.TelemetryEventDescription(startupEvent, "Conversations client startup", new Date()), startupEvent, browser$3.TelemetryPoint.Start);
|
40824
41326
|
|
40825
41327
|
_context.next = 8;
|
40826
41328
|
return _this._initialize();
|
40827
41329
|
|
40828
41330
|
case 8:
|
40829
|
-
_this.
|
41331
|
+
_this._services.twilsockClient.addPartialTelemetryEvent(new browser$3.TelemetryEventDescription("", "", new Date()), startupEvent, browser$3.TelemetryPoint.End);
|
40830
41332
|
|
40831
41333
|
_context.next = 15;
|
40832
41334
|
break;
|
@@ -40838,7 +41340,10 @@ this.Twilio.Conversations = (function (exports) {
|
|
40838
41340
|
// Fail ChatClient if initialization is incomplete
|
40839
41341
|
_this._rejectEnsureReady(_context.t0);
|
40840
41342
|
|
40841
|
-
_this.emit("stateChanged",
|
41343
|
+
_this.emit("stateChanged", {
|
41344
|
+
state: "failed",
|
41345
|
+
error: _context.t0
|
41346
|
+
});
|
40842
41347
|
|
40843
41348
|
case 15:
|
40844
41349
|
case "end":
|
@@ -40856,154 +41361,77 @@ this.Twilio.Conversations = (function (exports) {
|
|
40856
41361
|
}); // @todo How to process unhandled rejection here?
|
40857
41362
|
|
40858
41363
|
if (startTwilsock) {
|
40859
|
-
_this.
|
41364
|
+
_this._services.twilsockClient.connect();
|
40860
41365
|
}
|
40861
41366
|
|
40862
41367
|
return _this;
|
40863
41368
|
}
|
41369
|
+
/**
|
41370
|
+
* Information of the logged-in user. Before client initialization, returns an
|
41371
|
+
* uninitialized user. Will trigger a {@link Client.userUpdated} event after
|
41372
|
+
* initialization.
|
41373
|
+
*/
|
41374
|
+
|
40864
41375
|
|
40865
41376
|
_createClass$3(Client, [{
|
40866
41377
|
key: "user",
|
40867
|
-
get:
|
40868
|
-
/**
|
40869
|
-
* Information of the logged-in user. Before client initialization, returns an
|
40870
|
-
* uninitialized user. Will trigger a {@link Client.userUpdated} event after
|
40871
|
-
* initialization.
|
40872
|
-
*/
|
40873
|
-
function get() {
|
41378
|
+
get: function get() {
|
40874
41379
|
return this._myself;
|
40875
41380
|
}
|
40876
41381
|
/**
|
40877
|
-
* Client reachability state. Throws if accessed before the client
|
41382
|
+
* Client reachability state. Throws an error if accessed before the client
|
40878
41383
|
* initialization was completed.
|
40879
41384
|
*/
|
40880
41385
|
|
40881
41386
|
}, {
|
40882
41387
|
key: "reachabilityEnabled",
|
40883
41388
|
get: function get() {
|
40884
|
-
if (!this.
|
41389
|
+
if (!this._configuration) {
|
40885
41390
|
throw new Error("Reachability information could not yet be accessed as the client " + "has not yet been initialized. Subscribe to the 'stateChanged' event " + "to properly react to the client initialization.");
|
40886
41391
|
}
|
40887
41392
|
|
40888
|
-
return this.
|
40889
|
-
}
|
40890
|
-
}, {
|
40891
|
-
key: "token",
|
40892
|
-
get: function get() {
|
40893
|
-
return this.fpaToken;
|
40894
|
-
}
|
40895
|
-
}, {
|
40896
|
-
key: "_subscribeToPushNotifications",
|
40897
|
-
value: function _subscribeToPushNotifications(channelType) {
|
40898
|
-
var _this2 = this;
|
40899
|
-
|
40900
|
-
[NotificationTypes.NEW_MESSAGE, NotificationTypes.ADDED_TO_CONVERSATION, NotificationTypes.REMOVED_FROM_CONVERSATION, NotificationTypes.TYPING_INDICATOR, NotificationTypes.CONSUMPTION_UPDATE].forEach(function (messageType) {
|
40901
|
-
_this2.services.notificationClient.subscribe(channelType, messageType);
|
40902
|
-
});
|
41393
|
+
return this._configuration.reachabilityEnabled;
|
40903
41394
|
}
|
40904
|
-
|
40905
|
-
|
40906
|
-
|
40907
|
-
|
41395
|
+
/**
|
41396
|
+
* @deprecated Call constructor directly.
|
41397
|
+
*
|
41398
|
+
* Factory method to create a Conversations client instance.
|
41399
|
+
*
|
41400
|
+
* The factory method will automatically trigger connection.
|
41401
|
+
* Do not use it if you need finer-grained control.
|
41402
|
+
*
|
41403
|
+
* Since this method returns an already-initialized client, some of the events
|
41404
|
+
* will be lost because they happen *before* the initialization. It is
|
41405
|
+
* recommended that `client.onWithReplay` is used as opposed to `client.on`
|
41406
|
+
* for subscribing to client events. The `client.onWithReplay` will re-emit
|
41407
|
+
* the most recent value for a given event if it emitted before the
|
41408
|
+
* subscription.
|
41409
|
+
*
|
41410
|
+
* @param token Access token.
|
41411
|
+
* @param options Options to customize the client.
|
41412
|
+
* @returns Returns a fully initialized client.
|
41413
|
+
*/
|
40908
41414
|
|
40909
|
-
[NotificationTypes.NEW_MESSAGE, NotificationTypes.ADDED_TO_CONVERSATION, NotificationTypes.REMOVED_FROM_CONVERSATION, NotificationTypes.TYPING_INDICATOR, NotificationTypes.CONSUMPTION_UPDATE].forEach(function (messageType) {
|
40910
|
-
_this3.services.notificationClient.unsubscribe(channelType, messageType);
|
40911
|
-
});
|
40912
|
-
}
|
40913
41415
|
}, {
|
40914
|
-
key: "
|
40915
|
-
value:
|
40916
|
-
|
40917
|
-
|
40918
|
-
|
40919
|
-
|
41416
|
+
key: "shutdown",
|
41417
|
+
value:
|
41418
|
+
/**
|
41419
|
+
* Gracefully shut down the client.
|
41420
|
+
*/
|
41421
|
+
function () {
|
41422
|
+
var _shutdown = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2() {
|
40920
41423
|
return _regeneratorRuntime$1.wrap(function _callee2$(_context2) {
|
40921
41424
|
while (1) {
|
40922
41425
|
switch (_context2.prev = _context2.next) {
|
40923
41426
|
case 0:
|
40924
41427
|
_context2.next = 2;
|
40925
|
-
return this.
|
41428
|
+
return this._ensureReady;
|
40926
41429
|
|
40927
41430
|
case 2:
|
40928
|
-
|
40929
|
-
this.
|
40930
|
-
|
40931
|
-
this._myself._resolveInitialization(this.configuration, this.configuration.userIdentity, this.configuration.userInfo, true);
|
40932
|
-
|
40933
|
-
this.services.typingIndicator = new TypingIndicator(this.getConversationBySid.bind(this), this.configuration, this.services);
|
40934
|
-
this.services.network = new Network(this.configuration, this.services);
|
40935
|
-
this.services.users = new Users(this._myself, this.configuration, this.services);
|
40936
|
-
this.services.users.on("userSubscribed", function (user) {
|
40937
|
-
_this4.emit("userSubscribed", user);
|
40938
|
-
});
|
40939
|
-
this.services.users.on("userUpdated", function (args) {
|
40940
|
-
return _this4.emit("userUpdated", args);
|
40941
|
-
});
|
40942
|
-
this.services.users.on("userUnsubscribed", function (user) {
|
40943
|
-
_this4.emit("userUnsubscribed", user);
|
40944
|
-
});
|
40945
|
-
this.conversations = new Conversations(this.configuration, this.services);
|
40946
|
-
this.conversations.on("conversationAdded", function (conversation) {
|
40947
|
-
_this4.emit("conversationAdded", conversation);
|
40948
|
-
});
|
40949
|
-
this.conversations.on("conversationRemoved", function (conversation) {
|
40950
|
-
_this4.emit("conversationRemoved", conversation);
|
40951
|
-
});
|
40952
|
-
this.conversations.on("conversationJoined", function (conversation) {
|
40953
|
-
_this4.emit("conversationJoined", conversation);
|
40954
|
-
});
|
40955
|
-
this.conversations.on("conversationLeft", function (conversation) {
|
40956
|
-
_this4.emit("conversationLeft", conversation);
|
40957
|
-
});
|
40958
|
-
this.conversations.on("conversationUpdated", function (args) {
|
40959
|
-
return _this4.emit("conversationUpdated", args);
|
40960
|
-
});
|
40961
|
-
this.conversations.on("participantJoined", function (participant) {
|
40962
|
-
_this4.emit("participantJoined", participant);
|
40963
|
-
});
|
40964
|
-
this.conversations.on("participantLeft", function (participant) {
|
40965
|
-
_this4.emit("participantLeft", participant);
|
40966
|
-
});
|
40967
|
-
this.conversations.on("participantUpdated", function (args) {
|
40968
|
-
return _this4.emit("participantUpdated", args);
|
40969
|
-
});
|
40970
|
-
this.conversations.on("messageAdded", function (message) {
|
40971
|
-
return _this4.emit("messageAdded", message);
|
40972
|
-
});
|
40973
|
-
this.conversations.on("messageUpdated", function (args) {
|
40974
|
-
return _this4.emit("messageUpdated", args);
|
40975
|
-
});
|
40976
|
-
this.conversations.on("messageRemoved", function (message) {
|
40977
|
-
return _this4.emit("messageRemoved", message);
|
40978
|
-
});
|
40979
|
-
this.conversations.on("typingStarted", function (participant) {
|
40980
|
-
return _this4.emit("typingStarted", participant);
|
40981
|
-
});
|
40982
|
-
this.conversations.on("typingEnded", function (participant) {
|
40983
|
-
return _this4.emit("typingEnded", participant);
|
40984
|
-
});
|
40985
|
-
this.conversationsPromise = this.conversations.fetchConversations().then(function () {
|
40986
|
-
return _this4.conversations;
|
40987
|
-
}).catch(function (error) {
|
40988
|
-
throw error;
|
40989
|
-
});
|
40990
|
-
_context2.next = 28;
|
40991
|
-
return this.services.users.myself._ensureFetched();
|
40992
|
-
|
40993
|
-
case 28:
|
40994
|
-
Client_1.supportedPushChannels.forEach(function (channelType) {
|
40995
|
-
return _this4._subscribeToPushNotifications(channelType);
|
40996
|
-
});
|
40997
|
-
this.services.typingIndicator.initialize();
|
40998
|
-
this.services.mcsClient = new browser.McsClient(this.fpaToken, this.configuration.links.mediaService, this.configuration.links.mediaSetService, _objectSpread(_objectSpread({}, this.options), {}, {
|
40999
|
-
transport: undefined
|
41000
|
-
}));
|
41001
|
-
|
41002
|
-
this._resolveEnsureReady();
|
41003
|
-
|
41004
|
-
this.emit("stateChanged", "initialized");
|
41431
|
+
_context2.next = 4;
|
41432
|
+
return this._services.twilsockClient.disconnect();
|
41005
41433
|
|
41006
|
-
case
|
41434
|
+
case 4:
|
41007
41435
|
case "end":
|
41008
41436
|
return _context2.stop();
|
41009
41437
|
}
|
@@ -41011,20 +41439,21 @@ this.Twilio.Conversations = (function (exports) {
|
|
41011
41439
|
}, _callee2, this);
|
41012
41440
|
}));
|
41013
41441
|
|
41014
|
-
function
|
41015
|
-
return
|
41442
|
+
function shutdown() {
|
41443
|
+
return _shutdown.apply(this, arguments);
|
41016
41444
|
}
|
41017
41445
|
|
41018
|
-
return
|
41446
|
+
return shutdown;
|
41019
41447
|
}()
|
41020
41448
|
/**
|
41021
|
-
*
|
41449
|
+
* Update the token used by the client and re-register with the Conversations services.
|
41450
|
+
* @param token New access token.
|
41022
41451
|
*/
|
41023
41452
|
|
41024
41453
|
}, {
|
41025
|
-
key: "
|
41454
|
+
key: "updateToken",
|
41026
41455
|
value: function () {
|
41027
|
-
var
|
41456
|
+
var _updateToken = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(token) {
|
41028
41457
|
return _regeneratorRuntime$1.wrap(function _callee3$(_context3) {
|
41029
41458
|
while (1) {
|
41030
41459
|
switch (_context3.prev = _context3.next) {
|
@@ -41033,10 +41462,32 @@ this.Twilio.Conversations = (function (exports) {
|
|
41033
41462
|
return this._ensureReady;
|
41034
41463
|
|
41035
41464
|
case 2:
|
41036
|
-
|
41037
|
-
return this.services.twilsockClient.disconnect();
|
41465
|
+
Client_1._logger.info("updateToken");
|
41038
41466
|
|
41039
|
-
|
41467
|
+
if (!(this._fpaToken === token)) {
|
41468
|
+
_context3.next = 5;
|
41469
|
+
break;
|
41470
|
+
}
|
41471
|
+
|
41472
|
+
return _context3.abrupt("return", this);
|
41473
|
+
|
41474
|
+
case 5:
|
41475
|
+
_context3.next = 7;
|
41476
|
+
return this._services.twilsockClient.updateToken(token);
|
41477
|
+
|
41478
|
+
case 7:
|
41479
|
+
_context3.next = 9;
|
41480
|
+
return this._services.notificationClient.updateToken(token);
|
41481
|
+
|
41482
|
+
case 9:
|
41483
|
+
_context3.next = 11;
|
41484
|
+
return this._services.mcsClient.updateToken(token);
|
41485
|
+
|
41486
|
+
case 11:
|
41487
|
+
this._fpaToken = token;
|
41488
|
+
return _context3.abrupt("return", this);
|
41489
|
+
|
41490
|
+
case 13:
|
41040
41491
|
case "end":
|
41041
41492
|
return _context3.stop();
|
41042
41493
|
}
|
@@ -41044,21 +41495,22 @@ this.Twilio.Conversations = (function (exports) {
|
|
41044
41495
|
}, _callee3, this);
|
41045
41496
|
}));
|
41046
41497
|
|
41047
|
-
function
|
41048
|
-
return
|
41498
|
+
function updateToken(_x) {
|
41499
|
+
return _updateToken.apply(this, arguments);
|
41049
41500
|
}
|
41050
41501
|
|
41051
|
-
return
|
41502
|
+
return updateToken;
|
41052
41503
|
}()
|
41053
41504
|
/**
|
41054
|
-
*
|
41055
|
-
* @param
|
41505
|
+
* Get a known conversation by its SID.
|
41506
|
+
* @param conversationSid Conversation sid
|
41056
41507
|
*/
|
41057
41508
|
|
41058
41509
|
}, {
|
41059
|
-
key: "
|
41510
|
+
key: "getConversationBySid",
|
41060
41511
|
value: function () {
|
41061
|
-
var
|
41512
|
+
var _getConversationBySid = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(conversationSid) {
|
41513
|
+
var conversation;
|
41062
41514
|
return _regeneratorRuntime$1.wrap(function _callee4$(_context4) {
|
41063
41515
|
while (1) {
|
41064
41516
|
switch (_context4.prev = _context4.next) {
|
@@ -41067,32 +41519,27 @@ this.Twilio.Conversations = (function (exports) {
|
|
41067
41519
|
return this._ensureReady;
|
41068
41520
|
|
41069
41521
|
case 2:
|
41070
|
-
|
41522
|
+
_context4.next = 4;
|
41523
|
+
return this._conversations.myConversationsRead.promise;
|
41071
41524
|
|
41072
|
-
|
41073
|
-
|
41074
|
-
|
41075
|
-
}
|
41525
|
+
case 4:
|
41526
|
+
_context4.next = 6;
|
41527
|
+
return this._conversations.getConversation(conversationSid);
|
41076
41528
|
|
41077
|
-
|
41529
|
+
case 6:
|
41530
|
+
conversation = _context4.sent;
|
41078
41531
|
|
41079
|
-
|
41080
|
-
|
41081
|
-
|
41532
|
+
if (conversation) {
|
41533
|
+
_context4.next = 9;
|
41534
|
+
break;
|
41535
|
+
}
|
41082
41536
|
|
41083
|
-
|
41084
|
-
_context4.next = 9;
|
41085
|
-
return this.services.notificationClient.updateToken(token);
|
41537
|
+
throw new Error("Conversation with SID ".concat(conversationSid, " is not found."));
|
41086
41538
|
|
41087
41539
|
case 9:
|
41088
|
-
_context4.
|
41089
|
-
return this.services.mcsClient.updateToken(token);
|
41090
|
-
|
41091
|
-
case 11:
|
41092
|
-
this.fpaToken = token;
|
41093
|
-
return _context4.abrupt("return", this);
|
41540
|
+
return _context4.abrupt("return", conversation);
|
41094
41541
|
|
41095
|
-
case
|
41542
|
+
case 10:
|
41096
41543
|
case "end":
|
41097
41544
|
return _context4.stop();
|
41098
41545
|
}
|
@@ -41100,21 +41547,22 @@ this.Twilio.Conversations = (function (exports) {
|
|
41100
41547
|
}, _callee4, this);
|
41101
41548
|
}));
|
41102
41549
|
|
41103
|
-
function
|
41104
|
-
return
|
41550
|
+
function getConversationBySid(_x2) {
|
41551
|
+
return _getConversationBySid.apply(this, arguments);
|
41105
41552
|
}
|
41106
41553
|
|
41107
|
-
return
|
41554
|
+
return getConversationBySid;
|
41108
41555
|
}()
|
41109
41556
|
/**
|
41110
|
-
*
|
41557
|
+
* Peek a conversation by its SID.
|
41111
41558
|
* @param conversationSid Conversation sid
|
41559
|
+
* @internal
|
41112
41560
|
*/
|
41113
41561
|
|
41114
41562
|
}, {
|
41115
|
-
key: "
|
41563
|
+
key: "peekConversationBySid",
|
41116
41564
|
value: function () {
|
41117
|
-
var
|
41565
|
+
var _peekConversationBySid = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(conversationSid) {
|
41118
41566
|
var conversation;
|
41119
41567
|
return _regeneratorRuntime$1.wrap(function _callee5$(_context5) {
|
41120
41568
|
while (1) {
|
@@ -41125,38 +41573,22 @@ this.Twilio.Conversations = (function (exports) {
|
|
41125
41573
|
|
41126
41574
|
case 2:
|
41127
41575
|
_context5.next = 4;
|
41128
|
-
return this.
|
41576
|
+
return this._conversations.peekConversation(conversationSid);
|
41129
41577
|
|
41130
41578
|
case 4:
|
41131
|
-
_context5.next = 6;
|
41132
|
-
return this.conversations.getConversation(conversationSid);
|
41133
|
-
|
41134
|
-
case 6:
|
41135
|
-
conversation = _context5.sent;
|
41136
|
-
|
41137
|
-
if (conversation) {
|
41138
|
-
_context5.next = 11;
|
41139
|
-
break;
|
41140
|
-
}
|
41141
|
-
|
41142
|
-
_context5.next = 10;
|
41143
|
-
return this.conversations.peekConversation(conversationSid);
|
41144
|
-
|
41145
|
-
case 10:
|
41146
41579
|
conversation = _context5.sent;
|
41147
41580
|
|
41148
|
-
case 11:
|
41149
41581
|
if (conversation) {
|
41150
|
-
_context5.next =
|
41582
|
+
_context5.next = 7;
|
41151
41583
|
break;
|
41152
41584
|
}
|
41153
41585
|
|
41154
41586
|
throw new Error("Conversation with SID ".concat(conversationSid, " is not found."));
|
41155
41587
|
|
41156
|
-
case
|
41588
|
+
case 7:
|
41157
41589
|
return _context5.abrupt("return", conversation);
|
41158
41590
|
|
41159
|
-
case
|
41591
|
+
case 8:
|
41160
41592
|
case "end":
|
41161
41593
|
return _context5.stop();
|
41162
41594
|
}
|
@@ -41164,11 +41596,11 @@ this.Twilio.Conversations = (function (exports) {
|
|
41164
41596
|
}, _callee5, this);
|
41165
41597
|
}));
|
41166
41598
|
|
41167
|
-
function
|
41168
|
-
return
|
41599
|
+
function peekConversationBySid(_x3) {
|
41600
|
+
return _peekConversationBySid.apply(this, arguments);
|
41169
41601
|
}
|
41170
41602
|
|
41171
|
-
return
|
41603
|
+
return peekConversationBySid;
|
41172
41604
|
}()
|
41173
41605
|
/**
|
41174
41606
|
* Get a known conversation by its unique identifier name.
|
@@ -41189,11 +41621,11 @@ this.Twilio.Conversations = (function (exports) {
|
|
41189
41621
|
|
41190
41622
|
case 2:
|
41191
41623
|
_context6.next = 4;
|
41192
|
-
return this.
|
41624
|
+
return this._conversations.myConversationsRead.promise;
|
41193
41625
|
|
41194
41626
|
case 4:
|
41195
41627
|
_context6.next = 6;
|
41196
|
-
return this.
|
41628
|
+
return this._conversations.getConversationByUniqueName(uniqueName);
|
41197
41629
|
|
41198
41630
|
case 6:
|
41199
41631
|
conversation = _context6.sent;
|
@@ -41216,7 +41648,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41216
41648
|
}, _callee6, this);
|
41217
41649
|
}));
|
41218
41650
|
|
41219
|
-
function getConversationByUniqueName(
|
41651
|
+
function getConversationByUniqueName(_x4) {
|
41220
41652
|
return _getConversationByUniqueName.apply(this, arguments);
|
41221
41653
|
}
|
41222
41654
|
|
@@ -41238,7 +41670,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41238
41670
|
return this._ensureReady;
|
41239
41671
|
|
41240
41672
|
case 2:
|
41241
|
-
return _context7.abrupt("return", this.
|
41673
|
+
return _context7.abrupt("return", this._conversationsPromise.then(function (conversations) {
|
41242
41674
|
return conversations.getConversations();
|
41243
41675
|
}));
|
41244
41676
|
|
@@ -41275,7 +41707,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41275
41707
|
|
41276
41708
|
case 2:
|
41277
41709
|
options = options || {};
|
41278
|
-
return _context8.abrupt("return", this.
|
41710
|
+
return _context8.abrupt("return", this._conversationsPromise.then(function (conversationsEntity) {
|
41279
41711
|
return conversationsEntity.addConversation(options);
|
41280
41712
|
}));
|
41281
41713
|
|
@@ -41287,7 +41719,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41287
41719
|
}, _callee8, this);
|
41288
41720
|
}));
|
41289
41721
|
|
41290
|
-
function createConversation(
|
41722
|
+
function createConversation(_x5) {
|
41291
41723
|
return _createConversation.apply(this, arguments);
|
41292
41724
|
}
|
41293
41725
|
|
@@ -41296,7 +41728,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
41296
41728
|
/**
|
41297
41729
|
* Register for push notifications.
|
41298
41730
|
* @param channelType Channel type.
|
41299
|
-
* @param registrationId Push notification ID provided by the FCM/APNS service
|
41731
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service
|
41732
|
+
* on the platform.
|
41300
41733
|
*/
|
41301
41734
|
|
41302
41735
|
}, {
|
@@ -41313,9 +41746,10 @@ this.Twilio.Conversations = (function (exports) {
|
|
41313
41746
|
case 2:
|
41314
41747
|
this._subscribeToPushNotifications(channelType);
|
41315
41748
|
|
41316
|
-
this.
|
41749
|
+
this._services.notificationClient.setPushRegistrationId(channelType, registrationId);
|
41750
|
+
|
41317
41751
|
_context9.next = 6;
|
41318
|
-
return this.
|
41752
|
+
return this._services.notificationClient.commitChanges();
|
41319
41753
|
|
41320
41754
|
case 6:
|
41321
41755
|
case "end":
|
@@ -41325,7 +41759,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41325
41759
|
}, _callee9, this);
|
41326
41760
|
}));
|
41327
41761
|
|
41328
|
-
function setPushRegistrationId(
|
41762
|
+
function setPushRegistrationId(_x6, _x7) {
|
41329
41763
|
return _setPushRegistrationId.apply(this, arguments);
|
41330
41764
|
}
|
41331
41765
|
|
@@ -41352,7 +41786,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41352
41786
|
this._unsubscribeFromPushNotifications(channelType);
|
41353
41787
|
|
41354
41788
|
_context10.next = 5;
|
41355
|
-
return this.
|
41789
|
+
return this._services.notificationClient.commitChanges();
|
41356
41790
|
|
41357
41791
|
case 5:
|
41358
41792
|
case "end":
|
@@ -41362,7 +41796,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41362
41796
|
}, _callee10, this);
|
41363
41797
|
}));
|
41364
41798
|
|
41365
|
-
function unsetPushRegistrationId(
|
41799
|
+
function unsetPushRegistrationId(_x8) {
|
41366
41800
|
return _unsetPushRegistrationId.apply(this, arguments);
|
41367
41801
|
}
|
41368
41802
|
|
@@ -41372,11 +41806,14 @@ this.Twilio.Conversations = (function (exports) {
|
|
41372
41806
|
* Clear existing registrations directly using provided device token.
|
41373
41807
|
* This is useful to ensure stopped subscriptions without resubscribing.
|
41374
41808
|
*
|
41375
|
-
* This function goes completely beside the state machine and removes all
|
41376
|
-
*
|
41809
|
+
* This function goes completely beside the state machine and removes all
|
41810
|
+
* registrations.
|
41811
|
+
* Use with caution: if it races with current state machine operations,
|
41812
|
+
* madness will ensue.
|
41377
41813
|
*
|
41378
41814
|
* @param channelType Channel type.
|
41379
|
-
* @param registrationId Push notification ID provided by the FCM/APNS service
|
41815
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service
|
41816
|
+
* on the platform.
|
41380
41817
|
*/
|
41381
41818
|
|
41382
41819
|
}, {
|
@@ -41388,7 +41825,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41388
41825
|
switch (_context11.prev = _context11.next) {
|
41389
41826
|
case 0:
|
41390
41827
|
_context11.next = 2;
|
41391
|
-
return this.
|
41828
|
+
return this._services.notificationClient.removeRegistrations(channelType, registrationId);
|
41392
41829
|
|
41393
41830
|
case 2:
|
41394
41831
|
case "end":
|
@@ -41398,17 +41835,22 @@ this.Twilio.Conversations = (function (exports) {
|
|
41398
41835
|
}, _callee11, this);
|
41399
41836
|
}));
|
41400
41837
|
|
41401
|
-
function removePushRegistrations(
|
41838
|
+
function removePushRegistrations(_x9, _x10) {
|
41402
41839
|
return _removePushRegistrations.apply(this, arguments);
|
41403
41840
|
}
|
41404
41841
|
|
41405
41842
|
return removePushRegistrations;
|
41406
41843
|
}()
|
41844
|
+
/**
|
41845
|
+
* Current version of the Conversations client.
|
41846
|
+
*/
|
41847
|
+
|
41407
41848
|
}, {
|
41408
41849
|
key: "handlePushNotification",
|
41409
41850
|
value:
|
41410
41851
|
/**
|
41411
|
-
* Handle push notification payload parsing and emit the
|
41852
|
+
* Handle push notification payload parsing and emit the
|
41853
|
+
* {@link Client.pushNotification} event on this {@link Client} instance.
|
41412
41854
|
* @param notificationPayload Push notification payload
|
41413
41855
|
*/
|
41414
41856
|
function () {
|
@@ -41421,7 +41863,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
41421
41863
|
return this._ensureReady;
|
41422
41864
|
|
41423
41865
|
case 2:
|
41424
|
-
|
41866
|
+
Client_1._logger.debug("handlePushNotification, notificationPayload=", notificationPayload);
|
41867
|
+
|
41425
41868
|
this.emit("pushNotification", Client_1.parsePushNotification(notificationPayload));
|
41426
41869
|
|
41427
41870
|
case 4:
|
@@ -41432,14 +41875,15 @@ this.Twilio.Conversations = (function (exports) {
|
|
41432
41875
|
}, _callee12, this);
|
41433
41876
|
}));
|
41434
41877
|
|
41435
|
-
function handlePushNotification(
|
41878
|
+
function handlePushNotification(_x11) {
|
41436
41879
|
return _handlePushNotification.apply(this, arguments);
|
41437
41880
|
}
|
41438
41881
|
|
41439
41882
|
return handlePushNotification;
|
41440
41883
|
}()
|
41441
41884
|
/**
|
41442
|
-
* Gets a user with the given identity. If it's in the subscribed list, then
|
41885
|
+
* Gets a user with the given identity. If it's in the subscribed list, then
|
41886
|
+
* return the user object from it;
|
41443
41887
|
* if not, then subscribe and add user to the subscribed list.
|
41444
41888
|
* @param identity Identity of the user.
|
41445
41889
|
* @returns A fully initialized user.
|
@@ -41457,7 +41901,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41457
41901
|
return this._ensureReady;
|
41458
41902
|
|
41459
41903
|
case 2:
|
41460
|
-
return _context13.abrupt("return", this.
|
41904
|
+
return _context13.abrupt("return", this._services.users.getUser(identity));
|
41461
41905
|
|
41462
41906
|
case 3:
|
41463
41907
|
case "end":
|
@@ -41467,7 +41911,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41467
41911
|
}, _callee13, this);
|
41468
41912
|
}));
|
41469
41913
|
|
41470
|
-
function getUser(
|
41914
|
+
function getUser(_x12) {
|
41471
41915
|
return _getUser.apply(this, arguments);
|
41472
41916
|
}
|
41473
41917
|
|
@@ -41489,7 +41933,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41489
41933
|
return this._ensureReady;
|
41490
41934
|
|
41491
41935
|
case 2:
|
41492
|
-
return _context14.abrupt("return", this.
|
41936
|
+
return _context14.abrupt("return", this._services.users.getSubscribedUsers());
|
41493
41937
|
|
41494
41938
|
case 3:
|
41495
41939
|
case "end":
|
@@ -41505,52 +41949,254 @@ this.Twilio.Conversations = (function (exports) {
|
|
41505
41949
|
|
41506
41950
|
return getSubscribedUsers;
|
41507
41951
|
}()
|
41508
|
-
|
41509
|
-
|
41510
|
-
|
41511
|
-
|
41512
|
-
|
41952
|
+
/**
|
41953
|
+
* Get content URLs for all media attachments in the given set of media sids
|
41954
|
+
* using a single operation.
|
41955
|
+
* @param mediaSids Set of media sids to query for the content URL.
|
41956
|
+
*/
|
41957
|
+
|
41958
|
+
}, {
|
41959
|
+
key: "getTemporaryContentUrlsForMediaSids",
|
41960
|
+
value: function getTemporaryContentUrlsForMediaSids(mediaSids) {
|
41961
|
+
var _this2 = this;
|
41962
|
+
|
41963
|
+
return new browser.CancellablePromise( /*#__PURE__*/function () {
|
41964
|
+
var _ref2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee15(resolve, reject, onCancel) {
|
41965
|
+
var request, urls;
|
41966
|
+
return _regeneratorRuntime$1.wrap(function _callee15$(_context15) {
|
41967
|
+
while (1) {
|
41968
|
+
switch (_context15.prev = _context15.next) {
|
41969
|
+
case 0:
|
41970
|
+
if (!(!_this2._services.mcsClient || !mediaSids)) {
|
41971
|
+
_context15.next = 3;
|
41972
|
+
break;
|
41973
|
+
}
|
41974
|
+
|
41975
|
+
reject(new Error("Media Content Service is unavailable"));
|
41976
|
+
return _context15.abrupt("return");
|
41977
|
+
|
41978
|
+
case 3:
|
41979
|
+
request = _this2._services.mcsClient.mediaSetGetContentUrls(mediaSids);
|
41980
|
+
onCancel(function () {
|
41981
|
+
request.cancel();
|
41982
|
+
});
|
41983
|
+
_context15.prev = 5;
|
41984
|
+
_context15.next = 8;
|
41985
|
+
return request;
|
41986
|
+
|
41987
|
+
case 8:
|
41988
|
+
urls = _context15.sent;
|
41989
|
+
resolve(urls);
|
41990
|
+
_context15.next = 15;
|
41991
|
+
break;
|
41992
|
+
|
41993
|
+
case 12:
|
41994
|
+
_context15.prev = 12;
|
41995
|
+
_context15.t0 = _context15["catch"](5);
|
41996
|
+
reject(_context15.t0);
|
41997
|
+
|
41998
|
+
case 15:
|
41999
|
+
case "end":
|
42000
|
+
return _context15.stop();
|
42001
|
+
}
|
42002
|
+
}
|
42003
|
+
}, _callee15, null, [[5, 12]]);
|
42004
|
+
}));
|
42005
|
+
|
42006
|
+
return function (_x13, _x14, _x15) {
|
42007
|
+
return _ref2.apply(this, arguments);
|
42008
|
+
};
|
42009
|
+
}());
|
41513
42010
|
}
|
41514
42011
|
/**
|
41515
|
-
*
|
41516
|
-
*
|
41517
|
-
*
|
41518
|
-
* Parameters:
|
41519
|
-
* 1. {@link Conversation} `conversation` - the conversation in question
|
41520
|
-
* @event
|
42012
|
+
* Get content URLs for all media attachments in the given set using a single
|
42013
|
+
* operation.
|
42014
|
+
* @param contentSet Set of media attachments to query content URLs.
|
41521
42015
|
*/
|
41522
42016
|
|
41523
42017
|
}, {
|
41524
|
-
key: "
|
41525
|
-
value:
|
42018
|
+
key: "getTemporaryContentUrlsForMedia",
|
42019
|
+
value: function getTemporaryContentUrlsForMedia(contentSet) {
|
42020
|
+
// We ignore existing mcsMedia members of each of the media entries.
|
42021
|
+
// Instead, we just collect their sids and pull new descriptors from a
|
42022
|
+
// mediaSet GET endpoint.
|
42023
|
+
var sids = contentSet.map(function (m) {
|
42024
|
+
return m.sid;
|
42025
|
+
});
|
42026
|
+
return this.getTemporaryContentUrlsForMediaSids(sids);
|
42027
|
+
}
|
41526
42028
|
/**
|
41527
|
-
*
|
41528
|
-
*
|
41529
|
-
* Factory method to create a Conversations client instance.
|
41530
|
-
*
|
41531
|
-
* The factory method will automatically trigger connection.
|
41532
|
-
* Do not use it if you need finer-grained control.
|
41533
|
-
*
|
41534
|
-
* Since this method returns an already-initialized client, some of the events
|
41535
|
-
* will be lost because they happen *before* the initialization. It is
|
41536
|
-
* recommended that `client.onWithReplay` is used as opposed to `client.on`
|
41537
|
-
* for subscribing to client events. The `client.onWithReplay` will re-emit
|
41538
|
-
* the most recent value for a given event if it emitted before the
|
41539
|
-
* subscription.
|
41540
|
-
*
|
41541
|
-
* @param token Access token.
|
41542
|
-
* @param options Options to customize the client.
|
41543
|
-
* @returns Returns a fully initialized client.
|
42029
|
+
* Initialize the client.
|
41544
42030
|
*/
|
41545
|
-
|
41546
|
-
|
42031
|
+
|
42032
|
+
}, {
|
42033
|
+
key: "_initialize",
|
42034
|
+
value: function () {
|
42035
|
+
var _initialize2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee16() {
|
42036
|
+
var _this3 = this;
|
42037
|
+
|
42038
|
+
var configurationResponse;
|
42039
|
+
return _regeneratorRuntime$1.wrap(function _callee16$(_context16) {
|
42040
|
+
while (1) {
|
42041
|
+
switch (_context16.prev = _context16.next) {
|
42042
|
+
case 0:
|
42043
|
+
_context16.next = 2;
|
42044
|
+
return this._services.commandExecutor.fetchResource("Client/v2/Configuration");
|
42045
|
+
|
42046
|
+
case 2:
|
42047
|
+
configurationResponse = _context16.sent;
|
42048
|
+
this._configuration = new Configuration$1(this._options, configurationResponse, Client_1._logger);
|
42049
|
+
|
42050
|
+
this._myself._resolveInitialization(this._configuration, this._configuration.userIdentity, this._configuration.userInfo, true);
|
42051
|
+
|
42052
|
+
this._services.typingIndicator = new TypingIndicator(this.getConversationBySid.bind(this), this._configuration, this._services);
|
42053
|
+
this._services.network = new Network(this._configuration, this._services);
|
42054
|
+
this._services.users = new Users(this._myself, this._configuration, this._services);
|
42055
|
+
|
42056
|
+
this._services.users.on("userSubscribed", function (user) {
|
42057
|
+
_this3.emit("userSubscribed", user);
|
42058
|
+
});
|
42059
|
+
|
42060
|
+
this._services.users.on("userUpdated", function (args) {
|
42061
|
+
return _this3.emit("userUpdated", args);
|
42062
|
+
});
|
42063
|
+
|
42064
|
+
this._services.users.on("userUnsubscribed", function (user) {
|
42065
|
+
_this3.emit("userUnsubscribed", user);
|
42066
|
+
});
|
42067
|
+
|
42068
|
+
this._conversations = new Conversations(this._configuration, this._services);
|
42069
|
+
|
42070
|
+
this._conversations.on("conversationAdded", function (conversation) {
|
42071
|
+
_this3.emit("conversationAdded", conversation);
|
42072
|
+
});
|
42073
|
+
|
42074
|
+
this._conversations.on("conversationRemoved", function (conversation) {
|
42075
|
+
_this3.emit("conversationRemoved", conversation);
|
42076
|
+
});
|
42077
|
+
|
42078
|
+
this._conversations.on("conversationJoined", function (conversation) {
|
42079
|
+
_this3.emit("conversationJoined", conversation);
|
42080
|
+
});
|
42081
|
+
|
42082
|
+
this._conversations.on("conversationLeft", function (conversation) {
|
42083
|
+
_this3.emit("conversationLeft", conversation);
|
42084
|
+
});
|
42085
|
+
|
42086
|
+
this._conversations.on("conversationUpdated", function (args) {
|
42087
|
+
return _this3.emit("conversationUpdated", args);
|
42088
|
+
});
|
42089
|
+
|
42090
|
+
this._conversations.on("participantJoined", function (participant) {
|
42091
|
+
_this3.emit("participantJoined", participant);
|
42092
|
+
});
|
42093
|
+
|
42094
|
+
this._conversations.on("participantLeft", function (participant) {
|
42095
|
+
_this3.emit("participantLeft", participant);
|
42096
|
+
});
|
42097
|
+
|
42098
|
+
this._conversations.on("participantUpdated", function (args) {
|
42099
|
+
return _this3.emit("participantUpdated", args);
|
42100
|
+
});
|
42101
|
+
|
42102
|
+
this._conversations.on("messageAdded", function (message) {
|
42103
|
+
return _this3.emit("messageAdded", message);
|
42104
|
+
});
|
42105
|
+
|
42106
|
+
this._conversations.on("messageUpdated", function (args) {
|
42107
|
+
return _this3.emit("messageUpdated", args);
|
42108
|
+
});
|
42109
|
+
|
42110
|
+
this._conversations.on("messageRemoved", function (message) {
|
42111
|
+
return _this3.emit("messageRemoved", message);
|
42112
|
+
});
|
42113
|
+
|
42114
|
+
this._conversations.on("typingStarted", function (participant) {
|
42115
|
+
return _this3.emit("typingStarted", participant);
|
42116
|
+
});
|
42117
|
+
|
42118
|
+
this._conversations.on("typingEnded", function (participant) {
|
42119
|
+
return _this3.emit("typingEnded", participant);
|
42120
|
+
});
|
42121
|
+
|
42122
|
+
this._conversationsPromise = this._conversations.fetchConversations().then(function () {
|
42123
|
+
return _this3._conversations;
|
42124
|
+
}).catch(function (error) {
|
42125
|
+
throw error;
|
42126
|
+
});
|
42127
|
+
_context16.next = 28;
|
42128
|
+
return this._services.users.myself._ensureFetched();
|
42129
|
+
|
42130
|
+
case 28:
|
42131
|
+
Client_1._supportedPushChannels.forEach(function (channelType) {
|
42132
|
+
return _this3._subscribeToPushNotifications(channelType);
|
42133
|
+
});
|
42134
|
+
|
42135
|
+
this._services.typingIndicator.initialize();
|
42136
|
+
|
42137
|
+
this._services.mcsClient = new browser.McsClient(this._fpaToken, this._configuration.links.mediaService, this._configuration.links.mediaSetService, _objectSpread(_objectSpread({}, this._options), {}, {
|
42138
|
+
transport: undefined
|
42139
|
+
}));
|
42140
|
+
|
42141
|
+
this._resolveEnsureReady();
|
42142
|
+
|
42143
|
+
this.emit("stateChanged", {
|
42144
|
+
state: "initialized"
|
42145
|
+
});
|
42146
|
+
|
42147
|
+
case 33:
|
42148
|
+
case "end":
|
42149
|
+
return _context16.stop();
|
42150
|
+
}
|
42151
|
+
}
|
42152
|
+
}, _callee16, this);
|
42153
|
+
}));
|
42154
|
+
|
42155
|
+
function _initialize() {
|
42156
|
+
return _initialize2.apply(this, arguments);
|
42157
|
+
}
|
42158
|
+
|
42159
|
+
return _initialize;
|
42160
|
+
}()
|
42161
|
+
/**
|
42162
|
+
* Subscribe to push notifications.
|
42163
|
+
* @param channelType The channel type to subscribe to.
|
42164
|
+
*/
|
42165
|
+
|
42166
|
+
}, {
|
42167
|
+
key: "_subscribeToPushNotifications",
|
42168
|
+
value: function _subscribeToPushNotifications(channelType) {
|
42169
|
+
var _this4 = this;
|
42170
|
+
|
42171
|
+
[NotificationTypes.NEW_MESSAGE, NotificationTypes.ADDED_TO_CONVERSATION, NotificationTypes.REMOVED_FROM_CONVERSATION, NotificationTypes.TYPING_INDICATOR, NotificationTypes.CONSUMPTION_UPDATE].forEach(function (messageType) {
|
42172
|
+
_this4._services.notificationClient.subscribe(channelType, messageType);
|
42173
|
+
});
|
42174
|
+
}
|
42175
|
+
/**
|
42176
|
+
* Unsubscribe from push notifications.
|
42177
|
+
* @param channelType The channel type to unsubscribe from.
|
42178
|
+
*/
|
42179
|
+
|
42180
|
+
}, {
|
42181
|
+
key: "_unsubscribeFromPushNotifications",
|
42182
|
+
value: function _unsubscribeFromPushNotifications(channelType) {
|
42183
|
+
var _this5 = this;
|
42184
|
+
|
42185
|
+
[NotificationTypes.NEW_MESSAGE, NotificationTypes.ADDED_TO_CONVERSATION, NotificationTypes.REMOVED_FROM_CONVERSATION, NotificationTypes.TYPING_INDICATOR, NotificationTypes.CONSUMPTION_UPDATE].forEach(function (messageType) {
|
42186
|
+
_this5._services.notificationClient.unsubscribe(channelType, messageType);
|
42187
|
+
});
|
42188
|
+
}
|
42189
|
+
}], [{
|
42190
|
+
key: "create",
|
42191
|
+
value: function () {
|
42192
|
+
var _create = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee17(token, options) {
|
41547
42193
|
var client;
|
41548
|
-
return _regeneratorRuntime$1.wrap(function
|
42194
|
+
return _regeneratorRuntime$1.wrap(function _callee17$(_context17) {
|
41549
42195
|
while (1) {
|
41550
|
-
switch (
|
42196
|
+
switch (_context17.prev = _context17.next) {
|
41551
42197
|
case 0:
|
41552
42198
|
if (!(options !== null && options !== void 0 && options.twilsockClient)) {
|
41553
|
-
|
42199
|
+
_context17.next = 2;
|
41554
42200
|
break;
|
41555
42201
|
}
|
41556
42202
|
|
@@ -41558,64 +42204,45 @@ this.Twilio.Conversations = (function (exports) {
|
|
41558
42204
|
|
41559
42205
|
case 2:
|
41560
42206
|
client = new Client_1(token, options);
|
41561
|
-
|
42207
|
+
_context17.next = 5;
|
41562
42208
|
return client._ensureReady;
|
41563
42209
|
|
41564
42210
|
case 5:
|
41565
|
-
return
|
42211
|
+
return _context17.abrupt("return", client);
|
41566
42212
|
|
41567
42213
|
case 6:
|
41568
42214
|
case "end":
|
41569
|
-
return
|
42215
|
+
return _context17.stop();
|
41570
42216
|
}
|
41571
42217
|
}
|
41572
|
-
},
|
42218
|
+
}, _callee17);
|
41573
42219
|
}));
|
41574
42220
|
|
41575
|
-
function create(
|
42221
|
+
function create(_x16, _x17) {
|
41576
42222
|
return _create.apply(this, arguments);
|
41577
42223
|
}
|
41578
42224
|
|
41579
42225
|
return create;
|
41580
42226
|
}()
|
41581
|
-
}, {
|
41582
|
-
key: "parsePushNotificationChatData",
|
41583
|
-
value: function parsePushNotificationChatData(data) {
|
41584
|
-
var result = {};
|
41585
|
-
|
41586
|
-
for (var key in Client_1.supportedPushDataFields) {
|
41587
|
-
if (typeof data[key] === "undefined" || data[key] === null) {
|
41588
|
-
continue;
|
41589
|
-
}
|
41590
|
-
|
41591
|
-
if (key !== "message_index") {
|
41592
|
-
result[Client_1.supportedPushDataFields[key]] = data[key];
|
41593
|
-
continue;
|
41594
|
-
}
|
41595
|
-
|
41596
|
-
if (parseToNumber(data[key]) !== null) {
|
41597
|
-
result[Client_1.supportedPushDataFields[key]] = Number(data[key]);
|
41598
|
-
}
|
41599
|
-
}
|
41600
|
-
|
41601
|
-
return result;
|
41602
|
-
}
|
41603
42227
|
/**
|
41604
|
-
* Static method for push notification payload parsing. Returns parsed push as
|
42228
|
+
* Static method for push notification payload parsing. Returns parsed push as
|
42229
|
+
* a {@link PushNotification} object.
|
41605
42230
|
* @param notificationPayload Push notification payload.
|
41606
42231
|
*/
|
41607
42232
|
|
41608
42233
|
}, {
|
41609
42234
|
key: "parsePushNotification",
|
41610
42235
|
value: function parsePushNotification(notificationPayload) {
|
41611
|
-
|
42236
|
+
Client_1._logger.debug("parsePushNotification, notificationPayload=", notificationPayload); // APNS specifics
|
42237
|
+
|
41612
42238
|
|
41613
42239
|
if (typeof notificationPayload.aps !== "undefined") {
|
41614
42240
|
if (!notificationPayload.twi_message_type) {
|
41615
42241
|
throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
|
41616
42242
|
}
|
41617
42243
|
|
41618
|
-
var data = Client_1.
|
42244
|
+
var data = Client_1._parsePushNotificationChatData(notificationPayload);
|
42245
|
+
|
41619
42246
|
var apsPayload = notificationPayload.aps;
|
41620
42247
|
var body;
|
41621
42248
|
var title = null;
|
@@ -41646,7 +42273,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
41646
42273
|
throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");
|
41647
42274
|
}
|
41648
42275
|
|
41649
|
-
var _data = Client_1.
|
42276
|
+
var _data = Client_1._parsePushNotificationChatData(notificationPayload.data);
|
41650
42277
|
|
41651
42278
|
return new PushNotification({
|
41652
42279
|
title: dataPayload.twi_title || null,
|
@@ -41661,19 +42288,80 @@ this.Twilio.Conversations = (function (exports) {
|
|
41661
42288
|
|
41662
42289
|
throw new Error("Provided push notification payload is not Programmable Chat notification");
|
41663
42290
|
}
|
42291
|
+
/**
|
42292
|
+
* Static method for parsing push notification chat data.
|
42293
|
+
* @param data Data to parse
|
42294
|
+
*/
|
42295
|
+
|
42296
|
+
}, {
|
42297
|
+
key: "_parsePushNotificationChatData",
|
42298
|
+
value: function _parsePushNotificationChatData(data) {
|
42299
|
+
var result = {};
|
42300
|
+
|
42301
|
+
for (var key in Client_1._supportedPushDataFields) {
|
42302
|
+
var value = data[key];
|
42303
|
+
|
42304
|
+
if (typeof value === "undefined" || value === null) {
|
42305
|
+
continue;
|
42306
|
+
}
|
42307
|
+
|
42308
|
+
if (key === "message_index" || key === "media_count") {
|
42309
|
+
var number = parseToNumber(value);
|
42310
|
+
|
42311
|
+
if (number !== null) {
|
42312
|
+
result[Client_1._supportedPushDataFields[key]] = number;
|
42313
|
+
}
|
42314
|
+
|
42315
|
+
continue;
|
42316
|
+
}
|
42317
|
+
|
42318
|
+
if (key === "media") {
|
42319
|
+
if (typeof value === "string") {
|
42320
|
+
try {
|
42321
|
+
result[Client_1._supportedPushDataFields[key]] = JSON.parse(value);
|
42322
|
+
} catch (_unused) {
|
42323
|
+
Client_1._logger.debug("Media message notification parsing error");
|
42324
|
+
}
|
42325
|
+
}
|
42326
|
+
|
42327
|
+
continue;
|
42328
|
+
}
|
42329
|
+
|
42330
|
+
result[Client_1._supportedPushDataFields[key]] = value;
|
42331
|
+
}
|
42332
|
+
|
42333
|
+
return result;
|
42334
|
+
}
|
42335
|
+
/**
|
42336
|
+
* Populate the client with init registrations.
|
42337
|
+
* @param reg The init registration to populate.
|
42338
|
+
*/
|
42339
|
+
|
42340
|
+
}, {
|
42341
|
+
key: "populateInitRegistrations",
|
42342
|
+
value: function populateInitRegistrations(reg) {
|
42343
|
+
reg.populateInitRegistrations([NotificationTypes.TYPING_INDICATOR]);
|
42344
|
+
SyncClient.populateInitRegistrations(reg);
|
42345
|
+
}
|
41664
42346
|
}]);
|
41665
42347
|
|
41666
42348
|
return Client;
|
41667
|
-
}(ReplayEventEmitter_1), _defineProperty$3(_class, "version",
|
42349
|
+
}(ReplayEventEmitter_1), _defineProperty$3(_class, "conversationAdded", "conversationAdded"), _defineProperty$3(_class, "conversationJoined", "conversationJoined"), _defineProperty$3(_class, "conversationLeft", "conversationLeft"), _defineProperty$3(_class, "conversationRemoved", "conversationRemoved"), _defineProperty$3(_class, "conversationUpdated", "conversationUpdated"), _defineProperty$3(_class, "participantJoined", "participantJoined"), _defineProperty$3(_class, "participantLeft", "participantLeft"), _defineProperty$3(_class, "participantUpdated", "participantUpdated"), _defineProperty$3(_class, "messageAdded", "messageAdded"), _defineProperty$3(_class, "messageRemoved", "messageRemoved"), _defineProperty$3(_class, "messageUpdated", "messageUpdated"), _defineProperty$3(_class, "tokenAboutToExpire", "tokenAboutToExpire"), _defineProperty$3(_class, "tokenExpired", "tokenExpired"), _defineProperty$3(_class, "typingEnded", "typingEnded"), _defineProperty$3(_class, "typingStarted", "typingStarted"), _defineProperty$3(_class, "pushNotification", "pushNotification"), _defineProperty$3(_class, "userSubscribed", "userSubscribed"), _defineProperty$3(_class, "userUnsubscribed", "userUnsubscribed"), _defineProperty$3(_class, "userUpdated", "userUpdated"), _defineProperty$3(_class, "stateChanged", "stateChanged"), _defineProperty$3(_class, "connectionStateChanged", "connectionStateChanged"), _defineProperty$3(_class, "connectionError", "connectionError"), _defineProperty$3(_class, "version", version), _defineProperty$3(_class, "_logger", Logger.scope("Client")), _defineProperty$3(_class, "_supportedPushChannels", ["fcm", "apn"]), _defineProperty$3(_class, "_supportedPushDataFields", {
|
41668
42350
|
conversation_sid: "conversationSid",
|
42351
|
+
conversation_title: "conversationTitle",
|
41669
42352
|
message_sid: "messageSid",
|
41670
|
-
message_index: "messageIndex"
|
41671
|
-
|
42353
|
+
message_index: "messageIndex",
|
42354
|
+
media_count: "mediaCount",
|
42355
|
+
media: "media" // object
|
42356
|
+
|
42357
|
+
}), _temp);
|
41672
42358
|
|
41673
42359
|
__decorate$1([validateTypesAsync_1(nonEmptyString_1), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String]), __metadata$1("design:returntype", Promise)], exports.Client.prototype, "updateToken", null);
|
41674
42360
|
|
41675
42361
|
__decorate$1([validateTypesAsync_1(nonEmptyString_1), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String]), __metadata$1("design:returntype", Promise)], exports.Client.prototype, "getConversationBySid", null);
|
41676
42362
|
|
42363
|
+
__decorate$1([validateTypesAsync_1(nonEmptyString_1), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String]), __metadata$1("design:returntype", Promise)], exports.Client.prototype, "peekConversationBySid", null);
|
42364
|
+
|
41677
42365
|
__decorate$1([validateTypesAsync_1(nonEmptyString_1), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String]), __metadata$1("design:returntype", Promise)], exports.Client.prototype, "getConversationByUniqueName", null);
|
41678
42366
|
|
41679
42367
|
__decorate$1([validateTypesAsync_1(["undefined", objectSchema_1("conversation options", {
|