@webex/plugin-presence 0.0.0-next.7 → 0.0.0-next.70

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/interface.js CHANGED
@@ -4,4 +4,17 @@ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/defi
4
4
  _Object$defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ exports.PresenceStatus = void 0;
8
+ var PresenceStatus = exports.PresenceStatus = /*#__PURE__*/function (PresenceStatus) {
9
+ PresenceStatus["ACTIVE"] = "active";
10
+ PresenceStatus["CALENDAR_ITEM"] = "calendarItem";
11
+ PresenceStatus["CALL"] = "call";
12
+ PresenceStatus["CLEAR"] = "clear";
13
+ PresenceStatus["DND"] = "dnd";
14
+ PresenceStatus["INACTIVE"] = "inactive";
15
+ PresenceStatus["MEETING"] = "meeting";
16
+ PresenceStatus["OOO"] = "ooo";
17
+ PresenceStatus["PRESENTING"] = "presenting";
18
+ return PresenceStatus;
19
+ }({});
7
20
  //# sourceMappingURL=interface.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["interface.ts"],"sourcesContent":["export interface IPresenceStatusObject {\n url: string;\n subject: string;\n status: string;\n statusTime: string;\n lastActive: string;\n expiresTTL: number;\n expiresTime: string;\n vectorCounters: object;\n suppressNotifications: boolean;\n lastseeeDeviceUrl: string;\n}\n\nexport interface IEventPayload {\n type: string;\n payload: any;\n}\n\nexport interface IPresence {\n initialize(): void;\n emitEvent(event: string, payload: IEventPayload): void;\n enable(): Promise<boolean>;\n disable(): Promise<boolean>;\n isEnabled(): Promise<boolean>;\n get(personId: string): Promise<IPresenceStatusObject>;\n list(personIds: string[]): Promise<{statusList: IPresenceStatusObject[]}>;\n subscribe(personIds: string | string[], subscriptionTtl?: number): Promise<{responses: any[]}>;\n unsubscribe(personIds: string | string[]): Promise<{responses: any}>;\n setStatus(status: string, ttl: number): Promise<any>;\n enqueue(id: string): void;\n dequeue(id: string): void;\n}\n\nexport interface IWebex {\n internal: any;\n presence: IPresence;\n}\n\nexport interface IGenericKeyValue {\n [id: string]: number;\n}\n\nexport interface IPresenceBatcher {\n handleHttpSuccess(res: any): Promise<any>;\n handleItemFailure(item: string, response: any): Promise<any>;\n handleItemSuccess(item: string, response: any): Promise<any>;\n fingerprintRequest(id: string): Promise<string>;\n fingerprintResponse(id: string): Promise<string>;\n prepareRequest(ids: string[]): Promise<string[]>;\n submitHttpRequest(subjects: any): Promise<any>;\n}\n\nexport interface IResponse {\n body: {\n eventType: string;\n subject: string;\n status?: string;\n };\n}\n\nexport interface IPredicate {\n name: string;\n direction: string;\n test(ctx: any, response: IResponse): Promise<boolean>;\n extract?(response: IResponse): Promise<IResponse>;\n}\n\nexport interface ITransform {\n name: string;\n direction: string;\n fn(ctx: any, response: IResponse): void;\n}\n"],"mappings":""}
