@webex/internal-plugin-presence 2.29.2 → 2.29.5
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/dist/presence.js +2 -2
- package/dist/presence.js.map +1 -1
- package/package.json +30 -23
- package/src/presence.js +1 -1
package/dist/presence.js
CHANGED
|
@@ -118,7 +118,7 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
118
118
|
* @property {string} expiresTime: DateTime in RFC3339 format that the current status will expire. Missing
|
|
119
119
|
* field means no known expiration.
|
|
120
120
|
* @property {Object} vectorCounters: Used for packet ordering and tracking.
|
|
121
|
-
* @property {Boolean} suppressNotifications: Indicates if notification
|
|
121
|
+
* @property {Boolean} suppressNotifications: Indicates if notification suppression is recommended for this status.
|
|
122
122
|
* @property {string} lastSeenDeviceUrl: Resource Identifier of the last device to post presence activity for
|
|
123
123
|
* this user.
|
|
124
124
|
*/
|
|
@@ -292,7 +292,7 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
292
292
|
dequeue: function dequeue(id) {
|
|
293
293
|
return this.worker.dequeue(id);
|
|
294
294
|
},
|
|
295
|
-
version: "2.29.
|
|
295
|
+
version: "2.29.5"
|
|
296
296
|
});
|
|
297
297
|
|
|
298
298
|
var _default2 = Presence;
|
package/dist/presence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultSubscriptionTtl","USER","USER_PRESENCE_ENABLED","Presence","WebexPlugin","extend","namespace","children","batcher","PresenceBatcher","session","worker","default","PresenceWorker","type","initialize","webex","once","config","initializeWorker","emitEvent","event","payload","trigger","enable","internal","feature","setFeature","then","response","value","disable","isEnabled","getFeature","get","personId","reject","Error","request","method","service","resource","body","list","personIds","all","map","id","presences","statusList","subscribe","subscriptionTtl","subjects","batches","batchLimit","i","length","push","slice","ids","api","includeStatus","responses","idBatches","concat","unsubscribe","setStatus","status","ttl","subject","device","userId","eventType","enqueue","dequeue"],"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.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.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 suppresion 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.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) =>\n this.batcher.request(id)))\n .then((presences) => ({statusList: presences}));\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 }\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(batches.map((ids) =>\n this.webex.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 .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 }\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.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":";;;;;;;;;;;;;;;;;;AAIA;;AAEA;;AAEA;;AACA;;AATA;AACA;AACA;AASA,IAAMA,sBAAsB,GAAG,GAA/B;AACA,IAAMC,IAAI,GAAG,MAAb;AACA,IAAMC,qBAAqB,GAAG,uBAA9B;AAEA;AACA;AACA;AACA;;AACA,IAAMC,QAAQ,GAAGC,sBAAA,CAAYC,MAAZ,CAAmB;EAClCC,SAAS,EAAE,UADuB;EAGlCC,QAAQ,EAAE;IACRC,OAAO,E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B,CAAP;EACD,CAjOiC;;EAmOlC;AACF;AACA;AACA;AACA;EACE2B,OAxOkC,mBAwO1B3B,EAxO0B,EAwOtB;IACV,OAAO,KAAKpC,MAAL,CAAY+D,OAAZ,CAAoB3B,EAApB,CAAP;EACD,CA1OiC;EAAA;AAAA,CAAnB,CAAjB;;gBA6Oe5C,Q"}
|
|
1
|
+
{"version":3,"names":["defaultSubscriptionTtl","USER","USER_PRESENCE_ENABLED","Presence","WebexPlugin","extend","namespace","children","batcher","PresenceBatcher","session","worker","default","PresenceWorker","type","initialize","webex","once","config","initializeWorker","emitEvent","event","payload","trigger","enable","internal","feature","setFeature","then","response","value","disable","isEnabled","getFeature","get","personId","reject","Error","request","method","service","resource","body","list","personIds","all","map","id","presences","statusList","subscribe","subscriptionTtl","subjects","batches","batchLimit","i","length","push","slice","ids","api","includeStatus","responses","idBatches","concat","unsubscribe","setStatus","status","ttl","subject","device","userId","eventType","enqueue","dequeue"],"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.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.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.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) =>\n this.batcher.request(id)))\n .then((presences) => ({statusList: presences}));\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 }\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(batches.map((ids) =>\n this.webex.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 .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 }\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.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":";;;;;;;;;;;;;;;;;;AAIA;;AAEA;;AAEA;;AACA;;AATA;AACA;AACA;AASA,IAAMA,sBAAsB,GAAG,GAA/B;AACA,IAAMC,IAAI,GAAG,MAAb;AACA,IAAMC,qBAAqB,GAAG,uBAA9B;AAEA;AACA;AACA;AACA;;AACA,IAAMC,QAAQ,GAAGC,sBAAA,CAAYC,MAAZ,CAAmB;EAClCC,SAAS,EAAE,UADuB;EAGlCC,QAAQ,EAAE;IACRC,OAAO,EAAEC;EADD,CAHwB;EAOlCC,OAAO,EAAE;IACPC,MAAM,EAAE;MACNC,OADM,sBACI;QACR,OAAO,IAAIC,uBAAJ,EAAP;MACD,CAHK;MAINC,IAAI,EAAE;IAJA;EADD,CAPyB;;EAgBlC;AACF;AACA;AACA;EACEC,UApBkC,wBAoBrB;IAAA;;IACX,KAAKC,KAAL,CAAWC,IAAX,CAAgB,OAAhB,EAAyB,YAAM;MAC7B,IAAI,KAAI,CAACC,MAAL,CAAYC,gBAAhB,EAAkC;QAChC,KAAI,CAACR,MAAL,CAAYI,UAAZ,CAAuB,KAAI,CAACC,KAA5B;MACD;IACF,CAJD;EAKD,CA1BiC;;EA4BlC;AACF;AACA;AACA;AACA;AACA;EACEI,SAlCkC,qBAkCxBC,KAlCwB,EAkCjBC,OAlCiB,EAkCR;IACxB,IAAIA,OAAO,CAACR,IAAR,IAAgBQ,OAAO,CAACA,OAA5B,EAAqC;MACnC,KAAKC,OAAL,CAAaF,KAAb,EAAoBC,OAApB;IACD;E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",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"devMain": "src/index.js",
|
|
8
|
+
"repository": "https://github.com/webex/webex-js-sdk/tree/master/packages/@webex/internal-plugin-presence",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=14"
|
|
11
|
+
},
|
|
12
|
+
"browserify": {
|
|
13
|
+
"transform": [
|
|
14
|
+
"babelify",
|
|
15
|
+
"envify"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"sinon": "^9.2.4"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@webex/internal-plugin-device": "workspace:^",
|
|
23
|
+
"@webex/internal-plugin-mercury": "workspace:^",
|
|
24
|
+
"@webex/internal-plugin-presence": "workspace:^",
|
|
25
|
+
"@webex/test-helper-chai": "workspace:^",
|
|
26
|
+
"@webex/test-helper-mocha": "workspace:^",
|
|
27
|
+
"@webex/test-helper-mock-webex": "workspace:^",
|
|
28
|
+
"@webex/test-helper-test-users": "workspace:^",
|
|
29
|
+
"@webex/webex-core": "workspace:^",
|
|
30
|
+
"lodash": "^4.17.21"
|
|
31
|
+
}
|
|
25
32
|
}
|
package/src/presence.js
CHANGED
|
@@ -98,7 +98,7 @@ const Presence = WebexPlugin.extend({
|
|
|
98
98
|
* @property {string} expiresTime: DateTime in RFC3339 format that the current status will expire. Missing
|
|
99
99
|
* field means no known expiration.
|
|
100
100
|
* @property {Object} vectorCounters: Used for packet ordering and tracking.
|
|
101
|
-
* @property {Boolean} suppressNotifications: Indicates if notification
|
|
101
|
+
* @property {Boolean} suppressNotifications: Indicates if notification suppression is recommended for this status.
|
|
102
102
|
* @property {string} lastSeenDeviceUrl: Resource Identifier of the last device to post presence activity for
|
|
103
103
|
* this user.
|
|
104
104
|
*/
|