@twilio/conversations 1.3.0-rc8 → 2.0.0-rc.4
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 +210 -0
- package/README.md +22 -17
- package/dist/browser.js +7873 -0
- package/dist/browser.js.map +1 -0
- package/dist/docs/assets/css/main.css +2660 -0
- package/dist/docs/assets/images/icons.png +0 -0
- package/dist/docs/assets/images/icons@2x.png +0 -0
- package/dist/docs/assets/images/widgets.png +0 -0
- package/dist/docs/assets/images/widgets@2x.png +0 -0
- package/dist/docs/assets/js/main.js +248 -0
- package/dist/docs/assets/js/search.js +1 -0
- package/dist/docs/classes/AggregatedDeliveryReceipt.html +3286 -0
- package/dist/docs/classes/Client.html +4181 -0
- package/dist/docs/classes/Conversation.html +4397 -0
- package/dist/docs/classes/DetailedDeliveryReceipt.html +3265 -0
- package/dist/docs/classes/Media.html +3295 -0
- package/dist/docs/classes/Message.html +3713 -0
- package/dist/docs/classes/MessageBuilder.html +3280 -0
- package/dist/docs/classes/Participant.html +3517 -0
- package/dist/docs/classes/PushNotification.html +3232 -0
- package/dist/docs/classes/RestPaginator.html +3262 -0
- package/dist/docs/classes/UnsentMessage.html +3144 -0
- package/dist/docs/classes/User.html +3451 -0
- package/dist/docs/index.html +3394 -212
- package/dist/docs/interfaces/ClientOptions.html +3136 -0
- package/dist/docs/interfaces/ConversationState.html +3152 -0
- package/dist/docs/interfaces/CreateConversationOptions.html +3168 -0
- package/dist/docs/interfaces/LastMessage.html +3152 -0
- package/dist/docs/interfaces/Paginator.html +3243 -0
- package/dist/docs/interfaces/PushNotificationData.html +3168 -0
- package/dist/docs/interfaces/SendEmailOptions.html +3136 -0
- package/dist/docs/interfaces/SendMediaOptions.html +3170 -0
- package/dist/docs/modules.html +3425 -0
- package/dist/lib.d.ts +1952 -0
- package/dist/lib.js +7873 -0
- package/dist/lib.js.map +1 -0
- package/dist/post-install.js +29 -0
- package/dist/react-native.js +4038 -0
- package/dist/react-native.js.map +1 -0
- package/dist/twilio-conversations.js +40912 -0
- package/dist/twilio-conversations.min.js +156 -0
- package/package.json +59 -48
- package/.circleci/config.yml +0 -650
- package/.deepsource.toml +0 -6
- package/.env.example +0 -13
- package/browser/aggregateddeliveryreceipt.js +0 -152
- package/browser/client.js +0 -991
- package/browser/configuration.js +0 -80
- package/browser/conversation.js +0 -1826
- package/browser/data/conversations.js +0 -632
- package/browser/data/messages.js +0 -522
- package/browser/data/participants.js +0 -411
- package/browser/data/users.js +0 -281
- package/browser/detaileddeliveryreceipt.js +0 -44
- package/browser/index.js +0 -4
- package/browser/interfaces/limits.js +0 -3
- package/browser/interfaces/notificationtypes.js +0 -21
- package/browser/interfaces/paginator.js +0 -53
- package/browser/interfaces/responsecodes.js +0 -20
- package/browser/interfaces/transport.js +0 -3
- package/browser/logger.js +0 -141
- package/browser/media.js +0 -198
- package/browser/message.js +0 -685
- package/browser/participant.js +0 -415
- package/browser/pushnotification.js +0 -49
- package/browser/restpaginator.js +0 -74
- package/browser/services/network.js +0 -223
- package/browser/services/readhorizon.js +0 -181
- package/browser/services/typingindicator.js +0 -142
- package/browser/session.js +0 -505
- package/browser/sessionerror.js +0 -93
- package/browser/sri.json +0 -1
- package/browser/synclist.js +0 -90
- package/browser/synclistdescriptor.js +0 -29
- package/browser/syncpaginator.js +0 -63
- package/browser/user.js +0 -431
- package/browser/util/deferred.js +0 -56
- package/browser/util/index.js +0 -108
- package/dist/@twilio/conversations.js +0 -35533
- package/dist/@twilio/conversations.min.js +0 -204
- package/dist/docs/AggregatedDeliveryReceipt.html +0 -948
- package/dist/docs/Client.html +0 -5075
- package/dist/docs/Conversation.html +0 -6018
- package/dist/docs/DetailedDeliveryReceipt.html +0 -641
- package/dist/docs/Media.html +0 -694
- package/dist/docs/Message.html +0 -1934
- package/dist/docs/Paginator.html +0 -605
- package/dist/docs/Participant.html +0 -1510
- package/dist/docs/PushNotification.html +0 -836
- package/dist/docs/SessionError.html +0 -379
- package/dist/docs/User.html +0 -1315
- package/dist/docs/classes.list.html +0 -4431
- package/dist/docs/fonts/glyphicons-halflings-regular.eot +0 -0
- package/dist/docs/fonts/glyphicons-halflings-regular.svg +0 -288
- package/dist/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/dist/docs/fonts/glyphicons-halflings-regular.woff +0 -0
- package/dist/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/dist/docs/img/glyphicons-halflings-white.png +0 -0
- package/dist/docs/img/glyphicons-halflings.png +0 -0
- package/dist/docs/quicksearch.html +0 -31
- package/dist/docs/scripts/docstrap.lib.js +0 -11
- package/dist/docs/scripts/fulltext-search-ui.js +0 -89
- package/dist/docs/scripts/fulltext-search.js +0 -36
- package/dist/docs/scripts/lunr.min.js +0 -6
- package/dist/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/dist/docs/scripts/prettify/jquery.min.js +0 -6
- package/dist/docs/scripts/prettify/lang-css.js +0 -21
- package/dist/docs/scripts/prettify/prettify.js +0 -496
- package/dist/docs/scripts/sunlight.js +0 -1157
- package/dist/docs/scripts/toc.js +0 -203
- package/dist/docs/styles/darkstrap.css +0 -960
- package/dist/docs/styles/prettify-tomorrow.css +0 -132
- package/dist/docs/styles/site.cerulean.css +0 -7008
- package/dist/docs/styles/site.cosmo.css +0 -7061
- package/dist/docs/styles/site.cyborg.css +0 -7048
- package/dist/docs/styles/site.darkly.css +0 -7171
- package/dist/docs/styles/site.darkstrap.css +0 -5638
- package/dist/docs/styles/site.dibs-bootstrap.css +0 -5899
- package/dist/docs/styles/site.flatly.css +0 -7147
- package/dist/docs/styles/site.journal.css +0 -6973
- package/dist/docs/styles/site.lumen.css +0 -7298
- package/dist/docs/styles/site.paper.css +0 -7623
- package/dist/docs/styles/site.readable.css +0 -6997
- package/dist/docs/styles/site.sandstone.css +0 -7035
- package/dist/docs/styles/site.simplex.css +0 -7023
- package/dist/docs/styles/site.slate.css +0 -7343
- package/dist/docs/styles/site.spacelab.css +0 -7055
- package/dist/docs/styles/site.superhero.css +0 -7131
- package/dist/docs/styles/site.united.css +0 -6895
- package/dist/docs/styles/site.yeti.css +0 -7195
- package/dist/docs/styles/sunlight.dark.css +0 -345
- package/dist/docs/styles/sunlight.default.css +0 -344
- package/dist/sri.json +0 -1
- package/lib/aggregateddeliveryreceipt.d.ts +0 -98
- package/lib/aggregateddeliveryreceipt.js +0 -112
- package/lib/client.d.ts +0 -317
- package/lib/client.js +0 -633
- package/lib/configuration.d.ts +0 -21
- package/lib/configuration.js +0 -41
- package/lib/conversation.d.ts +0 -460
- package/lib/conversation.js +0 -940
- package/lib/data/conversations.d.ts +0 -57
- package/lib/data/conversations.js +0 -296
- package/lib/data/messages.d.ts +0 -75
- package/lib/data/messages.js +0 -208
- package/lib/data/participants.d.ts +0 -94
- package/lib/data/participants.js +0 -204
- package/lib/data/users.d.ts +0 -42
- package/lib/data/users.js +0 -113
- package/lib/detaileddeliveryreceipt.d.ts +0 -45
- package/lib/detaileddeliveryreceipt.js +0 -34
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -3
- package/lib/interfaces/limits.d.ts +0 -8
- package/lib/interfaces/limits.js +0 -2
- package/lib/interfaces/notificationtypes.d.ts +0 -8
- package/lib/interfaces/notificationtypes.js +0 -11
- package/lib/interfaces/paginator.d.ts +0 -52
- package/lib/interfaces/paginator.js +0 -28
- package/lib/interfaces/responsecodes.d.ts +0 -8
- package/lib/interfaces/responsecodes.js +0 -10
- package/lib/interfaces/transport.d.ts +0 -13
- package/lib/interfaces/transport.js +0 -2
- package/lib/logger.d.ts +0 -18
- package/lib/logger.js +0 -35
- package/lib/media.d.ts +0 -52
- package/lib/media.js +0 -69
- package/lib/message.d.ts +0 -136
- package/lib/message.js +0 -305
- package/lib/participant.d.ts +0 -142
- package/lib/participant.js +0 -219
- package/lib/pushnotification.d.ts +0 -48
- package/lib/pushnotification.js +0 -39
- package/lib/restpaginator.d.ts +0 -19
- package/lib/restpaginator.js +0 -36
- package/lib/services/network.d.ts +0 -22
- package/lib/services/network.js +0 -87
- package/lib/services/readhorizon.d.ts +0 -28
- package/lib/services/readhorizon.js +0 -112
- package/lib/services/typingindicator.d.ts +0 -50
- package/lib/services/typingindicator.js +0 -102
- package/lib/session.d.ts +0 -63
- package/lib/session.js +0 -213
- package/lib/sessionerror.d.ts +0 -12
- package/lib/sessionerror.js +0 -24
- package/lib/sri.json +0 -1
- package/lib/synclist.d.ts +0 -24
- package/lib/synclist.js +0 -28
- package/lib/synclistdescriptor.d.ts +0 -27
- package/lib/synclistdescriptor.js +0 -19
- package/lib/syncpaginator.d.ts +0 -22
- package/lib/syncpaginator.js +0 -37
- package/lib/user.d.ts +0 -98
- package/lib/user.js +0 -219
- package/lib/util/deferred.d.ts +0 -12
- package/lib/util/deferred.js +0 -22
- package/lib/util/index.d.ts +0 -28
- package/lib/util/index.js +0 -82
- package/tools/rtd-sdk-cdn-pin/.gitrepo +0 -12
- package/tools/rtd-sdk-cdn-pin/README.md +0 -54
- package/tools/rtd-sdk-cdn-pin/bintray-settings.xml.template +0 -16
- package/tools/rtd-sdk-cdn-pin/cdn-common/cdn-prepare.sh +0 -67
- package/tools/rtd-sdk-cdn-pin/cdn-pin-latest.sh +0 -19
- package/tools/rtd-sdk-cdn-pin/cdn-pin.sh +0 -19
- package/tools/rtd-sdk-cdn-pin/cdn-upload.sh +0 -13
- package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-bintray-android.sh +0 -34
- package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-npm.sh +0 -18
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-android.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-js.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-android.sh +0 -6
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-js.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-android.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-js.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch-artifact.sh +0 -26
- package/tools/sdk-release-tool/.gitrepo +0 -12
- package/tools/sdk-release-tool/Makefile +0 -49
- package/tools/sdk-release-tool/README.md +0 -275
- package/tools/sdk-release-tool/delete +0 -3
- package/tools/sdk-release-tool/download +0 -3
- package/tools/sdk-release-tool/get-cors +0 -3
- package/tools/sdk-release-tool/list +0 -3
- package/tools/sdk-release-tool/pin +0 -3
- package/tools/sdk-release-tool/pin-latest +0 -3
- package/tools/sdk-release-tool/requirements.txt +0 -4
- package/tools/sdk-release-tool/sdk-release-tool +0 -3
- package/tools/sdk-release-tool/sdk_release_tools/__init__.py +0 -0
- package/tools/sdk-release-tool/sdk_release_tools/__main__.py +0 -110
- package/tools/sdk-release-tool/sdk_release_tools/aws.py +0 -70
- package/tools/sdk-release-tool/sdk_release_tools/cli.py +0 -181
- package/tools/sdk-release-tool/sdk_release_tools/log.py +0 -24
- package/tools/sdk-release-tool/sdk_release_tools/ops.py +0 -295
- package/tools/sdk-release-tool/sdk_release_tools/rpm.py +0 -28
- package/tools/sdk-release-tool/sdk_release_tools/util.py +0 -186
- package/tools/sdk-release-tool/sdk_release_tools/versions.py +0 -362
- package/tools/sdk-release-tool/signal-sdk-js.json +0 -28
- package/tools/sdk-release-tool/tests/test_versions.py +0 -94
- package/tools/sdk-release-tool/twilio-accessmanager-android.json +0 -19
- package/tools/sdk-release-tool/twilio-accessmanager-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-auth-ios.json +0 -29
- package/tools/sdk-release-tool/twilio-authenticator-ios.json +0 -29
- package/tools/sdk-release-tool/twilio-chat-android-2.json +0 -19
- package/tools/sdk-release-tool/twilio-chat-android.json +0 -22
- package/tools/sdk-release-tool/twilio-chat-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-chat-js.json +0 -27
- package/tools/sdk-release-tool/twilio-client-android-aar.json +0 -22
- package/tools/sdk-release-tool/twilio-client-android.json +0 -22
- package/tools/sdk-release-tool/twilio-client-ios.json +0 -20
- package/tools/sdk-release-tool/twilio-client-js.json +0 -17
- package/tools/sdk-release-tool/twilio-client-sounds-js.json +0 -14
- package/tools/sdk-release-tool/twilio-common-android-maven.json +0 -16
- package/tools/sdk-release-tool/twilio-common-android.json +0 -22
- package/tools/sdk-release-tool/twilio-common-ios-rtc.json +0 -25
- package/tools/sdk-release-tool/twilio-common-ios.json +0 -25
- package/tools/sdk-release-tool/twilio-common-js.json +0 -19
- package/tools/sdk-release-tool/twilio-conversations-android.json +0 -22
- package/tools/sdk-release-tool/twilio-conversations-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-conversations-js.json +0 -27
- package/tools/sdk-release-tool/twilio-flex-js.json +0 -20
- package/tools/sdk-release-tool/twilio-flex-webchat-js.json +0 -16
- package/tools/sdk-release-tool/twilio-frame-chat-android.json +0 -22
- package/tools/sdk-release-tool/twilio-frame-chat-ios.json +0 -23
- package/tools/sdk-release-tool/twilio-frame-chat-js.json +0 -23
- package/tools/sdk-release-tool/twilio-ip-messaging-android-maven.json +0 -16
- package/tools/sdk-release-tool/twilio-ip-messaging-android.json +0 -22
- package/tools/sdk-release-tool/twilio-ip-messaging-ios.json +0 -25
- package/tools/sdk-release-tool/twilio-ip-messaging-js.json +0 -21
- package/tools/sdk-release-tool/twilio-sync-android.json +0 -22
- package/tools/sdk-release-tool/twilio-sync-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-sync-js.json +0 -39
- package/tools/sdk-release-tool/twilio-taskrouter-js.json +0 -17
- package/tools/sdk-release-tool/twilio-video-android.json +0 -22
- package/tools/sdk-release-tool/twilio-video-cpp-linux-cross-rootfs.json +0 -13
- package/tools/sdk-release-tool/twilio-video-cpp.json +0 -33
- package/tools/sdk-release-tool/twilio-video-ios.json +0 -25
- package/tools/sdk-release-tool/twilio-video-js.json +0 -19
- package/tools/sdk-release-tool/twilio-video-jsdocs.json +0 -14
- package/tools/sdk-release-tool/twilio-voice-android.json +0 -22
- package/tools/sdk-release-tool/twilio-voice-ios.json +0 -29
- package/tools/sdk-release-tool/unpin +0 -3
- package/tools/sdk-release-tool/unpin-latest +0 -3
- package/tools/sdk-release-tool/upload +0 -3
- package/twilio-chat.js.iml +0 -9
@@ -1,632 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _promise = require("babel-runtime/core-js/promise");
|
4
|
-
|
5
|
-
var _promise2 = _interopRequireDefault(_promise);
|
6
|
-
|
7
|
-
var _stringify = require("babel-runtime/core-js/json/stringify");
|
8
|
-
|
9
|
-
var _stringify2 = _interopRequireDefault(_stringify);
|
10
|
-
|
11
|
-
var _set = require("babel-runtime/core-js/set");
|
12
|
-
|
13
|
-
var _set2 = _interopRequireDefault(_set);
|
14
|
-
|
15
|
-
var _map = require("babel-runtime/core-js/map");
|
16
|
-
|
17
|
-
var _map2 = _interopRequireDefault(_map);
|
18
|
-
|
19
|
-
var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of");
|
20
|
-
|
21
|
-
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
22
|
-
|
23
|
-
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
|
24
|
-
|
25
|
-
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
26
|
-
|
27
|
-
var _createClass2 = require("babel-runtime/helpers/createClass");
|
28
|
-
|
29
|
-
var _createClass3 = _interopRequireDefault(_createClass2);
|
30
|
-
|
31
|
-
var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
|
32
|
-
|
33
|
-
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
34
|
-
|
35
|
-
var _inherits2 = require("babel-runtime/helpers/inherits");
|
36
|
-
|
37
|
-
var _inherits3 = _interopRequireDefault(_inherits2);
|
38
|
-
|
39
|
-
var _regenerator = require("babel-runtime/regenerator");
|
40
|
-
|
41
|
-
var _regenerator2 = _interopRequireDefault(_regenerator);
|
42
|
-
|
43
|
-
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
|
44
|
-
|
45
|
-
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
46
|
-
|
47
|
-
var wrapService = function () {
|
48
|
-
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(services) {
|
49
|
-
return _regenerator2.default.wrap(function _callee$(_context) {
|
50
|
-
while (1) {
|
51
|
-
switch (_context.prev = _context.next) {
|
52
|
-
case 0:
|
53
|
-
_context.next = 2;
|
54
|
-
return services.session.getMediaLimits();
|
55
|
-
|
56
|
-
case 2:
|
57
|
-
_context.t0 = _context.sent;
|
58
|
-
_context.t1 = services.session;
|
59
|
-
_context.t2 = services.syncClient;
|
60
|
-
_context.t3 = services.users;
|
61
|
-
_context.t4 = services.typingIndicator;
|
62
|
-
_context.t5 = services.readHorizon;
|
63
|
-
_context.t6 = services.network;
|
64
|
-
_context.t7 = services.mcsClient;
|
65
|
-
return _context.abrupt("return", {
|
66
|
-
limits: _context.t0,
|
67
|
-
session: _context.t1,
|
68
|
-
syncClient: _context.t2,
|
69
|
-
users: _context.t3,
|
70
|
-
typingIndicator: _context.t4,
|
71
|
-
readHorizon: _context.t5,
|
72
|
-
network: _context.t6,
|
73
|
-
mcsClient: _context.t7
|
74
|
-
});
|
75
|
-
|
76
|
-
case 11:
|
77
|
-
case "end":
|
78
|
-
return _context.stop();
|
79
|
-
}
|
80
|
-
}
|
81
|
-
}, _callee, this);
|
82
|
-
}));
|
83
|
-
|
84
|
-
return function wrapService(_x) {
|
85
|
-
return _ref.apply(this, arguments);
|
86
|
-
};
|
87
|
-
}();
|
88
|
-
/**
|
89
|
-
* Represents conversations collection
|
90
|
-
* {@see Conversation}
|
91
|
-
*/
|
92
|
-
|
93
|
-
|
94
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
95
|
-
|
96
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
97
|
-
var events_1 = require("events");
|
98
|
-
var logger_1 = require("../logger");
|
99
|
-
var conversation_1 = require("../conversation");
|
100
|
-
exports.Conversation = conversation_1.Conversation;
|
101
|
-
var deferred_1 = require("../util/deferred");
|
102
|
-
var util_1 = require("../util");
|
103
|
-
var log = logger_1.Logger.scope('Conversations');
|
104
|
-
|
105
|
-
var Conversations = function (_events_1$EventEmitte) {
|
106
|
-
(0, _inherits3.default)(Conversations, _events_1$EventEmitte);
|
107
|
-
|
108
|
-
function Conversations(services) {
|
109
|
-
(0, _classCallCheck3.default)(this, Conversations);
|
110
|
-
|
111
|
-
var _this = (0, _possibleConstructorReturn3.default)(this, (Conversations.__proto__ || (0, _getPrototypeOf2.default)(Conversations)).call(this));
|
112
|
-
|
113
|
-
_this.services = services;
|
114
|
-
_this.conversations = new _map2.default();
|
115
|
-
_this.tombstones = new _set2.default();
|
116
|
-
_this.syncListFetched = false;
|
117
|
-
_this.syncListRead = new deferred_1.Deferred();
|
118
|
-
return _this;
|
119
|
-
}
|
120
|
-
|
121
|
-
(0, _createClass3.default)(Conversations, [{
|
122
|
-
key: "getMap",
|
123
|
-
value: function getMap() {
|
124
|
-
var _this2 = this;
|
125
|
-
|
126
|
-
return this.services.session.getMyConversationsId().then(function (name) {
|
127
|
-
return _this2.services.syncClient.map({ id: name, mode: 'open_existing' });
|
128
|
-
});
|
129
|
-
}
|
130
|
-
/**
|
131
|
-
* Add conversation to server
|
132
|
-
* @private
|
133
|
-
* @returns {Promise<Conversation>} Conversation
|
134
|
-
*/
|
135
|
-
|
136
|
-
}, {
|
137
|
-
key: "addConversation",
|
138
|
-
value: function () {
|
139
|
-
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(options) {
|
140
|
-
var attributes, response, conversationSid, conversationDocument, existingConversation, conversation;
|
141
|
-
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
142
|
-
while (1) {
|
143
|
-
switch (_context2.prev = _context2.next) {
|
144
|
-
case 0:
|
145
|
-
attributes = void 0;
|
146
|
-
|
147
|
-
if (typeof options.attributes === 'undefined') {
|
148
|
-
attributes = {};
|
149
|
-
} else {
|
150
|
-
attributes = options.attributes;
|
151
|
-
}
|
152
|
-
_context2.next = 4;
|
153
|
-
return this.services.session.addCommand('createConversation', {
|
154
|
-
friendlyName: options.friendlyName,
|
155
|
-
uniqueName: options.uniqueName,
|
156
|
-
attributes: (0, _stringify2.default)(attributes)
|
157
|
-
});
|
158
|
-
|
159
|
-
case 4:
|
160
|
-
response = _context2.sent;
|
161
|
-
conversationSid = 'conversationSid' in response ? response['conversationSid'] : null;
|
162
|
-
conversationDocument = 'conversation' in response ? response['conversation'] : null;
|
163
|
-
existingConversation = this.conversations.get(conversationSid);
|
164
|
-
|
165
|
-
if (!existingConversation) {
|
166
|
-
_context2.next = 12;
|
167
|
-
break;
|
168
|
-
}
|
169
|
-
|
170
|
-
_context2.next = 11;
|
171
|
-
return existingConversation._subscribe();
|
172
|
-
|
173
|
-
case 11:
|
174
|
-
return _context2.abrupt("return", existingConversation);
|
175
|
-
|
176
|
-
case 12:
|
177
|
-
_context2.t0 = conversation_1.Conversation;
|
178
|
-
_context2.next = 15;
|
179
|
-
return wrapService(this.services);
|
180
|
-
|
181
|
-
case 15:
|
182
|
-
_context2.t1 = _context2.sent;
|
183
|
-
_context2.t2 = {
|
184
|
-
channel: conversationDocument,
|
185
|
-
entityName: null,
|
186
|
-
uniqueName: null,
|
187
|
-
attributes: null,
|
188
|
-
createdBy: null,
|
189
|
-
friendlyName: null,
|
190
|
-
lastConsumedMessageIndex: null,
|
191
|
-
dateCreated: null,
|
192
|
-
dateUpdated: null
|
193
|
-
};
|
194
|
-
_context2.t3 = conversationSid;
|
195
|
-
conversation = new _context2.t0(_context2.t1, _context2.t2, _context2.t3);
|
196
|
-
|
197
|
-
this.conversations.set(conversation.sid, conversation);
|
198
|
-
this.registerForEvents(conversation);
|
199
|
-
_context2.next = 23;
|
200
|
-
return conversation._subscribe();
|
201
|
-
|
202
|
-
case 23:
|
203
|
-
this.emit('conversationAdded', conversation);
|
204
|
-
return _context2.abrupt("return", conversation);
|
205
|
-
|
206
|
-
case 25:
|
207
|
-
case "end":
|
208
|
-
return _context2.stop();
|
209
|
-
}
|
210
|
-
}
|
211
|
-
}, _callee2, this);
|
212
|
-
}));
|
213
|
-
|
214
|
-
function addConversation(_x2) {
|
215
|
-
return _ref2.apply(this, arguments);
|
216
|
-
}
|
217
|
-
|
218
|
-
return addConversation;
|
219
|
-
}()
|
220
|
-
/**
|
221
|
-
* Fetch conversations list and instantiate all necessary objects
|
222
|
-
*/
|
223
|
-
|
224
|
-
}, {
|
225
|
-
key: "fetchConversations",
|
226
|
-
value: function fetchConversations() {
|
227
|
-
var _this3 = this;
|
228
|
-
|
229
|
-
this.getMap().then(function () {
|
230
|
-
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(map) {
|
231
|
-
var upserts, paginator, items;
|
232
|
-
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
233
|
-
while (1) {
|
234
|
-
switch (_context3.prev = _context3.next) {
|
235
|
-
case 0:
|
236
|
-
map.on('itemAdded', function (args) {
|
237
|
-
log.debug('itemAdded: ' + args.item.key);
|
238
|
-
_this3.upsertConversation('sync', args.item.key, args.item.data);
|
239
|
-
});
|
240
|
-
map.on('itemRemoved', function (args) {
|
241
|
-
log.debug('itemRemoved: ' + args.key);
|
242
|
-
var sid = args.key;
|
243
|
-
if (!_this3.syncListFetched) {
|
244
|
-
_this3.tombstones.add(sid);
|
245
|
-
}
|
246
|
-
var conversation = _this3.conversations.get(sid);
|
247
|
-
if (conversation) {
|
248
|
-
if (conversation && conversation.status === 'joined' /*|| conversation.status === 'invited'*/) {
|
249
|
-
conversation._setStatus('notParticipating', 'sync');
|
250
|
-
_this3.emit('conversationLeft', conversation);
|
251
|
-
}
|
252
|
-
_this3.conversations.delete(sid);
|
253
|
-
_this3.emit('conversationRemoved', conversation);
|
254
|
-
conversation.emit('removed', conversation);
|
255
|
-
}
|
256
|
-
});
|
257
|
-
map.on('itemUpdated', function (args) {
|
258
|
-
log.debug('itemUpdated: ' + args.item.key);
|
259
|
-
_this3.upsertConversation('sync', args.item.key, args.item.data);
|
260
|
-
});
|
261
|
-
upserts = [];
|
262
|
-
_context3.next = 6;
|
263
|
-
return _this3.services.syncList.getPage();
|
264
|
-
|
265
|
-
case 6:
|
266
|
-
paginator = _context3.sent;
|
267
|
-
items = paginator.items;
|
268
|
-
|
269
|
-
items.forEach(function (item) {
|
270
|
-
upserts.push(_this3.upsertConversation('synclist', item.channel_sid, item));
|
271
|
-
});
|
272
|
-
|
273
|
-
case 9:
|
274
|
-
if (!paginator.hasNextPage) {
|
275
|
-
_context3.next = 16;
|
276
|
-
break;
|
277
|
-
}
|
278
|
-
|
279
|
-
_context3.next = 12;
|
280
|
-
return paginator.nextPage();
|
281
|
-
|
282
|
-
case 12:
|
283
|
-
paginator = _context3.sent;
|
284
|
-
|
285
|
-
paginator.items.forEach(function (item) {
|
286
|
-
upserts.push(_this3.upsertConversation('synclist', item.channel_sid, item));
|
287
|
-
});
|
288
|
-
_context3.next = 9;
|
289
|
-
break;
|
290
|
-
|
291
|
-
case 16:
|
292
|
-
_this3.syncListRead.set(true);
|
293
|
-
return _context3.abrupt("return", _promise2.default.all(upserts));
|
294
|
-
|
295
|
-
case 18:
|
296
|
-
case "end":
|
297
|
-
return _context3.stop();
|
298
|
-
}
|
299
|
-
}
|
300
|
-
}, _callee3, _this3);
|
301
|
-
}));
|
302
|
-
|
303
|
-
return function (_x3) {
|
304
|
-
return _ref3.apply(this, arguments);
|
305
|
-
};
|
306
|
-
}()).then(function () {
|
307
|
-
_this3.syncListFetched = true;
|
308
|
-
_this3.tombstones.clear();
|
309
|
-
log.debug('Conversations list fetched');
|
310
|
-
}).then(function () {
|
311
|
-
return _this3;
|
312
|
-
}).catch(function (e) {
|
313
|
-
if (_this3.services.syncClient.connectionState != 'disconnected') {
|
314
|
-
log.error('Failed to get conversations list', e);
|
315
|
-
}
|
316
|
-
log.debug('ERROR: Failed to get conversations list', e);
|
317
|
-
throw e;
|
318
|
-
});
|
319
|
-
}
|
320
|
-
}, {
|
321
|
-
key: "_wrapPaginator",
|
322
|
-
value: function _wrapPaginator(page, op) {
|
323
|
-
var _this4 = this;
|
324
|
-
|
325
|
-
return op(page.items).then(function (items) {
|
326
|
-
return {
|
327
|
-
items: items,
|
328
|
-
hasNextPage: page.hasNextPage,
|
329
|
-
hasPrevPage: page.hasPrevPage,
|
330
|
-
nextPage: function nextPage() {
|
331
|
-
return page.nextPage().then(function (x) {
|
332
|
-
return _this4._wrapPaginator(x, op);
|
333
|
-
});
|
334
|
-
},
|
335
|
-
prevPage: function prevPage() {
|
336
|
-
return page.prevPage().then(function (x) {
|
337
|
-
return _this4._wrapPaginator(x, op);
|
338
|
-
});
|
339
|
-
}
|
340
|
-
};
|
341
|
-
});
|
342
|
-
}
|
343
|
-
}, {
|
344
|
-
key: "getConversations",
|
345
|
-
value: function getConversations(args) {
|
346
|
-
var _this5 = this;
|
347
|
-
|
348
|
-
return this.getMap().then(function (conversationsMap) {
|
349
|
-
return conversationsMap.getItems(args);
|
350
|
-
}).then(function (page) {
|
351
|
-
return _this5._wrapPaginator(page, function (items) {
|
352
|
-
return _promise2.default.all(items.map(function (item) {
|
353
|
-
return _this5.upsertConversation('sync', item.key, item.data);
|
354
|
-
}));
|
355
|
-
});
|
356
|
-
});
|
357
|
-
}
|
358
|
-
}, {
|
359
|
-
key: "getConversation",
|
360
|
-
value: function getConversation(sid) {
|
361
|
-
var _this6 = this;
|
362
|
-
|
363
|
-
return this.getMap().then(function (conversationsMap) {
|
364
|
-
return conversationsMap.getItems({ key: sid });
|
365
|
-
}).then(function (page) {
|
366
|
-
return page.items.map(function (item) {
|
367
|
-
return _this6.upsertConversation('sync', item.key, item.data);
|
368
|
-
});
|
369
|
-
}).then(function (items) {
|
370
|
-
return items.length > 0 ? items[0] : null;
|
371
|
-
});
|
372
|
-
}
|
373
|
-
}, {
|
374
|
-
key: "getConversationByUniqueName",
|
375
|
-
value: function () {
|
376
|
-
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(uniqueName) {
|
377
|
-
var _a, _b, links, url, response, body, sid, data;
|
378
|
-
|
379
|
-
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
380
|
-
while (1) {
|
381
|
-
switch (_context4.prev = _context4.next) {
|
382
|
-
case 0:
|
383
|
-
_context4.next = 2;
|
384
|
-
return this.services.session.getSessionLinks();
|
385
|
-
|
386
|
-
case 2:
|
387
|
-
links = _context4.sent;
|
388
|
-
url = new util_1.UriBuilder(links.myChannelsUrl).path(uniqueName).build();
|
389
|
-
_context4.next = 6;
|
390
|
-
return this.services.network.get(url);
|
391
|
-
|
392
|
-
case 6:
|
393
|
-
response = _context4.sent;
|
394
|
-
body = response.body;
|
395
|
-
sid = body.channel_sid;
|
396
|
-
data = {
|
397
|
-
entityName: null,
|
398
|
-
lastConsumedMessageIndex: body.last_consumed_message_index,
|
399
|
-
status: ((_a = body) === null || _a === void 0 ? void 0 : _a.status) || 'unknown',
|
400
|
-
friendlyName: body.friendly_name,
|
401
|
-
dateUpdated: body.date_updated,
|
402
|
-
dateCreated: body.date_created,
|
403
|
-
uniqueName: body.unique_name,
|
404
|
-
createdBy: body.created_by,
|
405
|
-
attributes: body.attributes,
|
406
|
-
channel: sid + ".channel",
|
407
|
-
notificationLevel: (_b = body) === null || _b === void 0 ? void 0 : _b.notification_level,
|
408
|
-
sid: sid
|
409
|
-
};
|
410
|
-
return _context4.abrupt("return", this.upsertConversation('sync', sid, data));
|
411
|
-
|
412
|
-
case 11:
|
413
|
-
case "end":
|
414
|
-
return _context4.stop();
|
415
|
-
}
|
416
|
-
}
|
417
|
-
}, _callee4, this);
|
418
|
-
}));
|
419
|
-
|
420
|
-
function getConversationByUniqueName(_x4) {
|
421
|
-
return _ref4.apply(this, arguments);
|
422
|
-
}
|
423
|
-
|
424
|
-
return getConversationByUniqueName;
|
425
|
-
}()
|
426
|
-
}, {
|
427
|
-
key: "getWhisperConversation",
|
428
|
-
value: function () {
|
429
|
-
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(sid) {
|
430
|
-
var _a, _b, links, url, response, body, data;
|
431
|
-
|
432
|
-
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
433
|
-
while (1) {
|
434
|
-
switch (_context5.prev = _context5.next) {
|
435
|
-
case 0:
|
436
|
-
_context5.next = 2;
|
437
|
-
return this.services.session.getSessionLinks();
|
438
|
-
|
439
|
-
case 2:
|
440
|
-
links = _context5.sent;
|
441
|
-
url = new util_1.UriBuilder(links.publicChannelsUrl).path(sid).build();
|
442
|
-
_context5.next = 6;
|
443
|
-
return this.services.network.get(url);
|
444
|
-
|
445
|
-
case 6:
|
446
|
-
response = _context5.sent;
|
447
|
-
body = response.body;
|
448
|
-
|
449
|
-
if (!(body.type !== 'private')) {
|
450
|
-
_context5.next = 10;
|
451
|
-
break;
|
452
|
-
}
|
453
|
-
|
454
|
-
return _context5.abrupt("return", null);
|
455
|
-
|
456
|
-
case 10:
|
457
|
-
data = {
|
458
|
-
entityName: null,
|
459
|
-
lastConsumedMessageIndex: body.last_consumed_message_index,
|
460
|
-
status: ((_a = body) === null || _a === void 0 ? void 0 : _a.status) || 'unknown',
|
461
|
-
friendlyName: body.friendly_name,
|
462
|
-
dateUpdated: body.date_updated,
|
463
|
-
dateCreated: body.date_created,
|
464
|
-
uniqueName: body.unique_name,
|
465
|
-
createdBy: body.created_by,
|
466
|
-
attributes: body.attributes,
|
467
|
-
channel: sid + ".channel",
|
468
|
-
notificationLevel: (_b = body) === null || _b === void 0 ? void 0 : _b.notification_level,
|
469
|
-
sid: sid
|
470
|
-
};
|
471
|
-
return _context5.abrupt("return", this.upsertConversation('sync', sid, data));
|
472
|
-
|
473
|
-
case 12:
|
474
|
-
case "end":
|
475
|
-
return _context5.stop();
|
476
|
-
}
|
477
|
-
}
|
478
|
-
}, _callee5, this);
|
479
|
-
}));
|
480
|
-
|
481
|
-
function getWhisperConversation(_x5) {
|
482
|
-
return _ref5.apply(this, arguments);
|
483
|
-
}
|
484
|
-
|
485
|
-
return getWhisperConversation;
|
486
|
-
}()
|
487
|
-
}, {
|
488
|
-
key: "upsertConversation",
|
489
|
-
value: function () {
|
490
|
-
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(source, sid, data) {
|
491
|
-
var _this7 = this;
|
492
|
-
|
493
|
-
var conversation, updateData;
|
494
|
-
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
495
|
-
while (1) {
|
496
|
-
switch (_context6.prev = _context6.next) {
|
497
|
-
case 0:
|
498
|
-
log.trace('upsertConversation(sid=' + sid + ', data=', data);
|
499
|
-
conversation = this.conversations.get(sid);
|
500
|
-
// Update the Conversation's status if we know about it
|
501
|
-
|
502
|
-
if (!conversation) {
|
503
|
-
_context6.next = 6;
|
504
|
-
break;
|
505
|
-
}
|
506
|
-
|
507
|
-
log.trace('upsertConversation: conversation ' + sid + ' is known and it\'s' + ' status is known from source ' + conversation._statusSource() + ' and update came from source ' + source, conversation);
|
508
|
-
if (typeof conversation._statusSource() === 'undefined' || source === conversation._statusSource() || source === 'synclist' && conversation._statusSource() !== 'sync' || source === 'sync') {
|
509
|
-
if (data.status === 'joined' && conversation.status !== 'joined') {
|
510
|
-
conversation._setStatus('joined', source);
|
511
|
-
updateData = {};
|
512
|
-
|
513
|
-
if (typeof data.notificationLevel !== 'undefined') {
|
514
|
-
updateData.notificationLevel = data.notificationLevel;
|
515
|
-
}
|
516
|
-
if (typeof data.lastConsumedMessageIndex !== 'undefined') {
|
517
|
-
updateData.lastConsumedMessageIndex = data.lastConsumedMessageIndex;
|
518
|
-
}
|
519
|
-
if (!util_1.isDeepEqual(updateData, {})) {
|
520
|
-
conversation._update(updateData);
|
521
|
-
}
|
522
|
-
conversation._subscribe().then(function () {
|
523
|
-
_this7.emit('conversationJoined', conversation);
|
524
|
-
});
|
525
|
-
} else if (data.status === 'notParticipating' && conversation.status === 'joined') {
|
526
|
-
conversation._setStatus('notParticipating', source);
|
527
|
-
conversation._update(data);
|
528
|
-
conversation._subscribe().then(function () {
|
529
|
-
_this7.emit('conversationLeft', conversation);
|
530
|
-
});
|
531
|
-
} else if (data.status === 'notParticipating') {
|
532
|
-
conversation._subscribe();
|
533
|
-
} else {
|
534
|
-
conversation._update(data);
|
535
|
-
}
|
536
|
-
} else {
|
537
|
-
log.trace('upsertConversation: conversation is known from sync and came from chat, ignoring', {
|
538
|
-
sid: sid,
|
539
|
-
data: data.status,
|
540
|
-
conversation: conversation.status
|
541
|
-
});
|
542
|
-
}
|
543
|
-
return _context6.abrupt("return", conversation._subscribe().then(function () {
|
544
|
-
return conversation;
|
545
|
-
}));
|
546
|
-
|
547
|
-
case 6:
|
548
|
-
if (!((source === 'chat' || source === 'synclist') && this.tombstones.has(sid))) {
|
549
|
-
_context6.next = 9;
|
550
|
-
break;
|
551
|
-
}
|
552
|
-
|
553
|
-
// if conversation was deleted, we ignore it
|
554
|
-
log.trace('upsertConversation: conversation is deleted and came again from chat, ignoring', sid);
|
555
|
-
return _context6.abrupt("return");
|
556
|
-
|
557
|
-
case 9:
|
558
|
-
// Fetch the Conversation if we don't know about it
|
559
|
-
log.trace('upsertConversation: creating local conversation object with sid ' + sid, data);
|
560
|
-
_context6.t0 = conversation_1.Conversation;
|
561
|
-
_context6.next = 13;
|
562
|
-
return wrapService(this.services);
|
563
|
-
|
564
|
-
case 13:
|
565
|
-
_context6.t1 = _context6.sent;
|
566
|
-
_context6.t2 = data;
|
567
|
-
_context6.t3 = sid;
|
568
|
-
conversation = new _context6.t0(_context6.t1, _context6.t2, _context6.t3);
|
569
|
-
|
570
|
-
this.conversations.set(sid, conversation);
|
571
|
-
return _context6.abrupt("return", conversation._subscribe().then(function () {
|
572
|
-
_this7.registerForEvents(conversation);
|
573
|
-
_this7.emit('conversationAdded', conversation);
|
574
|
-
if (data.status === 'joined') {
|
575
|
-
conversation._setStatus('joined', source);
|
576
|
-
_this7.emit('conversationJoined', conversation);
|
577
|
-
}
|
578
|
-
return conversation;
|
579
|
-
}));
|
580
|
-
|
581
|
-
case 19:
|
582
|
-
case "end":
|
583
|
-
return _context6.stop();
|
584
|
-
}
|
585
|
-
}
|
586
|
-
}, _callee6, this);
|
587
|
-
}));
|
588
|
-
|
589
|
-
function upsertConversation(_x6, _x7, _x8) {
|
590
|
-
return _ref6.apply(this, arguments);
|
591
|
-
}
|
592
|
-
|
593
|
-
return upsertConversation;
|
594
|
-
}()
|
595
|
-
}, {
|
596
|
-
key: "onConversationRemoved",
|
597
|
-
value: function onConversationRemoved(sid) {
|
598
|
-
var conversation = this.conversations.get(sid);
|
599
|
-
if (conversation) {
|
600
|
-
this.conversations.delete(sid);
|
601
|
-
this.emit('conversationRemoved', conversation);
|
602
|
-
}
|
603
|
-
}
|
604
|
-
}, {
|
605
|
-
key: "registerForEvents",
|
606
|
-
value: function registerForEvents(conversation) {
|
607
|
-
var _this8 = this;
|
608
|
-
|
609
|
-
conversation.on('removed', function () {
|
610
|
-
return _this8.onConversationRemoved(conversation.sid);
|
611
|
-
});
|
612
|
-
conversation.on('updated', function (args) {
|
613
|
-
return _this8.emit('conversationUpdated', args);
|
614
|
-
});
|
615
|
-
conversation.on('participantJoined', this.emit.bind(this, 'participantJoined'));
|
616
|
-
conversation.on('participantLeft', this.emit.bind(this, 'participantLeft'));
|
617
|
-
conversation.on('participantUpdated', function (args) {
|
618
|
-
return _this8.emit('participantUpdated', args);
|
619
|
-
});
|
620
|
-
conversation.on('messageAdded', this.emit.bind(this, 'messageAdded'));
|
621
|
-
conversation.on('messageUpdated', function (args) {
|
622
|
-
return _this8.emit('messageUpdated', args);
|
623
|
-
});
|
624
|
-
conversation.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));
|
625
|
-
conversation.on('typingStarted', this.emit.bind(this, 'typingStarted'));
|
626
|
-
conversation.on('typingEnded', this.emit.bind(this, 'typingEnded'));
|
627
|
-
}
|
628
|
-
}]);
|
629
|
-
return Conversations;
|
630
|
-
}(events_1.EventEmitter);
|
631
|
-
|
632
|
-
exports.Conversations = Conversations;
|