1
+ {"version":3,"names":["PresenceStatus","exports"],"sources":["interface.ts"],"sourcesContent":["export enum PresenceStatus {\n ACTIVE = 'active',\n CALENDAR_ITEM = 'calendarItem',\n CALL = 'call',\n CLEAR = 'clear',\n DND = 'dnd',\n INACTIVE = 'inactive',\n MEETING = 'meeting',\n OOO = 'ooo',\n PRESENTING = 'presenting',\n}\n\nexport interface IPresenceStatusObject {\n url: string;\n subject: string;\n status: PresenceStatus;\n statusTime: string;\n lastActive: string;\n expiresTTL: number;\n vectorCounters: object;\n suppressNotifications: boolean;\n}\n\nexport interface IEventPayload {\n type: string;\n payload: any;\n}\n\nexport interface IPresence {\n initialize(): void;\n emitEvent(event: string, payload: IEventPayload): void;\n enable(): Promise<boolean>;\n disable(): Promise<boolean>;\n isEnabled(): Promise<boolean>;\n get(personId: string): Promise<IPresenceStatusObject>;\n list(personIds: string[]): Promise<{statusList: IPresenceStatusObject[]}>;\n subscribe(personIds: string | string[], subscriptionTtl?: number): Promise<{responses: any[]}>;\n unsubscribe(personIds: string | string[]): Promise<{responses: any}>;\n setStatus(status: string, ttl: number): Promise<any>;\n enqueue(id: string): void;\n dequeue(id: string): void;\n}\n\nexport interface IWebex {\n internal: any;\n presence: IPresence;\n}\n\nexport interface IGenericKeyValue {\n [id: string]: number;\n}\n\nexport interface IPresenceBatcher {\n handleHttpSuccess(res: any): Promise<any>;\n handleItemFailure(item: string, response: any): Promise<any>;\n handleItemSuccess(item: string, response: any): Promise<any>;\n fingerprintRequest(id: string): Promise<string>;\n fingerprintResponse(id: string): Promise<string>;\n prepareRequest(ids: string[]): Promise<string[]>;\n submitHttpRequest(subjects: any): Promise<any>;\n}\n\nexport interface IResponse {\n body: {\n eventType: string;\n subject: string;\n status?: string;\n };\n}\n\nexport interface IPredicate {\n name: string;\n direction: string;\n test(ctx: any, response: IResponse): Promise<boolean>;\n extract?(response: IResponse): Promise<IResponse>;\n}\n\nexport interface ITransform {\n name: string;\n direction: string;\n fn(ctx: any, response: IResponse): void;\n}\n"],"mappings":";;;;;;;IAAYA,cAAc,GAAAC,OAAA,CAAAD,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
package/dist/presence.js CHANGED
@@ -39,7 +39,7 @@ var Presence = _webexCore.WebexPlugin.extend({
39
39
  }
40
40
  },
41
41
  /**
42
- * Initialize the presence worker for client
42
+ * Initialize the presence plugin
43
43
  * @returns {undefined}
44
44
  */
45
45
  initialize: function initialize() {
@@ -50,6 +50,20 @@ var Presence = _webexCore.WebexPlugin.extend({
50
50
  }
51
51
  });
52
52
  },
53
+ /**
54
+ * Initializes the presence worker.
55
+ * @returns {undefined}
56
+ */
57
+ initializeWorker: function initializeWorker() {
58
+ var _this2 = this;
59
+ if (this.webex.ready) {
60
+ this.worker.initialize(this.webex);
61
+ } else {
62
+ this.webex.once('ready', function () {
63
+ _this2.worker.initialize(_this2.webex);
64
+ });
65
+ }
66
+ },
53
67
  /**
54
68
  * Trigger an event.
55
69
  * @param {string} event
@@ -132,12 +146,12 @@ var Presence = _webexCore.WebexPlugin.extend({
132
146
  * @returns {Promise<PresenceStatusesObject>} resolves with an object with key of `statusList` array
133
147
  */
