@webex/internal-plugin-dss 3.0.0-beta.8 → 3.0.0-bnr.0

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/constants.js CHANGED
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
4
  _Object$defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
-
9
7
  exports.SEARCH_TYPES = exports.DSS_UNREGISTERED = exports.DSS_SERVICE_NAME = exports.DSS_SEARCH_MERCURY_EVENT = exports.DSS_RESULT = exports.DSS_REGISTERED = exports.DSS_LOOKUP_RESULT = exports.DSS_LOOKUP_MERCURY_EVENT = void 0;
10
8
  var DSS_REGISTERED = 'dss:registered';
11
9
  exports.DSS_REGISTERED = DSS_REGISTERED;
@@ -1 +1 @@
1
- {"version":3,"names":["DSS_REGISTERED","DSS_UNREGISTERED","DSS_LOOKUP_MERCURY_EVENT","DSS_SEARCH_MERCURY_EVENT","DSS_LOOKUP_RESULT","DSS_RESULT","DSS_SERVICE_NAME","SEARCH_TYPES","PERSON","CALLING_SERVICE","EXTERNAL_CALLING","ROOM","ROBOT"],"sources":["constants.ts"],"sourcesContent":["export const DSS_REGISTERED = 'dss:registered';\nexport const DSS_UNREGISTERED = 'dss:unregistered';\nexport const DSS_LOOKUP_MERCURY_EVENT = 'event:directory.lookup';\nexport const DSS_SEARCH_MERCURY_EVENT = 'event:directory.search';\nexport const DSS_LOOKUP_RESULT = 'dss:lookup.result';\nexport const DSS_RESULT = 'dss:result';\nexport const DSS_SERVICE_NAME = 'directorySearch';\nexport const SEARCH_TYPES = {\n PERSON: 'PERSON',\n CALLING_SERVICE: 'CALLING_SERVICE',\n EXTERNAL_CALLING: 'EXTERNAL_CALLING',\n ROOM: 'ROOM',\n ROBOT: 'ROBOT',\n};\n"],"mappings":";;;;;;;;;AAAO,IAAMA,cAAc,GAAG,gBAAvB;;AACA,IAAMC,gBAAgB,GAAG,kBAAzB;;AACA,IAAMC,wBAAwB,GAAG,wBAAjC;;AACA,IAAMC,wBAAwB,GAAG,wBAAjC;;AACA,IAAMC,iBAAiB,GAAG,mBAA1B;;AACA,IAAMC,UAAU,GAAG,YAAnB;;AACA,IAAMC,gBAAgB,GAAG,iBAAzB;;AACA,IAAMC,YAAY,GAAG;EAC1BC,MAAM,EAAE,QADkB;EAE1BC,eAAe,EAAE,iBAFS;EAG1BC,gBAAgB,EAAE,kBAHQ;EAI1BC,IAAI,EAAE,MAJoB;EAK1BC,KAAK,EAAE;AALmB,CAArB"}
1
+ {"version":3,"names":["DSS_REGISTERED","DSS_UNREGISTERED","DSS_LOOKUP_MERCURY_EVENT","DSS_SEARCH_MERCURY_EVENT","DSS_LOOKUP_RESULT","DSS_RESULT","DSS_SERVICE_NAME","SEARCH_TYPES","PERSON","CALLING_SERVICE","EXTERNAL_CALLING","ROOM","ROBOT"],"sources":["constants.ts"],"sourcesContent":["export const DSS_REGISTERED = 'dss:registered';\nexport const DSS_UNREGISTERED = 'dss:unregistered';\nexport const DSS_LOOKUP_MERCURY_EVENT = 'event:directory.lookup';\nexport const DSS_SEARCH_MERCURY_EVENT = 'event:directory.search';\nexport const DSS_LOOKUP_RESULT = 'dss:lookup.result';\nexport const DSS_RESULT = 'dss:result';\nexport const DSS_SERVICE_NAME = 'directorySearch';\nexport const SEARCH_TYPES = {\n PERSON: 'PERSON',\n CALLING_SERVICE: 'CALLING_SERVICE',\n EXTERNAL_CALLING: 'EXTERNAL_CALLING',\n ROOM: 'ROOM',\n ROBOT: 'ROBOT',\n};\n"],"mappings":";;;;;;;AAAO,IAAMA,cAAc,GAAG,gBAAgB;AAAC;AACxC,IAAMC,gBAAgB,GAAG,kBAAkB;AAAC;AAC5C,IAAMC,wBAAwB,GAAG,wBAAwB;AAAC;AAC1D,IAAMC,wBAAwB,GAAG,wBAAwB;AAAC;AAC1D,IAAMC,iBAAiB,GAAG,mBAAmB;AAAC;AAC9C,IAAMC,UAAU,GAAG,YAAY;AAAC;AAChC,IAAMC,gBAAgB,GAAG,iBAAiB;AAAC;AAC3C,IAAMC,YAAY,GAAG;EAC1BC,MAAM,EAAE,QAAQ;EAChBC,eAAe,EAAE,iBAAiB;EAClCC,gBAAgB,EAAE,kBAAkB;EACpCC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE;AACT,CAAC;AAAC"}
package/dist/dss.js CHANGED
@@ -1,54 +1,31 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
4
-
5
4
  var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
6
-
7
5
  var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
8
-
9
6
  var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
10
-
11
7
  var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
12
-
13
8
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
14
-
15
9
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
16
-
17
10
  _Object$defineProperty(exports, "__esModule", {
18
11
  value: true
19
12
  });
20
-
21
13
  exports.default = void 0;
22
-
23
14
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
24
-
25
15
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
26
-
27
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
28
-
29
17
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
30
-
31
18
  var _get2 = _interopRequireDefault(require("lodash/get"));
32
-
33
19
  var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
34
-
35
20
  var _range2 = _interopRequireDefault(require("lodash/range"));
36
-
37
21
  var _uuid = _interopRequireDefault(require("uuid"));
38
-
39
22
  var _webexCore = require("@webex/webex-core");
40
-
41
23
  require("@webex/internal-plugin-mercury");
42
-
43
24
  var _constants = require("./constants");
