@twilio/conversations 3.0.0-canary.100 → 3.0.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builds/browser.js +599 -436
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +6 -2
- package/builds/lib.js +599 -436
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +3599 -2598
- package/builds/twilio-conversations.min.js +1 -1
- package/dist/client.js +6 -7
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +16 -9
- package/dist/command-executor.js.map +1 -1
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +1 -4
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/users.js +1 -3
- package/dist/data/users.js.map +1 -1
- package/dist/message.js +0 -1
- package/dist/message.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/participant.js +33 -33
- package/dist/participant.js.map +1 -1
- package/dist/rest-paginator.js +11 -11
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +95 -26
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +12 -6
- package/dist/services/typing-indicator.js.map +1 -1
- package/package.json +10 -10
package/builds/lib.js
CHANGED
@@ -172,15 +172,17 @@ require('core-js/modules/es.function.name.js');
|
|
172
172
|
require('core-js/modules/es.regexp.test.js');
|
173
173
|
require('core-js/modules/es.symbol.description.js');
|
174
174
|
require('core-js/modules/es.symbol.iterator.js');
|
175
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
175
176
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
176
177
|
require('core-js/modules/es.map.js');
|
178
|
+
require('core-js/modules/es.set.js');
|
177
179
|
var operationRetrier = require('@twilio/operation-retrier');
|
178
180
|
var twilsock = require('twilsock');
|
181
|
+
var syncerror = require('twilio-sync/src/utils/syncerror');
|
182
|
+
var shared = require('@twilio/shared');
|
179
183
|
var notifications = require('@twilio/notifications');
|
180
184
|
var twilioSync = require('twilio-sync');
|
181
185
|
var mcsClient = require('@twilio/mcs-client');
|
182
|
-
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
183
|
-
require('core-js/modules/es.set.js');
|
184
186
|
require('core-js/modules/es.number.is-integer.js');
|
185
187
|
require('core-js/modules/es.typed-array.uint8-array.js');
|
186
188
|
require('core-js/modules/es.typed-array.at.js');
|
@@ -250,8 +252,8 @@ var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regenerat
|
|
250
252
|
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
251
253
|
var loglevelLog__namespace = /*#__PURE__*/_interopNamespace(loglevelLog);
|
252
254
|
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
253
|
-
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
254
255
|
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
256
|
+
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
255
257
|
|
256
258
|
function __decorate(decorators, target, key, desc) {
|
257
259
|
var c = arguments.length,
|
@@ -829,10 +831,11 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
829
831
|
return _ensureFetched2.apply(this, arguments);
|
830
832
|
}
|
831
833
|
return _ensureFetched;
|
832
|
-
}()
|
833
|
-
|
834
|
-
|
835
|
-
|
834
|
+
}()
|
835
|
+
/**
|
836
|
+
* Edit user attributes.
|
837
|
+
* @param attributes New attributes.
|
838
|
+
*/
|
836
839
|
}, {
|
837
840
|
key: "updateAttributes",
|
838
841
|
value: function () {
|
@@ -867,10 +870,11 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
867
870
|
return _updateAttributes.apply(this, arguments);
|
868
871
|
}
|
869
872
|
return updateAttributes;
|
870
|
-
}()
|
871
|
-
|
872
|
-
|
873
|
-
|
873
|
+
}()
|
874
|
+
/**
|
875
|
+
* Update the friendly name of the user.
|
876
|
+
* @param friendlyName New friendly name.
|
877
|
+
*/
|
874
878
|
}, {
|
875
879
|
key: "updateFriendlyName",
|
876
880
|
value: function () {
|
@@ -905,10 +909,11 @@ var User = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
905
909
|
return _updateFriendlyName.apply(this, arguments);
|
906
910
|
}
|
907
911
|
return updateFriendlyName;
|
908
|
-
}()
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
+
}()
|
913
|
+
/**
|
914
|
+
* Remove the user from the subscription list.
|
915
|
+
* @return A promise of completion.
|
916
|
+
*/
|
912
917
|
}, {
|
913
918
|
key: "unsubscribe",
|
914
919
|
value: function () {
|
@@ -969,6 +974,36 @@ __decorate([declarativeTypeValidator.validateTypesAsync(["string"]), __metadata(
|
|
969
974
|
function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
970
975
|
function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
|
971
976
|
function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
977
|
+
function messageFromErrorBody(transportError, payload) {
|
978
|
+
if (payload !== null && payload !== void 0 && payload.message) {
|
979
|
+
return payload.message;
|
980
|
+
}
|
981
|
+
switch (transportError.statusCode) {
|
982
|
+
case 429:
|
983
|
+
return "Throttled by server";
|
984
|
+
case 404:
|
985
|
+
return "Not found from server";
|
986
|
+
default:
|
987
|
+
return "Error from server";
|
988
|
+
}
|
989
|
+
}
|
990
|
+
function codeFromErrorBody(payload) {
|
991
|
+
var _payload$code;
|
992
|
+
return (_payload$code = payload === null || payload === void 0 ? void 0 : payload.code) !== null && _payload$code !== void 0 ? _payload$code : 0;
|
993
|
+
}
|
994
|
+
function mapTransportError(transportError, payload) {
|
995
|
+
if (transportError.statusCode === 409) {
|
996
|
+
return new syncerror.SyncNetworkError(messageFromErrorBody(transportError, payload), transportError.statusCode, codeFromErrorBody(payload), payload);
|
997
|
+
} else if (transportError.statusCode) {
|
998
|
+
return new syncerror.SyncError(messageFromErrorBody(transportError, payload), transportError.statusCode, codeFromErrorBody(payload));
|
999
|
+
// todo: still idk
|
1000
|
+
} else if (transportError instanceof shared.TwilioError && transportError.errorInfo.reason === "transportDisconnected") {
|
1001
|
+
return transportError;
|
1002
|
+
} else {
|
1003
|
+
var _ref, _payload$message;
|
1004
|
+
return new syncerror.SyncError((_ref = (_payload$message = payload === null || payload === void 0 ? void 0 : payload.message) !== null && _payload$message !== void 0 ? _payload$message : transportError.message) !== null && _ref !== void 0 ? _ref : "Unexpected error", 0, 0);
|
1005
|
+
}
|
1006
|
+
}
|
972
1007
|
var Network = /*#__PURE__*/function () {
|
973
1008
|
function Network(configuration, services) {
|
974
1009
|
_classCallCheck__default["default"](this, Network);
|
@@ -977,10 +1012,13 @@ var Network = /*#__PURE__*/function () {
|
|
977
1012
|
_defineProperty__default["default"](this, "cacheLifetime", void 0);
|
978
1013
|
_defineProperty__default["default"](this, "cache", void 0);
|
979
1014
|
_defineProperty__default["default"](this, "timer", void 0);
|
1015
|
+
_defineProperty__default["default"](this, "pendingRequests", void 0);
|
1016
|
+
_defineProperty__default["default"](this, "isShutdownInitiated", false);
|
980
1017
|
this.configuration = configuration;
|
981
1018
|
this.services = services;
|
982
1019
|
this.cache = new Map();
|
983
1020
|
this.cacheLifetime = this.configuration.httpCacheInterval * 100;
|
1021
|
+
this.pendingRequests = new Set();
|
984
1022
|
this.cleanupCache();
|
985
1023
|
}
|
986
1024
|
_createClass__default["default"](Network, [{
|
@@ -1019,55 +1057,65 @@ var Network = /*#__PURE__*/function () {
|
|
1019
1057
|
return _this.cleanupCache();
|
1020
1058
|
}, this.cacheLifetime * 2);
|
1021
1059
|
}
|
1060
|
+
}, {
|
1061
|
+
key: "responsePostProcess",
|
1062
|
+
value: function responsePostProcess(response) {
|
1063
|
+
var body;
|
1064
|
+
try {
|
1065
|
+
body = JSON.parse(response.payload);
|
1066
|
+
} catch (_unused) {
|
1067
|
+
body = response.payload;
|
1068
|
+
}
|
1069
|
+
return {
|
1070
|
+
status: {
|
1071
|
+
code: response.statusCode,
|
1072
|
+
status: response.status
|
1073
|
+
},
|
1074
|
+
headers: response.headers,
|
1075
|
+
body: body
|
1076
|
+
};
|
1077
|
+
}
|
1022
1078
|
}, {
|
1023
1079
|
key: "executeWithRetry",
|
1024
1080
|
value: function executeWithRetry(request) {
|
1025
1081
|
var _this2 = this;
|
1082
|
+
var retryWhenThrottled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1026
1083
|
return new Promise(function (resolve, reject) {
|
1084
|
+
var codesToRetryOn = [502, 503, 504];
|
1085
|
+
if (retryWhenThrottled) {
|
1086
|
+
codesToRetryOn.push(429);
|
1087
|
+
}
|
1027
1088
|
var retrier = new operationRetrier.Retrier(_this2.configuration.backoffConfiguration);
|
1028
1089
|
retrier.on("attempt", function () {
|
1029
1090
|
request().then(function (result) {
|
1030
|
-
var isError = result.statusCode >= 400
|
1091
|
+
var isError = result.statusCode >= 400;
|
1031
1092
|
if (!isError) {
|
1032
1093
|
retrier.succeeded(result);
|
1033
1094
|
return;
|
1034
1095
|
}
|
1035
|
-
var parsedPayload =
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
if (
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
retrier.removeAllListeners();
|
1051
|
-
retrier.cancel();
|
1052
|
-
reject(mapTransportError(result, parsedPayload));
|
1053
|
-
}
|
1096
|
+
var parsedPayload = {};
|
1097
|
+
try {
|
1098
|
+
parsedPayload = JSON.parse(result.payload);
|
1099
|
+
} catch (_unused2) {}
|
1100
|
+
if (codesToRetryOn.includes(result.statusCode)) {
|
1101
|
+
var delayOverride = parseInt(result.headers ? result.headers["Retry-After"] : null);
|
1102
|
+
retrier.failed(mapTransportError(result, parsedPayload), isNaN(delayOverride) ? undefined : delayOverride * 1000);
|
1103
|
+
} else if (parsedPayload.message === "Twilsock disconnected") {
|
1104
|
+
// Ugly hack. We must make a proper exceptions for twilsock
|
1105
|
+
retrier.failed(mapTransportError(result, parsedPayload));
|
1106
|
+
} else {
|
1107
|
+
// Fatal error
|
1108
|
+
retrier.removeAllListeners();
|
1109
|
+
retrier.cancel();
|
1110
|
+
reject(mapTransportError(result, parsedPayload));
|
1054
1111
|
}
|
1055
|
-
*/
|
1056
1112
|
}).catch(function (err) {
|
1057
|
-
// if (codesToRetryOn.indexOf(err.status) > -1) {
|
1058
|
-
// retrier.failed(err);
|
1059
|
-
// } else if (err.message === "Twilsock disconnected") {
|
1060
|
-
// // Ugly hack. We must make a proper exceptions for twilsock
|
1061
|
-
// retrier.failed(err);
|
1062
|
-
// } else {
|
1063
1113
|
// Fatal error
|
1064
1114
|
retrier.removeAllListeners();
|
1065
1115
|
retrier.cancel();
|
1066
1116
|
reject(err);
|
1067
|
-
// }
|
1068
1117
|
});
|
1069
1118
|
});
|
1070
|
-
|
1071
1119
|
retrier.on("succeeded", function (result) {
|
1072
1120
|
resolve(result);
|
1073
1121
|
});
|
@@ -1085,34 +1133,44 @@ var Network = /*#__PURE__*/function () {
|
|
1085
1133
|
value: function () {
|
1086
1134
|
var _get = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(url) {
|
1087
1135
|
var _this3 = this;
|
1088
|
-
var cacheEntry, response;
|
1136
|
+
var cacheEntry, responsePromise, response, postprocessedResponse;
|
1089
1137
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
1090
1138
|
while (1) {
|
1091
1139
|
switch (_context.prev = _context.next) {
|
1092
1140
|
case 0:
|
1141
|
+
if (!this.isShutdownInitiated) {
|
1142
|
+
_context.next = 2;
|
1143
|
+
break;
|
1144
|
+
}
|
1145
|
+
throw new Error("Client has been shut down.");
|
1146
|
+
case 2:
|
1093
1147
|
cacheEntry = this.cache.get(url);
|
1094
1148
|
if (!(cacheEntry && !this.isExpired(cacheEntry.timestamp))) {
|
1095
|
-
_context.next =
|
1149
|
+
_context.next = 5;
|
1096
1150
|
break;
|
1097
1151
|
}
|
1098
1152
|
return _context.abrupt("return", cacheEntry.response);
|
1099
|
-
case
|
1100
|
-
|
1101
|
-
|
1102
|
-
return _this3.services.transport.get({
|
1153
|
+
case 5:
|
1154
|
+
responsePromise = this.executeWithRetry(function () {
|
1155
|
+
return _this3.services.transport.sendRequest(new twilsock.HttpRequest({
|
1103
1156
|
url: url,
|
1104
1157
|
grant: _this3.configuration.productId
|
1105
|
-
});
|
1158
|
+
}));
|
1106
1159
|
}, this.configuration.retryWhenThrottled);
|
1107
|
-
|
1160
|
+
this.pendingRequests.add(responsePromise);
|
1161
|
+
_context.next = 9;
|
1162
|
+
return responsePromise;
|
1163
|
+
case 9:
|
1108
1164
|
response = _context.sent;
|
1165
|
+
this.pendingRequests.delete(responsePromise);
|
1166
|
+
postprocessedResponse = this.responsePostProcess(response);
|
1109
1167
|
this.cache.set(url, {
|
1110
|
-
response:
|
1168
|
+
response: postprocessedResponse,
|
1111
1169
|
timestamp: Date.now()
|
1112
1170
|
});
|
1113
1171
|
this.pokeTimer();
|
1114
|
-
return _context.abrupt("return",
|
1115
|
-
case
|
1172
|
+
return _context.abrupt("return", postprocessedResponse);
|
1173
|
+
case 15:
|
1116
1174
|
case "end":
|
1117
1175
|
return _context.stop();
|
1118
1176
|
}
|
@@ -1124,6 +1182,39 @@ var Network = /*#__PURE__*/function () {
|
|
1124
1182
|
}
|
1125
1183
|
return get;
|
1126
1184
|
}()
|
1185
|
+
}, {
|
1186
|
+
key: "disconnect",
|
1187
|
+
value: function () {
|
1188
|
+
var _disconnect = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
|
1189
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
1190
|
+
while (1) {
|
1191
|
+
switch (_context2.prev = _context2.next) {
|
1192
|
+
case 0:
|
1193
|
+
this.isShutdownInitiated = true;
|
1194
|
+
_context2.prev = 1;
|
1195
|
+
_context2.next = 4;
|
1196
|
+
return Promise.all(_toConsumableArray__default["default"](this.pendingRequests));
|
1197
|
+
case 4:
|
1198
|
+
_context2.next = 8;
|
1199
|
+
break;
|
1200
|
+
case 6:
|
1201
|
+
_context2.prev = 6;
|
1202
|
+
_context2.t0 = _context2["catch"](1);
|
1203
|
+
case 8:
|
1204
|
+
_context2.next = 10;
|
1205
|
+
return this.services.syncClient.shutdown();
|
1206
|
+
case 10:
|
1207
|
+
case "end":
|
1208
|
+
return _context2.stop();
|
1209
|
+
}
|
1210
|
+
}
|
1211
|
+
}, _callee2, this, [[1, 6]]);
|
1212
|
+
}));
|
1213
|
+
function disconnect() {
|
1214
|
+
return _disconnect.apply(this, arguments);
|
1215
|
+
}
|
1216
|
+
return disconnect;
|
1217
|
+
}()
|
1127
1218
|
}]);
|
1128
1219
|
return Network;
|
1129
1220
|
}();
|
@@ -1403,9 +1494,10 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1403
1494
|
return _getUser.apply(this, arguments);
|
1404
1495
|
}
|
1405
1496
|
return getUser;
|
1406
|
-
}()
|
1407
|
-
|
1408
|
-
|
1497
|
+
}()
|
1498
|
+
/**
|
1499
|
+
* Remove the participant from the conversation.
|
1500
|
+
*/
|
1409
1501
|
}, {
|
1410
1502
|
key: "remove",
|
1411
1503
|
value: function () {
|
@@ -1426,10 +1518,11 @@ var Participant = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1426
1518
|
return _remove.apply(this, arguments);
|
1427
1519
|
}
|
1428
1520
|
return remove;
|
1429
|
-
}()
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1521
|
+
}()
|
1522
|
+
/**
|
1523
|
+
* Update the attributes of the participant.
|
1524
|
+
* @param attributes New attributes.
|
1525
|
+
*/
|
1433
1526
|
}, {
|
1434
1527
|
key: "updateAttributes",
|
1435
1528
|
value: function () {
|
@@ -1650,9 +1743,10 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1650
1743
|
return _upsertParticipant.apply(this, arguments);
|
1651
1744
|
}
|
1652
1745
|
return upsertParticipant;
|
1653
|
-
}()
|
1654
|
-
|
1655
|
-
|
1746
|
+
}()
|
1747
|
+
/**
|
1748
|
+
* @returns {Promise<Array<Participant>>} returns list of participants {@see Participant}
|
1749
|
+
*/
|
1656
1750
|
}, {
|
1657
1751
|
key: "getParticipants",
|
1658
1752
|
value: function () {
|
@@ -1680,10 +1774,11 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1680
1774
|
return _getParticipants.apply(this, arguments);
|
1681
1775
|
}
|
1682
1776
|
return getParticipants;
|
1683
|
-
}()
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1777
|
+
}()
|
1778
|
+
/**
|
1779
|
+
* Get participant by SID from conversation
|
1780
|
+
* @returns {Promise<Participant>}
|
1781
|
+
*/
|
1687
1782
|
}, {
|
1688
1783
|
key: "getParticipantBySid",
|
1689
1784
|
value: function () {
|
@@ -1711,10 +1806,11 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1711
1806
|
return _getParticipantBySid.apply(this, arguments);
|
1712
1807
|
}
|
1713
1808
|
return getParticipantBySid;
|
1714
|
-
}()
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1809
|
+
}()
|
1810
|
+
/**
|
1811
|
+
* Get participant by identity from conversation
|
1812
|
+
* @returns {Promise<Participant>}
|
1813
|
+
*/
|
1718
1814
|
}, {
|
1719
1815
|
key: "getParticipantByIdentity",
|
1720
1816
|
value: function () {
|
@@ -1748,9 +1844,10 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1748
1844
|
return _getParticipantByIdentity.apply(this, arguments);
|
1749
1845
|
}
|
1750
1846
|
return getParticipantByIdentity;
|
1751
|
-
}()
|
1752
|
-
|
1753
|
-
|
1847
|
+
}()
|
1848
|
+
/**
|
1849
|
+
* Add a chat participant to the conversation
|
1850
|
+
*/
|
1754
1851
|
}, {
|
1755
1852
|
key: "add",
|
1756
1853
|
value: function () {
|
@@ -1782,9 +1879,10 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1782
1879
|
return _add.apply(this, arguments);
|
1783
1880
|
}
|
1784
1881
|
return add;
|
1785
|
-
}()
|
1786
|
-
|
1787
|
-
|
1882
|
+
}()
|
1883
|
+
/**
|
1884
|
+
* Add a non-chat participant to the conversation.
|
1885
|
+
*/
|
1788
1886
|
}, {
|
1789
1887
|
key: "addNonChatParticipant",
|
1790
1888
|
value: function () {
|
@@ -1827,9 +1925,10 @@ var Participants = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
1827
1925
|
return _addNonChatParticipant.apply(this, arguments);
|
1828
1926
|
}
|
1829
1927
|
return addNonChatParticipant;
|
1830
|
-
}()
|
1831
|
-
|
1832
|
-
|
1928
|
+
}()
|
1929
|
+
/**
|
1930
|
+
* Remove the participant with a given identity from a conversation.
|
1931
|
+
*/
|
1833
1932
|
}, {
|
1834
1933
|
key: "remove",
|
1835
1934
|
value: function remove(identity) {
|
@@ -2062,7 +2161,8 @@ var Media = /*#__PURE__*/function () {
|
|
2062
2161
|
* errors (in the case of MMS for instance).
|
2063
2162
|
*
|
2064
2163
|
* {@link AggregatedDeliveryReceipt} class contains an aggregated value {@link DeliveryAmount} for each delivery status.
|
2065
|
-
*/
|
2164
|
+
*/
|
2165
|
+
var AggregatedDeliveryReceipt = /*#__PURE__*/function () {
|
2066
2166
|
/**
|
2067
2167
|
* @internal
|
2068
2168
|
*/
|
@@ -2157,7 +2257,8 @@ var Media = /*#__PURE__*/function () {
|
|
2157
2257
|
|
2158
2258
|
/**
|
2159
2259
|
* Pagination helper class.
|
2160
|
-
*/
|
2260
|
+
*/
|
2261
|
+
var RestPaginator = /*#__PURE__*/function () {
|
2161
2262
|
/**
|
2162
2263
|
* @internal
|
2163
2264
|
*/
|
@@ -2218,7 +2319,8 @@ var Media = /*#__PURE__*/function () {
|
|
2218
2319
|
|
2219
2320
|
/**
|
2220
2321
|
* Represents a delivery receipt of a message.
|
2221
|
-
*/
|
2322
|
+
*/
|
2323
|
+
var DetailedDeliveryReceipt = /*#__PURE__*/_createClass__default["default"](
|
2222
2324
|
/**
|
2223
2325
|
* Unique identifier for the delivery receipt.
|
2224
2326
|
*/
|
@@ -2630,9 +2732,10 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2630
2732
|
return _getParticipant.apply(this, arguments);
|
2631
2733
|
}
|
2632
2734
|
return getParticipant;
|
2633
|
-
}()
|
2634
|
-
|
2635
|
-
|
2735
|
+
}()
|
2736
|
+
/**
|
2737
|
+
* Get the delivery receipts of the message.
|
2738
|
+
*/
|
2636
2739
|
}, {
|
2637
2740
|
key: "getDetailedDeliveryReceipts",
|
2638
2741
|
value: function () {
|
@@ -2672,9 +2775,10 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2672
2775
|
return _getDetailedDeliveryReceipts.apply(this, arguments);
|
2673
2776
|
}
|
2674
2777
|
return getDetailedDeliveryReceipts;
|
2675
|
-
}()
|
2676
|
-
|
2677
|
-
|
2778
|
+
}()
|
2779
|
+
/**
|
2780
|
+
* Remove the message.
|
2781
|
+
*/
|
2678
2782
|
}, {
|
2679
2783
|
key: "remove",
|
2680
2784
|
value: function () {
|
@@ -2698,10 +2802,11 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2698
2802
|
return _remove.apply(this, arguments);
|
2699
2803
|
}
|
2700
2804
|
return remove;
|
2701
|
-
}()
|
2702
|
-
|
2703
|
-
|
2704
|
-
|
2805
|
+
}()
|
2806
|
+
/**
|
2807
|
+
* Edit the message body.
|
2808
|
+
* @param body New body of the message.
|
2809
|
+
*/
|
2705
2810
|
}, {
|
2706
2811
|
key: "updateBody",
|
2707
2812
|
value: function () {
|
@@ -2727,10 +2832,11 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2727
2832
|
return _updateBody.apply(this, arguments);
|
2728
2833
|
}
|
2729
2834
|
return updateBody;
|
2730
|
-
}()
|
2731
|
-
|
2732
|
-
|
2733
|
-
|
2835
|
+
}()
|
2836
|
+
/**
|
2837
|
+
* Edit the message attributes.
|
2838
|
+
* @param attributes New attributes.
|
2839
|
+
*/
|
2734
2840
|
}, {
|
2735
2841
|
key: "updateAttributes",
|
2736
2842
|
value: function () {
|
@@ -2756,10 +2862,11 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2756
2862
|
return _updateAttributes.apply(this, arguments);
|
2757
2863
|
}
|
2758
2864
|
return updateAttributes;
|
2759
|
-
}()
|
2760
|
-
|
2761
|
-
|
2762
|
-
|
2865
|
+
}()
|
2866
|
+
/**
|
2867
|
+
* Get content URLs for all media attachments in the given set using a single operation.
|
2868
|
+
* @param contentSet Set of media attachments to query content URLs.
|
2869
|
+
*/
|
2763
2870
|
}, {
|
2764
2871
|
key: "getTemporaryContentUrlsForMedia",
|
2765
2872
|
value: function getTemporaryContentUrlsForMedia(contentSet) {
|
@@ -2844,7 +2951,7 @@ var Message = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
2844
2951
|
switch (_context7.prev = _context7.next) {
|
2845
2952
|
case 0:
|
2846
2953
|
messagesReceiptsUrl = this.configuration.links.messagesReceipts.replace("%s", this.conversation.sid).replace("%s", this.sid);
|
2847
|
-
url = new UriBuilder(messagesReceiptsUrl).arg("PageToken", options === null || options === void 0 ? void 0 : options.pageToken).arg("PageSize", options === null || options === void 0 ? void 0 : options.pageSize).build();
|
2954
|
+
url = new UriBuilder(messagesReceiptsUrl).arg("PageToken", options === null || options === void 0 ? void 0 : options.pageToken).arg("PageSize", options === null || options === void 0 ? void 0 : options.pageSize).build();
|
2848
2955
|
_context7.next = 4;
|
2849
2956
|
return this.services.network.get(url);
|
2850
2957
|
case 4:
|
@@ -3016,10 +3123,11 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3016
3123
|
return _unsubscribe.apply(this, arguments);
|
3017
3124
|
}
|
3018
3125
|
return unsubscribe;
|
3019
|
-
}()
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3126
|
+
}()
|
3127
|
+
/**
|
3128
|
+
* Send a message to the conversation. The message could include text and multiple media attachments.
|
3129
|
+
* @param message Message to post
|
3130
|
+
*/
|
3023
3131
|
}, {
|
3024
3132
|
key: "sendV2",
|
3025
3133
|
value: function sendV2(message) {
|
@@ -3151,13 +3259,14 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3151
3259
|
return _send.apply(this, arguments);
|
3152
3260
|
}
|
3153
3261
|
return send;
|
3154
|
-
}()
|
3155
|
-
|
3156
|
-
|
3157
|
-
|
3158
|
-
|
3159
|
-
|
3160
|
-
|
3262
|
+
}()
|
3263
|
+
/**
|
3264
|
+
* Send Media Message to the conversation
|
3265
|
+
* @param mediaContent Media content to post
|
3266
|
+
* @param attributes Message attributes
|
3267
|
+
* @param emailOptions Email options
|
3268
|
+
* @returns Returns promise which can fail
|
3269
|
+
*/
|
3161
3270
|
}, {
|
3162
3271
|
key: "sendMedia",
|
3163
3272
|
value: function () {
|
@@ -3210,13 +3319,14 @@ var Messages = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3210
3319
|
return _sendMedia.apply(this, arguments);
|
3211
3320
|
}
|
3212
3321
|
return sendMedia;
|
3213
|
-
}()
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
|
3322
|
+
}()
|
3323
|
+
/**
|
3324
|
+
* Returns messages from conversation using paginator interface
|
3325
|
+
* @param pageSize Number of messages to return in single chunk. By default it's 30.
|
3326
|
+
* @param anchor Most early message id which is already known, or 'end' by default
|
3327
|
+
* @param direction Pagination order 'backwards' or 'forward', 'forward' by default
|
3328
|
+
* @returns Last page of messages by default
|
3329
|
+
*/
|
3220
3330
|
}, {
|
3221
3331
|
key: "getMessages",
|
3222
3332
|
value: function () {
|
@@ -3964,12 +4074,14 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3964
4074
|
*/
|
3965
4075
|
}, {
|
3966
4076
|
key: "add",
|
3967
|
-
value:
|
3968
|
-
|
3969
|
-
|
3970
|
-
|
3971
|
-
|
3972
|
-
|
4077
|
+
value:
|
4078
|
+
/**
|
4079
|
+
* Add a participant to the conversation by its identity.
|
4080
|
+
* @param identity Identity of the Client to add.
|
4081
|
+
* @param attributes Attributes to be attached to the participant.
|
4082
|
+
* @returns The added participant.
|
4083
|
+
*/
|
4084
|
+
function () {
|
3973
4085
|
var _add = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(identity, attributes) {
|
3974
4086
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
3975
4087
|
while (1) {
|
@@ -3987,15 +4099,16 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
3987
4099
|
return _add.apply(this, arguments);
|
3988
4100
|
}
|
3989
4101
|
return add;
|
3990
|
-
}()
|
3991
|
-
|
3992
|
-
|
3993
|
-
|
3994
|
-
|
3995
|
-
|
3996
|
-
|
3997
|
-
|
3998
|
-
|
4102
|
+
}()
|
4103
|
+
/**
|
4104
|
+
* Add a non-chat participant to the conversation.
|
4105
|
+
* @param proxyAddress Proxy (Twilio) address of the participant.
|
4106
|
+
* @param address User address of the participant.
|
4107
|
+
* @param attributes Attributes to be attached to the participant.
|
4108
|
+
* @param bindingOptions Options for adding email participants - name and
|
4109
|
+
* CC/To level.
|
4110
|
+
* @returns The added participant.
|
4111
|
+
*/
|
3999
4112
|
}, {
|
4000
4113
|
key: "addNonChatParticipant",
|
4001
4114
|
value: function () {
|
@@ -4021,14 +4134,15 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4021
4134
|
return _addNonChatParticipant.apply(this, arguments);
|
4022
4135
|
}
|
4023
4136
|
return addNonChatParticipant;
|
4024
|
-
}()
|
4025
|
-
|
4026
|
-
|
4027
|
-
|
4028
|
-
|
4029
|
-
|
4030
|
-
|
4031
|
-
|
4137
|
+
}()
|
4138
|
+
/**
|
4139
|
+
* Advance the conversation's last read message index to the current read
|
4140
|
+
* horizon. Rejects if the user is not a participant of the conversation. Last
|
4141
|
+
* read message index is updated only if the new index value is higher than
|
4142
|
+
* the previous.
|
4143
|
+
* @param index Message index to advance to.
|
4144
|
+
* @return Resulting unread messages count in the conversation.
|
4145
|
+
*/
|
4032
4146
|
}, {
|
4033
4147
|
key: "advanceLastReadMessageIndex",
|
4034
4148
|
value: function () {
|
@@ -4065,9 +4179,10 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4065
4179
|
return _advanceLastReadMessageIndex.apply(this, arguments);
|
4066
4180
|
}
|
4067
4181
|
return advanceLastReadMessageIndex;
|
4068
|
-
}()
|
4069
|
-
|
4070
|
-
|
4182
|
+
}()
|
4183
|
+
/**
|
4184
|
+
* Delete the conversation and unsubscribe from its events.
|
4185
|
+
*/
|
4071
4186
|
}, {
|
4072
4187
|
key: "delete",
|
4073
4188
|
value: function () {
|
@@ -4091,9 +4206,10 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4091
4206
|
return _delete2.apply(this, arguments);
|
4092
4207
|
}
|
4093
4208
|
return _delete;
|
4094
|
-
}()
|
4095
|
-
|
4096
|
-
|
4209
|
+
}()
|
4210
|
+
/**
|
4211
|
+
* Get the custom attributes of this Conversation.
|
4212
|
+
*/
|
4097
4213
|
}, {
|
4098
4214
|
key: "getAttributes",
|
4099
4215
|
value: function () {
|
@@ -4117,17 +4233,18 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4117
4233
|
return _getAttributes.apply(this, arguments);
|
4118
4234
|
}
|
4119
4235
|
return getAttributes;
|
4120
|
-
}()
|
4121
|
-
|
4122
|
-
|
4123
|
-
|
4124
|
-
|
4125
|
-
|
4126
|
-
|
4127
|
-
|
4128
|
-
|
4129
|
-
|
4130
|
-
|
4236
|
+
}()
|
4237
|
+
/**
|
4238
|
+
* Returns messages from the conversation using the paginator interface.
|
4239
|
+
* @param pageSize Number of messages to return in a single chunk. Default is
|
4240
|
+
* 30.
|
4241
|
+
* @param anchor Index of the newest message to fetch. Default is from the
|
4242
|
+
* end.
|
4243
|
+
* @param direction Query direction. By default, it queries backwards
|
4244
|
+
* from newer to older. The `"forward"` value will query in the opposite
|
4245
|
+
* direction.
|
4246
|
+
* @return A page of messages.
|
4247
|
+
*/
|
4131
4248
|
}, {
|
4132
4249
|
key: "getMessages",
|
4133
4250
|
value: function () {
|
@@ -4151,9 +4268,10 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4151
4268
|
return _getMessages.apply(this, arguments);
|
4152
4269
|
}
|
4153
4270
|
return getMessages;
|
4154
|
-
}()
|
4155
|
-
|
4156
|
-
|
4271
|
+
}()
|
4272
|
+
/**
|
4273
|
+
* Get a list of all the participants who are joined to this conversation.
|
4274
|
+
*/
|
4157
4275
|
}, {
|
4158
4276
|
key: "getParticipants",
|
4159
4277
|
value: function () {
|
@@ -4177,17 +4295,18 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4177
4295
|
return _getParticipants.apply(this, arguments);
|
4178
4296
|
}
|
4179
4297
|
return getParticipants;
|
4180
|
-
}()
|
4181
|
-
|
4182
|
-
|
4183
|
-
|
4184
|
-
|
4185
|
-
|
4186
|
-
|
4187
|
-
|
4188
|
-
|
4189
|
-
|
4190
|
-
|
4298
|
+
}()
|
4299
|
+
/**
|
4300
|
+
* Get conversation participants count.
|
4301
|
+
*
|
4302
|
+
* This method is semi-realtime. This means that this data will be eventually
|
4303
|
+
* correct, but will also be possibly incorrect for a few seconds. The
|
4304
|
+
* Conversations system does not provide real time events for counter values
|
4305
|
+
* changes.
|
4306
|
+
*
|
4307
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
4308
|
+
* core application logic based on these counters being accurate in real time.
|
4309
|
+
*/
|
4191
4310
|
}, {
|
4192
4311
|
key: "getParticipantsCount",
|
4193
4312
|
value: function () {
|
@@ -4215,10 +4334,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4215
4334
|
return _getParticipantsCount.apply(this, arguments);
|
4216
4335
|
}
|
4217
4336
|
return getParticipantsCount;
|
4218
|
-
}()
|
4219
|
-
|
4220
|
-
|
4221
|
-
|
4337
|
+
}()
|
4338
|
+
/**
|
4339
|
+
* Get a participant by its SID.
|
4340
|
+
* @param participantSid Participant SID.
|
4341
|
+
*/
|
4222
4342
|
}, {
|
4223
4343
|
key: "getParticipantBySid",
|
4224
4344
|
value: function () {
|
@@ -4239,10 +4359,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4239
4359
|
return _getParticipantBySid.apply(this, arguments);
|
4240
4360
|
}
|
4241
4361
|
return getParticipantBySid;
|
4242
|
-
}()
|
4243
|
-
|
4244
|
-
|
4245
|
-
|
4362
|
+
}()
|
4363
|
+
/**
|
4364
|
+
* Get a participant by its identity.
|
4365
|
+
* @param identity Participant identity.
|
4366
|
+
*/
|
4246
4367
|
}, {
|
4247
4368
|
key: "getParticipantByIdentity",
|
4248
4369
|
value: function () {
|
@@ -4266,17 +4387,18 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4266
4387
|
return _getParticipantByIdentity.apply(this, arguments);
|
4267
4388
|
}
|
4268
4389
|
return getParticipantByIdentity;
|
4269
|
-
}()
|
4270
|
-
|
4271
|
-
|
4272
|
-
|
4273
|
-
|
4274
|
-
|
4275
|
-
|
4276
|
-
|
4277
|
-
|
4278
|
-
|
4279
|
-
|
4390
|
+
}()
|
4391
|
+
/**
|
4392
|
+
* Get the total message count in the conversation.
|
4393
|
+
*
|
4394
|
+
* This method is semi-realtime. This means that this data will be eventually
|
4395
|
+
* correct, but will also be possibly incorrect for a few seconds. The
|
4396
|
+
* Conversations system does not provide real time events for counter values
|
4397
|
+
* changes.
|
4398
|
+
*
|
4399
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
4400
|
+
* core application logic based on these counters being accurate in real time.
|
4401
|
+
*/
|
4280
4402
|
}, {
|
4281
4403
|
key: "getMessagesCount",
|
4282
4404
|
value: function () {
|
@@ -4304,29 +4426,30 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4304
4426
|
return _getMessagesCount.apply(this, arguments);
|
4305
4427
|
}
|
4306
4428
|
return getMessagesCount;
|
4307
|
-
}()
|
4308
|
-
|
4309
|
-
|
4310
|
-
|
4311
|
-
|
4312
|
-
|
4313
|
-
|
4314
|
-
|
4315
|
-
|
4316
|
-
|
4317
|
-
|
4318
|
-
|
4319
|
-
|
4320
|
-
|
4321
|
-
|
4322
|
-
|
4323
|
-
|
4324
|
-
|
4325
|
-
|
4326
|
-
|
4327
|
-
|
4328
|
-
|
4329
|
-
|
4429
|
+
}()
|
4430
|
+
/**
|
4431
|
+
* Get count of unread messages for the user if they are a participant of this
|
4432
|
+
* conversation. Rejects if the user is not a participant of the conversation.
|
4433
|
+
*
|
4434
|
+
* Use this method to obtain the number of unread messages together with
|
4435
|
+
* {@link Conversation.updateLastReadMessageIndex} instead of relying on the
|
4436
|
+
* message indices which may have gaps. See {@link Message.index} for details.
|
4437
|
+
*
|
4438
|
+
* This method is semi-realtime. This means that this data will be eventually
|
4439
|
+
* correct, but it will also be possibly incorrect for a few seconds. The
|
4440
|
+
* Conversations system does not provide real time events for counter values
|
4441
|
+
* changes.
|
4442
|
+
*
|
4443
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
4444
|
+
* core application logic based on these counters being accurate in real time.
|
4445
|
+
*
|
4446
|
+
* If the read horizon is not set, this function will return null. This could mean
|
4447
|
+
* that all messages in the conversation are unread, or that the read horizon system
|
4448
|
+
* is not being used. How to interpret this `null` value is up to the customer application.
|
4449
|
+
*
|
4450
|
+
* @return Number of unread messages based on the current read horizon set for
|
4451
|
+
* the user or `null` if the read horizon is not set.
|
4452
|
+
*/
|
4330
4453
|
}, {
|
4331
4454
|
key: "getUnreadMessagesCount",
|
4332
4455
|
value: function () {
|
@@ -4366,9 +4489,10 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4366
4489
|
return _getUnreadMessagesCount.apply(this, arguments);
|
4367
4490
|
}
|
4368
4491
|
return getUnreadMessagesCount;
|
4369
|
-
}()
|
4370
|
-
|
4371
|
-
|
4492
|
+
}()
|
4493
|
+
/**
|
4494
|
+
* Join the conversation and subscribe to its events.
|
4495
|
+
*/
|
4372
4496
|
}, {
|
4373
4497
|
key: "join",
|
4374
4498
|
value: function () {
|
@@ -4394,9 +4518,10 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4394
4518
|
return _join.apply(this, arguments);
|
4395
4519
|
}
|
4396
4520
|
return join;
|
4397
|
-
}()
|
4398
|
-
|
4399
|
-
|
4521
|
+
}()
|
4522
|
+
/**
|
4523
|
+
* Leave the conversation.
|
4524
|
+
*/
|
4400
4525
|
}, {
|
4401
4526
|
key: "leave",
|
4402
4527
|
value: function () {
|
@@ -4424,11 +4549,12 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4424
4549
|
return _leave.apply(this, arguments);
|
4425
4550
|
}
|
4426
4551
|
return leave;
|
4427
|
-
}()
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4552
|
+
}()
|
4553
|
+
/**
|
4554
|
+
* Remove a participant from the conversation. When a string is passed as the
|
4555
|
+
* argument, it will assume that the string is an identity or SID.
|
4556
|
+
* @param participant Identity, SID or the participant object to remove.
|
4557
|
+
*/
|
4432
4558
|
}, {
|
4433
4559
|
key: "removeParticipant",
|
4434
4560
|
value: function () {
|
@@ -4450,15 +4576,16 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4450
4576
|
return _removeParticipant.apply(this, arguments);
|
4451
4577
|
}
|
4452
4578
|
return removeParticipant;
|
4453
|
-
}()
|
4454
|
-
|
4455
|
-
|
4456
|
-
|
4457
|
-
|
4458
|
-
|
4459
|
-
|
4460
|
-
|
4461
|
-
|
4579
|
+
}()
|
4580
|
+
/**
|
4581
|
+
* Send a message to the conversation.
|
4582
|
+
* @param message Message body for the text message,
|
4583
|
+
* `FormData` or {@link SendMediaOptions} for media content. Sending FormData
|
4584
|
+
* is supported only with the browser engine.
|
4585
|
+
* @param messageAttributes Attributes for the message.
|
4586
|
+
* @param emailOptions Email options for the message.
|
4587
|
+
* @return Index of the new message.
|
4588
|
+
*/
|
4462
4589
|
}, {
|
4463
4590
|
key: "sendMessage",
|
4464
4591
|
value: function () {
|
@@ -4529,11 +4656,12 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4529
4656
|
return _sendMessage.apply(this, arguments);
|
4530
4657
|
}
|
4531
4658
|
return sendMessage;
|
4532
|
-
}()
|
4533
|
-
|
4534
|
-
|
4535
|
-
|
4536
|
-
|
4659
|
+
}()
|
4660
|
+
/**
|
4661
|
+
* New interface to prepare for sending a message.
|
4662
|
+
* Use this instead of {@link Message.sendMessage}.
|
4663
|
+
* @return A MessageBuilder to help set all message sending options.
|
4664
|
+
*/
|
4537
4665
|
}, {
|
4538
4666
|
key: "prepareMessage",
|
4539
4667
|
value: function prepareMessage() {
|
@@ -4578,10 +4706,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4578
4706
|
return _setAllMessagesRead.apply(this, arguments);
|
4579
4707
|
}
|
4580
4708
|
return setAllMessagesRead;
|
4581
|
-
}()
|
4582
|
-
|
4583
|
-
|
4584
|
-
|
4709
|
+
}()
|
4710
|
+
/**
|
4711
|
+
* Set all messages in the conversation unread.
|
4712
|
+
* @returns New count of unread messages after this update.
|
4713
|
+
*/
|
4585
4714
|
}, {
|
4586
4715
|
key: "setAllMessagesUnread",
|
4587
4716
|
value: function () {
|
@@ -4608,10 +4737,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4608
4737
|
return _setAllMessagesUnread.apply(this, arguments);
|
4609
4738
|
}
|
4610
4739
|
return setAllMessagesUnread;
|
4611
|
-
}()
|
4612
|
-
|
4613
|
-
|
4614
|
-
|
4740
|
+
}()
|
4741
|
+
/**
|
4742
|
+
* Set user notification level for this conversation.
|
4743
|
+
* @param notificationLevel New user notification level.
|
4744
|
+
*/
|
4615
4745
|
}, {
|
4616
4746
|
key: "setUserNotificationLevel",
|
4617
4747
|
value: function () {
|
@@ -4635,12 +4765,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4635
4765
|
return _setUserNotificationLevel.apply(this, arguments);
|
4636
4766
|
}
|
4637
4767
|
return setUserNotificationLevel;
|
4638
|
-
}()
|
4639
|
-
|
4640
|
-
|
4641
|
-
|
4642
|
-
|
4643
|
-
|
4768
|
+
}()
|
4769
|
+
/**
|
4770
|
+
* Send a notification to the server indicating that this client is currently
|
4771
|
+
* typing in this conversation. Typing ended notification is sent after a
|
4772
|
+
* while automatically, but by calling this method again you ensure that
|
4773
|
+
* typing ended is not received.
|
4774
|
+
*/
|
4644
4775
|
}, {
|
4645
4776
|
key: "typing",
|
4646
4777
|
value: function typing() {
|
@@ -4675,10 +4806,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4675
4806
|
return _updateAttributes.apply(this, arguments);
|
4676
4807
|
}
|
4677
4808
|
return updateAttributes;
|
4678
|
-
}()
|
4679
|
-
|
4680
|
-
|
4681
|
-
|
4809
|
+
}()
|
4810
|
+
/**
|
4811
|
+
* Update the friendly name of the conversation.
|
4812
|
+
* @param friendlyName New friendly name.
|
4813
|
+
*/
|
4682
4814
|
}, {
|
4683
4815
|
key: "updateFriendlyName",
|
4684
4816
|
value: function () {
|
@@ -4708,12 +4840,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4708
4840
|
return _updateFriendlyName.apply(this, arguments);
|
4709
4841
|
}
|
4710
4842
|
return updateFriendlyName;
|
4711
|
-
}()
|
4712
|
-
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
|
4843
|
+
}()
|
4844
|
+
/**
|
4845
|
+
* Set the last read message index to the current read horizon.
|
4846
|
+
* @param index Message index to set as last read. If null is provided, then
|
4847
|
+
* the behavior is identical to {@link Conversation.setAllMessagesUnread}.
|
4848
|
+
* @returns New count of unread messages after this update.
|
4849
|
+
*/
|
4717
4850
|
}, {
|
4718
4851
|
key: "updateLastReadMessageIndex",
|
4719
4852
|
value: function () {
|
@@ -4737,11 +4870,12 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4737
4870
|
return _updateLastReadMessageIndex.apply(this, arguments);
|
4738
4871
|
}
|
4739
4872
|
return updateLastReadMessageIndex;
|
4740
|
-
}()
|
4741
|
-
|
4742
|
-
|
4743
|
-
|
4744
|
-
|
4873
|
+
}()
|
4874
|
+
/**
|
4875
|
+
* Update the unique name of the conversation.
|
4876
|
+
* @param uniqueName New unique name for the conversation. Setting unique name
|
4877
|
+
* to null removes it.
|
4878
|
+
*/
|
4745
4879
|
}, {
|
4746
4880
|
key: "updateUniqueName",
|
4747
4881
|
value: function () {
|
@@ -4772,12 +4906,13 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4772
4906
|
return _updateUniqueName.apply(this, arguments);
|
4773
4907
|
}
|
4774
4908
|
return updateUniqueName;
|
4775
|
-
}()
|
4776
|
-
|
4777
|
-
|
4778
|
-
|
4779
|
-
|
4780
|
-
|
4909
|
+
}()
|
4910
|
+
/**
|
4911
|
+
* Load and subscribe to this conversation and do not subscribe to its
|
4912
|
+
* participants and messages. This or _subscribeStreams will need to be called
|
4913
|
+
* before any events on conversation will fire.
|
4914
|
+
* @internal
|
4915
|
+
*/
|
4781
4916
|
}, {
|
4782
4917
|
key: "_subscribe",
|
4783
4918
|
value: function () {
|
@@ -4831,15 +4966,16 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4831
4966
|
return _subscribe2.apply(this, arguments);
|
4832
4967
|
}
|
4833
4968
|
return _subscribe;
|
4834
|
-
}()
|
4835
|
-
|
4836
|
-
|
4837
|
-
|
4838
|
-
|
4839
|
-
|
4840
|
-
|
4841
|
-
|
4842
|
-
|
4969
|
+
}()
|
4970
|
+
/**
|
4971
|
+
* Fetch participants and messages of the conversation. This method needs to
|
4972
|
+
* be called during conversation initialization to catch broken conversations
|
4973
|
+
* (broken conversations are conversations that have essential Sync entities
|
4974
|
+
* missing, i.e. the conversation document, the messages list or the
|
4975
|
+
* participant map). In case of this conversation being broken, the method
|
4976
|
+
* will throw an exception that will be caught and handled gracefully.
|
4977
|
+
* @internal
|
4978
|
+
*/
|
4843
4979
|
}, {
|
4844
4980
|
key: "_fetchStreams",
|
4845
4981
|
value: function () {
|
@@ -4880,13 +5016,14 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4880
5016
|
return _fetchStreams2.apply(this, arguments);
|
4881
5017
|
}
|
4882
5018
|
return _fetchStreams;
|
4883
|
-
}()
|
4884
|
-
|
4885
|
-
|
4886
|
-
|
4887
|
-
|
4888
|
-
|
4889
|
-
|
5019
|
+
}()
|
5020
|
+
/**
|
5021
|
+
* Load the attributes of this conversation and instantiate its participants
|
5022
|
+
* and messages. This or _subscribe will need to be called before any events
|
5023
|
+
* on the conversation will fire. This will need to be called before any
|
5024
|
+
* events on participants or messages will fire
|
5025
|
+
* @internal
|
5026
|
+
*/
|
4890
5027
|
}, {
|
4891
5028
|
key: "_subscribeStreams",
|
4892
5029
|
value: function () {
|
@@ -4928,10 +5065,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4928
5065
|
return _subscribeStreams2.apply(this, arguments);
|
4929
5066
|
}
|
4930
5067
|
return _subscribeStreams;
|
4931
|
-
}()
|
4932
|
-
|
4933
|
-
|
4934
|
-
|
5068
|
+
}()
|
5069
|
+
/**
|
5070
|
+
* Stop listening for and firing events on this conversation.
|
5071
|
+
* @internal
|
5072
|
+
*/
|
4935
5073
|
}, {
|
4936
5074
|
key: "_unsubscribe",
|
4937
5075
|
value: function () {
|
@@ -4962,10 +5100,11 @@ var Conversation = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
4962
5100
|
return _unsubscribe2.apply(this, arguments);
|
4963
5101
|
}
|
4964
5102
|
return _unsubscribe;
|
4965
|
-
}()
|
4966
|
-
|
4967
|
-
|
4968
|
-
|
5103
|
+
}()
|
5104
|
+
/**
|
5105
|
+
* Set conversation status.
|
5106
|
+
* @internal
|
5107
|
+
*/
|
4969
5108
|
}, {
|
4970
5109
|
key: "_setStatus",
|
4971
5110
|
value: function _setStatus(status, source) {
|
@@ -5349,9 +5488,10 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5349
5488
|
return _addConversation.apply(this, arguments);
|
5350
5489
|
}
|
5351
5490
|
return addConversation;
|
5352
|
-
}()
|
5353
|
-
|
5354
|
-
|
5491
|
+
}()
|
5492
|
+
/**
|
5493
|
+
* Fetch conversations list and instantiate all necessary objects
|
5494
|
+
*/
|
5355
5495
|
}, {
|
5356
5496
|
key: "fetchConversations",
|
5357
5497
|
value: function () {
|
@@ -5523,8 +5663,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5523
5663
|
return this.services.network.get(url);
|
5524
5664
|
case 3:
|
5525
5665
|
response = _context5.sent;
|
5526
|
-
|
5527
|
-
body = JSON.parse(response.payload);
|
5666
|
+
body = response.body;
|
5528
5667
|
sid = body.conversation_sid;
|
5529
5668
|
data = {
|
5530
5669
|
entityName: null,
|
@@ -5562,7 +5701,7 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5562
5701
|
while (1) {
|
5563
5702
|
switch (_context6.prev = _context6.next) {
|
5564
5703
|
case 0:
|
5565
|
-
url = new UriBuilder(this.configuration.links.conversations).path(sid).build();
|
5704
|
+
url = new UriBuilder(this.configuration.links.conversations).path(sid).build();
|
5566
5705
|
_context6.next = 3;
|
5567
5706
|
return this.services.network.get(url);
|
5568
5707
|
case 3:
|
@@ -5844,7 +5983,6 @@ var Conversations = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
5844
5983
|
if (pageToken) {
|
5845
5984
|
url.arg("PageToken", pageToken);
|
5846
5985
|
}
|
5847
|
-
// todo: remove any after the release of new Twilsock
|
5848
5986
|
_context11.next = 6;
|
5849
5987
|
return this.services.network.get(url.build());
|
5850
5988
|
case 6:
|
@@ -6067,9 +6205,10 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6067
6205
|
return _getUser.apply(this, arguments);
|
6068
6206
|
}
|
6069
6207
|
return getUser;
|
6070
|
-
}()
|
6071
|
-
|
6072
|
-
|
6208
|
+
}()
|
6209
|
+
/**
|
6210
|
+
* @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
|
6211
|
+
*/
|
6073
6212
|
}, {
|
6074
6213
|
key: "getSubscribedUsers",
|
6075
6214
|
value: function () {
|
@@ -6098,27 +6237,27 @@ var Users = /*#__PURE__*/function (_ReplayEventEmitter) {
|
|
6098
6237
|
return _getSubscribedUsers.apply(this, arguments);
|
6099
6238
|
}
|
6100
6239
|
return getSubscribedUsers;
|
6101
|
-
}()
|
6102
|
-
|
6103
|
-
|
6240
|
+
}()
|
6241
|
+
/**
|
6242
|
+
* @returns {Promise<string>} User's sync unique name
|
6243
|
+
*/
|
6104
6244
|
}, {
|
6105
6245
|
key: "getSyncUniqueName",
|
6106
6246
|
value: function () {
|
6107
6247
|
var _getSyncUniqueName = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(identity) {
|
6108
|
-
var
|
6109
|
-
var url, response
|
6248
|
+
var _response$body$sync_o;
|
6249
|
+
var url, response;
|
6110
6250
|
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
6111
6251
|
while (1) {
|
6112
6252
|
switch (_context3.prev = _context3.next) {
|
6113
6253
|
case 0:
|
6114
|
-
url = new UriBuilder(this.configuration.links.users).path(identity).build();
|
6254
|
+
url = new UriBuilder(this.configuration.links.users).path(identity).build();
|
6115
6255
|
_context3.next = 3;
|
6116
6256
|
return this.services.network.get(url);
|
6117
6257
|
case 3:
|
6118
6258
|
response = _context3.sent;
|
6119
|
-
body =
|
6120
|
-
|
6121
|
-
case 6:
|
6259
|
+
return _context3.abrupt("return", (_response$body$sync_o = response.body.sync_objects.user_info_map) !== null && _response$body$sync_o !== void 0 ? _response$body$sync_o : "");
|
6260
|
+
case 5:
|
6122
6261
|
case "end":
|
6123
6262
|
return _context3.stop();
|
6124
6263
|
}
|
@@ -6191,7 +6330,7 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6191
6330
|
break;
|
6192
6331
|
}
|
6193
6332
|
_context.next = 3;
|
6194
|
-
return _this._handleRemoteTyping(message);
|
6333
|
+
return _this._handleRemoteTyping(JSON.parse(message));
|
6195
6334
|
case 3:
|
6196
6335
|
case "end":
|
6197
6336
|
return _context.stop();
|
@@ -6243,10 +6382,11 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6243
6382
|
return _handleRemoteTyping2.apply(this, arguments);
|
6244
6383
|
}
|
6245
6384
|
return _handleRemoteTyping;
|
6246
|
-
}()
|
6247
|
-
|
6248
|
-
|
6249
|
-
|
6385
|
+
}()
|
6386
|
+
/**
|
6387
|
+
* Send typing event for the given conversation sid
|
6388
|
+
* @param {String} conversationSid
|
6389
|
+
*/
|
6250
6390
|
}, {
|
6251
6391
|
key: "send",
|
6252
6392
|
value: function send(conversationSid) {
|
@@ -6266,15 +6406,14 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6266
6406
|
var headers = {
|
6267
6407
|
"Content-Type": "application/x-www-form-urlencoded"
|
6268
6408
|
};
|
6269
|
-
var
|
6270
|
-
return this.services.twilsockClient.
|
6409
|
+
var payload = "ChannelSid=".concat(conversationSid);
|
6410
|
+
return this.services.twilsockClient.sendRequest(new twilsock.HttpRequest({
|
6411
|
+
method: "POST",
|
6271
6412
|
url: url,
|
6272
6413
|
headers: headers,
|
6273
|
-
|
6414
|
+
payload: payload,
|
6274
6415
|
grant: this.configuration.productId
|
6275
|
-
})
|
6276
|
-
// todo: remove any after the release of new Twilsock
|
6277
|
-
.then(function (response) {
|
6416
|
+
})).then(function (response) {
|
6278
6417
|
var body = JSON.parse(response.payload);
|
6279
6418
|
if (body.hasOwnProperty("typing_timeout")) {
|
6280
6419
|
_this3.serviceTypingTimeout = body.typing_timeout * 1000;
|
@@ -6290,7 +6429,8 @@ var TypingIndicator = /*#__PURE__*/function () {
|
|
6290
6429
|
|
6291
6430
|
/**
|
6292
6431
|
* Push notification for a Conversations client.
|
6293
|
-
*/
|
6432
|
+
*/
|
6433
|
+
var PushNotification = /*#__PURE__*/_createClass__default["default"](
|
6294
6434
|
/**
|
6295
6435
|
* Title of the notification.
|
6296
6436
|
*/
|
@@ -6340,7 +6480,7 @@ function PushNotification(data) {
|
|
6340
6480
|
this.data = data.data || {};
|
6341
6481
|
});
|
6342
6482
|
|
6343
|
-
var version = "
|
6483
|
+
var version = "3.0.0-rc.1";
|
6344
6484
|
|
6345
6485
|
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
6346
6486
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
@@ -6395,32 +6535,34 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
6395
6535
|
}).join("&");
|
6396
6536
|
}
|
6397
6537
|
_context.next = 9;
|
6398
|
-
return this._services.transport.
|
6538
|
+
return this._services.transport.sendRequest(new twilsock.HttpRequest({
|
6399
6539
|
url: getUrl,
|
6400
6540
|
headers: finalHeaders,
|
6401
6541
|
grant: this._productId
|
6402
|
-
});
|
6542
|
+
}));
|
6403
6543
|
case 9:
|
6404
6544
|
response = _context.sent;
|
6405
6545
|
return _context.abrupt("break", 19);
|
6406
6546
|
case 11:
|
6407
6547
|
_context.next = 13;
|
6408
|
-
return this._services.transport.
|
6548
|
+
return this._services.transport.sendRequest(new twilsock.HttpRequest({
|
6549
|
+
method: "POST",
|
6409
6550
|
url: preProcessedUrl,
|
6410
6551
|
headers: finalHeaders,
|
6411
|
-
|
6552
|
+
payload: JSON.stringify(requestBody),
|
6412
6553
|
grant: this._productId
|
6413
|
-
});
|
6554
|
+
}));
|
6414
6555
|
case 13:
|
6415
6556
|
response = _context.sent;
|
6416
6557
|
return _context.abrupt("break", 19);
|
6417
6558
|
case 15:
|
6418
6559
|
_context.next = 17;
|
6419
|
-
return this._services.transport.
|
6560
|
+
return this._services.transport.sendRequest(new twilsock.HttpRequest({
|
6561
|
+
method: "DELETE",
|
6420
6562
|
url: preProcessedUrl,
|
6421
6563
|
headers: finalHeaders,
|
6422
6564
|
grant: this._productId
|
6423
|
-
});
|
6565
|
+
}));
|
6424
6566
|
case 17:
|
6425
6567
|
response = _context.sent;
|
6426
6568
|
return _context.abrupt("break", 19);
|
@@ -6498,18 +6640,21 @@ var CommandExecutor = /*#__PURE__*/function () {
|
|
6498
6640
|
});
|
6499
6641
|
case 2:
|
6500
6642
|
result = _context3.sent;
|
6501
|
-
parsedPayload =
|
6643
|
+
parsedPayload = {};
|
6644
|
+
try {
|
6645
|
+
parsedPayload = JSON.parse(result.payload);
|
6646
|
+
} catch (_unused) {}
|
6502
6647
|
if (!isMutationConflictResponse(result)) {
|
6503
|
-
_context3.next =
|
6648
|
+
_context3.next = 9;
|
6504
6649
|
break;
|
6505
6650
|
}
|
6506
|
-
_context3.next =
|
6651
|
+
_context3.next = 8;
|
6507
6652
|
return this.fetchResource(parsedPayload.resource_url);
|
6508
|
-
case 7:
|
6509
|
-
return _context3.abrupt("return", _context3.sent);
|
6510
6653
|
case 8:
|
6511
|
-
return _context3.abrupt("return",
|
6654
|
+
return _context3.abrupt("return", _context3.sent);
|
6512
6655
|
case 9:
|
6656
|
+
return _context3.abrupt("return", parsedPayload);
|
6657
|
+
case 10:
|
6513
6658
|
case "end":
|
6514
6659
|
return _context3.stop();
|
6515
6660
|
}
|
@@ -6545,9 +6690,10 @@ var ClientServices = /*#__PURE__*/_createClass__default["default"](function Clie
|
|
6545
6690
|
_defineProperty__default["default"](this, "syncClient", void 0);
|
6546
6691
|
_defineProperty__default["default"](this, "mcsClient", void 0);
|
6547
6692
|
_defineProperty__default["default"](this, "transport", void 0);
|
6548
|
-
});
|
6549
|
-
|
6550
|
-
|
6693
|
+
});
|
6694
|
+
/**
|
6695
|
+
* A client is the starting point to the Twilio Conversations functionality.
|
6696
|
+
*/
|
6551
6697
|
exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter) {
|
6552
6698
|
_inherits__default["default"](Client, _ReplayEventEmitter);
|
6553
6699
|
var _super = _createSuper(Client);
|
@@ -6939,12 +7085,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
6939
7085
|
});
|
6940
7086
|
_this._services.transport = _this._options.transport = (_this$_options$transp = _this._options.transport) !== null && _this$_options$transp !== void 0 ? _this$_options$transp : _this._options.twilsockClient;
|
6941
7087
|
_this._services.notificationClient = _this._options.notificationsClient = (_this$_options$notifi = _this._options.notificationsClient) !== null && _this$_options$notifi !== void 0 ? _this$_options$notifi : new notifications.Notifications(fpaToken, _this._options);
|
6942
|
-
_this._services.syncClient = _this._options.syncClient = (_this$_options$syncCl = _this._options.syncClient) !== null && _this$_options$syncCl !== void 0 ? _this$_options$syncCl :
|
6943
|
-
// TwilsockClient is different between versions 0.12.2
|
6944
|
-
// (dep of twilio-sync@3.2.2) and 0.13.1 (dep of current
|
6945
|
-
// @twilio/conversations). Thus, casting to any.
|
6946
|
-
// todo: fix sync caching and migrate to that version of sync.
|
6947
|
-
new twilioSync.SyncClient(fpaToken, _this._options);
|
7088
|
+
_this._services.syncClient = _this._options.syncClient = (_this$_options$syncCl = _this._options.syncClient) !== null && _this$_options$syncCl !== void 0 ? _this$_options$syncCl : new twilioSync.SyncClient(fpaToken, _this._options);
|
6948
7089
|
var configurationOptions = (options === null || options === void 0 ? void 0 : options.Chat) || (options === null || options === void 0 ? void 0 : options.IPMessaging) || options || {};
|
6949
7090
|
var region = configurationOptions.region || (options === null || options === void 0 ? void 0 : options.region);
|
6950
7091
|
var baseUrl = configurationOptions.apiUri || configurationOptions.typingUri || "https://aim.".concat(region || "us1", ".twilio.com");
|
@@ -7047,10 +7188,13 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7047
7188
|
*/
|
7048
7189
|
}, {
|
7049
7190
|
key: "shutdown",
|
7050
|
-
value:
|
7051
|
-
|
7052
|
-
|
7191
|
+
value:
|
7192
|
+
/**
|
7193
|
+
* Gracefully shut down the client.
|
7194
|
+
*/
|
7195
|
+
function () {
|
7053
7196
|
var _shutdown = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
|
7197
|
+
var _this$_services$netwo;
|
7054
7198
|
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
7055
7199
|
while (1) {
|
7056
7200
|
switch (_context2.prev = _context2.next) {
|
@@ -7059,7 +7203,7 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7059
7203
|
return this._ensureReady;
|
7060
7204
|
case 2:
|
7061
7205
|
_context2.next = 4;
|
7062
|
-
return this._services.
|
7206
|
+
return (_this$_services$netwo = this._services.network) === null || _this$_services$netwo === void 0 ? void 0 : _this$_services$netwo.disconnect();
|
7063
7207
|
case 4:
|
7064
7208
|
case "end":
|
7065
7209
|
return _context2.stop();
|
@@ -7071,10 +7215,11 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7071
7215
|
return _shutdown.apply(this, arguments);
|
7072
7216
|
}
|
7073
7217
|
return shutdown;
|
7074
|
-
}()
|
7075
|
-
|
7076
|
-
|
7077
|
-
|
7218
|
+
}()
|
7219
|
+
/**
|
7220
|
+
* Update the token used by the client and re-register with the Conversations services.
|
7221
|
+
* @param token New access token.
|
7222
|
+
*/
|
7078
7223
|
}, {
|
7079
7224
|
key: "updateToken",
|
7080
7225
|
value: function () {
|
@@ -7115,10 +7260,11 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7115
7260
|
return _updateToken.apply(this, arguments);
|
7116
7261
|
}
|
7117
7262
|
return updateToken;
|
7118
|
-
}()
|
7119
|
-
|
7120
|
-
|
7121
|
-
|
7263
|
+
}()
|
7264
|
+
/**
|
7265
|
+
* Get a known conversation by its SID.
|
7266
|
+
* @param conversationSid Conversation sid
|
7267
|
+
*/
|
7122
7268
|
}, {
|
7123
7269
|
key: "getConversationBySid",
|
7124
7270
|
value: function () {
|
@@ -7156,11 +7302,12 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7156
7302
|
return _getConversationBySid.apply(this, arguments);
|
7157
7303
|
}
|
7158
7304
|
return getConversationBySid;
|
7159
|
-
}()
|
7160
|
-
|
7161
|
-
|
7162
|
-
|
7163
|
-
|
7305
|
+
}()
|
7306
|
+
/**
|
7307
|
+
* Peek a conversation by its SID.
|
7308
|
+
* @param conversationSid Conversation sid
|
7309
|
+
* @internal
|
7310
|
+
*/
|
7164
7311
|
}, {
|
7165
7312
|
key: "peekConversationBySid",
|
7166
7313
|
value: function () {
|
@@ -7195,10 +7342,11 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7195
7342
|
return _peekConversationBySid.apply(this, arguments);
|
7196
7343
|
}
|
7197
7344
|
return peekConversationBySid;
|
7198
|
-
}()
|
7199
|
-
|
7200
|
-
|
7201
|
-
|
7345
|
+
}()
|
7346
|
+
/**
|
7347
|
+
* Get a known conversation by its unique identifier name.
|
7348
|
+
* @param uniqueName The unique identifier name of the conversation.
|
7349
|
+
*/
|
7202
7350
|
}, {
|
7203
7351
|
key: "getConversationByUniqueName",
|
7204
7352
|
value: function () {
|
@@ -7236,9 +7384,10 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7236
7384
|
return _getConversationByUniqueName.apply(this, arguments);
|
7237
7385
|
}
|
7238
7386
|
return getConversationByUniqueName;
|
7239
|
-
}()
|
7240
|
-
|
7241
|
-
|
7387
|
+
}()
|
7388
|
+
/**
|
7389
|
+
* Get the current list of all the subscribed conversations.
|
7390
|
+
*/
|
7242
7391
|
}, {
|
7243
7392
|
key: "getSubscribedConversations",
|
7244
7393
|
value: function () {
|
@@ -7264,11 +7413,12 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7264
7413
|
return _getSubscribedConversations.apply(this, arguments);
|
7265
7414
|
}
|
7266
7415
|
return getSubscribedConversations;
|
7267
|
-
}()
|
7268
|
-
|
7269
|
-
|
7270
|
-
|
7271
|
-
|
7416
|
+
}()
|
7417
|
+
/**
|
7418
|
+
* Create a conversation on the server and subscribe to its events.
|
7419
|
+
* The default is a conversation with an empty friendly name.
|
7420
|
+
* @param options Options for the conversation.
|
7421
|
+
*/
|
7272
7422
|
}, {
|
7273
7423
|
key: "createConversation",
|
7274
7424
|
value: function () {
|
@@ -7295,12 +7445,13 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7295
7445
|
return _createConversation.apply(this, arguments);
|
7296
7446
|
}
|
7297
7447
|
return createConversation;
|
7298
|
-
}()
|
7299
|
-
|
7300
|
-
|
7301
|
-
|
7302
|
-
|
7303
|
-
|
7448
|
+
}()
|
7449
|
+
/**
|
7450
|
+
* Register for push notifications.
|
7451
|
+
* @param channelType Channel type.
|
7452
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service
|
7453
|
+
* on the platform.
|
7454
|
+
*/
|
7304
7455
|
}, {
|
7305
7456
|
key: "setPushRegistrationId",
|
7306
7457
|
value: function () {
|
@@ -7327,11 +7478,12 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7327
7478
|
return _setPushRegistrationId.apply(this, arguments);
|
7328
7479
|
}
|
7329
7480
|
return setPushRegistrationId;
|
7330
|
-
}()
|
7331
|
-
|
7332
|
-
|
7333
|
-
|
7334
|
-
|
7481
|
+
}()
|
7482
|
+
/**
|
7483
|
+
* Unregister from push notifications.
|
7484
|
+
* @param channelType Channel type.
|
7485
|
+
* @deprecated Use removePushRegistrations() instead.
|
7486
|
+
*/
|
7335
7487
|
}, {
|
7336
7488
|
key: "unsetPushRegistrationId",
|
7337
7489
|
value: function () {
|
@@ -7357,19 +7509,20 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7357
7509
|
return _unsetPushRegistrationId.apply(this, arguments);
|
7358
7510
|
}
|
7359
7511
|
return unsetPushRegistrationId;
|
7360
|
-
}()
|
7361
|
-
|
7362
|
-
|
7363
|
-
|
7364
|
-
|
7365
|
-
|
7366
|
-
|
7367
|
-
|
7368
|
-
|
7369
|
-
|
7370
|
-
|
7371
|
-
|
7372
|
-
|
7512
|
+
}()
|
7513
|
+
/**
|
7514
|
+
* Clear existing registrations directly using provided device token.
|
7515
|
+
* This is useful to ensure stopped subscriptions without resubscribing.
|
7516
|
+
*
|
7517
|
+
* This function goes completely beside the state machine and removes all
|
7518
|
+
* registrations.
|
7519
|
+
* Use with caution: if it races with current state machine operations,
|
7520
|
+
* madness will ensue.
|
7521
|
+
*
|
7522
|
+
* @param channelType Channel type.
|
7523
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service
|
7524
|
+
* on the platform.
|
7525
|
+
*/
|
7373
7526
|
}, {
|
7374
7527
|
key: "removePushRegistrations",
|
7375
7528
|
value: function () {
|
@@ -7391,16 +7544,19 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7391
7544
|
return _removePushRegistrations.apply(this, arguments);
|
7392
7545
|
}
|
7393
7546
|
return removePushRegistrations;
|
7394
|
-
}()
|
7395
|
-
|
7396
|
-
|
7547
|
+
}()
|
7548
|
+
/**
|
7549
|
+
* Current version of the Conversations client.
|
7550
|
+
*/
|
7397
7551
|
}, {
|
7398
7552
|
key: "handlePushNotification",
|
7399
|
-
value:
|
7400
|
-
|
7401
|
-
|
7402
|
-
|
7403
|
-
|
7553
|
+
value:
|
7554
|
+
/**
|
7555
|
+
* Handle push notification payload parsing and emit the
|
7556
|
+
* {@link Client.pushNotification} event on this {@link Client} instance.
|
7557
|
+
* @param notificationPayload Push notification payload
|
7558
|
+
*/
|
7559
|
+
function () {
|
7404
7560
|
var _handlePushNotification = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12(notificationPayload) {
|
7405
7561
|
return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context12) {
|
7406
7562
|
while (1) {
|
@@ -7422,13 +7578,14 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7422
7578
|
return _handlePushNotification.apply(this, arguments);
|
7423
7579
|
}
|
7424
7580
|
return handlePushNotification;
|
7425
|
-
}()
|
7426
|
-
|
7427
|
-
|
7428
|
-
|
7429
|
-
|
7430
|
-
|
7431
|
-
|
7581
|
+
}()
|
7582
|
+
/**
|
7583
|
+
* Gets a user with the given identity. If it's in the subscribed list, then
|
7584
|
+
* return the user object from it;
|
7585
|
+
* if not, then subscribe and add user to the subscribed list.
|
7586
|
+
* @param identity Identity of the user.
|
7587
|
+
* @returns A fully initialized user.
|
7588
|
+
*/
|
7432
7589
|
}, {
|
7433
7590
|
key: "getUser",
|
7434
7591
|
value: function () {
|
@@ -7452,9 +7609,10 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7452
7609
|
return _getUser.apply(this, arguments);
|
7453
7610
|
}
|
7454
7611
|
return getUser;
|
7455
|
-
}()
|
7456
|
-
|
7457
|
-
|
7612
|
+
}()
|
7613
|
+
/**
|
7614
|
+
* Get a list of subscribed user objects.
|
7615
|
+
*/
|
7458
7616
|
}, {
|
7459
7617
|
key: "getSubscribedUsers",
|
7460
7618
|
value: function () {
|
@@ -7478,11 +7636,12 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7478
7636
|
return _getSubscribedUsers.apply(this, arguments);
|
7479
7637
|
}
|
7480
7638
|
return getSubscribedUsers;
|
7481
|
-
}()
|
7482
|
-
|
7483
|
-
|
7484
|
-
|
7485
|
-
|
7639
|
+
}()
|
7640
|
+
/**
|
7641
|
+
* Get content URLs for all media attachments in the given set of media sids
|
7642
|
+
* using a single operation.
|
7643
|
+
* @param mediaSids Set of media sids to query for the content URL.
|
7644
|
+
*/
|
7486
7645
|
}, {
|
7487
7646
|
key: "getTemporaryContentUrlsForMediaSids",
|
7488
7647
|
value: function getTemporaryContentUrlsForMediaSids(mediaSids) {
|
@@ -7619,6 +7778,9 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7619
7778
|
this._conversationsPromise = this._conversationsEntity.fetchConversations().then(function () {
|
7620
7779
|
return _this3._conversationsEntity;
|
7621
7780
|
}).catch(function (error) {
|
7781
|
+
if (error.message === "Client has been shut down.") {
|
7782
|
+
return _this3._conversationsEntity;
|
7783
|
+
}
|
7622
7784
|
throw error;
|
7623
7785
|
});
|
7624
7786
|
_context16.next = 28;
|
@@ -7644,10 +7806,11 @@ exports.Client = Client_1 = (_class = /*#__PURE__*/function (_ReplayEventEmitter
|
|
7644
7806
|
return _initialize2.apply(this, arguments);
|
7645
7807
|
}
|
7646
7808
|
return _initialize;
|
7647
|
-
}()
|
7648
|
-
|
7649
|
-
|
7650
|
-
|
7809
|
+
}()
|
7810
|
+
/**
|
7811
|
+
* Subscribe to push notifications.
|
7812
|
+
* @param channelType The channel type to subscribe to.
|
7813
|
+
*/
|
7651
7814
|
}, {
|
7652
7815
|
key: "_subscribeToPushNotifications",
|
7653
7816
|
value: function _subscribeToPushNotifications(channelType) {
|