134
148
  list: function list(personIds) {
135
- var _this2 = this;
149
+ var _this3 = this;
136
150
  if (!personIds || !(0, _isArray.default)(personIds)) {
137
151
  return _promise.default.reject(new Error('An array of person ids is required'));
138
152
  }
139
153
  return _promise.default.all(personIds.map(function (id) {
140
- return _this2.batcher.request(id);
154
+ return _this3.batcher.request(id);
141
155
  })).then(function (presences) {
142
156
  return {
143
157
  statusList: presences
@@ -152,7 +166,7 @@ var Presence = _webexCore.WebexPlugin.extend({
152
166
  * @returns {Promise}
153
167
  */
154
168
  subscribe: function subscribe(personIds) {
155
- var _this3 = this;
169
+ var _this4 = this;
156
170
  var subscriptionTtl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultSubscriptionTtl;
157
171
  var subjects;
158
172
  var batches = [];
@@ -170,7 +184,7 @@ var Presence = _webexCore.WebexPlugin.extend({
170
184
  batches.push(subjects.slice(i, i + batchLimit));
171
185
  }
172
186
  return _promise.default.all(batches.map(function (ids) {
173
- return _this3.webex.request({
187
+ return _this4.webex.request({
174
188
  method: 'POST',
175
189
  api: 'apheleia',
176
190
  resource: 'subscriptions',
@@ -232,6 +246,7 @@ var Presence = _webexCore.WebexPlugin.extend({
232
246
  body: {
233
247
  subject: this.webex.internal.device.userId,
234
248
  eventType: status,
249
+ label: this.webex.internal.device.userId,
235
250
  ttl: ttl
236
251
  }
237
252
  }).then(function (response) {
@@ -254,7 +269,7 @@ var Presence = _webexCore.WebexPlugin.extend({
254
269
  dequeue: function dequeue(id) {
255
270
  return this.worker.dequeue(id);
256
271
  },
257
- version: "0.0.0-next.7"
272
+ version: "0.0.0-next.70"
258
273
  });
259
274
  var _default2 = exports.default = Presence;
260
275
  //# sourceMappingURL=presence.js.map
@@ -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.ts"],"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';\nimport {IEventPayload, IPresence, IPresenceStatusObject} from './interface';\n\nconst defaultSubscriptionTtl = 600;\nconst USER = 'user';\nconst USER_PRESENCE_ENABLED = 'user-presence-enabled';\n\n/**\n * @class\n * @extends WebexPlugin\n */\nconst Presence: IPresence = 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(): void {\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: string, payload: IEventPayload): void {\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(): Promise<boolean> {\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(): Promise<boolean> {\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(): Promise<boolean> {\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: string): Promise<IPresenceStatusObject> {\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: string[]): Promise<{statusList: IPresenceStatusObject[]}> {\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(\n personIds: string | string[],\n subscriptionTtl = defaultSubscriptionTtl\n ): Promise<{responses: any[]}> {\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: string | string[]): Promise<{responses: any}> {\n let subjects: string | string[];\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: string, ttl: number): Promise<any> {\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: string): void {\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: string): void {\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;;AAUA,IAAMK,sBAAsB,GAAG,GAAG;AAClC,IAAMC,IAAI,GAAG,MAAM;AACnB,IAAMC,qBAAqB,GAAG,uBAAuB;;AAErD;AACA;AACA;AACA;AACA,IAAMC,QAAmB,GAAGC,sBAAW,CAACC,MAAM,CAAC;EAC7CC,SAAS,EAAE,UAAU;EAErBC,QAAQ,EAAE;IACRC,OAAO,EAAEC;EACX,CAAC;EAEDC,OAAO,EAAE;IACPC,MAAM,EAAE;MACNC,OAAO,WAAAC,SAAA,EAAG;QACR,OAAO,IAAIC,uBAAc,CAAC,CAAC;MAC7B,CAAC;MACDC,IAAI,EAAE;IACR;EACF,CAAC;EAED;AACF;AACA;AACA;EACEC,UAAU,WAAAA,WAAA,EAAS;IAAA,IAAAC,KAAA;IACjB,IAAI,CAACC,KAAK,CAACC,IAAI,CAAC,OAAO,EAAE,YAAM;MAC7B,IAAIF,KAAI,CAACG,MAAM,CAACC,gBAAgB,EAAE;QAChCJ,KAAI,CAACN,MAAM,CAACK,UAAU,CAACC,KAAI,CAACC,KAAK,CAAC;MACpC;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AA,QAAChC,EAAU,EAAQ;IACxB,OAAO,IAAI,CAAC1C,MAAM,CAAC0E,OAAO,CAAChC,EAAE,CAAC;EAChC,CAAC;EAAAiC,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,SAAA,GAAAC,OAAA,CAAA5E,OAAA,GAEYT,QAAQ"}
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","_this2","ready","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","_this3","_isArray","all","map","id","presences","statusList","subscribe","_this4","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","label","enqueue","dequeue","version","_default2","exports"],"sources":["presence.ts"],"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';\nimport {IEventPayload, IPresence, IPresenceStatusObject} from './interface';\n\nconst defaultSubscriptionTtl = 600;\nconst USER = 'user';\nconst USER_PRESENCE_ENABLED = 'user-presence-enabled';\n\n/**\n * @class\n * @extends WebexPlugin\n */\nconst Presence: IPresence = 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 plugin\n * @returns {undefined}\n */\n initialize(): void {\n this.webex.once('ready', () => {\n if (this.config.initializeWorker) {\n this.worker.initialize(this.webex);\n }\n });\n },\n\n /**\n * Initializes the presence worker.\n * @returns {undefined}\n */\n initializeWorker(): void {\n if (this.webex.ready) {\n this.worker.initialize(this.webex);\n } else {\n this.webex.once('ready', () => {\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: string, payload: IEventPayload): void {\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(): Promise<boolean> {\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(): Promise<boolean> {\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(): Promise<boolean> {\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: string): Promise<IPresenceStatusObject> {\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: string[]): Promise<{statusList: IPresenceStatusObject[]}> {\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(\n personIds: string | string[],\n subscriptionTtl = defaultSubscriptionTtl\n ): Promise<{responses: any[]}> {\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: string | string[]): Promise<{responses: any}> {\n let subjects: string | string[];\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: string, ttl: number): Promise<any> {\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 label: this.webex.internal.device.userId,\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: string): void {\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: string): void {\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;;AAUA,IAAMK,sBAAsB,GAAG,GAAG;AAClC,IAAMC,IAAI,GAAG,MAAM;AACnB,IAAMC,qBAAqB,GAAG,uBAAuB;;AAErD;AACA;AACA;AACA;AACA,IAAMC,QAAmB,GAAGC,sBAAW,CAACC,MAAM,CAAC;EAC7CC,SAAS,EAAE,UAAU;EAErBC,QAAQ,EAAE;IACRC,OAAO,EAAEC;EACX,CAAC;EAEDC,OA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ACF;AACA;AACA;AACA;AACA;EACEO,SAAS,WAAAA,UAACC,MAAc,EAAEC,GAAW,EAAgB;IACnD,IAAI,CAACD,MAAM,EAAE;MACX,OAAOxC,QAAA,CAAA5B,OAAA,CAAQ6B,MAAM,CAAC,IAAIC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1D;IAEA,OAAO,IAAI,CAACxB,KAAK,CACdyB,OAAO,CAAC;MACPC,MAAM,EAAE,MAAM;MACd2B,GAAG,EAAE,UAAU;MACfzB,QAAQ,EAAE,QAAQ;MAClBE,IAAI,EAAE;QACJkC,OAAO,EAAE,IAAI,CAAChE,KAAK,CAACW,QAAQ,CAACsD,MAAM,CAACC,MAAM;QAC1CC,SAAS,EAAEL,MAAM;QACjBM,KAAK,EAAE,IAAI,CAACpE,KAAK,CAACW,QAAQ,CAACsD,MAAM,CAACC,MAAM;QACxCH,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;EACEuC,OAAO,WAAAA,QAAChC,EAAU,EAAQ;IACxB,OAAO,IAAI,CAAC5C,MAAM,CAAC4E,OAAO,CAAChC,EAAE,CAAC;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEiC,OAAO,WAAAA,QAACjC,EAAU,EAAQ;IACxB,OAAO,IAAI,CAAC5C,MAAM,CAAC6E,OAAO,CAACjC,EAAE,CAAC;EAChC,CAAC;EAAAkC,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,SAAA,GAAAC,OAAA,CAAA/E,OAAA,GAEYT,QAAQ"}
package/package.json CHANGED
@@ -20,38 +20,39 @@
20
20
  ]
21
21
  },
22
22
  "devDependencies": {
23
- "@babel/core": "^7.17.10",
23
+ "@babel/core": "7.17.10",
24
24
  "@webex/babel-config-legacy": "0.0.0",
25
25
  "@webex/eslint-config-legacy": "0.0.0",
26
26
  "@webex/jest-config-legacy": "0.0.0",
27
27
  "@webex/legacy-tools": "0.0.0",
28
- "@webex/test-helper-chai": "2.60.1-next.9",
29
- "@webex/test-helper-mocha": "2.60.1-next.9",
30
- "@webex/test-helper-mock-webex": "2.60.1-next.9",
31
- "@webex/test-helper-test-users": "2.60.1-next.9",
32
- "eslint": "^8.24.0",
33
- "prettier": "^2.7.1",
34
- "sinon": "^9.2.4"
28
+ "@webex/test-helper-chai": "3.5.0-next.19",
29
+ "@webex/test-helper-mocha": "3.5.0-next.19",
30
+ "@webex/test-helper-mock-webex": "3.5.0-next.19",
31
+ "@webex/test-helper-test-users": "3.5.0-next.19",
32
+ "eslint": "8.24.0",
33
+ "prettier": "2.7.1",
34
+ "sinon": "9.2.4",
35
+ "typedoc": "0.23.26"
35
36
  },
36
37
  "dependencies": {
37
- "@webex/internal-plugin-device": "2.60.1-next.9",
38
- "@webex/internal-plugin-mercury": "2.60.1-next.9",
39
- "@webex/test-helper-chai": "2.60.1-next.9",
40
- "@webex/test-helper-mocha": "2.60.1-next.9",
41
- "@webex/test-helper-mock-webex": "2.60.1-next.9",
42
- "@webex/test-helper-test-users": "2.60.1-next.9",
43
- "@webex/webex-core": "2.60.1-next.9",
44
- "lodash": "^4.17.21"
38
+ "@webex/internal-plugin-device": "3.5.0-next.19",
39
+ "@webex/internal-plugin-mercury": "3.5.0-next.19",
40
+ "@webex/test-helper-chai": "3.5.0-next.19",
41
+ "@webex/test-helper-mocha": "3.5.0-next.19",
42
+ "@webex/test-helper-mock-webex": "3.5.0-next.19",
43
+ "@webex/test-helper-test-users": "3.5.0-next.19",
44
+ "@webex/webex-core": "3.5.0-next.19",
45
+ "lodash": "4.17.21"
45
46
  },
46
47
  "scripts": {
47
48
  "build": "yarn run -T tsc --declaration true --declarationDir ./dist/types && yarn run build:src",
49
+ "build:docs": "typedoc --out ../../../docs/presence",
48
50
  "build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
49
51
  "deploy:npm": "yarn npm publish",
50
52
  "test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
51
- "test:browser:broken": "webex-legacy-tools test --integration --unit --runner karma",
52
- "test:integration": "webex-legacy-tools test --integration --runner mocha",
53
+ "test:browser:broken": "webex-legacy-tools test --integration --runner karma",
53
54
  "test:style": "eslint ./src/**/*.*",
54
55
  "test:unit": "webex-legacy-tools test --unit --runner jest"
55
56
  },
56
- "version": "0.0.0-next.7"
57
+ "version": "0.0.0-next.70"
57
58
  }
package/src/interface.ts CHANGED
@@ -1,14 +1,24 @@
1
+ export enum PresenceStatus {
2
+ ACTIVE = 'active',
3
+ CALENDAR_ITEM = 'calendarItem',
4
+ CALL = 'call',
5
+ CLEAR = 'clear',
6
+ DND = 'dnd',
7
+ INACTIVE = 'inactive',
8
+ MEETING = 'meeting',
9
+ OOO = 'ooo',
10
+ PRESENTING = 'presenting',
11
+ }
12
+
1
13
  export interface IPresenceStatusObject {
2
14
  url: string;
3
15
  subject: string;
4
- status: string;
16
+ status: PresenceStatus;
5
17
  statusTime: string;
6
18
  lastActive: string;
7
19
  expiresTTL: number;
8
- expiresTime: string;
9
20
  vectorCounters: object;
10
21
  suppressNotifications: boolean;
11
- lastseeeDeviceUrl: string;
12
22
  }
13
23
 
14
24
  export interface IEventPayload {
package/src/presence.ts CHANGED
@@ -35,7 +35,7 @@ const Presence: IPresence = WebexPlugin.extend({
35
35
  },
36
36
 
37
37
  /**
38
- * Initialize the presence worker for client
38
+ * Initialize the presence plugin
39
39
  * @returns {undefined}
40
40
  */
41
41
  initialize(): void {
@@ -46,6 +46,20 @@ const Presence: IPresence = WebexPlugin.extend({
46
46
  });
47
47
  },
48
48
 
49
+ /**
50
+ * Initializes the presence worker.
51
+ * @returns {undefined}
52
+ */
53
+ initializeWorker(): void {
54
+ if (this.webex.ready) {
55
+ this.worker.initialize(this.webex);
56
+ } else {
57
+ this.webex.once('ready', () => {
58
+ this.worker.initialize(this.webex);
59
+ });
60
+ }
61
+ },
62
+
49
63
  /**
50
64
  * Trigger an event.
51
65
  * @param {string} event
@@ -238,6 +252,7 @@ const Presence: IPresence = WebexPlugin.extend({
238
252
  body: {
239
253
  subject: this.webex.internal.device.userId,
240
254
  eventType: status,
255
+ label: this.webex.internal.device.userId,
241
256
  ttl,
242
257
  },
243
258
  })
@@ -203,8 +203,10 @@ describe.skip('plugin-presence', function () {
203
203
  spock.webex.presence.setStatus('dnd', 1500).then((statusResponse) => {
204
204
  assert.property(statusResponse, 'subject');
205
205
  assert.property(statusResponse, 'status');
206
+ assert.property(statusResponse, 'label');
206
207
  assert.equal(statusResponse.subject, spock.id);
207
208
  assert.equal(statusResponse.status, 'dnd');
209
+ assert.equal(statusResponse.subject, spock.id);
208
210
  }));
209
211
  });
210
212
  });
@@ -17,6 +17,7 @@ describe('plugin-presence', () => {
17
17
  presence: Presence,
18
18
  },
19
19
  });
20
+ webex.config.presence = {};
20
21
  });
21
22
 
22
23
  describe('#get()', () => {
@@ -61,6 +62,44 @@ describe('plugin-presence', () => {
61
62
  describe('#setStatus()', () => {
62
63
  it('requires a status', () =>
63
64
  assert.isRejected(webex.presence.setStatus(), /A status is required/));
65
+
66
+ it('passes a label to the API', () => {
67
+ const testGuid = 'test-guid';
68
+
69
+ webex.internal.device.userId = testGuid;
70
+
71
+ webex.request = function (options) {
72
+ return Promise.resolve({
73
+ statusCode: 204,
74
+ body: [],
75
+ options,
76
+ });
77
+ };
78
+ sinon.spy(webex, 'request');
79
+
80
+ webex.presence.setStatus('dnd');
81
+
82
+ assert.calledOnce(webex.request);
83
+
84
+ const request = webex.request.getCall(0);
85
+
86
+ assert.equal(request.args[0].body.label, testGuid);
87
+ });
88
+ });
89
+
90
+ describe('#initializeWorker()', () => {
91
+ it('initializes the worker once webex is ready', () => {
92
+ webex.presence.worker = {initialize: sinon.spy()};
93
+ webex.presence.config.initializeWorker = false;
94
+
95
+ webex.presence.initializeWorker();
96
+
97
+ assert.notCalled(webex.presence.worker.initialize);
98
+
99
+ webex.trigger('ready');
100
+
101
+ assert.calledOnce(webex.presence.worker.initialize);
102
+ });
64
103
  });
65
104
  });
66
105
  });
package/tsconfig.json CHANGED
@@ -1,4 +1,18 @@
1
1
  {
2
2
  "extends": "../../../tsconfig.json",
3
- "include": ["src"]
3
+ "include": ["src"],
4
+ "typedocOptions": {
5
+ "entryPoints": [
6
+ "./src/interface.ts"
7
+ ],
8
+ "sort": [
9
+ "source-order"
10
+ ],
11
+ "name": "Presence (@webex/plugin-presence)",
12
+ "disableSources": "true",
13
+ "entryPointStrategy": "expand",
14
+ "excludeExternals": "true",
15
+ "excludePrivate": "true",
16
+ "hideGenerator": "true",
17
+ },
4
18
  }