@webex/internal-plugin-dss 3.10.0-next.6 → 3.10.0-next.7

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/dss.js CHANGED
@@ -337,6 +337,47 @@ var DSS = _webexCore.WebexPlugin.extend({
337
337
  return null;
338
338
  });
339
339
  },
340
+ /**
341
+ * Retrieves basic information about entities by phone numbers within an organization.
342
+ * Supports up to 5 phone numbers per request. For larger batches, client should chunk
343
+ * requests into groups of 5.
344
+ * @param {string[]} phoneNumbers - Array of phone numbers to lookup in E.164 format (max 5)
345
+ * @returns {Promise<RequestResult>} Resolves with object containing:
346
+ * - resultArray: Array of matched entities
347
+ * - foundArray: Array of phone numbers that were found
348
+ * - notFoundArray: Array of phone numbers that were not found
349
+ * @throws {Error} When more than 5 phone numbers provided
350
+ * @throws {DssTimeoutError} When server does not respond in the specified timeframe
351
+ * @example
352
+ * const result = await webex.internal.dss.lookupByPhoneNumbers(['+15551234567']);
353
+ * console.log('Found:', result.foundArray);
354
+ * console.log('Entities:', result.resultArray);
355
+ */
356
+ lookupByPhoneNumbers: function lookupByPhoneNumbers(phoneNumbers) {
357
+ var _this5 = this;
358
+ if (!phoneNumbers || phoneNumbers.length === 0) {
359
+ return _promise.default.resolve({
360
+ resultArray: [],
361
+ foundArray: [],
362
+ notFoundArray: []
363
+ });
364
+ }
365
+ if (phoneNumbers.length > 5) {
366
+ this.logger.error("DSS->lookupByPhoneNumbers#ERROR, Maximum of 5 phone numbers allowed, received: ".concat(phoneNumbers.length));
367
+ return _promise.default.reject(new Error("lookupByPhoneNumbers accepts a maximum of 5 phone numbers. Received: ".concat(phoneNumbers.length, ". Please batch requests on the client side if needed.")));
368
+ }
369
+ var resource = "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/phonenumbers");
370
+ return this._request({
371
+ dataPath: _constants.LOOKUP_DATA_PATH,
372
+ foundPath: _constants.LOOKUP_FOUND_PATH,
373
+ notFoundPath: _constants.LOOKUP_NOT_FOUND_PATH,
374
+ resource: resource,
375
+ params: (0, _defineProperty2.default)({}, _constants.LOOKUP_REQUEST_KEY, phoneNumbers)
376
+ }).catch(function (error) {
377
+ _this5.logger.error("DSS->lookupByPhoneNumbers#ERROR, Phone number lookup failure, ".concat(error.message));
378
+ return _promise.default.reject(error);
379
+ });
380
+ },
340
381
  /**
341
382
  * Search for information about entities
342
383
  * @param {Object} options
@@ -380,7 +421,7 @@ var DSS = _webexCore.WebexPlugin.extend({
380
421
  * @returns {Promise} Resolves with an array of entities found
381
422
  */
382
423
  searchPlaces: function searchPlaces(options) {
383
- var _this5 = this;
424
+ var _this6 = this;
384
425
  var resultSize = options.resultSize,
385
426
  queryString = options.queryString,
386
427
  isOnlySchedulableRooms = options.isOnlySchedulableRooms;
@@ -393,11 +434,11 @@ var DSS = _webexCore.WebexPlugin.extend({
393
434
  isOnlySchedulableRooms: isOnlySchedulableRooms
394
435
  }
395
436
  }).catch(function (error) {
396
- _this5.logger.error("DSS->search place#ERROR, search place failure, ".concat(error.message));
437
+ _this6.logger.error("DSS->search place#ERROR, search place failure, ".concat(error.message));
397
438
  return _promise.default.reject(error);
398
439
  });
399
440
  },
400
- version: "3.10.0-next.6"
441
+ version: "3.10.0-next.7"
401
442
  });
402
443
  var _default = exports.default = DSS;
403
444
  //# sourceMappingURL=dss.js.map
