@webex/internal-plugin-presence 2.59.3-next.1 → 2.59.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/.eslintrc.js +6 -6
- package/README.md +42 -42
- package/babel.config.js +3 -3
- package/dist/config.js +2 -2
- package/dist/config.js.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/presence-batcher.js +42 -42
- package/dist/presence-batcher.js.map +1 -1
- package/dist/presence-worker.js +43 -43
- package/dist/presence-worker.js.map +1 -1
- package/dist/presence.js +75 -75
- package/dist/presence.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +18 -19
- package/process +1 -1
- package/src/config.js +11 -11
- package/src/constants.js +19 -19
- package/src/index.js +41 -41
- package/src/presence-batcher.js +100 -100
- package/src/presence-worker.js +268 -268
- package/src/presence.js +262 -262
- package/test/integration/spec/presence.js +213 -213
- package/test/unit/spec/presence-worker.js +264 -264
- package/test/unit/spec/presence.js +68 -68
package/dist/presence.js
CHANGED
|
@@ -13,17 +13,17 @@ require("@webex/internal-plugin-device");
|
|
|
13
13
|
var _webexCore = require("@webex/webex-core");
|
|
14
14
|
var _presenceBatcher = _interopRequireDefault(require("./presence-batcher"));
|
|
15
15
|
var _presenceWorker = _interopRequireDefault(require("./presence-worker"));
|
|
16
|
-
/*!
|
|
17
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
16
|
+
/*!
|
|
17
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
var defaultSubscriptionTtl = 600;
|
|
21
21
|
var USER = 'user';
|
|
22
22
|
var USER_PRESENCE_ENABLED = 'user-presence-enabled';
|
|
23
23
|
|
|
24
|
-
/**
|
|
25
|
-
* @class
|
|
26
|
-
* @extends WebexPlugin
|
|
24
|
+
/**
|
|
25
|
+
* @class
|
|
26
|
+
* @extends WebexPlugin
|
|
27
27
|
*/
|
|
28
28
|
var Presence = _webexCore.WebexPlugin.extend({
|
|
29
29
|
namespace: 'Presence',
|
|
@@ -38,9 +38,9 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
38
38
|
type: 'any'
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
-
/**
|
|
42
|
-
* Initialize the presence worker for client
|
|
43
|
-
* @returns {undefined}
|
|
41
|
+
/**
|
|
42
|
+
* Initialize the presence worker for client
|
|
43
|
+
* @returns {undefined}
|
|
44
44
|
*/
|
|
45
45
|
initialize: function initialize() {
|
|
46
46
|
var _this = this;
|
|
@@ -50,65 +50,65 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
},
|
|
53
|
-
/**
|
|
54
|
-
* Trigger an event.
|
|
55
|
-
* @param {string} event
|
|
56
|
-
* @param {string} payload
|
|
57
|
-
* @returns {undefined}
|
|
53
|
+
/**
|
|
54
|
+
* Trigger an event.
|
|
55
|
+
* @param {string} event
|
|
56
|
+
* @param {string} payload
|
|
57
|
+
* @returns {undefined}
|
|
58
58
|
*/
|
|
59
59
|
emitEvent: function emitEvent(event, payload) {
|
|
60
60
|
if (payload.type && payload.payload) {
|
|
61
61
|
this.trigger(event, payload);
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
-
/**
|
|
65
|
-
* Enables presence feature
|
|
66
|
-
* @returns {Promise<boolean>} resolves with true, if successful
|
|
64
|
+
/**
|
|
65
|
+
* Enables presence feature
|
|
66
|
+
* @returns {Promise<boolean>} resolves with true, if successful
|
|
67
67
|
*/
|
|
68
68
|
enable: function enable() {
|
|
69
69
|
return this.webex.internal.feature.setFeature(USER, USER_PRESENCE_ENABLED, true).then(function (response) {
|
|
70
70
|
return response.value;
|
|
71
71
|
});
|
|
72
72
|
},
|
|
73
|
-
/**
|
|
74
|
-
* Disables presence feature
|
|
75
|
-
* @returns {Promise<boolean>} resolves with false, if successful
|
|
73
|
+
/**
|
|
74
|
+
* Disables presence feature
|
|
75
|
+
* @returns {Promise<boolean>} resolves with false, if successful
|
|
76
76
|
*/
|
|
77
77
|
disable: function disable() {
|
|
78
78
|
return this.webex.internal.feature.setFeature(USER, USER_PRESENCE_ENABLED, false).then(function (response) {
|
|
79
79
|
return response.value;
|
|
80
80
|
});
|
|
81
81
|
},
|
|
82
|
-
/**
|
|
83
|
-
* Returns true if presence is enabled, false otherwise
|
|
84
|
-
* @returns {Promise<boolean>} resolves with true if presence is enabled
|
|
82
|
+
/**
|
|
83
|
+
* Returns true if presence is enabled, false otherwise
|
|
84
|
+
* @returns {Promise<boolean>} resolves with true if presence is enabled
|
|
85
85
|
*/
|
|
86
86
|
isEnabled: function isEnabled() {
|
|
87
87
|
return this.webex.internal.feature.getFeature(USER, USER_PRESENCE_ENABLED);
|
|
88
88
|
},
|
|
89
|
-
/**
|
|
90
|
-
* The status object
|
|
91
|
-
* @typedef {Object} PresenceStatusObject
|
|
92
|
-
* @property {string} url: Public resource identifier for presence
|
|
93
|
-
* @property {string} subject: User ID for the user the returned composed presence represents
|
|
94
|
-
* @property {string} status: Current composed presence state
|
|
95
|
-
* @property {string} statusTime: DateTime in RFC3339 format that the current status began
|
|
96
|
-
* @property {string} lastActive: DateTime in RFC3339 format that the service last saw activity from the user.
|
|
97
|
-
* @property {string} expires: DEPRECATED - DateTime in RFC3339 format that represents when the current
|
|
98
|
-
* status will expire. Will not exist if expiresTTL is -1.
|
|
99
|
-
* @property {Number} expiresTTL: TTL in seconds until the status will expire. If TTL is -1 the current
|
|
100
|
-
* status has no known expiration.
|
|
101
|
-
* @property {string} expiresTime: DateTime in RFC3339 format that the current status will expire. Missing
|
|
102
|
-
* field means no known expiration.
|
|
103
|
-
* @property {Object} vectorCounters: Used for packet ordering and tracking.
|
|
104
|
-
* @property {Boolean} suppressNotifications: Indicates if notification suppression is recommended for this status.
|
|
105
|
-
* @property {string} lastSeenDeviceUrl: Resource Identifier of the last device to post presence activity for
|
|
106
|
-
* this user.
|
|
89
|
+
/**
|
|
90
|
+
* The status object
|
|
91
|
+
* @typedef {Object} PresenceStatusObject
|
|
92
|
+
* @property {string} url: Public resource identifier for presence
|
|
93
|
+
* @property {string} subject: User ID for the user the returned composed presence represents
|
|
94
|
+
* @property {string} status: Current composed presence state
|
|
95
|
+
* @property {string} statusTime: DateTime in RFC3339 format that the current status began
|
|
96
|
+
* @property {string} lastActive: DateTime in RFC3339 format that the service last saw activity from the user.
|
|
97
|
+
* @property {string} expires: DEPRECATED - DateTime in RFC3339 format that represents when the current
|
|
98
|
+
* status will expire. Will not exist if expiresTTL is -1.
|
|
99
|
+
* @property {Number} expiresTTL: TTL in seconds until the status will expire. If TTL is -1 the current
|
|
100
|
+
* status has no known expiration.
|
|
101
|
+
* @property {string} expiresTime: DateTime in RFC3339 format that the current status will expire. Missing
|
|
102
|
+
* field means no known expiration.
|
|
103
|
+
* @property {Object} vectorCounters: Used for packet ordering and tracking.
|
|
104
|
+
* @property {Boolean} suppressNotifications: Indicates if notification suppression is recommended for this status.
|
|
105
|
+
* @property {string} lastSeenDeviceUrl: Resource Identifier of the last device to post presence activity for
|
|
106
|
+
* this user.
|
|
107
107
|
*/
|
|
108
|
-
/**
|
|
109
|
-
* Gets the current presence status of a given person id
|
|
110
|
-
* @param {string} personId
|
|
111
|
-
* @returns {Promise<PresenceStatusObject>} resolves with status object of person
|
|
108
|
+
/**
|
|
109
|
+
* Gets the current presence status of a given person id
|
|
110
|
+
* @param {string} personId
|
|
111
|
+
* @returns {Promise<PresenceStatusObject>} resolves with status object of person
|
|
112
112
|
*/
|
|
113
113
|
get: function get(personId) {
|
|
114
114
|
if (!personId) {
|
|
@@ -122,14 +122,14 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
122
122
|
return response.body;
|
|
123
123
|
});
|
|
124
124
|
},
|
|
125
|
-
/**
|
|
126
|
-
* @typedef {Object} PresenceStatusesObject
|
|
127
|
-
* @property {Array.<PresenceStatusObject>} statusList
|
|
125
|
+
/**
|
|
126
|
+
* @typedef {Object} PresenceStatusesObject
|
|
127
|
+
* @property {Array.<PresenceStatusObject>} statusList
|
|
128
128
|
*/
|
|
129
|
-
/**
|
|
130
|
-
* Gets the current presence statuses of an array of people ids
|
|
131
|
-
* @param {Array} personIds
|
|
132
|
-
* @returns {Promise<PresenceStatusesObject>} resolves with an object with key of `statusList` array
|
|
129
|
+
/**
|
|
130
|
+
* Gets the current presence statuses of an array of people ids
|
|
131
|
+
* @param {Array} personIds
|
|
132
|
+
* @returns {Promise<PresenceStatusesObject>} resolves with an object with key of `statusList` array
|
|
133
133
|
*/
|
|
134
134
|
list: function list(personIds) {
|
|
135
135
|
var _this2 = this;
|
|
@@ -144,12 +144,12 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
144
144
|
};
|
|
145
145
|
});
|
|
146
146
|
},
|
|
147
|
-
/**
|
|
148
|
-
* Subscribes to a person's presence status updates
|
|
149
|
-
* Updates are sent via mercury events `apheleia.subscription_update`
|
|
150
|
-
* @param {string | Array} personIds
|
|
151
|
-
* @param {number} subscriptionTtl - Requested length of subscriptions in seconds.
|
|
152
|
-
* @returns {Promise}
|
|
147
|
+
/**
|
|
148
|
+
* Subscribes to a person's presence status updates
|
|
149
|
+
* Updates are sent via mercury events `apheleia.subscription_update`
|
|
150
|
+
* @param {string | Array} personIds
|
|
151
|
+
* @param {number} subscriptionTtl - Requested length of subscriptions in seconds.
|
|
152
|
+
* @returns {Promise}
|
|
153
153
|
*/
|
|
154
154
|
subscribe: function subscribe(personIds) {
|
|
155
155
|
var _this3 = this;
|
|
@@ -189,10 +189,10 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
189
189
|
};
|
|
190
190
|
});
|
|
191
191
|
},
|
|
192
|
-
/**
|
|
193
|
-
* Unsubscribes from a person or group of people's presence subscription
|
|
194
|
-
* @param {string | Array} personIds
|
|
195
|
-
* @returns {Promise}
|
|
192
|
+
/**
|
|
193
|
+
* Unsubscribes from a person or group of people's presence subscription
|
|
194
|
+
* @param {string | Array} personIds
|
|
195
|
+
* @returns {Promise}
|
|
196
196
|
*/
|
|
197
197
|
unsubscribe: function unsubscribe(personIds) {
|
|
198
198
|
var subjects;
|
|
@@ -215,11 +215,11 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
215
215
|
}
|
|
216
216
|
});
|
|
217
217
|
},
|
|
218
|
-
/**
|
|
219
|
-
* Sets the status of the current user
|
|
220
|
-
* @param {string} status - active | inactive | ooo | dnd
|
|
221
|
-
* @param {number} ttl - Time To Live for the event in seconds.
|
|
222
|
-
* @returns {Promise}
|
|
218
|
+
/**
|
|
219
|
+
* Sets the status of the current user
|
|
220
|
+
* @param {string} status - active | inactive | ooo | dnd
|
|
221
|
+
* @param {number} ttl - Time To Live for the event in seconds.
|
|
222
|
+
* @returns {Promise}
|
|
223
223
|
*/
|
|
224
224
|
setStatus: function setStatus(status, ttl) {
|
|
225
225
|
if (!status) {
|
|
@@ -238,23 +238,23 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
238
238
|
return response.body;
|
|
239
239
|
});
|
|
240
240
|
},
|
|
241
|
-
/**
|
|
242
|
-
* Retrieves and subscribes to a user's presence.
|
|
243
|
-
* @param {string} id
|
|
244
|
-
* @returns {undefined}
|
|
241
|
+
/**
|
|
242
|
+
* Retrieves and subscribes to a user's presence.
|
|
243
|
+
* @param {string} id
|
|
244
|
+
* @returns {undefined}
|
|
245
245
|
*/
|
|
246
246
|
enqueue: function enqueue(id) {
|
|
247
247
|
return this.worker.enqueue(id);
|
|
248
248
|
},
|
|
249
|
-
/**
|
|
250
|
-
* Retract from subscribing to a user's presence.
|
|
251
|
-
* @param {string} id
|
|
252
|
-
* @returns {undefined}
|
|
249
|
+
/**
|
|
250
|
+
* Retract from subscribing to a user's presence.
|
|
251
|
+
* @param {string} id
|
|
252
|
+
* @returns {undefined}
|
|
253
253
|
*/
|
|
254
254
|
dequeue: function dequeue(id) {
|
|
255
255
|
return this.worker.dequeue(id);
|
|
256
256
|
},
|
|
257
|
-
version: "2.59.
|
|
257
|
+
version: "2.59.4"
|
|
258
258
|
});
|
|
259
259
|
var _default2 = Presence;
|
|
260
260
|
exports.default = _default2;
|
package/dist/presence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","_webexCore","_presenceBatcher","_interopRequireDefault","_presenceWorker","defaultSubscriptionTtl","USER","USER_PRESENCE_ENABLED","Presence","WebexPlugin","extend","namespace","children","batcher","PresenceBatcher","session","worker","default","_default","PresenceWorker","type","initialize","_this","webex","once","config","initializeWorker","emitEvent","event","payload","trigger","enable","internal","feature","setFeature","then","response","value","disable","isEnabled","getFeature","get","personId","_promise","reject","Error","request","method","service","resource","concat","body","list","personIds","_this2","_isArray","all","map","id","presences","statusList","subscribe","_this3","subscriptionTtl","arguments","length","undefined","subjects","batches","batchLimit","i","push","slice","ids","api","includeStatus","responses","idBatches","_ref","apply","_toConsumableArray2","unsubscribe","setStatus","status","ttl","subject","device","userId","eventType","enqueue","dequeue","version","_default2","exports"],"sources":["presence.js"],"sourcesContent":["/*!\r\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\r\n */\r\n\r\nimport '@webex/internal-plugin-device';\r\n\r\nimport {WebexPlugin} from '@webex/webex-core';\r\n\r\nimport PresenceBatcher from './presence-batcher';\r\nimport PresenceWorker from './presence-worker';\r\n\r\nconst defaultSubscriptionTtl = 600;\r\nconst USER = 'user';\r\nconst USER_PRESENCE_ENABLED = 'user-presence-enabled';\r\n\r\n/**\r\n * @class\r\n * @extends WebexPlugin\r\n */\r\nconst Presence = WebexPlugin.extend({\r\n namespace: 'Presence',\r\n\r\n children: {\r\n batcher: PresenceBatcher,\r\n },\r\n\r\n session: {\r\n worker: {\r\n default() {\r\n return new PresenceWorker();\r\n },\r\n type: 'any',\r\n },\r\n },\r\n\r\n /**\r\n * Initialize the presence worker for client\r\n * @returns {undefined}\r\n */\r\n initialize() {\r\n this.webex.once('ready', () => {\r\n if (this.config.initializeWorker) {\r\n this.worker.initialize(this.webex);\r\n }\r\n });\r\n },\r\n\r\n /**\r\n * Trigger an event.\r\n * @param {string} event\r\n * @param {string} payload\r\n * @returns {undefined}\r\n */\r\n emitEvent(event, payload) {\r\n if (payload.type && payload.payload) {\r\n this.trigger(event, payload);\r\n }\r\n },\r\n\r\n /**\r\n * Enables presence feature\r\n * @returns {Promise<boolean>} resolves with true, if successful\r\n */\r\n enable() {\r\n return this.webex.internal.feature\r\n .setFeature(USER, USER_PRESENCE_ENABLED, true)\r\n .then((response) => response.value);\r\n },\r\n\r\n /**\r\n * Disables presence feature\r\n * @returns {Promise<boolean>} resolves with false, if successful\r\n */\r\n disable() {\r\n return this.webex.internal.feature\r\n .setFeature(USER, USER_PRESENCE_ENABLED, false)\r\n .then((response) => response.value);\r\n },\r\n\r\n /**\r\n * Returns true if presence is enabled, false otherwise\r\n * @returns {Promise<boolean>} resolves with true if presence is enabled\r\n */\r\n isEnabled() {\r\n return this.webex.internal.feature.getFeature(USER, USER_PRESENCE_ENABLED);\r\n },\r\n\r\n /**\r\n * The status object\r\n * @typedef {Object} PresenceStatusObject\r\n * @property {string} url: Public resource identifier for presence\r\n * @property {string} subject: User ID for the user the returned composed presence represents\r\n * @property {string} status: Current composed presence state\r\n * @property {string} statusTime: DateTime in RFC3339 format that the current status began\r\n * @property {string} lastActive: DateTime in RFC3339 format that the service last saw activity from the user.\r\n * @property {string} expires: DEPRECATED - DateTime in RFC3339 format that represents when the current\r\n * status will expire. Will not exist if expiresTTL is -1.\r\n * @property {Number} expiresTTL: TTL in seconds until the status will expire. If TTL is -1 the current\r\n * status has no known expiration.\r\n * @property {string} expiresTime: DateTime in RFC3339 format that the current status will expire. Missing\r\n * field means no known expiration.\r\n * @property {Object} vectorCounters: Used for packet ordering and tracking.\r\n * @property {Boolean} suppressNotifications: Indicates if notification suppression is recommended for this status.\r\n * @property {string} lastSeenDeviceUrl: Resource Identifier of the last device to post presence activity for\r\n * this user.\r\n */\r\n\r\n /**\r\n * Gets the current presence status of a given person id\r\n * @param {string} personId\r\n * @returns {Promise<PresenceStatusObject>} resolves with status object of person\r\n */\r\n get(personId) {\r\n if (!personId) {\r\n return Promise.reject(new Error('A person id is required'));\r\n }\r\n\r\n return this.webex\r\n .request({\r\n method: 'GET',\r\n service: 'apheleia',\r\n resource: `compositions?userId=${personId}`,\r\n })\r\n .then((response) => response.body);\r\n },\r\n\r\n /**\r\n * @typedef {Object} PresenceStatusesObject\r\n * @property {Array.<PresenceStatusObject>} statusList\r\n */\r\n /**\r\n * Gets the current presence statuses of an array of people ids\r\n * @param {Array} personIds\r\n * @returns {Promise<PresenceStatusesObject>} resolves with an object with key of `statusList` array\r\n */\r\n list(personIds) {\r\n if (!personIds || !Array.isArray(personIds)) {\r\n return Promise.reject(new Error('An array of person ids is required'));\r\n }\r\n\r\n return Promise.all(personIds.map((id) => this.batcher.request(id))).then((presences) => ({\r\n statusList: presences,\r\n }));\r\n },\r\n\r\n /**\r\n * Subscribes to a person's presence status updates\r\n * Updates are sent via mercury events `apheleia.subscription_update`\r\n * @param {string | Array} personIds\r\n * @param {number} subscriptionTtl - Requested length of subscriptions in seconds.\r\n * @returns {Promise}\r\n */\r\n subscribe(personIds, subscriptionTtl = defaultSubscriptionTtl) {\r\n let subjects;\r\n const batches = [];\r\n const batchLimit = 50;\r\n\r\n if (!personIds) {\r\n return Promise.reject(new Error('A person id is required'));\r\n }\r\n if (Array.isArray(personIds)) {\r\n subjects = personIds;\r\n } else {\r\n subjects = [personIds];\r\n }\r\n // Limit batches to 50 ids per request\r\n for (let i = 0; i < subjects.length; i += batchLimit) {\r\n batches.push(subjects.slice(i, i + batchLimit));\r\n }\r\n\r\n return Promise.all(\r\n batches.map((ids) =>\r\n this.webex\r\n .request({\r\n method: 'POST',\r\n api: 'apheleia',\r\n resource: 'subscriptions',\r\n body: {\r\n subjects: ids,\r\n subscriptionTtl,\r\n includeStatus: true,\r\n },\r\n })\r\n .then((response) => response.body.responses)\r\n )\r\n ).then((idBatches) => ({responses: [].concat(...idBatches)}));\r\n },\r\n\r\n /**\r\n * Unsubscribes from a person or group of people's presence subscription\r\n * @param {string | Array} personIds\r\n * @returns {Promise}\r\n */\r\n unsubscribe(personIds) {\r\n let subjects;\r\n\r\n if (!personIds) {\r\n return Promise.reject(new Error('A person id is required'));\r\n }\r\n if (Array.isArray(personIds)) {\r\n subjects = personIds;\r\n } else {\r\n subjects = [personIds];\r\n }\r\n\r\n return this.webex.request({\r\n method: 'POST',\r\n api: 'apheleia',\r\n resource: 'subscriptions',\r\n body: {\r\n subjects,\r\n subscriptionTtl: 0,\r\n includeStatus: true,\r\n },\r\n });\r\n },\r\n\r\n /**\r\n * Sets the status of the current user\r\n * @param {string} status - active | inactive | ooo | dnd\r\n * @param {number} ttl - Time To Live for the event in seconds.\r\n * @returns {Promise}\r\n */\r\n setStatus(status, ttl) {\r\n if (!status) {\r\n return Promise.reject(new Error('A status is required'));\r\n }\r\n\r\n return this.webex\r\n .request({\r\n method: 'POST',\r\n api: 'apheleia',\r\n resource: 'events',\r\n body: {\r\n subject: this.webex.internal.device.userId,\r\n eventType: status,\r\n ttl,\r\n },\r\n })\r\n .then((response) => response.body);\r\n },\r\n\r\n /**\r\n * Retrieves and subscribes to a user's presence.\r\n * @param {string} id\r\n * @returns {undefined}\r\n */\r\n enqueue(id) {\r\n return this.worker.enqueue(id);\r\n },\r\n\r\n /**\r\n * Retract from subscribing to a user's presence.\r\n * @param {string} id\r\n * @returns {undefined}\r\n */\r\n dequeue(id) {\r\n return this.worker.dequeue(id);\r\n },\r\n});\r\n\r\nexport default Presence;\r\n"],"mappings":";;;;;;;;;;;AAIAA,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;;AASA,IAAMK,sBAAsB,GAAG,GAA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C,sBAAsB,CAAC,CAAC;IAC1D;IAEA,OAAO,IAAI,CAACtB,KAAK,CACduB,OAAO,CAAC;MACPC,MAAM,EAAE,MAAM;MACd2B,GAAG,EAAE,UAAU;MACfzB,QAAQ,EAAE,QAAQ;MAClBE,IAAI,EAAE;QACJkC,OAAO,EAAE,IAAI,CAAC9D,KAAK,CAACS,QAAQ,CAACsD,MAAM,CAACC,MAAM;QAC1CC,SAAS,EAAEL,MAAM;QACjBC,GAAG,EAAHA;MACF;IACF,CAAC,CAAC,CACDjD,IAAI,CAAC,UAACC,QAAQ;MAAA,OAAKA,QAAQ,CAACe,IAAI;IAAA,EAAC;EACtC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEsC,OAAO,WAAAA,QAAC/B,EAAE,EAAE;IACV,OAAO,IAAI,CAAC1C,MAAM,CAACyE,OAAO,CAAC/B,EAAE,CAAC;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEgC,OAAO,WAAAA,QAAChC,EAAE,EAAE;IACV,OAAO,IAAI,CAAC1C,MAAM,CAAC0E,OAAO,CAAChC,EAAE,CAAC;EAChC,CAAC;EAAAiC,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,SAAA,GAEYpF,QAAQ;AAAAqF,OAAA,CAAA5E,OAAA,GAAA2E,SAAA"}
|
|
1
|
+
{"version":3,"names":["require","_webexCore","_presenceBatcher","_interopRequireDefault","_presenceWorker","defaultSubscriptionTtl","USER","USER_PRESENCE_ENABLED","Presence","WebexPlugin","extend","namespace","children","batcher","PresenceBatcher","session","worker","default","_default","PresenceWorker","type","initialize","_this","webex","once","config","initializeWorker","emitEvent","event","payload","trigger","enable","internal","feature","setFeature","then","response","value","disable","isEnabled","getFeature","get","personId","_promise","reject","Error","request","method","service","resource","concat","body","list","personIds","_this2","_isArray","all","map","id","presences","statusList","subscribe","_this3","subscriptionTtl","arguments","length","undefined","subjects","batches","batchLimit","i","push","slice","ids","api","includeStatus","responses","idBatches","_ref","apply","_toConsumableArray2","unsubscribe","setStatus","status","ttl","subject","device","userId","eventType","enqueue","dequeue","version","_default2","exports"],"sources":["presence.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport '@webex/internal-plugin-device';\n\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport PresenceBatcher from './presence-batcher';\nimport PresenceWorker from './presence-worker';\n\nconst defaultSubscriptionTtl = 600;\nconst USER = 'user';\nconst USER_PRESENCE_ENABLED = 'user-presence-enabled';\n\n/**\n * @class\n * @extends WebexPlugin\n */\nconst Presence = WebexPlugin.extend({\n namespace: 'Presence',\n\n children: {\n batcher: PresenceBatcher,\n },\n\n session: {\n worker: {\n default() {\n return new PresenceWorker();\n },\n type: 'any',\n },\n },\n\n /**\n * Initialize the presence worker for client\n * @returns {undefined}\n */\n initialize() {\n this.webex.once('ready', () => {\n if (this.config.initializeWorker) {\n this.worker.initialize(this.webex);\n }\n });\n },\n\n /**\n * Trigger an event.\n * @param {string} event\n * @param {string} payload\n * @returns {undefined}\n */\n emitEvent(event, payload) {\n if (payload.type && payload.payload) {\n this.trigger(event, payload);\n }\n },\n\n /**\n * Enables presence feature\n * @returns {Promise<boolean>} resolves with true, if successful\n */\n enable() {\n return this.webex.internal.feature\n .setFeature(USER, USER_PRESENCE_ENABLED, true)\n .then((response) => response.value);\n },\n\n /**\n * Disables presence feature\n * @returns {Promise<boolean>} resolves with false, if successful\n */\n disable() {\n return this.webex.internal.feature\n .setFeature(USER, USER_PRESENCE_ENABLED, false)\n .then((response) => response.value);\n },\n\n /**\n * Returns true if presence is enabled, false otherwise\n * @returns {Promise<boolean>} resolves with true if presence is enabled\n */\n isEnabled() {\n return this.webex.internal.feature.getFeature(USER, USER_PRESENCE_ENABLED);\n },\n\n /**\n * The status object\n * @typedef {Object} PresenceStatusObject\n * @property {string} url: Public resource identifier for presence\n * @property {string} subject: User ID for the user the returned composed presence represents\n * @property {string} status: Current composed presence state\n * @property {string} statusTime: DateTime in RFC3339 format that the current status began\n * @property {string} lastActive: DateTime in RFC3339 format that the service last saw activity from the user.\n * @property {string} expires: DEPRECATED - DateTime in RFC3339 format that represents when the current\n * status will expire. Will not exist if expiresTTL is -1.\n * @property {Number} expiresTTL: TTL in seconds until the status will expire. If TTL is -1 the current\n * status has no known expiration.\n * @property {string} expiresTime: DateTime in RFC3339 format that the current status will expire. Missing\n * field means no known expiration.\n * @property {Object} vectorCounters: Used for packet ordering and tracking.\n * @property {Boolean} suppressNotifications: Indicates if notification suppression is recommended for this status.\n * @property {string} lastSeenDeviceUrl: Resource Identifier of the last device to post presence activity for\n * this user.\n */\n\n /**\n * Gets the current presence status of a given person id\n * @param {string} personId\n * @returns {Promise<PresenceStatusObject>} resolves with status object of person\n */\n get(personId) {\n if (!personId) {\n return Promise.reject(new Error('A person id is required'));\n }\n\n return this.webex\n .request({\n method: 'GET',\n service: 'apheleia',\n resource: `compositions?userId=${personId}`,\n })\n .then((response) => response.body);\n },\n\n /**\n * @typedef {Object} PresenceStatusesObject\n * @property {Array.<PresenceStatusObject>} statusList\n */\n /**\n * Gets the current presence statuses of an array of people ids\n * @param {Array} personIds\n * @returns {Promise<PresenceStatusesObject>} resolves with an object with key of `statusList` array\n */\n list(personIds) {\n if (!personIds || !Array.isArray(personIds)) {\n return Promise.reject(new Error('An array of person ids is required'));\n }\n\n return Promise.all(personIds.map((id) => this.batcher.request(id))).then((presences) => ({\n statusList: presences,\n }));\n },\n\n /**\n * Subscribes to a person's presence status updates\n * Updates are sent via mercury events `apheleia.subscription_update`\n * @param {string | Array} personIds\n * @param {number} subscriptionTtl - Requested length of subscriptions in seconds.\n * @returns {Promise}\n */\n subscribe(personIds, subscriptionTtl = defaultSubscriptionTtl) {\n let subjects;\n const batches = [];\n const batchLimit = 50;\n\n if (!personIds) {\n return Promise.reject(new Error('A person id is required'));\n }\n if (Array.isArray(personIds)) {\n subjects = personIds;\n } else {\n subjects = [personIds];\n }\n // Limit batches to 50 ids per request\n for (let i = 0; i < subjects.length; i += batchLimit) {\n batches.push(subjects.slice(i, i + batchLimit));\n }\n\n return Promise.all(\n batches.map((ids) =>\n this.webex\n .request({\n method: 'POST',\n api: 'apheleia',\n resource: 'subscriptions',\n body: {\n subjects: ids,\n subscriptionTtl,\n includeStatus: true,\n },\n })\n .then((response) => response.body.responses)\n )\n ).then((idBatches) => ({responses: [].concat(...idBatches)}));\n },\n\n /**\n * Unsubscribes from a person or group of people's presence subscription\n * @param {string | Array} personIds\n * @returns {Promise}\n */\n unsubscribe(personIds) {\n let subjects;\n\n if (!personIds) {\n return Promise.reject(new Error('A person id is required'));\n }\n if (Array.isArray(personIds)) {\n subjects = personIds;\n } else {\n subjects = [personIds];\n }\n\n return this.webex.request({\n method: 'POST',\n api: 'apheleia',\n resource: 'subscriptions',\n body: {\n subjects,\n subscriptionTtl: 0,\n includeStatus: true,\n },\n });\n },\n\n /**\n * Sets the status of the current user\n * @param {string} status - active | inactive | ooo | dnd\n * @param {number} ttl - Time To Live for the event in seconds.\n * @returns {Promise}\n */\n setStatus(status, ttl) {\n if (!status) {\n return Promise.reject(new Error('A status is required'));\n }\n\n return this.webex\n .request({\n method: 'POST',\n api: 'apheleia',\n resource: 'events',\n body: {\n subject: this.webex.internal.device.userId,\n eventType: status,\n ttl,\n },\n })\n .then((response) => response.body);\n },\n\n /**\n * Retrieves and subscribes to a user's presence.\n * @param {string} id\n * @returns {undefined}\n */\n enqueue(id) {\n return this.worker.enqueue(id);\n },\n\n /**\n * Retract from subscribing to a user's presence.\n * @param {string} id\n * @returns {undefined}\n */\n dequeue(id) {\n return this.worker.dequeue(id);\n },\n});\n\nexport default Presence;\n"],"mappings":";;;;;;;;;;;AAIAA,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;;AASA,IAAMK,sBAAsB,GAAG,GAAG;AAClC,I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,CAAC,CAAC;IAC1D;IAEA,OAAO,IAAI,CAACtB,KAAK,CACduB,OAAO,CAAC;MACPC,MAAM,EAAE,MAAM;MACd2B,GAAG,EAAE,UAAU;MACfzB,QAAQ,EAAE,QAAQ;MAClBE,IAAI,EAAE;QACJkC,OAAO,EAAE,IAAI,CAAC9D,KAAK,CAACS,QAAQ,CAACsD,MAAM,CAACC,MAAM;QAC1CC,SAAS,EAAEL,MAAM;QACjBC,GAAG,EAAHA;MACF;IACF,CAAC,CAAC,CACDjD,IAAI,CAAC,UAACC,QAAQ;MAAA,OAAKA,QAAQ,CAACe,IAAI;IAAA,EAAC;EACtC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEsC,OAAO,WAAAA,QAAC/B,EAAE,EAAE;IACV,OAAO,IAAI,CAAC1C,MAAM,CAACyE,OAAO,CAAC/B,EAAE,CAAC;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEgC,OAAO,WAAAA,QAAChC,EAAE,EAAE;IACV,OAAO,IAAI,CAAC1C,MAAM,CAAC0E,OAAO,CAAChC,EAAE,CAAC;EAChC,CAAC;EAAAiC,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,SAAA,GAEYpF,QAAQ;AAAAqF,OAAA,CAAA5E,OAAA,GAAA2E,SAAA"}
|
package/jest.config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const config = require('@webex/jest-config-legacy');
|
|
2
|
-
|
|
3
|
-
module.exports = config;
|
|
1
|
+
const config = require('@webex/jest-config-legacy');
|
|
2
|
+
|
|
3
|
+
module.exports = config;
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/internal-plugin-presence",
|
|
3
|
+
"version": "2.59.4",
|
|
3
4
|
"description": "",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"main": "dist/index.js",
|
|
@@ -20,37 +21,35 @@
|
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"@babel/core": "^7.17.10",
|
|
23
|
-
"@webex/babel-config-legacy": "
|
|
24
|
-
"@webex/eslint-config-legacy": "
|
|
25
|
-
"@webex/jest-config-legacy": "
|
|
26
|
-
"@webex/legacy-tools": "
|
|
27
|
-
"@webex/test-helper-chai": "
|
|
28
|
-
"@webex/test-helper-mocha": "
|
|
29
|
-
"@webex/test-helper-mock-webex": "
|
|
30
|
-
"@webex/test-helper-test-users": "
|
|
24
|
+
"@webex/babel-config-legacy": "2.59.4",
|
|
25
|
+
"@webex/eslint-config-legacy": "2.59.4",
|
|
26
|
+
"@webex/jest-config-legacy": "2.59.4",
|
|
27
|
+
"@webex/legacy-tools": "2.59.4",
|
|
28
|
+
"@webex/test-helper-chai": "2.59.4",
|
|
29
|
+
"@webex/test-helper-mocha": "2.59.4",
|
|
30
|
+
"@webex/test-helper-mock-webex": "2.59.4",
|
|
31
|
+
"@webex/test-helper-test-users": "2.59.4",
|
|
31
32
|
"eslint": "^8.24.0",
|
|
32
33
|
"prettier": "^2.7.1",
|
|
33
34
|
"sinon": "^9.2.4"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@webex/internal-plugin-device": "
|
|
37
|
-
"@webex/internal-plugin-mercury": "
|
|
38
|
-
"@webex/test-helper-chai": "
|
|
39
|
-
"@webex/test-helper-mocha": "
|
|
40
|
-
"@webex/test-helper-mock-webex": "
|
|
41
|
-
"@webex/test-helper-test-users": "
|
|
42
|
-
"@webex/webex-core": "
|
|
37
|
+
"@webex/internal-plugin-device": "2.59.4",
|
|
38
|
+
"@webex/internal-plugin-mercury": "2.59.4",
|
|
39
|
+
"@webex/test-helper-chai": "2.59.4",
|
|
40
|
+
"@webex/test-helper-mocha": "2.59.4",
|
|
41
|
+
"@webex/test-helper-mock-webex": "2.59.4",
|
|
42
|
+
"@webex/test-helper-test-users": "2.59.4",
|
|
43
|
+
"@webex/webex-core": "2.59.4",
|
|
43
44
|
"lodash": "^4.17.21"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
47
|
"build": "yarn build:src",
|
|
47
48
|
"build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
|
|
48
|
-
"deploy:npm": "yarn npm publish",
|
|
49
49
|
"test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
|
|
50
50
|
"test:browser:broken": "webex-legacy-tools test --integration --unit --runner karma",
|
|
51
51
|
"test:integration": "webex-legacy-tools test --integration --runner mocha",
|
|
52
52
|
"test:style": "eslint ./src/**/*.*",
|
|
53
53
|
"test:unit": "webex-legacy-tools test --unit --runner jest"
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
}
|
|
54
|
+
}
|
|
55
|
+
}
|
package/process
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = {browser: true};
|
|
1
|
+
module.exports = {browser: true};
|
package/src/config.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
presence: {
|
|
7
|
-
batcherWait: 50,
|
|
8
|
-
batcherMaxCalls: 50,
|
|
9
|
-
batcherMaxWait: 150,
|
|
10
|
-
},
|
|
11
|
-
};
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
presence: {
|
|
7
|
+
batcherWait: 50,
|
|
8
|
+
batcherMaxCalls: 50,
|
|
9
|
+
batcherMaxWait: 150,
|
|
10
|
+
},
|
|
11
|
+
};
|
package/src/constants.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export const GROUNDSKEEPER_INTERVAL = 20 * 1000; // 20 seconds in ms
|
|
2
|
-
|
|
3
|
-
export const FETCH_DELAY = 300; // ms
|
|
4
|
-
|
|
5
|
-
export const UPDATE_PRESENCE_DELAY = 60 * 1000; // 1 minute in ms
|
|
6
|
-
export const EXPIRED_PRESENCE_TIME = 10 * 60 * 1000; // 10 minutes in ms
|
|
7
|
-
|
|
8
|
-
export const SUBSCRIPTION_DELAY = 60 * 1000; // 1 minute in ms
|
|
9
|
-
export const PREMATURE_EXPIRATION_SUBSCRIPTION_TIME = 60 * 1000; // 1 minute in ms
|
|
10
|
-
export const DEFAULT_SUBSCRIPTION_TTL = 10 * 60 * 1000; // 10 minutes in ms
|
|
11
|
-
|
|
12
|
-
export const APHELEIA_SUBSCRIPTION_UPDATE = 'event:apheleia.subscription_update';
|
|
13
|
-
export const PRESENCE_UPDATE = 'updated';
|
|
14
|
-
|
|
15
|
-
export const ENVELOPE_TYPE = {
|
|
16
|
-
SUBSCRIPTION: 'subscription',
|
|
17
|
-
PRESENCE: 'presence',
|
|
18
|
-
DELETE: 'delete',
|
|
19
|
-
};
|
|
1
|
+
export const GROUNDSKEEPER_INTERVAL = 20 * 1000; // 20 seconds in ms
|
|
2
|
+
|
|
3
|
+
export const FETCH_DELAY = 300; // ms
|
|
4
|
+
|
|
5
|
+
export const UPDATE_PRESENCE_DELAY = 60 * 1000; // 1 minute in ms
|
|
6
|
+
export const EXPIRED_PRESENCE_TIME = 10 * 60 * 1000; // 10 minutes in ms
|
|
7
|
+
|
|
8
|
+
export const SUBSCRIPTION_DELAY = 60 * 1000; // 1 minute in ms
|
|
9
|
+
export const PREMATURE_EXPIRATION_SUBSCRIPTION_TIME = 60 * 1000; // 1 minute in ms
|
|
10
|
+
export const DEFAULT_SUBSCRIPTION_TTL = 10 * 60 * 1000; // 10 minutes in ms
|
|
11
|
+
|
|
12
|
+
export const APHELEIA_SUBSCRIPTION_UPDATE = 'event:apheleia.subscription_update';
|
|
13
|
+
export const PRESENCE_UPDATE = 'updated';
|
|
14
|
+
|
|
15
|
+
export const ENVELOPE_TYPE = {
|
|
16
|
+
SUBSCRIPTION: 'subscription',
|
|
17
|
+
PRESENCE: 'presence',
|
|
18
|
+
DELETE: 'delete',
|
|
19
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@webex/internal-plugin-device';
|
|
6
|
-
|
|
7
|
-
import {registerInternalPlugin} from '@webex/webex-core';
|
|
8
|
-
import {has} from 'lodash';
|
|
9
|
-
|
|
10
|
-
import Presence from './presence';
|
|
11
|
-
import config from './config';
|
|
12
|
-
|
|
13
|
-
registerInternalPlugin('presence', Presence, {
|
|
14
|
-
payloadTransformer: {
|
|
15
|
-
predicates: [
|
|
16
|
-
{
|
|
17
|
-
name: 'normalizeSingleStatusResponse',
|
|
18
|
-
direction: 'inbound',
|
|
19
|
-
test(ctx, response) {
|
|
20
|
-
// POST to /apheleia/api/v1/events
|
|
21
|
-
return Promise.resolve(has(response, 'body.eventType') && has(response, 'body.subject'));
|
|
22
|
-
},
|
|
23
|
-
extract(response) {
|
|
24
|
-
return Promise.resolve(response);
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
transforms: [
|
|
29
|
-
{
|
|
30
|
-
name: 'normalizeSingleStatusResponse',
|
|
31
|
-
direction: 'inbound',
|
|
32
|
-
fn(ctx, response) {
|
|
33
|
-
response.body.status = response.body.eventType;
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
config,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
export {default} from './presence';
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import '@webex/internal-plugin-device';
|
|
6
|
+
|
|
7
|
+
import {registerInternalPlugin} from '@webex/webex-core';
|
|
8
|
+
import {has} from 'lodash';
|
|
9
|
+
|
|
10
|
+
import Presence from './presence';
|
|
11
|
+
import config from './config';
|
|
12
|
+
|
|
13
|
+
registerInternalPlugin('presence', Presence, {
|
|
14
|
+
payloadTransformer: {
|
|
15
|
+
predicates: [
|
|
16
|
+
{
|
|
17
|
+
name: 'normalizeSingleStatusResponse',
|
|
18
|
+
direction: 'inbound',
|
|
19
|
+
test(ctx, response) {
|
|
20
|
+
// POST to /apheleia/api/v1/events
|
|
21
|
+
return Promise.resolve(has(response, 'body.eventType') && has(response, 'body.subject'));
|
|
22
|
+
},
|
|
23
|
+
extract(response) {
|
|
24
|
+
return Promise.resolve(response);
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
transforms: [
|
|
29
|
+
{
|
|
30
|
+
name: 'normalizeSingleStatusResponse',
|
|
31
|
+
direction: 'inbound',
|
|
32
|
+
fn(ctx, response) {
|
|
33
|
+
response.body.status = response.body.eventType;
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
config,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export {default} from './presence';
|