@twilio/conversations 1.3.0-rc7 → 2.0.0-rc.3
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 +201 -0
- package/README.md +5 -5
- package/dist/browser.js +7866 -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 +3387 -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 +3169 -0
- package/dist/docs/modules.html +3418 -0
- package/dist/lib.d.ts +1944 -0
- package/dist/lib.js +7866 -0
- package/dist/lib.js.map +1 -0
- package/dist/post-install.js +29 -0
- package/dist/react-native.js +4031 -0
- package/dist/react-native.js.map +1 -0
- package/dist/twilio-conversations.js +40905 -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 -665
- 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 -35565
- 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 -318
- 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,411 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _stringify = require("babel-runtime/core-js/json/stringify");
|
4
|
-
|
5
|
-
var _stringify2 = _interopRequireDefault(_stringify);
|
6
|
-
|
7
|
-
var _promise = require("babel-runtime/core-js/promise");
|
8
|
-
|
9
|
-
var _promise2 = _interopRequireDefault(_promise);
|
10
|
-
|
11
|
-
var _regenerator = require("babel-runtime/regenerator");
|
12
|
-
|
13
|
-
var _regenerator2 = _interopRequireDefault(_regenerator);
|
14
|
-
|
15
|
-
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
|
16
|
-
|
17
|
-
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
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
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
40
|
-
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
42
|
-
var events_1 = require("events");
|
43
|
-
var participant_1 = require("../participant");
|
44
|
-
var logger_1 = require("../logger");
|
45
|
-
var log = logger_1.Logger.scope('Participants');
|
46
|
-
/**
|
47
|
-
* @classdesc Represents the collection of participants for the conversation
|
48
|
-
* @fires Participants#participantJoined
|
49
|
-
* @fires Participants#participantLeft
|
50
|
-
* @fires Participants#participantUpdated
|
51
|
-
*/
|
52
|
-
|
53
|
-
var Participants = function (_events_1$EventEmitte) {
|
54
|
-
(0, _inherits3.default)(Participants, _events_1$EventEmitte);
|
55
|
-
|
56
|
-
function Participants(conversation, services, participants) {
|
57
|
-
(0, _classCallCheck3.default)(this, Participants);
|
58
|
-
|
59
|
-
var _this = (0, _possibleConstructorReturn3.default)(this, (Participants.__proto__ || (0, _getPrototypeOf2.default)(Participants)).call(this));
|
60
|
-
|
61
|
-
_this.services = services;
|
62
|
-
_this.conversation = conversation;
|
63
|
-
_this.participants = participants;
|
64
|
-
return _this;
|
65
|
-
}
|
66
|
-
|
67
|
-
(0, _createClass3.default)(Participants, [{
|
68
|
-
key: "unsubscribe",
|
69
|
-
value: function () {
|
70
|
-
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
|
71
|
-
var entity;
|
72
|
-
return _regenerator2.default.wrap(function _callee$(_context) {
|
73
|
-
while (1) {
|
74
|
-
switch (_context.prev = _context.next) {
|
75
|
-
case 0:
|
76
|
-
if (!this.rosterEntityPromise) {
|
77
|
-
_context.next = 6;
|
78
|
-
break;
|
79
|
-
}
|
80
|
-
|
81
|
-
_context.next = 3;
|
82
|
-
return this.rosterEntityPromise;
|
83
|
-
|
84
|
-
case 3:
|
85
|
-
entity = _context.sent;
|
86
|
-
|
87
|
-
entity.close();
|
88
|
-
this.rosterEntityPromise = null;
|
89
|
-
|
90
|
-
case 6:
|
91
|
-
case "end":
|
92
|
-
return _context.stop();
|
93
|
-
}
|
94
|
-
}
|
95
|
-
}, _callee, this);
|
96
|
-
}));
|
97
|
-
|
98
|
-
function unsubscribe() {
|
99
|
-
return _ref.apply(this, arguments);
|
100
|
-
}
|
101
|
-
|
102
|
-
return unsubscribe;
|
103
|
-
}()
|
104
|
-
}, {
|
105
|
-
key: "subscribe",
|
106
|
-
value: function subscribe(rosterObjectName) {
|
107
|
-
var _this2 = this;
|
108
|
-
|
109
|
-
return this.rosterEntityPromise = this.rosterEntityPromise || this.services.syncClient.map({ id: rosterObjectName, mode: 'open_existing' }).then(function (rosterMap) {
|
110
|
-
rosterMap.on('itemAdded', function (args) {
|
111
|
-
log.debug(_this2.conversation.sid + ' itemAdded: ' + args.item.key);
|
112
|
-
_this2.upsertParticipant(args.item.key, args.item.data).then(function (participant) {
|
113
|
-
_this2.emit('participantJoined', participant);
|
114
|
-
});
|
115
|
-
});
|
116
|
-
rosterMap.on('itemRemoved', function (args) {
|
117
|
-
log.debug(_this2.conversation.sid + ' itemRemoved: ' + args.key);
|
118
|
-
var participantSid = args.key;
|
119
|
-
if (!_this2.participants.has(participantSid)) {
|
120
|
-
return;
|
121
|
-
}
|
122
|
-
var leftParticipant = _this2.participants.get(participantSid);
|
123
|
-
_this2.participants.delete(participantSid);
|
124
|
-
_this2.emit('participantLeft', leftParticipant);
|
125
|
-
});
|
126
|
-
rosterMap.on('itemUpdated', function (args) {
|
127
|
-
log.debug(_this2.conversation.sid + ' itemUpdated: ' + args.item.key);
|
128
|
-
_this2.upsertParticipant(args.item.key, args.item.data);
|
129
|
-
});
|
130
|
-
var participantsPromises = [];
|
131
|
-
var that = _this2;
|
132
|
-
var rosterMapHandler = function rosterMapHandler(paginator) {
|
133
|
-
paginator.items.forEach(function (item) {
|
134
|
-
participantsPromises.push(that.upsertParticipant(item.key, item.data));
|
135
|
-
});
|
136
|
-
return paginator.hasNextPage ? paginator.nextPage().then(rosterMapHandler) : null;
|
137
|
-
};
|
138
|
-
return rosterMap.getItems().then(rosterMapHandler).then(function () {
|
139
|
-
return _promise2.default.all(participantsPromises);
|
140
|
-
}).then(function () {
|
141
|
-
return rosterMap;
|
142
|
-
});
|
143
|
-
}).catch(function (err) {
|
144
|
-
_this2.rosterEntityPromise = null;
|
145
|
-
if (_this2.services.syncClient.connectionState != 'disconnected') {
|
146
|
-
log.error('Failed to get roster object for conversation', _this2.conversation.sid, err);
|
147
|
-
}
|
148
|
-
log.debug('ERROR: Failed to get roster object for conversation', _this2.conversation.sid, err);
|
149
|
-
throw err;
|
150
|
-
});
|
151
|
-
}
|
152
|
-
}, {
|
153
|
-
key: "upsertParticipant",
|
154
|
-
value: function () {
|
155
|
-
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(participantSid, data) {
|
156
|
-
var _this3 = this;
|
157
|
-
|
158
|
-
var participant;
|
159
|
-
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
160
|
-
while (1) {
|
161
|
-
switch (_context2.prev = _context2.next) {
|
162
|
-
case 0:
|
163
|
-
participant = this.participants.get(participantSid);
|
164
|
-
|
165
|
-
if (!participant) {
|
166
|
-
_context2.next = 3;
|
167
|
-
break;
|
168
|
-
}
|
169
|
-
|
170
|
-
return _context2.abrupt("return", participant._update(data));
|
171
|
-
|
172
|
-
case 3:
|
173
|
-
participant = new participant_1.Participant(this.services, this.conversation, data, participantSid);
|
174
|
-
this.participants.set(participantSid, participant);
|
175
|
-
participant.on('updated', function (args) {
|
176
|
-
return _this3.emit('participantUpdated', args);
|
177
|
-
});
|
178
|
-
return _context2.abrupt("return", participant);
|
179
|
-
|
180
|
-
case 7:
|
181
|
-
case "end":
|
182
|
-
return _context2.stop();
|
183
|
-
}
|
184
|
-
}
|
185
|
-
}, _callee2, this);
|
186
|
-
}));
|
187
|
-
|
188
|
-
function upsertParticipant(_x, _x2) {
|
189
|
-
return _ref2.apply(this, arguments);
|
190
|
-
}
|
191
|
-
|
192
|
-
return upsertParticipant;
|
193
|
-
}()
|
194
|
-
/**
|
195
|
-
* @returns {Promise<Array<Participant>>} returns list of participants {@see Participant}
|
196
|
-
*/
|
197
|
-
|
198
|
-
}, {
|
199
|
-
key: "getParticipants",
|
200
|
-
value: function () {
|
201
|
-
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
|
202
|
-
var _this4 = this;
|
203
|
-
|
204
|
-
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
205
|
-
while (1) {
|
206
|
-
switch (_context3.prev = _context3.next) {
|
207
|
-
case 0:
|
208
|
-
return _context3.abrupt("return", this.rosterEntityPromise.then(function () {
|
209
|
-
var participants = [];
|
210
|
-
_this4.participants.forEach(function (participant) {
|
211
|
-
return participants.push(participant);
|
212
|
-
});
|
213
|
-
return participants;
|
214
|
-
}));
|
215
|
-
|
216
|
-
case 1:
|
217
|
-
case "end":
|
218
|
-
return _context3.stop();
|
219
|
-
}
|
220
|
-
}
|
221
|
-
}, _callee3, this);
|
222
|
-
}));
|
223
|
-
|
224
|
-
function getParticipants() {
|
225
|
-
return _ref3.apply(this, arguments);
|
226
|
-
}
|
227
|
-
|
228
|
-
return getParticipants;
|
229
|
-
}()
|
230
|
-
/**
|
231
|
-
* Get participant by SID from conversation
|
232
|
-
* @returns {Promise<Participant>}
|
233
|
-
*/
|
234
|
-
|
235
|
-
}, {
|
236
|
-
key: "getParticipantBySid",
|
237
|
-
value: function () {
|
238
|
-
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(participantSid) {
|
239
|
-
var _this5 = this;
|
240
|
-
|
241
|
-
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
242
|
-
while (1) {
|
243
|
-
switch (_context4.prev = _context4.next) {
|
244
|
-
case 0:
|
245
|
-
return _context4.abrupt("return", this.rosterEntityPromise.then(function () {
|
246
|
-
var participant = _this5.participants.get(participantSid);
|
247
|
-
if (!participant) {
|
248
|
-
throw new Error('Participant with SID ' + participantSid + ' was not found');
|
249
|
-
}
|
250
|
-
return participant;
|
251
|
-
}));
|
252
|
-
|
253
|
-
case 1:
|
254
|
-
case "end":
|
255
|
-
return _context4.stop();
|
256
|
-
}
|
257
|
-
}
|
258
|
-
}, _callee4, this);
|
259
|
-
}));
|
260
|
-
|
261
|
-
function getParticipantBySid(_x3) {
|
262
|
-
return _ref4.apply(this, arguments);
|
263
|
-
}
|
264
|
-
|
265
|
-
return getParticipantBySid;
|
266
|
-
}()
|
267
|
-
/**
|
268
|
-
* Get participant by identity from conversation
|
269
|
-
* @returns {Promise<Participant>}
|
270
|
-
*/
|
271
|
-
|
272
|
-
}, {
|
273
|
-
key: "getParticipantByIdentity",
|
274
|
-
value: function () {
|
275
|
-
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(identity) {
|
276
|
-
var _this6 = this;
|
277
|
-
|
278
|
-
var foundParticipant;
|
279
|
-
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
280
|
-
while (1) {
|
281
|
-
switch (_context5.prev = _context5.next) {
|
282
|
-
case 0:
|
283
|
-
foundParticipant = null;
|
284
|
-
return _context5.abrupt("return", this.rosterEntityPromise.then(function () {
|
285
|
-
_this6.participants.forEach(function (participant) {
|
286
|
-
if (participant.identity === identity) {
|
287
|
-
foundParticipant = participant;
|
288
|
-
}
|
289
|
-
});
|
290
|
-
if (!foundParticipant) {
|
291
|
-
throw new Error('Participant with identity ' + identity + ' was not found');
|
292
|
-
}
|
293
|
-
return foundParticipant;
|
294
|
-
}));
|
295
|
-
|
296
|
-
case 2:
|
297
|
-
case "end":
|
298
|
-
return _context5.stop();
|
299
|
-
}
|
300
|
-
}
|
301
|
-
}, _callee5, this);
|
302
|
-
}));
|
303
|
-
|
304
|
-
function getParticipantByIdentity(_x4) {
|
305
|
-
return _ref5.apply(this, arguments);
|
306
|
-
}
|
307
|
-
|
308
|
-
return getParticipantByIdentity;
|
309
|
-
}()
|
310
|
-
/**
|
311
|
-
* Add a chat participant to the conversation
|
312
|
-
* @returns {Promise<any>}
|
313
|
-
*/
|
314
|
-
|
315
|
-
}, {
|
316
|
-
key: "add",
|
317
|
-
value: function add(identity, attributes) {
|
318
|
-
return this.services.session.addCommand('addMemberV2', {
|
319
|
-
channelSid: this.conversation.sid,
|
320
|
-
attributes: (0, _stringify2.default)(attributes),
|
321
|
-
username: identity
|
322
|
-
});
|
323
|
-
}
|
324
|
-
/**
|
325
|
-
* Add a non-chat participant to the conversation.
|
326
|
-
*
|
327
|
-
* @param proxyAddress
|
328
|
-
* @param address
|
329
|
-
* @param attributes
|
330
|
-
* @param bindingOptions
|
331
|
-
* @returns {Promise<any>}
|
332
|
-
*/
|
333
|
-
|
334
|
-
}, {
|
335
|
-
key: "addNonChatParticipant",
|
336
|
-
value: function addNonChatParticipant(proxyAddress, address) {
|
337
|
-
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
338
|
-
var bindingOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
339
|
-
|
340
|
-
var _a, _b, _c, _d;
|
341
|
-
return this.services.session.addCommand('addNonChatParticipant', {
|
342
|
-
conversationSid: this.conversation.sid,
|
343
|
-
proxyAddress: proxyAddress,
|
344
|
-
attributes: (0, _stringify2.default)(attributes),
|
345
|
-
address: address,
|
346
|
-
name: (_b = (_a = bindingOptions) === null || _a === void 0 ? void 0 : _a.email) === null || _b === void 0 ? void 0 : _b.name,
|
347
|
-
level: (_d = (_c = bindingOptions) === null || _c === void 0 ? void 0 : _c.email) === null || _d === void 0 ? void 0 : _d.level
|
348
|
-
});
|
349
|
-
}
|
350
|
-
/**
|
351
|
-
* Invites user to the conversation
|
352
|
-
* User can choose either to join or not
|
353
|
-
* @returns {Promise<any>}
|
354
|
-
*/
|
355
|
-
|
356
|
-
}, {
|
357
|
-
key: "invite",
|
358
|
-
value: function invite(identity) {
|
359
|
-
return this.services.session.addCommand('inviteMember', {
|
360
|
-
channelSid: this.conversation.sid,
|
361
|
-
username: identity
|
362
|
-
});
|
363
|
-
}
|
364
|
-
/**
|
365
|
-
* Remove participant from conversation by Identity
|
366
|
-
* @returns {Promise<any>}
|
367
|
-
*/
|
368
|
-
|
369
|
-
}, {
|
370
|
-
key: "removeByIdentity",
|
371
|
-
value: function removeByIdentity(identity) {
|
372
|
-
return this.services.session.addCommand('removeMember', {
|
373
|
-
channelSid: this.conversation.sid,
|
374
|
-
username: identity
|
375
|
-
});
|
376
|
-
}
|
377
|
-
/**
|
378
|
-
* Remove participant from conversation by sid
|
379
|
-
* @returns {Promise<any>}
|
380
|
-
*/
|
381
|
-
|
382
|
-
}, {
|
383
|
-
key: "removeBySid",
|
384
|
-
value: function removeBySid(sid) {
|
385
|
-
return this.services.session.addCommand('removeMember', {
|
386
|
-
channelSid: this.conversation.sid,
|
387
|
-
memberSid: sid
|
388
|
-
});
|
389
|
-
}
|
390
|
-
}]);
|
391
|
-
return Participants;
|
392
|
-
}(events_1.EventEmitter);
|
393
|
-
|
394
|
-
exports.Participants = Participants;
|
395
|
-
/**
|
396
|
-
* Fired when participant joined conversation
|
397
|
-
* @event Participants#participantJoined
|
398
|
-
* @type {Participant}
|
399
|
-
*/
|
400
|
-
/**
|
401
|
-
* Fired when participant left conversation
|
402
|
-
* @event Participants#participantLeft
|
403
|
-
* @type {Participant}
|
404
|
-
*/
|
405
|
-
/**
|
406
|
-
* Fired when participant updated
|
407
|
-
* @event Participants#participantUpdated
|
408
|
-
* @type {Object}
|
409
|
-
* @property {Participant} participant - Updated Participant
|
410
|
-
* @property {Participant#UpdateReason[]} updateReasons - Array of Participant's updated event reasons
|
411
|
-
*/
|
package/browser/data/users.js
DELETED
@@ -1,281 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _regenerator = require("babel-runtime/regenerator");
|
4
|
-
|
5
|
-
var _regenerator2 = _interopRequireDefault(_regenerator);
|
6
|
-
|
7
|
-
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
|
8
|
-
|
9
|
-
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
10
|
-
|
11
|
-
var _map = require("babel-runtime/core-js/map");
|
12
|
-
|
13
|
-
var _map2 = _interopRequireDefault(_map);
|
14
|
-
|
15
|
-
var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of");
|
16
|
-
|
17
|
-
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
18
|
-
|
19
|
-
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
|
20
|
-
|
21
|
-
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
22
|
-
|
23
|
-
var _createClass2 = require("babel-runtime/helpers/createClass");
|
24
|
-
|
25
|
-
var _createClass3 = _interopRequireDefault(_createClass2);
|
26
|
-
|
27
|
-
var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
|
28
|
-
|
29
|
-
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
30
|
-
|
31
|
-
var _inherits2 = require("babel-runtime/helpers/inherits");
|
32
|
-
|
33
|
-
var _inherits3 = _interopRequireDefault(_inherits2);
|
34
|
-
|
35
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
36
|
-
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
38
|
-
var events_1 = require("events");
|
39
|
-
var user_1 = require("../user");
|
40
|
-
var util_1 = require("../util");
|
41
|
-
/**
|
42
|
-
* @classdesc Container for known users
|
43
|
-
* @fires Users#userUpdated
|
44
|
-
*/
|
45
|
-
|
46
|
-
var Users = function (_events_1$EventEmitte) {
|
47
|
-
(0, _inherits3.default)(Users, _events_1$EventEmitte);
|
48
|
-
|
49
|
-
function Users(services) {
|
50
|
-
(0, _classCallCheck3.default)(this, Users);
|
51
|
-
|
52
|
-
var _this = (0, _possibleConstructorReturn3.default)(this, (Users.__proto__ || (0, _getPrototypeOf2.default)(Users)).call(this));
|
53
|
-
|
54
|
-
_this.services = services;
|
55
|
-
_this.fifoStack = [];
|
56
|
-
_this.fifoStackMaxLength = 100;
|
57
|
-
_this.myself = new user_1.User(null, null, _this.services);
|
58
|
-
_this.myself.on('updated', function (args) {
|
59
|
-
return _this.emit('userUpdated', args);
|
60
|
-
});
|
61
|
-
_this.myself.on('userSubscribed', function () {
|
62
|
-
return _this.emit('userSubscribed', _this.myself);
|
63
|
-
});
|
64
|
-
_this.myself.on('userUnsubscribed', function () {
|
65
|
-
_this.emit('userUnsubscribed', _this.myself);
|
66
|
-
_this.myself._ensureFetched();
|
67
|
-
});
|
68
|
-
_this.services = services;
|
69
|
-
_this.subscribedUsers = new _map2.default();
|
70
|
-
_this.userUrlPromise = _this.services.session.getSessionLinks().then(function (links) {
|
71
|
-
_this.userUrl = links.usersUrl;
|
72
|
-
return _this.userUrl;
|
73
|
-
});
|
74
|
-
_this.services.session.getMaxUserInfosToSubscribe().then(function (maxUserInfosToSubscribe) {
|
75
|
-
_this.fifoStackMaxLength = maxUserInfosToSubscribe;
|
76
|
-
});
|
77
|
-
_this.services.session.getUsersData().then(function (data) {
|
78
|
-
_this.myself.identity = data.identity;
|
79
|
-
_this.myself.entityName = data.user;
|
80
|
-
return _this.myself._ensureFetched();
|
81
|
-
});
|
82
|
-
return _this;
|
83
|
-
}
|
84
|
-
|
85
|
-
(0, _createClass3.default)(Users, [{
|
86
|
-
key: "handleUnsubscribeUser",
|
87
|
-
value: function handleUnsubscribeUser(user) {
|
88
|
-
if (this.subscribedUsers.has(user.identity)) {
|
89
|
-
this.subscribedUsers.delete(user.identity);
|
90
|
-
}
|
91
|
-
var foundItemIndex = -1;
|
92
|
-
var foundItem = this.fifoStack.find(function (item, index) {
|
93
|
-
if (item == user.identity) {
|
94
|
-
foundItemIndex = index;
|
95
|
-
return true;
|
96
|
-
}
|
97
|
-
return false;
|
98
|
-
});
|
99
|
-
if (foundItem) {
|
100
|
-
this.fifoStack.splice(foundItemIndex, 1);
|
101
|
-
}
|
102
|
-
this.emit('userUnsubscribed', user);
|
103
|
-
}
|
104
|
-
}, {
|
105
|
-
key: "handleSubscribeUser",
|
106
|
-
value: function handleSubscribeUser(user) {
|
107
|
-
if (this.subscribedUsers.has(user.identity)) {
|
108
|
-
return;
|
109
|
-
}
|
110
|
-
if (this.fifoStack.length >= this.fifoStackMaxLength) {
|
111
|
-
this.subscribedUsers.get(this.fifoStack.shift()).unsubscribe();
|
112
|
-
}
|
113
|
-
this.fifoStack.push(user.identity);
|
114
|
-
this.subscribedUsers.set(user.identity, user);
|
115
|
-
this.emit('userSubscribed', user);
|
116
|
-
}
|
117
|
-
/**
|
118
|
-
* Gets user, if it's in subscribed list - then return the user object from it,
|
119
|
-
* if not - then subscribes and adds user to the FIFO stack
|
120
|
-
* @returns {Promise<User>} Fully initialized user
|
121
|
-
*/
|
122
|
-
|
123
|
-
}, {
|
124
|
-
key: "getUser",
|
125
|
-
value: function () {
|
126
|
-
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(identity) {
|
127
|
-
var _this2 = this;
|
128
|
-
|
129
|
-
var entityName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
130
|
-
var user;
|
131
|
-
return _regenerator2.default.wrap(function _callee$(_context) {
|
132
|
-
while (1) {
|
133
|
-
switch (_context.prev = _context.next) {
|
134
|
-
case 0:
|
135
|
-
_context.next = 2;
|
136
|
-
return this.services.session.getUsersData();
|
137
|
-
|
138
|
-
case 2:
|
139
|
-
_context.next = 4;
|
140
|
-
return this.myself._ensureFetched();
|
141
|
-
|
142
|
-
case 4:
|
143
|
-
if (!(identity == this.myself.identity)) {
|
144
|
-
_context.next = 6;
|
145
|
-
break;
|
146
|
-
}
|
147
|
-
|
148
|
-
return _context.abrupt("return", this.myself);
|
149
|
-
|
150
|
-
case 6:
|
151
|
-
user = this.subscribedUsers.get(identity);
|
152
|
-
|
153
|
-
if (user) {
|
154
|
-
_context.next = 18;
|
155
|
-
break;
|
156
|
-
}
|
157
|
-
|
158
|
-
if (entityName) {
|
159
|
-
_context.next = 12;
|
160
|
-
break;
|
161
|
-
}
|
162
|
-
|
163
|
-
_context.next = 11;
|
164
|
-
return this.getSyncUniqueName(identity);
|
165
|
-
|
166
|
-
case 11:
|
167
|
-
entityName = _context.sent;
|
168
|
-
|
169
|
-
case 12:
|
170
|
-
user = new user_1.User(identity, entityName, this.services);
|
171
|
-
user.on('updated', function (args) {
|
172
|
-
return _this2.emit('userUpdated', args);
|
173
|
-
});
|
174
|
-
user.on('userSubscribed', function () {
|
175
|
-
return _this2.handleSubscribeUser(user);
|
176
|
-
});
|
177
|
-
user.on('userUnsubscribed', function () {
|
178
|
-
return _this2.handleUnsubscribeUser(user);
|
179
|
-
});
|
180
|
-
_context.next = 18;
|
181
|
-
return user._ensureFetched();
|
182
|
-
|
183
|
-
case 18:
|
184
|
-
return _context.abrupt("return", user);
|
185
|
-
|
186
|
-
case 19:
|
187
|
-
case "end":
|
188
|
-
return _context.stop();
|
189
|
-
}
|
190
|
-
}
|
191
|
-
}, _callee, this);
|
192
|
-
}));
|
193
|
-
|
194
|
-
function getUser(_x2) {
|
195
|
-
return _ref.apply(this, arguments);
|
196
|
-
}
|
197
|
-
|
198
|
-
return getUser;
|
199
|
-
}()
|
200
|
-
/**
|
201
|
-
* @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
|
202
|
-
*/
|
203
|
-
|
204
|
-
}, {
|
205
|
-
key: "getSubscribedUsers",
|
206
|
-
value: function () {
|
207
|
-
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
|
208
|
-
var users;
|
209
|
-
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
210
|
-
while (1) {
|
211
|
-
switch (_context2.prev = _context2.next) {
|
212
|
-
case 0:
|
213
|
-
_context2.next = 2;
|
214
|
-
return this.services.session.getUsersData();
|
215
|
-
|
216
|
-
case 2:
|
217
|
-
_context2.next = 4;
|
218
|
-
return this.myself._ensureFetched();
|
219
|
-
|
220
|
-
case 4:
|
221
|
-
users = [this.myself];
|
222
|
-
|
223
|
-
this.subscribedUsers.forEach(function (user) {
|
224
|
-
return users.push(user);
|
225
|
-
});
|
226
|
-
return _context2.abrupt("return", users);
|
227
|
-
|
228
|
-
case 7:
|
229
|
-
case "end":
|
230
|
-
return _context2.stop();
|
231
|
-
}
|
232
|
-
}
|
233
|
-
}, _callee2, this);
|
234
|
-
}));
|
235
|
-
|
236
|
-
function getSubscribedUsers() {
|
237
|
-
return _ref2.apply(this, arguments);
|
238
|
-
}
|
239
|
-
|
240
|
-
return getSubscribedUsers;
|
241
|
-
}()
|
242
|
-
/**
|
243
|
-
* @returns {Promise<string>} User's sync unique name
|
244
|
-
*/
|
245
|
-
|
246
|
-
}, {
|
247
|
-
key: "getSyncUniqueName",
|
248
|
-
value: function () {
|
249
|
-
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(identity) {
|
250
|
-
var url, response;
|
251
|
-
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
252
|
-
while (1) {
|
253
|
-
switch (_context3.prev = _context3.next) {
|
254
|
-
case 0:
|
255
|
-
url = new util_1.UriBuilder(this.userUrl).path(identity).build();
|
256
|
-
_context3.next = 3;
|
257
|
-
return this.services.network.get(url);
|
258
|
-
|
259
|
-
case 3:
|
260
|
-
response = _context3.sent;
|
261
|
-
return _context3.abrupt("return", response.body.sync_unique_name);
|
262
|
-
|
263
|
-
case 5:
|
264
|
-
case "end":
|
265
|
-
return _context3.stop();
|
266
|
-
}
|
267
|
-
}
|
268
|
-
}, _callee3, this);
|
269
|
-
}));
|
270
|
-
|
271
|
-
function getSyncUniqueName(_x3) {
|
272
|
-
return _ref3.apply(this, arguments);
|
273
|
-
}
|
274
|
-
|
275
|
-
return getSyncUniqueName;
|
276
|
-
}()
|
277
|
-
}]);
|
278
|
-
return Users;
|
279
|
-
}(events_1.EventEmitter);
|
280
|
-
|
281
|
-
exports.Users = Users;
|