package/dist/dss.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_uuid","_interopRequireDefault","require","_webexCore","_lodash","_commonTimers","_constants","_dssBatcher","_dssErrors","ownKeys","e","r","t","_Object$keys2","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","DSS","WebexPlugin","extend","namespace","registered","initialize","_len","args","Array","_key","_apply","prototype","batchers","register","_this","webex","canAuthorize","logger","error","_promise","reject","Error","info","resolve","internal","mercury","connect","then","listenForEvents","trigger","DSS_REGISTERED","catch","concat","message","unregister","_this2","stopListeningForEvents","disconnect","DSS_UNREGISTERED","_this3","on","DSS_LOOKUP_MERCURY_EVENT","envelope","_handleEvent","data","DSS_SEARCH_MERCURY_EVENT","off","_getResultEventName","requestId","DSS_RESULT","DSS_LOOKUP_RESULT","_request","options","_this4","resource","params","dataPath","foundPath","notFoundPath","timeout","config","requestTimeout","uuid","v4","eventName","result","expectedSeqNums","notFoundArray","timer","Timer","stopListening","DssTimeoutError","listenTo","reset","resultData","get","found","sequence","finished","range","map","String","done","isEqual","_keys","cancel","resultArray","foundArray","index","seqResult","_toConsumableArray2","resolveValue","request","service","DSS_SERVICE_NAME","method","contentType","body","start","_batchedLookup","lookupValue","LOOKUP_DATA_PATH","entitiesFoundPath","LOOKUP_FOUND_PATH","entitiesNotFoundPath","LOOKUP_NOT_FOUND_PATH","requestKey","LOOKUP_REQUEST_KEY","DssBatcher","parent","lookupDetail","id","device","orgId","_ref","lookup","entityProviderType","_options$shouldBatch","shouldBatch","_ref2","lookupByEmail","email","_ref3","search","requestedTypes","resultSize","queryString","includeCommonAreaPhones","includeOnlyPairableDevices","includePersonalDevices","SEARCH_DATA_PATH","_ref4","searchPlaces","_this5","isOnlySchedulableRooms","version","_default","exports"],"sources":["dss.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\n/*!\n * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.\n */\n/* eslint-disable no-underscore-dangle */\nimport uuid from 'uuid';\nimport {WebexPlugin} from '@webex/webex-core';\nimport '@webex/internal-plugin-mercury';\nimport {range, isEqual, get} from 'lodash';\n\nimport {Timer} from '@webex/common-timers';\nimport type {\n SearchOptions,\n LookupDetailOptions,\n LookupOptions,\n LookupByEmailOptions,\n SearchPlaceOptions,\n} from './types';\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 LOOKUP_DATA_PATH,\n LOOKUP_FOUND_PATH,\n LOOKUP_NOT_FOUND_PATH,\n LOOKUP_REQUEST_KEY,\n SEARCH_DATA_PATH,\n} from './constants';\nimport DssBatcher from './dss-batcher';\nimport {DssTimeoutError} from './dss-errors';\nimport {BatcherOptions, RequestOptions, RequestResult} from './types';\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 * Initializer\n * @private\n * @param {Object} attrs\n * @param {Object} options\n * @returns {undefined}\n */\n initialize(...args) {\n Reflect.apply(WebexPlugin.prototype.initialize, this, args);\n this.batchers = {};\n },\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 * constructs the event name based on request id\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 * Takes incoming data and triggers correct events\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 {Mixed} options.params additional params for the body of the request\n * @param {string} options.dataPath the path to get the data in the result object\n * @param {string} [options.foundPath] the path to get the lookups of the found data\n * @param {string} [options.notFoundPath] the path to get the lookups of the not found data\n * @returns {Promise<Object>} result Resolves with an object\n * @returns {Array} result.resultArray an array of entities found\n * @returns {Array} result.foundArray an array of the lookups of the found entities (if foundPath provided)\n * @returns {Array} result.notFoundArray an array of the lookups of the not found entities (if notFoundPath provided)\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n _request(options: RequestOptions): Promise<RequestResult> {\n const {resource, params, dataPath, foundPath, notFoundPath} = options;\n\n const timeout = this.config.requestTimeout;\n const requestId = uuid.v4();\n const eventName = this._getResultEventName(requestId);\n const result = {};\n let expectedSeqNums: string[];\n let notFoundArray: unknown[];\n\n return new Promise((resolve, reject) => {\n const timer = new Timer(() => {\n this.stopListening(this, eventName);\n reject(new DssTimeoutError({requestId, timeout, resource, params}));\n }, timeout);\n\n this.listenTo(this, eventName, (data) => {\n timer.reset();\n const resultData = get(data, dataPath, []);\n let found;\n\n if (foundPath) {\n found = get(data, foundPath, []);\n }\n result[data.sequence] = foundPath ? {resultData, found} : {resultData};\n\n if (data.finished) {\n expectedSeqNums = range(data.sequence + 1).map(String);\n if (notFoundPath) {\n notFoundArray = get(data, notFoundPath, []);\n }\n }\n\n const done = isEqual(expectedSeqNums, Object.keys(result));\n\n if (done) {\n timer.cancel();\n\n const resultArray: any[] = [];\n const foundArray: any[] = [];\n\n expectedSeqNums.forEach((index) => {\n const seqResult = result[index];\n\n if (seqResult) {\n resultArray.push(...seqResult.resultData);\n if (foundPath) {\n foundArray.push(...seqResult.found);\n }\n }\n });\n const resolveValue: RequestResult = {\n resultArray,\n };\n\n if (foundPath) {\n resolveValue.foundArray = foundArray;\n }\n if (notFoundPath) {\n resolveValue.notFoundArray = notFoundArray;\n }\n resolve(resolveValue);\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 timer.start();\n });\n },\n\n /**\n * Uses a batcher to make the request to the directory service\n * @param {Object} options\n * @param {string} options.resource the URL to query\n * @param {string} options.value the id or email to lookup\n * @returns {Promise} Resolves with an array of entities found\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n _batchedLookup(options: BatcherOptions) {\n const {resource, lookupValue} = options;\n const dataPath = LOOKUP_DATA_PATH;\n const entitiesFoundPath = LOOKUP_FOUND_PATH;\n const entitiesNotFoundPath = LOOKUP_NOT_FOUND_PATH;\n const requestKey = LOOKUP_REQUEST_KEY;\n\n this.batchers[resource] =\n this.batchers[resource] ||\n new DssBatcher({\n resource,\n dataPath,\n entitiesFoundPath,\n entitiesNotFoundPath,\n requestKey,\n parent: this,\n });\n\n return this.batchers[resource].request(lookupValue);\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 the entity found or null if not found\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n lookupDetail(options: LookupDetailOptions) {\n const {id} = options;\n\n const resource = `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`;\n\n return this._request({\n dataPath: LOOKUP_DATA_PATH,\n foundPath: LOOKUP_FOUND_PATH,\n resource,\n }).then(({resultArray, foundArray}) => {\n // TODO: find out what is actually returned!\n if (foundArray[0] === id) {\n return resultArray[0];\n }\n\n return null;\n });\n },\n\n /**\n * Retrieves basic information about an entity within an organization\n * @param {Object} options\n * @param {UUID} options.id the id of the entity to lookup\n * @param {UUID} [options.entityProviderType] the provider to query\n * @param {Boolean} options.shouldBatch whether to batch the query, set to false for single immediate result (defaults to true)\n * @returns {Promise} Resolves with the entity found or null if not found\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n lookup(options: LookupOptions) {\n const {id, entityProviderType, shouldBatch = true} = 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 if (shouldBatch) {\n return this._batchedLookup({\n resource,\n lookupValue: id,\n });\n }\n\n return this._request({\n dataPath: LOOKUP_DATA_PATH,\n foundPath: LOOKUP_FOUND_PATH,\n resource,\n params: {\n [LOOKUP_REQUEST_KEY]: [id],\n },\n }).then(({resultArray, foundArray}) => {\n if (foundArray[0] === id) {\n return resultArray[0];\n }\n\n return null;\n });\n },\n\n /**\n * Retrieves basic information about an enitity within an organization\n * @param {Object} options\n * @param {UUID} options.email the email of the entity to lookup\n * @returns {Promise} Resolves with the entity found or rejects if not found\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n lookupByEmail(options: LookupByEmailOptions) {\n const {email} = options;\n const resource = `/lookup/orgid/${this.webex.internal.device.orgId}/emails`;\n\n return this._request({\n dataPath: LOOKUP_DATA_PATH,\n foundPath: LOOKUP_FOUND_PATH,\n resource,\n params: {\n [LOOKUP_REQUEST_KEY]: [email],\n },\n }).then(({resultArray, foundArray}) => {\n if (foundArray[0] === email) {\n return resultArray[0];\n }\n\n return null;\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 * @param {boolean} options.includePersonalDevices If true, includes personal devices associated with users in the search results.\n * @param {boolean} options.includeCommonAreaPhones If true, includes common area phones in the search results.\n * @param {boolean} options.includeOnlyPairableDevices If true, include the devices that are pairable in the search results.\n * @returns {Promise} Resolves with an array of entities found\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n search(options: SearchOptions) {\n const {\n requestedTypes,\n resultSize,\n queryString,\n includeCommonAreaPhones,\n includeOnlyPairableDevices,\n includePersonalDevices,\n } = options;\n\n return this._request({\n dataPath: SEARCH_DATA_PATH,\n resource: `/search/orgid/${this.webex.internal.device.orgId}/entities`,\n params: {\n queryString,\n resultSize,\n requestedTypes,\n includeCommonAreaPhones,\n includeOnlyPairableDevices,\n includePersonalDevices,\n },\n }).then(({resultArray}) => resultArray);\n },\n\n /**\n * Search for information about places\n * @param {Object} options\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: placeName, displayName.\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 searchPlaces(options: SearchPlaceOptions) {\n const {resultSize, queryString, isOnlySchedulableRooms} = options;\n\n return this._request({\n dataPath: 'directoryEntities',\n resource: `/search/orgid/${this.webex.internal.device.orgId}/places`,\n params: {\n queryString,\n resultSize,\n isOnlySchedulableRooms,\n },\n }).catch((error) => {\n this.logger.error(`DSS->search place#ERROR, search place failure, ${error.message}`);\n\n return Promise.reject(error);\n });\n },\n});\n\nex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AAK,CAACe,OAAO,CAAE,CAAC;MAEpF,OAAOd,QAAA,CAAAvB,OAAA,CAAQwB,MAAM,CAACF,KAAK,CAAC;IAC9B,CAAC,CAAC;EACJ,CAAC;EAAAqH,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7I,OAAA,GAEYI,GAAG","ignoreList":[]}
1
+ {"version":3,"names":["_uuid","_interopRequireDefault","require","_webexCore","_lodash","_commonTimers","_constants","_dssBatcher","_dssErrors","ownKeys","e","r","t","_Object$keys2","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","DSS","WebexPlugin","extend","namespace","registered","initialize","_len","args","Array","_key","_apply","prototype","batchers","register","_this","webex","canAuthorize","logger","error","_promise","reject","Error","info","resolve","internal","mercury","connect","then","listenForEvents","trigger","DSS_REGISTERED","catch","concat","message","unregister","_this2","stopListeningForEvents","disconnect","DSS_UNREGISTERED","_this3","on","DSS_LOOKUP_MERCURY_EVENT","envelope","_handleEvent","data","DSS_SEARCH_MERCURY_EVENT","off","_getResultEventName","requestId","DSS_RESULT","DSS_LOOKUP_RESULT","_request","options","_this4","resource","params","dataPath","foundPath","notFoundPath","timeout","config","requestTimeout","uuid","v4","eventName","result","expectedSeqNums","notFoundArray","timer","Timer","stopListening","DssTimeoutError","listenTo","reset","resultData","get","found","sequence","finished","range","map","String","done","isEqual","_keys","cancel","resultArray","foundArray","index","seqResult","_toConsumableArray2","resolveValue","request","service","DSS_SERVICE_NAME","method","contentType","body","start","_batchedLookup","lookupValue","LOOKUP_DATA_PATH","entitiesFoundPath","LOOKUP_FOUND_PATH","entitiesNotFoundPath","LOOKUP_NOT_FOUND_PATH","requestKey","LOOKUP_REQUEST_KEY","DssBatcher","parent","lookupDetail","id","device","orgId","_ref","lookup","entityProviderType","_options$shouldBatch","shouldBatch","_ref2","lookupByEmail","email","_ref3","lookupByPhoneNumbers","phoneNumbers","_this5","search","requestedTypes","resultSize","queryString","includeCommonAreaPhones","includeOnlyPairableDevices","includePersonalDevices","SEARCH_DATA_PATH","_ref4","searchPlaces","_this6","isOnlySchedulableRooms","version","_default","exports"],"sources":["dss.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\n/*!\n * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.\n */\n/* eslint-disable no-underscore-dangle */\nimport uuid from 'uuid';\nimport {WebexPlugin} from '@webex/webex-core';\nimport '@webex/internal-plugin-mercury';\nimport {range, isEqual, get} from 'lodash';\n\nimport {Timer} from '@webex/common-timers';\nimport type {\n SearchOptions,\n LookupDetailOptions,\n LookupOptions,\n LookupByEmailOptions,\n SearchPlaceOptions,\n} from './types';\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 LOOKUP_DATA_PATH,\n LOOKUP_FOUND_PATH,\n LOOKUP_NOT_FOUND_PATH,\n LOOKUP_REQUEST_KEY,\n SEARCH_DATA_PATH,\n} from './constants';\nimport DssBatcher from './dss-batcher';\nimport {DssTimeoutError} from './dss-errors';\nimport {BatcherOptions, RequestOptions, RequestResult} from './types';\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 * Initializer\n * @private\n * @param {Object} attrs\n * @param {Object} options\n * @returns {undefined}\n */\n initialize(...args) {\n Reflect.apply(WebexPlugin.prototype.initialize, this, args);\n this.batchers = {};\n },\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 * constructs the event name based on request id\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 * Takes incoming data and triggers correct events\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 {Mixed} options.params additional params for the body of the request\n * @param {string} options.dataPath the path to get the data in the result object\n * @param {string} [options.foundPath] the path to get the lookups of the found data\n * @param {string} [options.notFoundPath] the path to get the lookups of the not found data\n * @returns {Promise<Object>} result Resolves with an object\n * @returns {Array} result.resultArray an array of entities found\n * @returns {Array} result.foundArray an array of the lookups of the found entities (if foundPath provided)\n * @returns {Array} result.notFoundArray an array of the lookups of the not found entities (if notFoundPath provided)\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n _request(options: RequestOptions): Promise<RequestResult> {\n const {resource, params, dataPath, foundPath, notFoundPath} = options;\n\n const timeout = this.config.requestTimeout;\n const requestId = uuid.v4();\n const eventName = this._getResultEventName(requestId);\n const result = {};\n let expectedSeqNums: string[];\n let notFoundArray: unknown[];\n\n return new Promise((resolve, reject) => {\n const timer = new Timer(() => {\n this.stopListening(this, eventName);\n reject(new DssTimeoutError({requestId, timeout, resource, params}));\n }, timeout);\n\n this.listenTo(this, eventName, (data) => {\n timer.reset();\n const resultData = get(data, dataPath, []);\n let found;\n\n if (foundPath) {\n found = get(data, foundPath, []);\n }\n result[data.sequence] = foundPath ? {resultData, found} : {resultData};\n\n if (data.finished) {\n expectedSeqNums = range(data.sequence + 1).map(String);\n if (notFoundPath) {\n notFoundArray = get(data, notFoundPath, []);\n }\n }\n\n const done = isEqual(expectedSeqNums, Object.keys(result));\n\n if (done) {\n timer.cancel();\n\n const resultArray: any[] = [];\n const foundArray: any[] = [];\n\n expectedSeqNums.forEach((index) => {\n const seqResult = result[index];\n\n if (seqResult) {\n resultArray.push(...seqResult.resultData);\n if (foundPath) {\n foundArray.push(...seqResult.found);\n }\n }\n });\n const resolveValue: RequestResult = {\n resultArray,\n };\n\n if (foundPath) {\n resolveValue.foundArray = foundArray;\n }\n if (notFoundPath) {\n resolveValue.notFoundArray = notFoundArray;\n }\n resolve(resolveValue);\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 timer.start();\n });\n },\n\n /**\n * Uses a batcher to make the request to the directory service\n * @param {Object} options\n * @param {string} options.resource the URL to query\n * @param {string} options.value the id or email to lookup\n * @returns {Promise} Resolves with an array of entities found\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n _batchedLookup(options: BatcherOptions) {\n const {resource, lookupValue} = options;\n const dataPath = LOOKUP_DATA_PATH;\n const entitiesFoundPath = LOOKUP_FOUND_PATH;\n const entitiesNotFoundPath = LOOKUP_NOT_FOUND_PATH;\n const requestKey = LOOKUP_REQUEST_KEY;\n\n this.batchers[resource] =\n this.batchers[resource] ||\n new DssBatcher({\n resource,\n dataPath,\n entitiesFoundPath,\n entitiesNotFoundPath,\n requestKey,\n parent: this,\n });\n\n return this.batchers[resource].request(lookupValue);\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 the entity found or null if not found\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n lookupDetail(options: LookupDetailOptions) {\n const {id} = options;\n\n const resource = `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`;\n\n return this._request({\n dataPath: LOOKUP_DATA_PATH,\n foundPath: LOOKUP_FOUND_PATH,\n resource,\n }).then(({resultArray, foundArray}) => {\n // TODO: find out what is actually returned!\n if (foundArray[0] === id) {\n return resultArray[0];\n }\n\n return null;\n });\n },\n\n /**\n * Retrieves basic information about an entity within an organization\n * @param {Object} options\n * @param {UUID} options.id the id of the entity to lookup\n * @param {UUID} [options.entityProviderType] the provider to query\n * @param {Boolean} options.shouldBatch whether to batch the query, set to false for single immediate result (defaults to true)\n * @returns {Promise} Resolves with the entity found or null if not found\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n lookup(options: LookupOptions) {\n const {id, entityProviderType, shouldBatch = true} = 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 if (shouldBatch) {\n return this._batchedLookup({\n resource,\n lookupValue: id,\n });\n }\n\n return this._request({\n dataPath: LOOKUP_DATA_PATH,\n foundPath: LOOKUP_FOUND_PATH,\n resource,\n params: {\n [LOOKUP_REQUEST_KEY]: [id],\n },\n }).then(({resultArray, foundArray}) => {\n if (foundArray[0] === id) {\n return resultArray[0];\n }\n\n return null;\n });\n },\n\n /**\n * Retrieves basic information about an enitity within an organization\n * @param {Object} options\n * @param {UUID} options.email the email of the entity to lookup\n * @returns {Promise} Resolves with the entity found or rejects if not found\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n lookupByEmail(options: LookupByEmailOptions) {\n const {email} = options;\n const resource = `/lookup/orgid/${this.webex.internal.device.orgId}/emails`;\n\n return this._request({\n dataPath: LOOKUP_DATA_PATH,\n foundPath: LOOKUP_FOUND_PATH,\n resource,\n params: {\n [LOOKUP_REQUEST_KEY]: [email],\n },\n }).then(({resultArray, foundArray}) => {\n if (foundArray[0] === email) {\n return resultArray[0];\n }\n\n return null;\n });\n },\n\n /**\n * Retrieves basic information about entities by phone numbers within an organization.\n * Supports up to 5 phone numbers per request. For larger batches, client should chunk\n * requests into groups of 5.\n * @param {string[]} phoneNumbers - Array of phone numbers to lookup in E.164 format (max 5)\n * @returns {Promise<RequestResult>} Resolves with object containing:\n * - resultArray: Array of matched entities\n * - foundArray: Array of phone numbers that were found\n * - notFoundArray: Array of phone numbers that were not found\n * @throws {Error} When more than 5 phone numbers provided\n * @throws {DssTimeoutError} When server does not respond in the specified timeframe\n * @example\n * const result = await webex.internal.dss.lookupByPhoneNumbers(['+15551234567']);\n * console.log('Found:', result.foundArray);\n * console.log('Entities:', result.resultArray);\n */\n lookupByPhoneNumbers(phoneNumbers: string[]): Promise<RequestResult> {\n if (!phoneNumbers || phoneNumbers.length === 0) {\n return Promise.resolve({resultArray: [], foundArray: [], notFoundArray: []});\n }\n\n if (phoneNumbers.length > 5) {\n this.logger.error(\n `DSS->lookupByPhoneNumbers#ERROR, Maximum of 5 phone numbers allowed, received: ${phoneNumbers.length}`\n );\n\n return Promise.reject(\n new Error(\n `lookupByPhoneNumbers accepts a maximum of 5 phone numbers. Received: ${phoneNumbers.length}. Please batch requests on the client side if needed.`\n )\n );\n }\n\n const resource = `/lookup/orgid/${this.webex.internal.device.orgId}/phonenumbers`;\n\n return this._request({\n dataPath: LOOKUP_DATA_PATH,\n foundPath: LOOKUP_FOUND_PATH,\n notFoundPath: LOOKUP_NOT_FOUND_PATH,\n resource,\n params: {\n [LOOKUP_REQUEST_KEY]: phoneNumbers,\n },\n }).catch((error) => {\n this.logger.error(\n `DSS->lookupByPhoneNumbers#ERROR, Phone number lookup failure, ${error.message}`\n );\n\n return Promise.reject(error);\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 * @param {boolean} options.includePersonalDevices If true, includes personal devices associated with users in the search results.\n * @param {boolean} options.includeCommonAreaPhones If true, includes common area phones in the search results.\n * @param {boolean} options.includeOnlyPairableDevices If true, include the devices that are pairable in the search results.\n * @returns {Promise} Resolves with an array of entities found\n * @throws {DssTimeoutError} when server does not respond in the specified timeframe\n */\n search(options: SearchOptions) {\n const {\n requestedTypes,\n resultSize,\n queryString,\n includeCommonAreaPhones,\n includeOnlyPairableDevices,\n includePersonalDevices,\n } = options;\n\n return this._request({\n dataPath: SEARCH_DATA_PATH,\n resource: `/search/orgid/${this.webex.internal.device.orgId}/entities`,\n params: {\n queryString,\n resultSize,\n requestedTypes,\n includeCommonAreaPhones,\n includeOnlyPairableDevices,\n includePersonalDevices,\n },\n }).then(({resultArray}) => resultArray);\n },\n\n /**\n * Search for information about places\n * @param {Object} options\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: placeName, displayName.\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 searchPlaces(options: SearchPlaceOptions) {\n const {resultSize, queryString, isOnlySchedulableRooms} = options;\n\n return this._request({\n dataPath: 'directoryEntities',\n resource: `/search/orgid/${this.webex.internal.device.orgId}/places`,\n params: {\n queryString,\n resultSize,\n isOnlySchedulableRooms,\n },\n }).catch((error) => {\n this.logger.error(`DSS->search place#ERROR, search place failure, ${error.message}`);\n\n return Promise.reject(error);\n });\n },\n});\n\nexport default DSS;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACAA,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAAG,aAAA,GAAAH,OAAA;AAQA,IAAAI,UAAA,GAAAJ,OAAA;AAcA,IAAAK,WAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAA6C,SAAAO,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,aAAA,CAAAH,CAAA,OAAAI,6BAAA,QAAAC,CAAA,GAAAD,6BAAA,CAAAJ,CAAA,GAAAC,CAAA,KAAAI,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAL,CAAA,WAAAM,gCAAA,CAAAP,CAAA,EAAAC,CAAA,EAAAO,UAAA,OAAAN,CAAA,CAAAO,IAAA,CAAAC,KAAA,CAAAR,CAAA,EAAAG,CAAA,YAAAH,CAAA;AAAA,SAAAS,cAAAX,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAW,SAAA,CAAAC,MAAA,EAAAZ,CAAA,UAAAC,CAAA,WAAAU,SAAA,CAAAX,CAAA,IAAAW,SAAA,CAAAX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9C6E,WAAW;MAAEQ,sBAAsB,GAAIrF,OAAO,CAAjCqF,sBAAsB;IAEtD,OAAO,IAAI,CAACtF,QAAQ,CAAC;MACnBK,QAAQ,EAAE,mBAAmB;MAC7BF,QAAQ,mBAAAtB,MAAA,CAAmB,IAAI,CAACjB,KAAK,CAACS,QAAQ,CAACwF,MAAM,CAACC,KAAK,YAAS;MACpE1D,MAAM,EAAE;QACN0E,WAAW,EAAXA,WAAW;QACXD,UAAU,EAAVA,UAAU;QACVS,sBAAsB,EAAtBA;MACF;IACF,CAAC,CAAC,CAAC1G,KAAK,CAAC,UAACb,KAAK,EAAK;MAClBsH,MAAI,CAACvH,MAAM,CAACC,KAAK,mDAAAc,MAAA,CAAmDd,KAAK,CAACe,OAAO,CAAE,CAAC;MAEpF,OAAOd,QAAA,CAAAvB,OAAA,CAAQwB,MAAM,CAACF,KAAK,CAAC;IAC9B,CAAC,CAAC;EACJ,CAAC;EAAAwH,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhJ,OAAA,GAEYI,GAAG","ignoreList":[]}
package/package.json CHANGED
@@ -20,10 +20,10 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@webex/common": "3.8.1-next.11",
24
- "@webex/common-timers": "3.8.1-next.11",
25
- "@webex/internal-plugin-mercury": "3.10.0-next.6",
26
- "@webex/webex-core": "3.10.0-next.6",
23
+ "@webex/common": "3.10.0-next.1",
24
+ "@webex/common-timers": "3.10.0-next.1",
25
+ "@webex/internal-plugin-mercury": "3.10.0-next.7",
26
+ "@webex/webex-core": "3.10.0-next.7",
27
27
  "lodash": "^4.17.21",
28
28
  "uuid": "^3.3.2"
29
29
  },
@@ -33,9 +33,9 @@
33
33
  "@webex/eslint-config-legacy": "0.0.0",
34
34
  "@webex/jest-config-legacy": "0.0.0",
35
35
  "@webex/legacy-tools": "0.0.0",
36
- "@webex/test-helper-chai": "3.8.1-next.11",
37
- "@webex/test-helper-mock-webex": "3.8.1-next.11",
38
- "@webex/test-helper-test-users": "3.8.1-next.11",
36
+ "@webex/test-helper-chai": "3.10.0-next.1",
37
+ "@webex/test-helper-mock-webex": "3.10.0-next.1",
38
+ "@webex/test-helper-test-users": "3.10.0-next.1",
39
39
  "eslint": "^8.24.0",
40
40
  "prettier": "^2.7.1",
41
41
  "sinon": "^9.2.4"
@@ -49,5 +49,5 @@
49
49
  "test:style": "eslint ./src/**/*.*",
50
50
  "test:unit": "webex-legacy-tools test --unit --runner jest"
51
51
  },
52
- "version": "3.10.0-next.6"
52
+ "version": "3.10.0-next.7"
53
53
  }
package/src/dss.ts CHANGED
@@ -365,6 +365,58 @@ const DSS = WebexPlugin.extend({
365
365
  });
366
366
  },
367
367
 
368
+ /**
369
+ * Retrieves basic information about entities by phone numbers within an organization.
370
+ * Supports up to 5 phone numbers per request. For larger batches, client should chunk
371
+ * requests into groups of 5.
372
+ * @param {string[]} phoneNumbers - Array of phone numbers to lookup in E.164 format (max 5)
373
+ * @returns {Promise<RequestResult>} Resolves with object containing:
374
+ * - resultArray: Array of matched entities
375
+ * - foundArray: Array of phone numbers that were found
376
+ * - notFoundArray: Array of phone numbers that were not found
377
+ * @throws {Error} When more than 5 phone numbers provided
378
+ * @throws {DssTimeoutError} When server does not respond in the specified timeframe
379
+ * @example
380
+ * const result = await webex.internal.dss.lookupByPhoneNumbers(['+15551234567']);
381
+ * console.log('Found:', result.foundArray);
382
+ * console.log('Entities:', result.resultArray);
383
+ */
384
+ lookupByPhoneNumbers(phoneNumbers: string[]): Promise<RequestResult> {
385
+ if (!phoneNumbers || phoneNumbers.length === 0) {
386
+ return Promise.resolve({resultArray: [], foundArray: [], notFoundArray: []});
387
+ }
388
+
389
+ if (phoneNumbers.length > 5) {
390
+ this.logger.error(
391
+ `DSS->lookupByPhoneNumbers#ERROR, Maximum of 5 phone numbers allowed, received: ${phoneNumbers.length}`
392
+ );
393
+
394
+ return Promise.reject(
395
+ new Error(
396
+ `lookupByPhoneNumbers accepts a maximum of 5 phone numbers. Received: ${phoneNumbers.length}. Please batch requests on the client side if needed.`
397
+ )
398
+ );
399
+ }
400
+
401
+ const resource = `/lookup/orgid/${this.webex.internal.device.orgId}/phonenumbers`;
402
+
403
+ return this._request({
404
+ dataPath: LOOKUP_DATA_PATH,
405
+ foundPath: LOOKUP_FOUND_PATH,
406
+ notFoundPath: LOOKUP_NOT_FOUND_PATH,
407
+ resource,
408
+ params: {
409
+ [LOOKUP_REQUEST_KEY]: phoneNumbers,
410
+ },
411
+ }).catch((error) => {
412
+ this.logger.error(
413
+ `DSS->lookupByPhoneNumbers#ERROR, Phone number lookup failure, ${error.message}`
414
+ );
415
+
416
+ return Promise.reject(error);
417
+ });
418
+ },
419
+
368
420
  /**
369
421
  * Search for information about entities
370
422
  * @param {Object} options
@@ -0,0 +1,69 @@
1
+ /*!
2
+ * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+ import {assert} from '@webex/test-helper-chai';
5
+ import sinon from 'sinon';
6
+ import MockWebex from '@webex/test-helper-mock-webex';
7
+ import DSS from '@webex/internal-plugin-dss';
8
+
9
+ describe('plugin-dss (browser)', function () {
10
+ this.timeout(10000);
11
+
12
+ let webex;
13
+ let mercury;
14
+
15
+ beforeEach(() => {
16
+ mercury = {
17
+ connect: sinon.stub().resolves(),
18
+ disconnect: sinon.stub().resolves(),
19
+ on: sinon.stub(),
20
+ off: sinon.stub(),
21
+ };
22
+
23
+ webex = MockWebex({
24
+ canAuthorize: true,
25
+ children: {
26
+ dss: DSS,
27
+ },
28
+ });
29
+ webex.config.dss = {};
30
+ webex.internal.mercury = mercury;
31
+ });
32
+
33
+ afterEach(() => {
34
+ sinon.restore();
35
+ });
36
+
37
+ it('registers with mercury and emits DSS_REGISTERED', async () => {
38
+ const triggerSpy = sinon.spy(webex.internal.dss, 'trigger');
39
+
40
+ await webex.internal.dss.register();
41
+
42
+ sinon.assert.calledOnce(mercury.connect);
43
+ sinon.assert.calledWith(
44
+ mercury.on.firstCall,
45
+ 'event:directory.lookup',
46
+ sinon.match.func
47
+ );
48
+ sinon.assert.calledWith(
49
+ mercury.on.secondCall,
50
+ 'event:directory.search',
51
+ sinon.match.func
52
+ );
53
+ assert.isTrue(webex.internal.dss.registered);
54
+ sinon.assert.calledWith(triggerSpy, 'dss:registered');
55
+ });
56
+
57
+ it('unregisters from mercury and emits DSS_UNREGISTERED', async () => {
58
+ await webex.internal.dss.register();
59
+ const triggerSpy = sinon.spy(webex.internal.dss, 'trigger');
60
+
61
+ await webex.internal.dss.unregister();
62
+
63
+ sinon.assert.calledOnce(mercury.disconnect);
64
+ sinon.assert.calledWith(mercury.off.firstCall, 'event:directory.lookup');
65
+ sinon.assert.calledWith(mercury.off.secondCall, 'event:directory.search');
66
+ assert.isFalse(webex.internal.dss.registered);
67
+ sinon.assert.calledWith(triggerSpy, 'dss:unregistered');
68
+ });
69
+ });
@@ -759,6 +759,262 @@ describe('plugin-dss', () => {
759
759
  });
760
760
  });
761
761
 
762
+ describe('#lookupByPhoneNumbers', () => {
763
+ // Test data constants
764
+ const PHONE_1 = '+15551234567';
765
+ const PHONE_2 = '+442012345678';
766
+ const PHONE_3 = '+33123456789';
767
+ const PHONE_BATCH = ['+15551111111', '+15552222222', '+15553333333', '+15554444444', '+15555555555'];
768
+
769
+ const ENTITY_1 = {id: 'user1', displayName: 'John Doe', phoneNumbers: [PHONE_1]};
770
+ const ENTITY_2 = {id: 'user2', displayName: 'Jane Smith', phoneNumbers: [PHONE_2]};
771
+ const ENTITY_3 = {id: 'user3', phoneNumbers: [PHONE_3]};
772
+
773
+ const EMPTY_RESULT = {
774
+ resultArray: [],
775
+ foundArray: [],
776
+ notFoundArray: [],
777
+ };
778
+
779
+ it('returns empty arrays for empty input', async () => {
780
+ const result = await webex.internal.dss.lookupByPhoneNumbers([]);
781
+
782
+ expect(result).to.deep.equal(EMPTY_RESULT);
783
+ });
784
+
785
+ it('rejects when more than 5 phone numbers provided', async () => {
786
+ const phoneNumbers = [...PHONE_BATCH, '+15556666666'];
787
+
788
+ return assert.isRejected(
789
+ webex.internal.dss.lookupByPhoneNumbers(phoneNumbers),
790
+ Error,
791
+ 'lookupByPhoneNumbers accepts a maximum of 5 phone numbers. Received: 6. Please batch requests on the client side if needed.'
792
+ );
793
+ });
794
+
795
+ it('works correctly with single phone number found', async () => {
796
+ const {requestId, promise} = await testMakeRequest({
797
+ method: 'lookupByPhoneNumbers',
798
+ resource: '/lookup/orgid/userOrgId/phonenumbers',
799
+ params: [PHONE_1],
800
+ bodyParams: {lookupValues: [PHONE_1]},
801
+ });
802
+
803
+ mercuryCallbacks['event:directory.lookup'](
804
+ createData(requestId, 0, true, 'lookupResult', {
805
+ entities: [ENTITY_1],
806
+ entitiesFound: [PHONE_1],
807
+ entitiesNotFound: [],
808
+ })
809
+ );
810
+ const result = await promise;
811
+
812
+ expect(result).to.deep.equal({
813
+ resultArray: [ENTITY_1],
814
+ foundArray: [PHONE_1],
815
+ notFoundArray: [],
816
+ });
817
+ });
818
+
819
+ it('works correctly with multiple phone numbers, some found', async () => {
820
+ const phoneNumbers = [PHONE_1, PHONE_2, PHONE_3];
821
+
822
+ const {requestId, promise} = await testMakeRequest({
823
+ method: 'lookupByPhoneNumbers',
824
+ resource: '/lookup/orgid/userOrgId/phonenumbers',
825
+ params: phoneNumbers,
826
+ bodyParams: {lookupValues: phoneNumbers},
827
+ });
828
+
829
+ mercuryCallbacks['event:directory.lookup'](
830
+ createData(requestId, 0, true, 'lookupResult', {
831
+ entities: [ENTITY_1, ENTITY_2],
832
+ entitiesFound: [PHONE_1, PHONE_2],
833
+ entitiesNotFound: [PHONE_3],
834
+ })
835
+ );
836
+ const result = await promise;
837
+
838
+ expect(result).to.deep.equal({
839
+ resultArray: [ENTITY_1, ENTITY_2],
840
+ foundArray: [PHONE_1, PHONE_2],
841
+ notFoundArray: [PHONE_3],
842
+ });
843
+ });
844
+
845
+ it('works correctly with all phone numbers not found', async () => {
846
+ const phoneNumbers = [PHONE_1, PHONE_2];
847
+
848
+ const {requestId, promise} = await testMakeRequest({
849
+ method: 'lookupByPhoneNumbers',
850
+ resource: '/lookup/orgid/userOrgId/phonenumbers',
851
+ params: phoneNumbers,
852
+ bodyParams: {lookupValues: phoneNumbers},
853
+ });
854
+
855
+ mercuryCallbacks['event:directory.lookup'](
856
+ createData(requestId, 0, true, 'lookupResult', {
857
+ entities: [],
858
+ entitiesFound: [],
859
+ entitiesNotFound: phoneNumbers,
860
+ })
861
+ );
862
+ const result = await promise;
863
+
864
+ expect(result).to.deep.equal({
865
+ resultArray: [],
866
+ foundArray: [],
867
+ notFoundArray: phoneNumbers,
868
+ });
869
+ });
870
+
871
+ it('works correctly with exactly 5 phone numbers', async () => {
872
+ const {requestId, promise} = await testMakeRequest({
873
+ method: 'lookupByPhoneNumbers',
874
+ resource: '/lookup/orgid/userOrgId/phonenumbers',
875
+ params: PHONE_BATCH,
876
+ bodyParams: {lookupValues: PHONE_BATCH},
877
+ });
878
+
879
+ const entities = PHONE_BATCH.map((phone, index) => ({
880
+ id: `user${index + 1}`,
881
+ phoneNumbers: [phone],
882
+ }));
883
+
884
+ mercuryCallbacks['event:directory.lookup'](
885
+ createData(requestId, 0, true, 'lookupResult', {
886
+ entities,
887
+ entitiesFound: PHONE_BATCH,
888
+ entitiesNotFound: [],
889
+ })
890
+ );
891
+ const result = await promise;
892
+
893
+ expect(result.resultArray).to.have.lengthOf(5);
894
+ expect(result.foundArray).to.deep.equal(PHONE_BATCH);
895
+ expect(result.notFoundArray).to.deep.equal([]);
896
+ });
897
+
898
+ it('handles multiple sequences correctly', async () => {
899
+ const phoneNumbers = [PHONE_1, PHONE_2];
900
+
901
+ const {requestId, promise} = await testMakeRequest({
902
+ method: 'lookupByPhoneNumbers',
903
+ resource: '/lookup/orgid/userOrgId/phonenumbers',
904
+ params: phoneNumbers,
905
+ bodyParams: {lookupValues: phoneNumbers},
906
+ });
907
+
908
+ // Send sequences out of order
909
+ mercuryCallbacks['event:directory.lookup'](
910
+ createData(requestId, 1, false, 'lookupResult', {
911
+ entities: [ENTITY_2],
912
+ entitiesFound: [PHONE_2],
913
+ })
914
+ );
915
+ mercuryCallbacks['event:directory.lookup'](
916
+ createData(requestId, 2, true, 'lookupResult', {
917
+ entities: [],
918
+ entitiesFound: [],
919
+ entitiesNotFound: [PHONE_3],
920
+ })
921
+ );
922
+ mercuryCallbacks['event:directory.lookup'](
923
+ createData(requestId, 0, false, 'lookupResult', {
924
+ entities: [ENTITY_1],
925
+ entitiesFound: [PHONE_1],
926
+ })
927
+ );
928
+
929
+ const result = await promise;
930
+
931
+ expect(result.resultArray).to.deep.equal([ENTITY_1, ENTITY_2]);
932
+ expect(result.foundArray).to.deep.equal([PHONE_1, PHONE_2]);
933
+ expect(result.notFoundArray).to.deep.equal([PHONE_3]);
934
+ });
935
+
936
+ it('fails with default timeout when mercury does not respond', async () => {
937
+ const {promise} = await testMakeRequest({
938
+ method: 'lookupByPhoneNumbers',
939
+ resource: '/lookup/orgid/userOrgId/phonenumbers',
940
+ params: [PHONE_1],
941
+ bodyParams: {lookupValues: [PHONE_1]},
942
+ });
943
+
944
+ promise.catch(() => {}); // to prevent the test from failing due to unhandled promise rejection
945
+
946
+ await clock.tickAsync(6000);
947
+
948
+ return assert.isRejected(
949
+ promise,
950
+ 'The DSS did not respond within 6000 ms.' +
951
+ '\n Request Id: randomid' +
952
+ '\n Resource: /lookup/orgid/userOrgId/phonenumbers' +
953
+ `\n Params: {"lookupValues":["${PHONE_1}"]}`
954
+ );
955
+ });
956
+
957
+ it('does not fail with timeout when mercury responds in time', async () => {
958
+ const {requestId, promise} = await testMakeRequest({
959
+ method: 'lookupByPhoneNumbers',
960
+ resource: '/lookup/orgid/userOrgId/phonenumbers',
961
+ params: [PHONE_1],
962
+ bodyParams: {lookupValues: [PHONE_1]},
963
+ });
964
+
965
+ await clock.tickAsync(5999);
966
+
967
+ mercuryCallbacks['event:directory.lookup'](
968
+ createData(requestId, 0, true, 'lookupResult', {
969
+ entities: [ENTITY_1],
970
+ entitiesFound: [PHONE_1],
971
+ entitiesNotFound: [],
972
+ })
973
+ );
974
+
975
+ return assert.isFulfilled(promise);
976
+ });
977
+
978
+ it('fails with timeout when request only partially resolved', async () => {
979
+ const phoneNumbers = [PHONE_1, PHONE_2];
980
+
981
+ const {requestId, promise} = await testMakeRequest({
982
+ method: 'lookupByPhoneNumbers',
983
+ resource: '/lookup/orgid/userOrgId/phonenumbers',
984
+ params: phoneNumbers,
985
+ bodyParams: {lookupValues: phoneNumbers},
986
+ });
987
+
988
+ // Send sequence 2 with finished flag, but missing sequence 1
989
+ mercuryCallbacks['event:directory.lookup'](
990
+ createData(requestId, 2, true, 'lookupResult', {
991
+ entities: [ENTITY_3],
992
+ entitiesFound: [PHONE_3],
993
+ entitiesNotFound: [],
994
+ })
995
+ );
996
+ mercuryCallbacks['event:directory.lookup'](
997
+ createData(requestId, 0, false, 'lookupResult', {
998
+ entities: [ENTITY_1],
999
+ entitiesFound: [PHONE_1],
1000
+ })
1001
+ );
1002
+ // Missing sequence 1
1003
+
1004
+ promise.catch(() => {}); // to prevent the test from failing due to unhandled promise rejection
1005
+
1006
+ await clock.tickAsync(6000);
1007
+
1008
+ return assert.isRejected(
1009
+ promise,
1010
+ 'The DSS did not respond within 6000 ms.' +
1011
+ '\n Request Id: randomid' +
1012
+ '\n Resource: /lookup/orgid/userOrgId/phonenumbers' +
1013
+ `\n Params: {"lookupValues":["${PHONE_1}","${PHONE_2}"]}`
1014
+ );
1015
+ });
1016
+ });
1017
+
762
1018
  describe('#search', () => {
763
1019
  it('calls _request correctly', async () => {
764
1020
  webex.internal.device.orgId = 'userOrgId';
@@ -1005,7 +1261,7 @@ describe('plugin-dss', () => {
1005
1261
 
1006
1262
  it('handles a request with foundPath correctly', async () => {
1007
1263
  webex.request = sinon.stub();
1008
- uuid.v4.returns('randomid');
1264
+ uuidStub.returns('randomid');
1009
1265
  const promise = webex.internal.dss._request({
1010
1266
  resource: '/search/orgid/userOrgId/entities',
1011
1267
  params: {some: 'param'},
@@ -1053,7 +1309,7 @@ describe('plugin-dss', () => {
1053
1309
 
1054
1310
  it('handles a request with foundPath and notFoundPath correctly', async () => {
1055
1311
  webex.request = sinon.stub();
1056
- uuid.v4.returns('randomid');
1312
+ uuidStub.returns('randomid');
1057
1313
  const promise = webex.internal.dss._request({
1058
1314
  resource: '/search/orgid/userOrgId/entities',
1059
1315
  params: {some: 'param'},
@@ -1212,6 +1468,7 @@ describe('plugin-dss', () => {
1212
1468
  expect(result).to.equal(response2);
1213
1469
  });
1214
1470
  // TODO - https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-518037
1471
+ // @ts-ignore - it.skip is valid but not in type definitions
1215
1472
  it.skip('fails fails when mercury does not respond, later batches can still pass ok', async () => {
1216
1473
  // Batch 1
1217
1474
  const {