44
-
45
25
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys2(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
46
-
47
26
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
48
-
49
27
  var DSS = _webexCore.WebexPlugin.extend({
50
28
  namespace: 'DSS',
51
-
52
29
  /**
53
30
  * registered value indicating events registration is successful
54
31
  * @instance
@@ -56,7 +33,6 @@ var DSS = _webexCore.WebexPlugin.extend({
56
33
  * @memberof DSS
57
34
  */
58
35
  registered: false,
59
-
60
36
  /**
61
37
  * Explicitly sets up the DSS plugin by connecting to mercury, and listening for DSS events.
62
38
  * @returns {Promise}
@@ -65,30 +41,23 @@ var DSS = _webexCore.WebexPlugin.extend({
65
41
  */
66
42
  register: function register() {
67
43
  var _this = this;
68
-
69
44
  if (!this.webex.canAuthorize) {
70
45
  this.logger.error('DSS->register#ERROR, Unable to register, SDK cannot authorize');
71
46
  return _promise.default.reject(new Error('SDK cannot authorize'));
72
47
  }
73
-
74
48
  if (this.registered) {
75
49
  this.logger.info('dss->register#INFO, DSS plugin already registered');
76
50
  return _promise.default.resolve();
77
51
  }
78
-
79
52
  return this.webex.internal.mercury.connect().then(function () {
80
53
  _this.listenForEvents();
81
-
82
54
  _this.trigger(_constants.DSS_REGISTERED);
83
-
84
55
  _this.registered = true;
85
56
  }).catch(function (error) {
86
57
  _this.logger.error("DSS->register#ERROR, Unable to register, ".concat(error.message));
87
-
88
58
  return _promise.default.reject(error);
89
59
  });
90
60
  },
91
-
92
61
  /**
93
62
  * Explicitly tears down the DSS plugin by disconnecting from mercury, and stops listening to DSS events
94
63
  * @returns {Promise}
@@ -97,20 +66,16 @@ var DSS = _webexCore.WebexPlugin.extend({
97
66
  */
98
67
  unregister: function unregister() {
99
68
  var _this2 = this;
100
-
101
69
  if (!this.registered) {
102
70
  this.logger.info('DSS->unregister#INFO, DSS plugin already unregistered');
103
71
  return _promise.default.resolve();
104
72
  }
105
-
106
73
  this.stopListeningForEvents();
107
74
  return this.webex.internal.mercury.disconnect().then(function () {
108
75
  _this2.trigger(_constants.DSS_UNREGISTERED);
109
-
110
76
  _this2.registered = false;
111
77
  });
112
78
  },
113
-
114
79
  /**
115
80
  * registers for DSS events through mercury
116
81
  * @returns {undefined}
@@ -118,7 +83,6 @@ var DSS = _webexCore.WebexPlugin.extend({
118
83
  */
119
84
  listenForEvents: function listenForEvents() {
120
85
  var _this3 = this;
121
-
122
86
  this.webex.internal.mercury.on(_constants.DSS_LOOKUP_MERCURY_EVENT, function (envelope) {
123
87
  _this3._handleEvent(envelope.data);
124
88
  });
@@ -126,7 +90,6 @@ var DSS = _webexCore.WebexPlugin.extend({
126
90
  _this3._handleEvent(envelope.data);
127
91
  });
128
92
  },
129
-
130
93
  /**
131
94
  * unregisteres all the DSS events from mercury
132
95
  * @returns {undefined}
@@ -136,7 +99,6 @@ var DSS = _webexCore.WebexPlugin.extend({
136
99
  this.webex.internal.mercury.off(_constants.DSS_LOOKUP_MERCURY_EVENT);
137
100
  this.webex.internal.mercury.off(_constants.DSS_SEARCH_MERCURY_EVENT);
138
101
  },
139
-
140
102
  /**
141
103
  * @param {UUID} requestId the id of the request
142
104
  * @returns {string}
@@ -144,7 +106,6 @@ var DSS = _webexCore.WebexPlugin.extend({
144
106
  _getResultEventName: function _getResultEventName(requestId) {
145
107
  return "".concat(_constants.DSS_RESULT).concat(requestId);
146
108
  },
147
-
148
109
  /**
149
110
  * @param {Object} data the event data
150
111
  * @returns {undefined}
@@ -153,54 +114,43 @@ var DSS = _webexCore.WebexPlugin.extend({
153
114
  this.trigger(this._getResultEventName(data.requestId), data);
154
115
  this.trigger(_constants.DSS_LOOKUP_RESULT, data);
155
116
  },
156
-
157
117
  /**
158
- * Makes the request to the directory service
159
- * @param {Object} options
160
- * @param {string} options.resource the URL to query
161
- * @param {string} options.params additional params for the body of the request
162
- * @param {string} options.dataPath to path to get the data in the result object
163
- * @returns {Promise} Resolves with an array of entities found
164
- */
118
+ * Makes the request to the directory service
119
+ * @param {Object} options
120
+ * @param {string} options.resource the URL to query
121
+ * @param {string} options.params additional params for the body of the request
122
+ * @param {string} options.dataPath to path to get the data in the result object
123
+ * @returns {Promise} Resolves with an array of entities found
124
+ */
165
125
  _request: function _request(options) {
166
126
  var _this4 = this;
167
-
168
127
  var resource = options.resource,
169
- params = options.params,
170
- dataPath = options.dataPath;
171
-
128
+ params = options.params,
129
+ dataPath = options.dataPath;
172
130
  var requestId = _uuid.default.v4();
173
-
174
131
  var eventName = this._getResultEventName(requestId);
175
-
176
132
  var result = {};
177
133
  var expectedSeqNums;
178
134
  return new _promise.default(function (resolve) {
179
135
  _this4.listenTo(_this4, eventName, function (data) {
180
136
  var resultData = (0, _get2.default)(data, dataPath);
181
137
  result[data.sequence] = resultData;
182
-
183
138
  if (data.finished) {
184
139
  expectedSeqNums = (0, _range2.default)(data.sequence + 1).map(String);
185
140
  }
186
-
187
141
  var done = (0, _isEqual2.default)(expectedSeqNums, (0, _keys.default)(result));
188
-
189
142
  if (done) {
190
143
  var resultArray = [];
191
144
  expectedSeqNums.forEach(function (index) {
192
145
  var seqResult = result[index];
193
-
194
146
  if (seqResult) {
195
147
  resultArray.push.apply(resultArray, (0, _toConsumableArray2.default)(seqResult));
196
148
  }
197
149
  });
198
150
  resolve(resultArray);
199
-
200
151
  _this4.stopListening(_this4, eventName);
201
152
  }
202
153
  });
203
-
204
154
  _this4.webex.request({
205
155
  service: _constants.DSS_SERVICE_NAME,
206
156
  resource: resource,
@@ -212,7 +162,6 @@ var DSS = _webexCore.WebexPlugin.extend({
212
162
  });
213
163
  });
214
164
  },
215
-
216
165
  /**
217
166
  * Retrieves detailed information about an entity
218
167
  * @param {Object} options
@@ -226,7 +175,6 @@ var DSS = _webexCore.WebexPlugin.extend({
226
175
  resource: "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/identity/").concat(id, "/detail")
227
176
  });
228
177
  },
229
-
230
178
  /**
231
179
  * Retrieves basic information about a list entities within an organization
232
180
  * @param {Object} options
@@ -236,7 +184,7 @@ var DSS = _webexCore.WebexPlugin.extend({
236
184
  */
237
185
  lookup: function lookup(options) {
238
186
  var ids = options.ids,
239
- entityProviderType = options.entityProviderType;
187
+ entityProviderType = options.entityProviderType;
240
188
  var resource = entityProviderType ? "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/entityprovidertype/").concat(entityProviderType) : "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/identities");
241
189
  return this._request({
242
190
  dataPath: 'lookupResult.entities',
@@ -246,7 +194,6 @@ var DSS = _webexCore.WebexPlugin.extend({
246
194
  }
247
195
  });
248
196
  },
249
-
250
197
  /**
251
198
  * Retrieves basic information about a list entities within an organization
252
199
  * @param {Object} options
@@ -263,7 +210,6 @@ var DSS = _webexCore.WebexPlugin.extend({
263
210
  }
264
211
  });
265
212
  },
266
-
267
213
  /**
268
214
  * Search for information about entities
269
215
  * @param {Object} options
@@ -274,8 +220,8 @@ var DSS = _webexCore.WebexPlugin.extend({
274
220
  */
275
221
  search: function search(options) {
276
222
  var requestedTypes = options.requestedTypes,
277
- resultSize = options.resultSize,
278
- queryString = options.queryString;
223
+ resultSize = options.resultSize,
224
+ queryString = options.queryString;
279
225
  return this._request({
280
226
  dataPath: 'directoryEntities',
281
227
  resource: "/search/orgid/".concat(this.webex.internal.device.orgId, "/entities"),
@@ -286,9 +232,8 @@ var DSS = _webexCore.WebexPlugin.extend({
286
232
  }
287
233
  });
288
234
  },
289
- version: "3.0.0-beta.8"
235
+ version: "3.0.0-bnr.0"
290
236
  });
291
-
292
237
  var _default = DSS;
293
238
  exports.default = _default;
294
239
  //# sourceMappingURL=dss.js.map
package/dist/dss.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["DSS","WebexPlugin","extend","namespace","registered","register","webex","canAuthorize","logger","error","reject","Error","info","resolve","internal","mercury","connect","then","listenForEvents","trigger","DSS_REGISTERED","catch","message","unregister","stopListeningForEvents","disconnect","DSS_UNREGISTERED","on","DSS_LOOKUP_MERCURY_EVENT","envelope","_handleEvent","data","DSS_SEARCH_MERCURY_EVENT","off","_getResultEventName","requestId","DSS_RESULT","DSS_LOOKUP_RESULT","_request","options","resource","params","dataPath","uuid","v4","eventName","result","expectedSeqNums","listenTo","resultData","sequence","finished","map","String","done","resultArray","forEach","index","seqResult","push","stopListening","request","service","DSS_SERVICE_NAME","method","contentType","body","lookupDetail","id","device","orgId","lookup","ids","entityProviderType","lookupValues","lookupByEmail","emails","search","requestedTypes","resultSize","queryString"],"sources":["dss.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\n/*!\n * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.\n */\nimport uuid from 'uuid';\nimport {WebexPlugin} from '@webex/webex-core';\nimport '@webex/internal-plugin-mercury';\nimport {range, isEqual, get} from 'lodash';\nimport type {SearchOptions, LookupDetailOptions, LookupOptions, LookupByEmailOptions} from './types';\n\nimport {\n DSS_REGISTERED,\n DSS_UNREGISTERED,\n DSS_LOOKUP_MERCURY_EVENT,\n DSS_LOOKUP_RESULT,\n DSS_SERVICE_NAME,\n DSS_SEARCH_MERCURY_EVENT,\n DSS_RESULT,\n} from './constants';\n\nconst DSS = WebexPlugin.extend({\n namespace: 'DSS',\n\n /**\n * registered value indicating events registration is successful\n * @instance\n * @type {Boolean}\n * @memberof DSS\n */\n registered: false,\n\n /**\n * Explicitly sets up the DSS plugin by connecting to mercury, and listening for DSS events.\n * @returns {Promise}\n * @public\n * @memberof DSS\n */\n register() {\n if (!this.webex.canAuthorize) {\n this.logger.error('DSS->register#ERROR, Unable to register, SDK cannot authorize');\n\n return Promise.reject(new Error('SDK cannot authorize'));\n }\n\n if (this.registered) {\n this.logger.info('dss->register#INFO, DSS plugin already registered');\n\n return Promise.resolve();\n }\n\n return this.webex.internal.mercury.connect()\n .then(() => {\n this.listenForEvents();\n this.trigger(DSS_REGISTERED);\n this.registered = true;\n })\n .catch((error) => {\n this.logger.error(`DSS->register#ERROR, Unable to register, ${error.message}`);\n\n return Promise.reject(error);\n });\n },\n\n /**\n * Explicitly tears down the DSS plugin by disconnecting from mercury, and stops listening to DSS events\n * @returns {Promise}\n * @public\n * @memberof DSS\n */\n unregister() {\n if (!this.registered) {\n this.logger.info('DSS->unregister#INFO, DSS plugin already unregistered');\n\n return Promise.resolve();\n }\n\n this.stopListeningForEvents();\n\n return this.webex.internal.mercury.disconnect()\n .then(() => {\n this.trigger(DSS_UNREGISTERED);\n this.registered = false;\n });\n },\n\n /**\n * registers for DSS events through mercury\n * @returns {undefined}\n * @private\n */\n listenForEvents() {\n this.webex.internal.mercury.on(DSS_LOOKUP_MERCURY_EVENT, (envelope) => {\n this._handleEvent(envelope.data);\n });\n this.webex.internal.mercury.on(DSS_SEARCH_MERCURY_EVENT, (envelope) => {\n this._handleEvent(envelope.data);\n });\n },\n\n /**\n * unregisteres all the DSS events from mercury\n * @returns {undefined}\n * @private\n */\n stopListeningForEvents() {\n this.webex.internal.mercury.off(DSS_LOOKUP_MERCURY_EVENT);\n this.webex.internal.mercury.off(DSS_SEARCH_MERCURY_EVENT);\n },\n\n /**\n * @param {UUID} requestId the id of the request\n * @returns {string}\n */\n _getResultEventName(requestId) {\n return `${DSS_RESULT}${requestId}`;\n },\n\n /**\n * @param {Object} data the event data\n * @returns {undefined}\n */\n _handleEvent(data) {\n this.trigger(this._getResultEventName(data.requestId), data);\n this.trigger(DSS_LOOKUP_RESULT, data);\n },\n\n /**\n * Makes the request to the directory service\n * @param {Object} options\n * @param {string} options.resource the URL to query\n * @param {string} options.params additional params for the body of the request\n * @param {string} options.dataPath to path to get the data in the result object\n * @returns {Promise} Resolves with an array of entities found\n */\n _request(options) {\n const {resource, params, dataPath} = options;\n\n const requestId = uuid.v4();\n const eventName = this._getResultEventName(requestId);\n const result = {};\n let expectedSeqNums;\n\n return new Promise((resolve) => {\n this.listenTo(this, eventName, (data) => {\n const resultData = get(data, dataPath);\n\n result[data.sequence] = resultData;\n\n if (data.finished) {\n expectedSeqNums = range(data.sequence + 1).map(String);\n }\n\n const done = isEqual(expectedSeqNums, Object.keys(result));\n\n if (done) {\n const resultArray = [];\n expectedSeqNums.forEach((index) => {\n const seqResult = result[index];\n if (seqResult) {\n resultArray.push(...seqResult);\n }\n })\n\n resolve(resultArray);\n this.stopListening(this, eventName);\n }\n });\n this.webex.request({\n service: DSS_SERVICE_NAME,\n resource,\n method: 'POST',\n contentType: 'application/json',\n body: {requestId, ...params}\n });\n });\n },\n\n /**\n * Retrieves detailed information about an entity\n * @param {Object} options\n * @param {UUID} options.id the id of the entity to lookup\n * @returns {Promise} Resolves with an array of entities found\n */\n lookupDetail(options: LookupDetailOptions) {\n const {id} = options;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource: `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`\n });\n },\n\n /**\n * Retrieves basic information about a list entities within an organization\n * @param {Object} options\n * @param {UUID} options.ids the id of the entity to lookup\n * @param {UUID} options.entityProviderType the provider to query (optional)\n * @returns {Promise} Resolves with an array of entities found\n */\n lookup(options: LookupOptions) {\n const {ids, entityProviderType} = options;\n\n const resource = entityProviderType ? `/lookup/orgid/${this.webex.internal.device.orgId}/entityprovidertype/${entityProviderType}` : `/lookup/orgid/${this.webex.internal.device.orgId}/identities`;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource,\n params: {\n lookupValues: ids,\n }\n });\n },\n\n /**\n * Retrieves basic information about a list entities within an organization\n * @param {Object} options\n * @param {UUID} options.emails the emails of the entities to lookup\n * @returns {Promise} Resolves with an array of entities found\n */\n lookupByEmail(options: LookupByEmailOptions) {\n const {emails} = options;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource: `/lookup/orgid/${this.webex.internal.device.orgId}/emails`,\n params: {\n lookupValues: emails,\n }\n });\n },\n\n /**\n * Search for information about entities\n * @param {Object} options\n * @param {SearchType[]} options.requestedTypes an array of search types from: PERSON, CALLING_SERVICE, EXTERNAL_CALLING, ROOM, ROBOT\n * @param {string[]} options.queryString A query string that will be transformed into a Directory search filter query. It is used to search the following fields: username, givenName, familyName, displayName and email\n * @param {number} options.resultSize The maximum number of results returned from each provider\n * @returns {Promise} Resolves with an array of entities found\n */\n search(options: SearchOptions) {\n const {\n requestedTypes, resultSize, queryString\n } = options;\n\n return this._request({\n dataPath: 'directoryEntities',\n resource: `/search/orgid/${this.webex.internal.device.orgId}/entities`,\n params: {\n queryString,\n resultSize,\n requestedTypes\n }\n });\n }\n\n});\n\nexport default DSS;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;AACA;;AAIA;;;;;;AAUA,IAAMA,GAAG,GAAGC,sBAAA,CAAYC,MAAZ,CAAmB;EAC7BC,SAAS,EAAE,KADkB;;EAG7B;AACF;AACA;AACA;AACA;AACA;EACEC,UAAU,EAAE,KATiB;;EAW7B;AACF;AACA;AACA;AACA;AACA;EACEC,QAjB6B,sBAiBlB;IAAA;;IACT,IAAI,CAAC,KAAKC,KAAL,CAAWC,YAAhB,EAA8B;MAC5B,KAAKC,MAAL,CAAYC,KAAZ,CAAkB,+DAAlB;MAEA,OAAO,iBAAQC,MAAR,CAAe,IAAIC,KAAJ,CAAU,sBAAV,CAAf,CAAP;IACD;;IAED,I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,QAAQ,0BAAmB,KAAKlC,KAAL,CAAWQ,QAAX,CAAoBuD,MAApB,CAA2BC,KAA9C,cAFW;MAGnB7B,MAAM,EAAE;QACNuC,WAAW,EAAXA,WADM;QAEND,UAAU,EAAVA,UAFM;QAGND,cAAc,EAAdA;MAHM;IAHW,CAAd,CAAP;EASD,CAzO4B;EAAA;AAAA,CAAnB,CAAZ;;eA6Oe9E,G"}
1
+ {"version":3,"names":["DSS","WebexPlugin","extend","namespace","registered","register","webex","canAuthorize","logger","error","reject","Error","info","resolve","internal","mercury","connect","then","listenForEvents","trigger","DSS_REGISTERED","catch","message","unregister","stopListeningForEvents","disconnect","DSS_UNREGISTERED","on","DSS_LOOKUP_MERCURY_EVENT","envelope","_handleEvent","data","DSS_SEARCH_MERCURY_EVENT","off","_getResultEventName","requestId","DSS_RESULT","DSS_LOOKUP_RESULT","_request","options","resource","params","dataPath","uuid","v4","eventName","result","expectedSeqNums","listenTo","resultData","sequence","finished","map","String","done","resultArray","forEach","index","seqResult","push","stopListening","request","service","DSS_SERVICE_NAME","method","contentType","body","lookupDetail","id","device","orgId","lookup","ids","entityProviderType","lookupValues","lookupByEmail","emails","search","requestedTypes","resultSize","queryString"],"sources":["dss.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\n/*!\n * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.\n */\nimport uuid from 'uuid';\nimport {WebexPlugin} from '@webex/webex-core';\nimport '@webex/internal-plugin-mercury';\nimport {range, isEqual, get} from 'lodash';\nimport type {\n SearchOptions,\n LookupDetailOptions,\n LookupOptions,\n LookupByEmailOptions,\n} from './types';\n\nimport {\n DSS_REGISTERED,\n DSS_UNREGISTERED,\n DSS_LOOKUP_MERCURY_EVENT,\n DSS_LOOKUP_RESULT,\n DSS_SERVICE_NAME,\n DSS_SEARCH_MERCURY_EVENT,\n DSS_RESULT,\n} from './constants';\n\nconst DSS = WebexPlugin.extend({\n namespace: 'DSS',\n\n /**\n * registered value indicating events registration is successful\n * @instance\n * @type {Boolean}\n * @memberof DSS\n */\n registered: false,\n\n /**\n * Explicitly sets up the DSS plugin by connecting to mercury, and listening for DSS events.\n * @returns {Promise}\n * @public\n * @memberof DSS\n */\n register() {\n if (!this.webex.canAuthorize) {\n this.logger.error('DSS->register#ERROR, Unable to register, SDK cannot authorize');\n\n return Promise.reject(new Error('SDK cannot authorize'));\n }\n\n if (this.registered) {\n this.logger.info('dss->register#INFO, DSS plugin already registered');\n\n return Promise.resolve();\n }\n\n return this.webex.internal.mercury\n .connect()\n .then(() => {\n this.listenForEvents();\n this.trigger(DSS_REGISTERED);\n this.registered = true;\n })\n .catch((error) => {\n this.logger.error(`DSS->register#ERROR, Unable to register, ${error.message}`);\n\n return Promise.reject(error);\n });\n },\n\n /**\n * Explicitly tears down the DSS plugin by disconnecting from mercury, and stops listening to DSS events\n * @returns {Promise}\n * @public\n * @memberof DSS\n */\n unregister() {\n if (!this.registered) {\n this.logger.info('DSS->unregister#INFO, DSS plugin already unregistered');\n\n return Promise.resolve();\n }\n\n this.stopListeningForEvents();\n\n return this.webex.internal.mercury.disconnect().then(() => {\n this.trigger(DSS_UNREGISTERED);\n this.registered = false;\n });\n },\n\n /**\n * registers for DSS events through mercury\n * @returns {undefined}\n * @private\n */\n listenForEvents() {\n this.webex.internal.mercury.on(DSS_LOOKUP_MERCURY_EVENT, (envelope) => {\n this._handleEvent(envelope.data);\n });\n this.webex.internal.mercury.on(DSS_SEARCH_MERCURY_EVENT, (envelope) => {\n this._handleEvent(envelope.data);\n });\n },\n\n /**\n * unregisteres all the DSS events from mercury\n * @returns {undefined}\n * @private\n */\n stopListeningForEvents() {\n this.webex.internal.mercury.off(DSS_LOOKUP_MERCURY_EVENT);\n this.webex.internal.mercury.off(DSS_SEARCH_MERCURY_EVENT);\n },\n\n /**\n * @param {UUID} requestId the id of the request\n * @returns {string}\n */\n _getResultEventName(requestId) {\n return `${DSS_RESULT}${requestId}`;\n },\n\n /**\n * @param {Object} data the event data\n * @returns {undefined}\n */\n _handleEvent(data) {\n this.trigger(this._getResultEventName(data.requestId), data);\n this.trigger(DSS_LOOKUP_RESULT, data);\n },\n\n /**\n * Makes the request to the directory service\n * @param {Object} options\n * @param {string} options.resource the URL to query\n * @param {string} options.params additional params for the body of the request\n * @param {string} options.dataPath to path to get the data in the result object\n * @returns {Promise} Resolves with an array of entities found\n */\n _request(options) {\n const {resource, params, dataPath} = options;\n\n const requestId = uuid.v4();\n const eventName = this._getResultEventName(requestId);\n const result = {};\n let expectedSeqNums;\n\n return new Promise((resolve) => {\n this.listenTo(this, eventName, (data) => {\n const resultData = get(data, dataPath);\n\n result[data.sequence] = resultData;\n\n if (data.finished) {\n expectedSeqNums = range(data.sequence + 1).map(String);\n }\n\n const done = isEqual(expectedSeqNums, Object.keys(result));\n\n if (done) {\n const resultArray = [];\n expectedSeqNums.forEach((index) => {\n const seqResult = result[index];\n if (seqResult) {\n resultArray.push(...seqResult);\n }\n });\n\n resolve(resultArray);\n this.stopListening(this, eventName);\n }\n });\n this.webex.request({\n service: DSS_SERVICE_NAME,\n resource,\n method: 'POST',\n contentType: 'application/json',\n body: {requestId, ...params},\n });\n });\n },\n\n /**\n * Retrieves detailed information about an entity\n * @param {Object} options\n * @param {UUID} options.id the id of the entity to lookup\n * @returns {Promise} Resolves with an array of entities found\n */\n lookupDetail(options: LookupDetailOptions) {\n const {id} = options;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource: `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`,\n });\n },\n\n /**\n * Retrieves basic information about a list entities within an organization\n * @param {Object} options\n * @param {UUID} options.ids the id of the entity to lookup\n * @param {UUID} options.entityProviderType the provider to query (optional)\n * @returns {Promise} Resolves with an array of entities found\n */\n lookup(options: LookupOptions) {\n const {ids, entityProviderType} = options;\n\n const resource = entityProviderType\n ? `/lookup/orgid/${this.webex.internal.device.orgId}/entityprovidertype/${entityProviderType}`\n : `/lookup/orgid/${this.webex.internal.device.orgId}/identities`;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource,\n params: {\n lookupValues: ids,\n },\n });\n },\n\n /**\n * Retrieves basic information about a list entities within an organization\n * @param {Object} options\n * @param {UUID} options.emails the emails of the entities to lookup\n * @returns {Promise} Resolves with an array of entities found\n */\n lookupByEmail(options: LookupByEmailOptions) {\n const {emails} = options;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource: `/lookup/orgid/${this.webex.internal.device.orgId}/emails`,\n params: {\n lookupValues: emails,\n },\n });\n },\n\n /**\n * Search for information about entities\n * @param {Object} options\n * @param {SearchType[]} options.requestedTypes an array of search types from: PERSON, CALLING_SERVICE, EXTERNAL_CALLING, ROOM, ROBOT\n * @param {string[]} options.queryString A query string that will be transformed into a Directory search filter query. It is used to search the following fields: username, givenName, familyName, displayName and email\n * @param {number} options.resultSize The maximum number of results returned from each provider\n * @returns {Promise} Resolves with an array of entities found\n */\n search(options: SearchOptions) {\n const {requestedTypes, resultSize, queryString} = options;\n\n return this._request({\n dataPath: 'directoryEntities',\n resource: `/search/orgid/${this.webex.internal.device.orgId}/entities`,\n params: {\n queryString,\n resultSize,\n requestedTypes,\n },\n });\n },\n});\n\nexport default DSS;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA;AACA;AACA;AASA;AAQqB;AAAA;AAErB,IAAMA,GAAG,GAAGC,sBAAW,CAACC,MAAM,CAAC;EAC7BC,SAAS,EAAE,KAAK;EAEhB;AACF;AACA;AACA;AACA;AACA;EACEC,UAAU,EAAE,KAAK;EAEjB;AACF;AACA;AACA;AACA;AACA;EACEC,QAAQ,sBAAG;IAAA;IACT,IAAI,CAAC,IAAI,CAACC,KAAK,CAACC,YAAY,EAAE;MAC5B,IAAI,CAACC,MAAM,CAACC,KAAK,CAAC,+DAA+D,CAAC;MAElF,OAAO,iBAAQC,MAAM,CAAC,IAAIC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1D;IAEA,IAAI,IAAI,CAACP,UAAU,EAAE;MACnB,IA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AAM,CAACC,KAAK,cAAW;MACtE7B,MAAM,EAAE;QACNuC,WAAW,EAAXA,WAAW;QACXD,UAAU,EAAVA,UAAU;QACVD,cAAc,EAAdA;MACF;IACF,CAAC,CAAC;EACJ,CAAC;EAAA;AACH,CAAC,CAAC;AAAC,eAEY9E,GAAG;AAAA"}
package/dist/index.js CHANGED
@@ -1,23 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
6
-
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
-
11
8
  _Object$defineProperty(exports, "default", {
12
9
  enumerable: true,
13
10
  get: function get() {
14
11
  return _dss.default;
15
12
  }
16
13
  });
17
-
18
14
  var _webexCore = require("@webex/webex-core");
19
-
20
15
  var _dss = _interopRequireDefault(require("./dss"));
21
-
22
16
  (0, _webexCore.registerInternalPlugin)('dss', _dss.default);
23
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["registerInternalPlugin","DSS"],"sources":["index.ts"],"sourcesContent":["import {registerInternalPlugin} from '@webex/webex-core';\n\nimport DSS from './dss';\n\nregisterInternalPlugin('dss', DSS);\n\nexport {default} from './dss';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAEA,IAAAA,iCAAA,EAAuB,KAAvB,EAA8BC,YAA9B"}
1
+ {"version":3,"names":["registerInternalPlugin","DSS"],"sources":["index.ts"],"sourcesContent":["import {registerInternalPlugin} from '@webex/webex-core';\n\nimport DSS from './dss';\n\nregisterInternalPlugin('dss', DSS);\n\nexport {default} from './dss';\n"],"mappings":";;;;;;;;;;;;;AAAA;AAEA;AAEA,IAAAA,iCAAsB,EAAC,KAAK,EAAEC,YAAG,CAAC"}
@@ -0,0 +1,4 @@
1
+ declare const DSS: any;
2
+ export default DSS;
3
+
4
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.34.4"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,14 @@
1
+ export declare const DSS_REGISTERED = "dss:registered";
2
+ export declare const DSS_UNREGISTERED = "dss:unregistered";
3
+ export declare const DSS_LOOKUP_MERCURY_EVENT = "event:directory.lookup";
4
+ export declare const DSS_SEARCH_MERCURY_EVENT = "event:directory.search";
5
+ export declare const DSS_LOOKUP_RESULT = "dss:lookup.result";
6
+ export declare const DSS_RESULT = "dss:result";
7
+ export declare const DSS_SERVICE_NAME = "directorySearch";
8
+ export declare const SEARCH_TYPES: {
9
+ PERSON: string;
10
+ CALLING_SERVICE: string;
11
+ EXTERNAL_CALLING: string;
12
+ ROOM: string;
13
+ ROBOT: string;
14
+ };
@@ -0,0 +1,3 @@
1
+ import '@webex/internal-plugin-mercury';
2
+ declare const DSS: any;
3
+ export default DSS;
@@ -0,0 +1 @@
1
+ export { default } from './dss';
@@ -0,0 +1,28 @@
1
+ export interface LookupDetailOptions {
2
+ id: string;
3
+ }
4
+ export declare enum EntityProviderType {
5
+ CI_USER = "CI_USER",
6
+ CI_MACHINE = "CI_MACHINE",
7
+ CONTACTS = "CONTACTS",
8
+ CSDM = "CSDM"
9
+ }
10
+ export interface LookupOptions {
11
+ ids: string[];
12
+ entityProviderType?: EntityProviderType;
13
+ }
14
+ export interface LookupByEmailOptions {
15
+ emails: string[];
16
+ }
17
+ export declare enum SearchType {
18
+ PERSON = "PERSON",
19
+ CALLING_SERVICE = "CALLING_SERVICE",
20
+ EXTERNAL_CALLING = "EXTERNAL_CALLING",
21
+ ROOM = "ROOM",
22
+ ROBOT = "ROBOT"
23
+ }
24
+ export interface SearchOptions {
25
+ requestedTypes: SearchType[];
26
+ resultSize: number;
27
+ queryString: string;
28
+ }
package/dist/types.js CHANGED
@@ -1,25 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
4
  _Object$defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
-
9
7
  exports.SearchType = exports.EntityProviderType = void 0;
8
+ // eslint-disable-next-line no-shadow
10
9
  var EntityProviderType;
11
10
  exports.EntityProviderType = EntityProviderType;
12
-
13
11
  (function (EntityProviderType) {
14
12
  EntityProviderType["CI_USER"] = "CI_USER";
15
13
  EntityProviderType["CI_MACHINE"] = "CI_MACHINE";
16
14
  EntityProviderType["CONTACTS"] = "CONTACTS";
17
15
  EntityProviderType["CSDM"] = "CSDM";
18
16
  })(EntityProviderType || (exports.EntityProviderType = EntityProviderType = {}));
19
-
17
+ // eslint-disable-next-line no-shadow
20
18
  var SearchType;
21
19
  exports.SearchType = SearchType;
22
-
23
20
  (function (SearchType) {
24
21
  SearchType["PERSON"] = "PERSON";
25
22
  SearchType["CALLING_SERVICE"] = "CALLING_SERVICE";
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["EntityProviderType","SearchType"],"sources":["types.ts"],"sourcesContent":["export interface LookupDetailOptions {\n id: string;\n}\n\nexport enum EntityProviderType {\n CI_USER = 'CI_USER',\n CI_MACHINE ='CI_MACHINE',\n CONTACTS = 'CONTACTS',\n CSDM = 'CSDM'\n}\n\nexport interface LookupOptions {\n ids: string[];\n entityProviderType?: EntityProviderType;\n}\n\nexport interface LookupByEmailOptions {\n emails: string[];\n}\n\nexport enum SearchType {\n PERSON = 'PERSON', \n CALLING_SERVICE = 'CALLING_SERVICE',\n EXTERNAL_CALLING = 'EXTERNAL_CALLING',\n ROOM = 'ROOM',\n ROBOT = 'ROBOT'\n}\n\nexport interface SearchOptions {\n requestedTypes: SearchType[],\n resultSize: number,\n queryString: string,\n}\n"],"mappings":";;;;;;;;;IAIYA,kB;;;WAAAA,kB;EAAAA,kB;EAAAA,kB;EAAAA,kB;EAAAA,kB;GAAAA,kB,kCAAAA,kB;;IAgBAC,U;;;WAAAA,U;EAAAA,U;EAAAA,U;EAAAA,U;EAAAA,U;EAAAA,U;GAAAA,U,0BAAAA,U"}
1
+ {"version":3,"names":["EntityProviderType","SearchType"],"sources":["types.ts"],"sourcesContent":["export interface LookupDetailOptions {\n id: string;\n}\n\n// eslint-disable-next-line no-shadow\nexport enum EntityProviderType {\n CI_USER = 'CI_USER',\n CI_MACHINE = 'CI_MACHINE',\n CONTACTS = 'CONTACTS',\n CSDM = 'CSDM',\n}\n\nexport interface LookupOptions {\n ids: string[];\n entityProviderType?: EntityProviderType;\n}\n\nexport interface LookupByEmailOptions {\n emails: string[];\n}\n\n// eslint-disable-next-line no-shadow\nexport enum SearchType {\n PERSON = 'PERSON',\n CALLING_SERVICE = 'CALLING_SERVICE',\n EXTERNAL_CALLING = 'EXTERNAL_CALLING',\n ROOM = 'ROOM',\n ROBOT = 'ROBOT',\n}\n\nexport interface SearchOptions {\n requestedTypes: SearchType[];\n resultSize: number;\n queryString: string;\n}\n"],"mappings":";;;;;;;AAIA;AAAA,IACYA,kBAAkB;AAAA;AAAA,WAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;AAAA,GAAlBA,kBAAkB,kCAAlBA,kBAAkB;AAgB9B;AAAA,IACYC,UAAU;AAAA;AAAA,WAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;AAAA,GAAVA,UAAU,0BAAVA,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/internal-plugin-dss",
3
- "version": "3.0.0-beta.8",
3
+ "version": "3.0.0-bnr.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "Colin Read <coread@cisco.com>",
@@ -21,14 +21,14 @@
21
21
  ]
22
22
  },
23
23
  "dependencies": {
24
- "@webex/internal-plugin-mercury": "3.0.0-beta.8",
25
- "@webex/webex-core": "3.0.0-beta.8",
24
+ "@webex/internal-plugin-mercury": "3.0.0-bnr.0",
25
+ "@webex/webex-core": "3.0.0-bnr.0",
26
26
  "lodash": "^4.17.21",
27
27
  "uuid": "^3.3.2"
28
28
  },
29
29
  "devDependencies": {
30
- "@webex/internal-plugin-dss": "3.0.0-beta.8",
31
- "@webex/test-helper-chai": "3.0.0-beta.8",
32
- "@webex/test-helper-mock-webex": "3.0.0-beta.8"
30
+ "@webex/internal-plugin-dss": "3.0.0-bnr.0",
31
+ "@webex/test-helper-chai": "3.0.0-bnr.0",
32
+ "@webex/test-helper-mock-webex": "3.0.0-bnr.0"
33
33
  }
34
34
  }
package/src/dss.ts CHANGED
@@ -6,7 +6,12 @@ import uuid from 'uuid';
6
6
  import {WebexPlugin} from '@webex/webex-core';
7
7
  import '@webex/internal-plugin-mercury';
8
8
  import {range, isEqual, get} from 'lodash';
9
- import type {SearchOptions, LookupDetailOptions, LookupOptions, LookupByEmailOptions} from './types';
9
+ import type {
10
+ SearchOptions,
11
+ LookupDetailOptions,
12
+ LookupOptions,
13
+ LookupByEmailOptions,
14
+ } from './types';
10
15
 
11
16
  import {
12
17
  DSS_REGISTERED,
@@ -48,7 +53,8 @@ const DSS = WebexPlugin.extend({
48
53
  return Promise.resolve();
49
54
  }
50
55
 
51
- return this.webex.internal.mercury.connect()
56
+ return this.webex.internal.mercury
57
+ .connect()
52
58
  .then(() => {
53
59
  this.listenForEvents();
54
60
  this.trigger(DSS_REGISTERED);
@@ -76,11 +82,10 @@ const DSS = WebexPlugin.extend({
76
82
 
77
83
  this.stopListeningForEvents();
78
84
 
79
- return this.webex.internal.mercury.disconnect()
80
- .then(() => {
81
- this.trigger(DSS_UNREGISTERED);
82
- this.registered = false;
83
- });
85
+ return this.webex.internal.mercury.disconnect().then(() => {
86
+ this.trigger(DSS_UNREGISTERED);
87
+ this.registered = false;
88
+ });
84
89
  },
85
90
 
86
91
  /**
@@ -125,13 +130,13 @@ const DSS = WebexPlugin.extend({
125
130
  },
126
131
 
127
132
  /**
128
- * Makes the request to the directory service
129
- * @param {Object} options
130
- * @param {string} options.resource the URL to query
131
- * @param {string} options.params additional params for the body of the request
132
- * @param {string} options.dataPath to path to get the data in the result object
133
- * @returns {Promise} Resolves with an array of entities found
134
- */
133
+ * Makes the request to the directory service
134
+ * @param {Object} options
135
+ * @param {string} options.resource the URL to query
136
+ * @param {string} options.params additional params for the body of the request
137
+ * @param {string} options.dataPath to path to get the data in the result object
138
+ * @returns {Promise} Resolves with an array of entities found
139
+ */
135
140
  _request(options) {
136
141
  const {resource, params, dataPath} = options;
137
142
 
@@ -159,7 +164,7 @@ const DSS = WebexPlugin.extend({
159
164
  if (seqResult) {
160
165
  resultArray.push(...seqResult);
161
166
  }
162
- })
167
+ });
163
168
 
164
169
  resolve(resultArray);
165
170
  this.stopListening(this, eventName);
@@ -170,7 +175,7 @@ const DSS = WebexPlugin.extend({
170
175
  resource,
171
176
  method: 'POST',
172
177
  contentType: 'application/json',
173
- body: {requestId, ...params}
178
+ body: {requestId, ...params},
174
179
  });
175
180
  });
176
181
  },
@@ -186,7 +191,7 @@ const DSS = WebexPlugin.extend({
186
191
 
187
192
  return this._request({
188
193
  dataPath: 'lookupResult.entities',
189
- resource: `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`
194
+ resource: `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`,
190
195
  });
191
196
  },
192
197
 
@@ -200,14 +205,16 @@ const DSS = WebexPlugin.extend({
200
205
  lookup(options: LookupOptions) {
201
206
  const {ids, entityProviderType} = options;
202
207
 
203
- const resource = entityProviderType ? `/lookup/orgid/${this.webex.internal.device.orgId}/entityprovidertype/${entityProviderType}` : `/lookup/orgid/${this.webex.internal.device.orgId}/identities`;
208
+ const resource = entityProviderType
209
+ ? `/lookup/orgid/${this.webex.internal.device.orgId}/entityprovidertype/${entityProviderType}`
210
+ : `/lookup/orgid/${this.webex.internal.device.orgId}/identities`;
204
211
 
205
212
  return this._request({
206
213
  dataPath: 'lookupResult.entities',
207
214
  resource,
208
215
  params: {
209
216
  lookupValues: ids,
210
- }
217
+ },
211
218
  });
212
219
  },
213
220
 
@@ -225,7 +232,7 @@ const DSS = WebexPlugin.extend({
225
232
  resource: `/lookup/orgid/${this.webex.internal.device.orgId}/emails`,
226
233
  params: {
227
234
  lookupValues: emails,
228
- }
235
+ },
229
236
  });
230
237
  },
231
238
 
@@ -238,9 +245,7 @@ const DSS = WebexPlugin.extend({
238
245
  * @returns {Promise} Resolves with an array of entities found
239
246
  */
240
247
  search(options: SearchOptions) {
241
- const {
242
- requestedTypes, resultSize, queryString
243
- } = options;
248
+ const {requestedTypes, resultSize, queryString} = options;
244
249
 
245
250
  return this._request({
246
251
  dataPath: 'directoryEntities',
@@ -248,11 +253,10 @@ const DSS = WebexPlugin.extend({
248
253
  params: {
249
254
  queryString,
250
255
  resultSize,
251
- requestedTypes
252
- }
256
+ requestedTypes,
257
+ },
253
258
  });
254
- }
255
-
259
+ },
256
260
  });
257
261
 
258
262
  export default DSS;
package/src/types.ts CHANGED
@@ -2,11 +2,12 @@ export interface LookupDetailOptions {
2
2
  id: string;
3
3
  }
4
4
 
5
+ // eslint-disable-next-line no-shadow
5
6
  export enum EntityProviderType {
6
7
  CI_USER = 'CI_USER',
7
- CI_MACHINE ='CI_MACHINE',
8
+ CI_MACHINE = 'CI_MACHINE',
8
9
  CONTACTS = 'CONTACTS',
9
- CSDM = 'CSDM'
10
+ CSDM = 'CSDM',
10
11
  }
11
12
 
12
13
  export interface LookupOptions {
@@ -18,16 +19,17 @@ export interface LookupByEmailOptions {
18
19
  emails: string[];
19
20
  }
20
21
 
22
+ // eslint-disable-next-line no-shadow
21
23
  export enum SearchType {
22
- PERSON = 'PERSON',
24
+ PERSON = 'PERSON',
23
25
  CALLING_SERVICE = 'CALLING_SERVICE',
24
26
  EXTERNAL_CALLING = 'EXTERNAL_CALLING',
25
27
  ROOM = 'ROOM',
26
- ROBOT = 'ROBOT'
28
+ ROBOT = 'ROBOT',
27
29
  }
28
30
 
29
31
  export interface SearchOptions {
30
- requestedTypes: SearchType[],
31
- resultSize: number,
32
- queryString: string,
32
+ requestedTypes: SearchType[];
33
+ resultSize: number;
34
+ queryString: string;
33
35
  }
@@ -2,16 +2,16 @@
2
2
  * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.
3
3
  */
4
4
 
5
- import { assert } from "@webex/test-helper-chai";
6
- import DSS from "@webex/internal-plugin-dss";
7
- import MockWebex from "@webex/test-helper-mock-webex";
8
- import sinon from "sinon";
9
- import { expect } from "chai";
10
- import { set } from "lodash";
11
- import uuid from "uuid";
12
-
13
- describe("plugin-dss", () => {
14
- describe("DSS", () => {
5
+ import {assert} from '@webex/test-helper-chai';
6
+ import DSS from '@webex/internal-plugin-dss';
7
+ import MockWebex from '@webex/test-helper-mock-webex';
8
+ import sinon from 'sinon';
9
+ import {expect} from 'chai';
10
+ import {set} from 'lodash';
11
+ import uuid from 'uuid';
12
+
13
+ describe('plugin-dss', () => {
14
+ describe('DSS', () => {
15
15
  let webex;
16
16
  let uuidStub;
17
17
  let mercuryCallbacks;
@@ -24,10 +24,10 @@ describe("plugin-dss", () => {
24
24
  },
25
25
  });
26
26
 
27
- uuidStub = sinon.stub(uuid, "v4").returns("randomid");
27
+ uuidStub = sinon.stub(uuid, 'v4').returns('randomid');
28
28
 
29
29
  webex.canAuthorize = true;
30
- webex.internal.device.orgId = "userOrgId";
30
+ webex.internal.device.orgId = 'userOrgId';
31
31
 
32
32
  mercuryCallbacks = {};
33
33
 
@@ -45,50 +45,51 @@ describe("plugin-dss", () => {
45
45
  uuidStub.restore();
46
46
  });
47
47
 
48
- describe("#register()", () => {
49
- it("registers correctly", async () => {
48
+ describe('#register()', () => {
49
+ it('registers correctly', async () => {
50
50
  await webex.internal.dss.register();
51
51
 
52
52
  assert.callCount(webex.internal.mercury.on, 2);
53
53
 
54
54
  const firstCallArgs = webex.internal.mercury.on.getCall(0).args;
55
- expect(firstCallArgs[0]).to.equal("event:directory.lookup");
56
- expect(firstCallArgs[1]).to.be.a("function");
55
+ expect(firstCallArgs[0]).to.equal('event:directory.lookup');
56
+ expect(firstCallArgs[1]).to.be.a('function');
57
57
 
58
58
  const secondCallArgs = webex.internal.mercury.on.getCall(1).args;
59
- expect(secondCallArgs[0]).to.equal("event:directory.search");
60
- expect(secondCallArgs[1]).to.be.a("function");
59
+ expect(secondCallArgs[0]).to.equal('event:directory.search');
60
+ expect(secondCallArgs[1]).to.be.a('function');
61
61
 
62
62
  assert.equal(webex.internal.dss.registered, true);
63
63
  });
64
64
 
65
- it("rejects when it cannot authorize", async () => {
65
+ it('rejects when it cannot authorize', async () => {
66
66
  webex.canAuthorize = false;
67
+ // @ts-ignore
67
68
  await expect(webex.internal.dss.register()).to.be.rejectedWith(
68
69
  Error,
69
- "SDK cannot authorize"
70
+ 'SDK cannot authorize'
70
71
  );
71
72
  assert.equal(webex.internal.dss.registered, false);
72
73
  });
73
74
  });
74
75
 
75
- describe("#unregister()", () => {
76
- it("unregisters correctly", async () => {
76
+ describe('#unregister()', () => {
77
+ it('unregisters correctly', async () => {
77
78
  webex.internal.dss.registered = true;
78
79
  await webex.internal.dss.unregister();
79
80
 
80
81
  assert.callCount(webex.internal.mercury.off, 2);
81
82
 
82
83
  const firstCallArgs = webex.internal.mercury.off.getCall(0).args;
83
- expect(firstCallArgs[0]).to.equal("event:directory.lookup");
84
+ expect(firstCallArgs[0]).to.equal('event:directory.lookup');
84
85
 
85
86
  const secondCallArgs = webex.internal.mercury.off.getCall(1).args;
86
- expect(secondCallArgs[0]).to.equal("event:directory.search");
87
+ expect(secondCallArgs[0]).to.equal('event:directory.search');
87
88
 
88
89
  assert.equal(webex.internal.dss.registered, false);
89
90
  });
90
91
 
91
- it("handles unregister when it is not registered", async () => {
92
+ it('handles unregister when it is not registered', async () => {
92
93
  const result = await webex.internal.dss.unregister();
93
94
  await expect(result).equal(undefined);
94
95
  assert.equal(webex.internal.dss.registered, false);
@@ -104,34 +105,27 @@ describe("plugin-dss", () => {
104
105
  (data as any).finished = finished;
105
106
  }
106
107
  set(data, dataPath, [`data${sequence}`]);
107
- return { data };
108
+ return {data};
108
109
  };
109
110
 
110
- const testRequest = async ({
111
- method,
112
- resource,
113
- params,
114
- bodyParams,
115
- dataPath,
116
- event,
117
- }) => {
111
+ const testRequest = async ({method, resource, params, bodyParams, dataPath, event}) => {
118
112
  webex.request = sinon.stub();
119
113
 
120
114
  await webex.internal.dss.register();
121
115
 
122
116
  const promise = webex.internal.dss[method](params);
123
117
 
124
- const requestId = "randomid";
118
+ const requestId = 'randomid';
125
119
 
126
120
  expect(webex.request.getCall(0).args).to.deep.equal([
127
121
  {
128
- service: "directorySearch",
122
+ service: 'directorySearch',
129
123
  body: {
130
124
  requestId,
131
125
  ...bodyParams,
132
126
  },
133
- contentType: "application/json",
134
- method: "POST",
127
+ contentType: 'application/json',
128
+ method: 'POST',
135
129
  resource,
136
130
  },
137
131
  ]);
@@ -141,241 +135,225 @@ describe("plugin-dss", () => {
141
135
  mercuryCallbacks[event](createData(requestId, 0, false, dataPath));
142
136
 
143
137
  const result = await promise;
144
- expect(result).to.deep.equal(["data0", "data1", "data2"]);
138
+ expect(result).to.deep.equal(['data0', 'data1', 'data2']);
145
139
  };
146
140
 
147
- describe("#lookupDetail", () => {
148
- it("calls _request correctly", async () => {
149
- webex.internal.device.orgId = "userOrgId";
150
- webex.internal.dss._request = sinon
151
- .stub()
152
- .returns(Promise.resolve("some return value"));
141
+ describe('#lookupDetail', () => {
142
+ it('calls _request correctly', async () => {
143
+ webex.internal.device.orgId = 'userOrgId';
144
+ webex.internal.dss._request = sinon.stub().returns(Promise.resolve('some return value'));
153
145
 
154
- const result = await webex.internal.dss.lookupDetail({ id: "test id" });
146
+ const result = await webex.internal.dss.lookupDetail({id: 'test id'});
155
147
  expect(webex.internal.dss._request.getCall(0).args).to.deep.equal([
156
148
  {
157
- dataPath: "lookupResult.entities",
149
+ dataPath: 'lookupResult.entities',
158
150
  resource: '/lookup/orgid/userOrgId/identity/test id/detail',
159
151
  },
160
152
  ]);
161
- expect(result).to.equal("some return value");
153
+ expect(result).to.equal('some return value');
162
154
  });
163
155
 
164
- it("works correctly", async () => {
156
+ it('works correctly', async () => {
165
157
  await testRequest({
166
- method: "lookupDetail",
167
- dataPath: "lookupResult.entities",
168
- event: "event:directory.lookup",
158
+ method: 'lookupDetail',
159
+ dataPath: 'lookupResult.entities',
160
+ event: 'event:directory.lookup',
169
161
  resource: '/lookup/orgid/userOrgId/identity/test id/detail',
170
162
  params: {
171
- id: "test id",
163
+ id: 'test id',
172
164
  },
173
165
  bodyParams: {},
174
166
  });
175
167
  });
176
168
  });
177
169
 
178
- describe("#lookup", () => {
179
- it("calls _request correctly", async () => {
180
- webex.internal.device.orgId = "userOrgId";
181
- webex.internal.dss._request = sinon
182
- .stub()
183
- .returns(Promise.resolve("some return value"));
170
+ describe('#lookup', () => {
171
+ it('calls _request correctly', async () => {
172
+ webex.internal.device.orgId = 'userOrgId';
173
+ webex.internal.dss._request = sinon.stub().returns(Promise.resolve('some return value'));
184
174
 
185
- const result = await webex.internal.dss.lookup({ ids: ["id1", "id2"] });
175
+ const result = await webex.internal.dss.lookup({ids: ['id1', 'id2']});
186
176
  expect(webex.internal.dss._request.getCall(0).args).to.deep.equal([
187
177
  {
188
- dataPath: "lookupResult.entities",
178
+ dataPath: 'lookupResult.entities',
189
179
  resource: '/lookup/orgid/userOrgId/identities',
190
180
  params: {
191
- lookupValues: ["id1", "id2"],
181
+ lookupValues: ['id1', 'id2'],
192
182
  },
193
183
  },
194
184
  ]);
195
- expect(result).to.equal("some return value");
185
+ expect(result).to.equal('some return value');
196
186
  });
197
187
 
198
- it("calls _request correctly with entityProviderType", async () => {
199
- webex.internal.device.orgId = "userOrgId";
200
- webex.internal.dss._request = sinon
201
- .stub()
202
- .returns(Promise.resolve("some return value"));
188
+ it('calls _request correctly with entityProviderType', async () => {
189
+ webex.internal.device.orgId = 'userOrgId';
190
+ webex.internal.dss._request = sinon.stub().returns(Promise.resolve('some return value'));
203
191
 
204
- const result = await webex.internal.dss.lookup({ ids: ["id1", "id2"], entityProviderType: 'CI_USER' });
192
+ const result = await webex.internal.dss.lookup({
193
+ ids: ['id1', 'id2'],
194
+ entityProviderType: 'CI_USER',
195
+ });
205
196
  expect(webex.internal.dss._request.getCall(0).args).to.deep.equal([
206
197
  {
207
- dataPath: "lookupResult.entities",
198
+ dataPath: 'lookupResult.entities',
208
199
  resource: '/lookup/orgid/userOrgId/entityprovidertype/CI_USER',
209
200
  params: {
210
- lookupValues: ["id1", "id2"],
201
+ lookupValues: ['id1', 'id2'],
211
202
  },
212
203
  },
213
204
  ]);
214
- expect(result).to.equal("some return value");
205
+ expect(result).to.equal('some return value');
215
206
  });
216
207
 
217
- it("works correctly", async () => {
208
+ it('works correctly', async () => {
218
209
  await testRequest({
219
- method: "lookup",
220
- dataPath: "lookupResult.entities",
221
- event: "event:directory.lookup",
210
+ method: 'lookup',
211
+ dataPath: 'lookupResult.entities',
212
+ event: 'event:directory.lookup',
222
213
  resource: '/lookup/orgid/userOrgId/identities',
223
214
  params: {
224
- ids: ["id1", "id2"],
215
+ ids: ['id1', 'id2'],
225
216
  },
226
217
  bodyParams: {
227
- lookupValues: ["id1", "id2"],
218
+ lookupValues: ['id1', 'id2'],
228
219
  },
229
220
  });
230
221
  });
231
222
  });
232
223
 
233
- describe("#lookupByEmail", () => {
234
- it("calls _request correctly", async () => {
235
- webex.internal.device.orgId = "userOrgId";
236
- webex.internal.dss._request = sinon
237
- .stub()
238
- .returns(Promise.resolve("some return value"));
224
+ describe('#lookupByEmail', () => {
225
+ it('calls _request correctly', async () => {
226
+ webex.internal.device.orgId = 'userOrgId';
227
+ webex.internal.dss._request = sinon.stub().returns(Promise.resolve('some return value'));
239
228
 
240
229
  const result = await webex.internal.dss.lookupByEmail({
241
- emails: ["email1", "email2"],
230
+ emails: ['email1', 'email2'],
242
231
  });
243
232
  expect(webex.internal.dss._request.getCall(0).args).to.deep.equal([
244
233
  {
245
- dataPath: "lookupResult.entities",
234
+ dataPath: 'lookupResult.entities',
246
235
  resource: '/lookup/orgid/userOrgId/emails',
247
236
  params: {
248
- lookupValues: ["email1", "email2"],
237
+ lookupValues: ['email1', 'email2'],
249
238
  },
250
239
  },
251
240
  ]);
252
- expect(result).to.equal("some return value");
241
+ expect(result).to.equal('some return value');
253
242
  });
254
243
 
255
- it("works correctly", async () => {
244
+ it('works correctly', async () => {
256
245
  await testRequest({
257
- method: "lookupByEmail",
258
- dataPath: "lookupResult.entities",
259
- event: "event:directory.lookup",
246
+ method: 'lookupByEmail',
247
+ dataPath: 'lookupResult.entities',
248
+ event: 'event:directory.lookup',
260
249
  resource: '/lookup/orgid/userOrgId/emails',
261
250
  params: {
262
- emails: ["email1", "email2"],
251
+ emails: ['email1', 'email2'],
263
252
  },
264
253
  bodyParams: {
265
- lookupValues: ["email1", "email2"],
254
+ lookupValues: ['email1', 'email2'],
266
255
  },
267
256
  });
268
257
  });
269
258
  });
270
259
 
271
- describe("#search", () => {
272
- it("calls _request correctly", async () => {
273
- webex.internal.device.orgId = "userOrgId";
274
- webex.internal.dss._request = sinon
275
- .stub()
276
- .returns(Promise.resolve("some return value"));
260
+ describe('#search', () => {
261
+ it('calls _request correctly', async () => {
262
+ webex.internal.device.orgId = 'userOrgId';
263
+ webex.internal.dss._request = sinon.stub().returns(Promise.resolve('some return value'));
277
264
 
278
265
  const result = await webex.internal.dss.search({
279
- requestedTypes: ["PERSON", "ROBOT"],
266
+ requestedTypes: ['PERSON', 'ROBOT'],
280
267
  resultSize: 100,
281
- queryString: "query",
268
+ queryString: 'query',
282
269
  });
283
270
  expect(webex.internal.dss._request.getCall(0).args).to.deep.equal([
284
271
  {
285
- dataPath: "directoryEntities",
272
+ dataPath: 'directoryEntities',
286
273
  resource: '/search/orgid/userOrgId/entities',
287
274
  params: {
288
- queryString: "query",
275
+ queryString: 'query',
289
276
  resultSize: 100,
290
- requestedTypes: ["PERSON", "ROBOT"],
277
+ requestedTypes: ['PERSON', 'ROBOT'],
291
278
  },
292
279
  },
293
280
  ]);
294
- expect(result).to.equal("some return value");
281
+ expect(result).to.equal('some return value');
295
282
  });
296
283
 
297
- it("works correctly", async () => {
284
+ it('works correctly', async () => {
298
285
  await testRequest({
299
- method: "search",
300
- event: "event:directory.search",
301
- dataPath: "directoryEntities",
286
+ method: 'search',
287
+ event: 'event:directory.search',
288
+ dataPath: 'directoryEntities',
302
289
  resource: '/search/orgid/userOrgId/entities',
303
290
  params: {
304
- requestedTypes: ["PERSON", "ROBOT"],
291
+ requestedTypes: ['PERSON', 'ROBOT'],
305
292
  resultSize: 100,
306
- queryString: "query",
293
+ queryString: 'query',
307
294
  },
308
295
  bodyParams: {
309
- requestedTypes: ["PERSON", "ROBOT"],
296
+ requestedTypes: ['PERSON', 'ROBOT'],
310
297
  resultSize: 100,
311
- queryString: "query",
298
+ queryString: 'query',
312
299
  },
313
300
  });
314
301
  });
315
302
  });
316
303
 
317
- describe("#_request", () => {
318
- it("handles a request correctly", async () => {
304
+ describe('#_request', () => {
305
+ it('handles a request correctly', async () => {
319
306
  webex.request = sinon.stub();
320
- uuid.v4.returns("randomid");
307
+ uuid.v4.returns('randomid');
321
308
  const promise = webex.internal.dss._request({
322
- resource: "/search/orgid/userOrgId/entities",
323
- params: { some: "param" },
324
- dataPath: "a.b.c",
309
+ resource: '/search/orgid/userOrgId/entities',
310
+ params: {some: 'param'},
311
+ dataPath: 'a.b.c',
325
312
  });
326
313
 
327
314
  expect(webex.request.getCall(0).args).to.deep.equal([
328
315
  {
329
- service: "directorySearch",
316
+ service: 'directorySearch',
330
317
  body: {
331
- requestId: "randomid",
332
- some: "param",
318
+ requestId: 'randomid',
319
+ some: 'param',
333
320
  },
334
- contentType: "application/json",
335
- method: "POST",
336
- resource: "/search/orgid/userOrgId/entities",
321
+ contentType: 'application/json',
322
+ method: 'POST',
323
+ resource: '/search/orgid/userOrgId/entities',
337
324
  },
338
325
  ]);
339
326
 
340
- webex.internal.dss.trigger(
341
- webex.internal.dss._getResultEventName("randomid"),
342
- {
343
- sequence: 1,
344
- a: {
345
- b: {
346
- c: ["data1"],
347
- },
327
+ webex.internal.dss.trigger(webex.internal.dss._getResultEventName('randomid'), {
328
+ sequence: 1,
329
+ a: {
330
+ b: {
331
+ c: ['data1'],
348
332
  },
349
- }
350
- );
333
+ },
334
+ });
351
335
 
352
- webex.internal.dss.trigger(
353
- webex.internal.dss._getResultEventName("randomid"),
354
- {
355
- sequence: 2,
356
- finished: true,
357
- a: {
358
- b: {
359
- c: ["data2"],
360
- },
336
+ webex.internal.dss.trigger(webex.internal.dss._getResultEventName('randomid'), {
337
+ sequence: 2,
338
+ finished: true,
339
+ a: {
340
+ b: {
341
+ c: ['data2'],
361
342
  },
362
- }
363
- );
343
+ },
344
+ });
364
345
 
365
- webex.internal.dss.trigger(
366
- webex.internal.dss._getResultEventName("randomid"),
367
- {
368
- sequence: 0,
369
- a: {
370
- b: {
371
- c: ["data0"],
372
- },
346
+ webex.internal.dss.trigger(webex.internal.dss._getResultEventName('randomid'), {
347
+ sequence: 0,
348
+ a: {
349
+ b: {
350
+ c: ['data0'],
373
351
  },
374
- }
375
- );
352
+ },
353
+ });
376
354
 
377
355
  const result = await promise;
378
- expect(result).to.deep.equal(["data0", "data1", "data2"]);
356
+ expect(result).to.deep.equal(['data0', 'data1', 'data2']);
379
357
  });
380
358
  });
381
359
  });