@webex/internal-plugin-dss 3.0.0-beta.15 → 3.0.0-beta.151

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.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 {\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;;;;;;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,IAAI,KAAKP,UAAT,EAAqB;MACnB,KAAKI,MAAL,CAAYI,IAAZ,CAAiB,mDAAjB;MAEA,OAAO,iBAAQC,OAAR,EAAP;IACD;;I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E;QACNuC,WAAW,EAAXA,WADM;QAEND,UAAU,EAAVA,UAFM;QAGND,cAAc,EAAdA;MAHM;IAHW,CAAd,CAAP;EASD,CAzO4B;EAAA;AAAA,CAAnB,CAAZ;;eA4Oe9E,G"}
1
+ {"version":3,"names":["DSS","WebexPlugin","extend","namespace","registered","initialize","args","prototype","batchers","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","foundPath","notFoundPath","uuid","v4","eventName","result","expectedSeqNums","notFoundArray","listenTo","resultData","found","sequence","finished","map","String","done","resultArray","foundArray","forEach","index","seqResult","push","resolveValue","stopListening","request","service","DSS_SERVICE_NAME","method","contentType","body","_batchedLookup","lookupValue","LOOKUP_DATA_PATH","entitiesFoundPath","LOOKUP_FOUND_PATH","entitiesNotFoundPath","LOOKUP_NOT_FOUND_PATH","requestKey","LOOKUP_REQUEST_KEY","DssBatcher","parent","lookupDetail","id","device","orgId","lookup","entityProviderType","shouldBatch","lookupByEmail","email","search","requestedTypes","resultSize","queryString","SEARCH_DATA_PATH"],"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 type {\n SearchOptions,\n LookupDetailOptions,\n LookupOptions,\n LookupByEmailOptions,\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';\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 {string} 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 (optional)\n * @param {string} options.notFoundPath the path to get the lookups of the not found data (optional)\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 */\n _request(options) {\n const {resource, params, dataPath, foundPath, notFoundPath} = options;\n\n const requestId = uuid.v4();\n const eventName = this._getResultEventName(requestId);\n const result = {};\n let expectedSeqNums;\n let notFoundArray;\n\n return new Promise((resolve) => {\n this.listenTo(this, eventName, (data) => {\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 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: {resultArray: any[]; foundArray?: any[]; notFoundArray?: any[]} = {\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 });\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 */\n _batchedLookup(options) {\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 */\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 (optional)\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 */\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 */\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 * @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: SEARCH_DATA_PATH,\n resource: `/search/orgid/${this.webex.internal.device.orgId}/entities`,\n params: {\n queryString,\n resultSize,\n requestedTypes,\n },\n }).then(({resultArray}) => resultArray);\n },\n});\n\nexport default DSS;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKA;AACA;AACA;AASA;AAcA;AAAuC;AAAA;AAEvC,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;AACA;EACEC,UAAU,wBAAU;IAAA,kCAANC,IAAI;MAAJA,IAAI;IAAA;IAChB,oBAAcL,sBAAW,CAACM,SAAS,CAACF,UAAU,EAAE,IAAI,EAAEC,IAAI,CAAC;IAC3D,IAAI,CAACE,QAAQ,GAAG,CAAC,CAAC;EACpB,CAAC;EAED;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,CAACX,UAAU,EAAE;MACnB,IAAI,CAACQ,MAAM,CAACI,IAAI,CAAC,mDAAmD,CAAC;MAErE,OAAO,iBAAQC,OAAO,EAAE;IAC1B;IAEA,OAAO,IAAI,CAACP,KAAK,CAACQ,QAAQ,CAACC,OAAO,CAC/BC,OAAO,EAAE,CACTC,IAAI,CAAC,YAAM;MACV,KAAI,CAACC,eAAe,EAAE;MACtB,KAAI,CAACC,OAAO,CAACC,yBAAc,CAAC;MAC5B,KAAI,CAACpB,UAAU,GAAG,IAAI;IACxB,CAAC,CA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C;MAAA,IAAE0C,WAAW,SAAXA,WAAW;MAAA,OAAMA,WAAW;IAAA,EAAC;EACzC,CAAC;EAAA;AACH,CAAC,CAAC;AAAC,eAEY/D,GAAG;AAAA"}
package/dist/index.js CHANGED
@@ -1,23 +1,20 @@
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
- (0, _webexCore.registerInternalPlugin)('dss', _dss.default);
16
+ var _config = _interopRequireDefault(require("./config"));
17
+ (0, _webexCore.registerInternalPlugin)('dss', _dss.default, {
18
+ config: _config.default
19
+ });
23
20
  //# 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","config"],"sources":["index.ts"],"sourcesContent":["import {registerInternalPlugin} from '@webex/webex-core';\n\nimport DSS from './dss';\nimport config from './config';\n\nregisterInternalPlugin('dss', DSS, {config});\n\nexport {default} from './dss';\n"],"mappings":";;;;;;;;;;;;;AAAA;AAEA;AACA;AAEA,IAAAA,iCAAsB,EAAC,KAAK,EAAEC,YAAG,EAAE;EAACC,MAAM,EAANA;AAAM,CAAC,CAAC"}
package/dist/types.js CHANGED
@@ -1,27 +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;
10
8
  // eslint-disable-next-line no-shadow
11
9
  var EntityProviderType;
12
10
  exports.EntityProviderType = EntityProviderType;
13
-
14
11
  (function (EntityProviderType) {
15
12
  EntityProviderType["CI_USER"] = "CI_USER";
16
13
  EntityProviderType["CI_MACHINE"] = "CI_MACHINE";
17
14
  EntityProviderType["CONTACTS"] = "CONTACTS";
18
15
  EntityProviderType["CSDM"] = "CSDM";
19
16
  })(EntityProviderType || (exports.EntityProviderType = EntityProviderType = {}));
20
-
21
17
  // eslint-disable-next-line no-shadow
22
18
  var SearchType;
23
19
  exports.SearchType = SearchType;
24
-
25
20
  (function (SearchType) {
26
21
  SearchType["PERSON"] = "PERSON";
27
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\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;IACYA,kB;;;WAAAA,kB;EAAAA,kB;EAAAA,kB;EAAAA,kB;EAAAA,kB;GAAAA,kB,kCAAAA,kB;;AAgBZ;IACYC,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 id: string;\n entityProviderType?: EntityProviderType;\n shouldBatch?: boolean;\n}\n\nexport interface LookupByEmailOptions {\n email: 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;AAiB9B;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.15",
3
+ "version": "3.0.0-beta.151",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "Colin Read <coread@cisco.com>",
@@ -21,14 +21,16 @@
21
21
  ]
22
22
  },
23
23
  "dependencies": {
24
- "@webex/internal-plugin-mercury": "3.0.0-beta.15",
25
- "@webex/webex-core": "3.0.0-beta.15",
24
+ "@webex/internal-plugin-mercury": "3.0.0-beta.151",
25
+ "@webex/webex-core": "3.0.0-beta.151",
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.15",
31
- "@webex/test-helper-chai": "3.0.0-beta.15",
32
- "@webex/test-helper-mock-webex": "3.0.0-beta.15"
30
+ "@webex/common": "3.0.0-beta.151",
31
+ "@webex/internal-plugin-dss": "3.0.0-beta.151",
32
+ "@webex/test-helper-chai": "3.0.0-beta.151",
33
+ "@webex/test-helper-mock-webex": "3.0.0-beta.151",
34
+ "sinon": "^9.2.4"
33
35
  }
34
36
  }
package/src/config.ts ADDED
@@ -0,0 +1,25 @@
1
+ /*!
2
+ * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ export default {
6
+ dss: {
7
+ /**
8
+ * Debounce wait (ms) before sending a dss request (gap between lookups that will trigger a request)
9
+ * @type {Number}
10
+ */
11
+ batcherWait: 50,
12
+
13
+ /**
14
+ * Maximum queue size before sending a dss request
15
+ * @type {Number}
16
+ */
17
+ batcherMaxCalls: 50,
18
+
19
+ /**
20
+ * Debounce max wait (ms) before sending a dss request (time from first lookup that will trigger a request)
21
+ * @type {Number}
22
+ */
23
+ batcherMaxWait: 150,
24
+ },
25
+ };
package/src/constants.ts CHANGED
@@ -12,3 +12,8 @@ export const SEARCH_TYPES = {
12
12
  ROOM: 'ROOM',
13
13
  ROBOT: 'ROBOT',
14
14
  };
15
+ export const LOOKUP_DATA_PATH = 'lookupResult.entities';
16
+ export const LOOKUP_FOUND_PATH = 'lookupResult.entitiesFound';
17
+ export const LOOKUP_NOT_FOUND_PATH = 'lookupResult.entitiesNotFound';
18
+ export const LOOKUP_REQUEST_KEY = 'lookupValues';
19
+ export const SEARCH_DATA_PATH = 'directoryEntities';
@@ -0,0 +1,129 @@
1
+ /*!
2
+ * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+ /* eslint-disable no-underscore-dangle */
5
+
6
+ import {Batcher} from '@webex/webex-core';
7
+
8
+ /**
9
+ * @class
10
+ */
11
+ const DssBatcher = Batcher.extend({
12
+ namespace: 'DSS',
13
+
14
+ props: {
15
+ resource: {
16
+ type: 'string',
17
+ required: true,
18
+ setOnce: true,
19
+ allowNull: false,
20
+ },
21
+ dataPath: {
22
+ type: 'string',
23
+ required: true,
24
+ setOnce: true,
25
+ allowNull: false,
26
+ },
27
+ entitiesFoundPath: {
28
+ type: 'string',
29
+ required: true,
30
+ setOnce: true,
31
+ allowNull: false,
32
+ },
33
+ entitiesNotFoundPath: {
34
+ type: 'string',
35
+ required: true,
36
+ setOnce: true,
37
+ allowNull: false,
38
+ },
39
+ requestKey: {
40
+ type: 'string',
41
+ required: true,
42
+ setOnce: true,
43
+ allowNull: false,
44
+ },
45
+ },
46
+
47
+ /**
48
+ * Submits the DSS request
49
+ * @param {Object} payload
50
+ * @returns {Promise<Array>}
51
+ */
52
+ submitHttpRequest(payload) {
53
+ return this.parent._request({
54
+ dataPath: this.dataPath,
55
+ foundPath: this.entitiesFoundPath,
56
+ notFoundPath: this.entitiesNotFoundPath,
57
+ resource: this.resource,
58
+ params: {
59
+ lookupValues: payload,
60
+ },
61
+ });
62
+ },
63
+
64
+ /**
65
+ * Actions taken when the http request returns a success
66
+ * @param {Promise<Array>} res
67
+ * @returns {Promise<undefined>}
68
+ */
69
+ handleHttpSuccess(res) {
70
+ const successItems = res.foundArray.map((requestValue, index) => ({
71
+ requestValue,
72
+ entity: res.resultArray[index],
73
+ }));
74
+ const failureItems = res.notFoundArray.map((requestValue) => ({requestValue, entity: null}));
75
+
76
+ return Promise.all(successItems.concat(failureItems).map((item) => this.acceptItem(item)));
77
+ },
78
+
79
+ /**
80
+ * Checks if the item was found
81
+ * @param {Object} item
82
+ * @returns {Promise<Boolean>}
83
+ */
84
+ didItemFail(item) {
85
+ return Promise.resolve(item.entity === null);
86
+ },
87
+
88
+ /**
89
+ * Finds the Defer for the specified item and resolves its promise with null
90
+ * @param {Object} item
91
+ * @returns {Promise<undefined>}
92
+ */
93
+ handleItemFailure(item) {
94
+ return this.getDeferredForResponse(item).then((defer) => {
95
+ defer.resolve(null);
96
+ });
97
+ },
98
+
99
+ /**
100
+ * Finds the Defer for the specified item and resolves its promise
101
+ * @param {Object} item
102
+ * @returns {Promise<undefined>}
103
+ */
104
+ handleItemSuccess(item) {
105
+ return this.getDeferredForResponse(item).then((defer) => {
106
+ defer.resolve(item.entity);
107
+ });
108
+ },
109
+
110
+ /**
111
+ * Returns a promise with the unique key for the item
112
+ * @param {Object} item
113
+ * @returns {Promise}
114
+ */
115
+ fingerprintRequest(item) {
116
+ return Promise.resolve(item);
117
+ },
118
+
119
+ /**
120
+ * Returns a promise with the unique key for the item
121
+ * @param {Object} item
122
+ * @returns {Promise}
123
+ */
124
+ fingerprintResponse(item) {
125
+ return Promise.resolve(item.requestValue);
126
+ },
127
+ });
128
+
129
+ export default DssBatcher;
package/src/dss.ts CHANGED
@@ -2,17 +2,18 @@
2
2
  /*!
3
3
  * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.
4
4
  */
5
+ /* eslint-disable no-underscore-dangle */
5
6
  import uuid from 'uuid';
6
7
  import {WebexPlugin} from '@webex/webex-core';
7
8
  import '@webex/internal-plugin-mercury';
8
9
  import {range, isEqual, get} from 'lodash';
10
+
9
11
  import type {
10
12
  SearchOptions,
11
13
  LookupDetailOptions,
12
14
  LookupOptions,
13
15
  LookupByEmailOptions,
14
16
  } from './types';
15
-
16
17
  import {
17
18
  DSS_REGISTERED,
18
19
  DSS_UNREGISTERED,
@@ -21,7 +22,13 @@ import {
21
22
  DSS_SERVICE_NAME,
22
23
  DSS_SEARCH_MERCURY_EVENT,
23
24
  DSS_RESULT,
25
+ LOOKUP_DATA_PATH,
26
+ LOOKUP_FOUND_PATH,
27
+ LOOKUP_NOT_FOUND_PATH,
28
+ LOOKUP_REQUEST_KEY,
29
+ SEARCH_DATA_PATH,
24
30
  } from './constants';
31
+ import DssBatcher from './dss-batcher';
25
32
 
26
33
  const DSS = WebexPlugin.extend({
27
34
  namespace: 'DSS',
@@ -34,6 +41,18 @@ const DSS = WebexPlugin.extend({
34
41
  */
35
42
  registered: false,
36
43
 
44
+ /**
45
+ * Initializer
46
+ * @private
47
+ * @param {Object} attrs
48
+ * @param {Object} options
49
+ * @returns {undefined}
50
+ */
51
+ initialize(...args) {
52
+ Reflect.apply(WebexPlugin.prototype.initialize, this, args);
53
+ this.batchers = {};
54
+ },
55
+
37
56
  /**
38
57
  * Explicitly sets up the DSS plugin by connecting to mercury, and listening for DSS events.
39
58
  * @returns {Promise}
@@ -113,6 +132,7 @@ const DSS = WebexPlugin.extend({
113
132
  },
114
133
 
115
134
  /**
135
+ * constructs the event name based on request id
116
136
  * @param {UUID} requestId the id of the request
117
137
  * @returns {string}
118
138
  */
@@ -121,6 +141,7 @@ const DSS = WebexPlugin.extend({
121
141
  },
122
142
 
123
143
  /**
144
+ * Takes incoming data and triggers correct events
124
145
  * @param {Object} data the event data
125
146
  * @returns {undefined}
126
147
  */
@@ -134,39 +155,67 @@ const DSS = WebexPlugin.extend({
134
155
  * @param {Object} options
135
156
  * @param {string} options.resource the URL to query
136
157
  * @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
158
+ * @param {string} options.dataPath the path to get the data in the result object
159
+ * @param {string} options.foundPath the path to get the lookups of the found data (optional)
160
+ * @param {string} options.notFoundPath the path to get the lookups of the not found data (optional)
161
+ * @returns {Promise<Object>} result Resolves with an object
162
+ * @returns {Array} result.resultArray an array of entities found
163
+ * @returns {Array} result.foundArray an array of the lookups of the found entities (if foundPath provided)
164
+ * @returns {Array} result.notFoundArray an array of the lookups of the not found entities (if notFoundPath provided)
139
165
  */
140
166
  _request(options) {
141
- const {resource, params, dataPath} = options;
167
+ const {resource, params, dataPath, foundPath, notFoundPath} = options;
142
168
 
143
169
  const requestId = uuid.v4();
144
170
  const eventName = this._getResultEventName(requestId);
145
171
  const result = {};
146
172
  let expectedSeqNums;
173
+ let notFoundArray;
147
174
 
148
175
  return new Promise((resolve) => {
149
176
  this.listenTo(this, eventName, (data) => {
150
- const resultData = get(data, dataPath);
177
+ const resultData = get(data, dataPath, []);
178
+ let found;
151
179
 
152
- result[data.sequence] = resultData;
180
+ if (foundPath) {
181
+ found = get(data, foundPath, []);
182
+ }
183
+ result[data.sequence] = foundPath ? {resultData, found} : {resultData};
153
184
 
154
185
  if (data.finished) {
155
186
  expectedSeqNums = range(data.sequence + 1).map(String);
187
+ if (notFoundPath) {
188
+ notFoundArray = get(data, notFoundPath, []);
189
+ }
156
190
  }
157
191
 
158
192
  const done = isEqual(expectedSeqNums, Object.keys(result));
159
193
 
160
194
  if (done) {
161
- const resultArray = [];
195
+ const resultArray: any[] = [];
196
+ const foundArray: any[] = [];
197
+
162
198
  expectedSeqNums.forEach((index) => {
163
199
  const seqResult = result[index];
200
+
164
201
  if (seqResult) {
165
- resultArray.push(...seqResult);
202
+ resultArray.push(...seqResult.resultData);
203
+ if (foundPath) {
204
+ foundArray.push(...seqResult.found);
205
+ }
166
206
  }
167
207
  });
168
-
169
- resolve(resultArray);
208
+ const resolveValue: {resultArray: any[]; foundArray?: any[]; notFoundArray?: any[]} = {
209
+ resultArray,
210
+ };
211
+
212
+ if (foundPath) {
213
+ resolveValue.foundArray = foundArray;
214
+ }
215
+ if (notFoundPath) {
216
+ resolveValue.notFoundArray = notFoundArray;
217
+ }
218
+ resolve(resolveValue);
170
219
  this.stopListening(this, eventName);
171
220
  }
172
221
  });
@@ -180,59 +229,120 @@ const DSS = WebexPlugin.extend({
180
229
  });
181
230
  },
182
231
 
232
+ /**
233
+ * Uses a batcher to make the request to the directory service
234
+ * @param {Object} options
235
+ * @param {string} options.resource the URL to query
236
+ * @param {string} options.value the id or email to lookup
237
+ * @returns {Promise} Resolves with an array of entities found
238
+ */
239
+ _batchedLookup(options) {
240
+ const {resource, lookupValue} = options;
241
+ const dataPath = LOOKUP_DATA_PATH;
242
+ const entitiesFoundPath = LOOKUP_FOUND_PATH;
243
+ const entitiesNotFoundPath = LOOKUP_NOT_FOUND_PATH;
244
+ const requestKey = LOOKUP_REQUEST_KEY;
245
+
246
+ this.batchers[resource] =
247
+ this.batchers[resource] ||
248
+ new DssBatcher({
249
+ resource,
250
+ dataPath,
251
+ entitiesFoundPath,
252
+ entitiesNotFoundPath,
253
+ requestKey,
254
+ parent: this,
255
+ });
256
+
257
+ return this.batchers[resource].request(lookupValue);
258
+ },
259
+
183
260
  /**
184
261
  * Retrieves detailed information about an entity
185
262
  * @param {Object} options
186
263
  * @param {UUID} options.id the id of the entity to lookup
187
- * @returns {Promise} Resolves with an array of entities found
264
+ * @returns {Promise} Resolves with the entity found or null if not found
188
265
  */
189
266
  lookupDetail(options: LookupDetailOptions) {
190
267
  const {id} = options;
191
268
 
269
+ const resource = `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`;
270
+
192
271
  return this._request({
193
- dataPath: 'lookupResult.entities',
194
- resource: `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`,
272
+ dataPath: LOOKUP_DATA_PATH,
273
+ foundPath: LOOKUP_FOUND_PATH,
274
+ resource,
275
+ }).then(({resultArray, foundArray}) => {
276
+ // TODO: find out what is actually returned!
277
+ if (foundArray[0] === id) {
278
+ return resultArray[0];
279
+ }
280
+
281
+ return null;
195
282
  });
196
283
  },
197
284
 
198
285
  /**
199
- * Retrieves basic information about a list entities within an organization
286
+ * Retrieves basic information about an entity within an organization
200
287
  * @param {Object} options
201
- * @param {UUID} options.ids the id of the entity to lookup
288
+ * @param {UUID} options.id the id of the entity to lookup
202
289
  * @param {UUID} options.entityProviderType the provider to query (optional)
203
- * @returns {Promise} Resolves with an array of entities found
290
+ * @param {Boolean} options.shouldBatch whether to batch the query, set to false for single immediate result (defaults to true)
291
+ * @returns {Promise} Resolves with the entity found or null if not found
204
292
  */
205
293
  lookup(options: LookupOptions) {
206
- const {ids, entityProviderType} = options;
294
+ const {id, entityProviderType, shouldBatch = true} = options;
207
295
 
208
296
  const resource = entityProviderType
209
297
  ? `/lookup/orgid/${this.webex.internal.device.orgId}/entityprovidertype/${entityProviderType}`
210
298
  : `/lookup/orgid/${this.webex.internal.device.orgId}/identities`;
211
299
 
300
+ if (shouldBatch) {
301
+ return this._batchedLookup({
302
+ resource,
303
+ lookupValue: id,
304
+ });
305
+ }
306
+
212
307
  return this._request({
213
- dataPath: 'lookupResult.entities',
308
+ dataPath: LOOKUP_DATA_PATH,
309
+ foundPath: LOOKUP_FOUND_PATH,
214
310
  resource,
215
311
  params: {
216
- lookupValues: ids,
312
+ [LOOKUP_REQUEST_KEY]: [id],
217
313
  },
314
+ }).then(({resultArray, foundArray}) => {
315
+ if (foundArray[0] === id) {
316
+ return resultArray[0];
317
+ }
318
+
319
+ return null;
218
320
  });
219
321
  },
220
322
 
221
323
  /**
222
- * Retrieves basic information about a list entities within an organization
324
+ * Retrieves basic information about an enitity within an organization
223
325
  * @param {Object} options
224
- * @param {UUID} options.emails the emails of the entities to lookup
225
- * @returns {Promise} Resolves with an array of entities found
326
+ * @param {UUID} options.email the email of the entity to lookup
327
+ * @returns {Promise} Resolves with the entity found or rejects if not found
226
328
  */
227
329
  lookupByEmail(options: LookupByEmailOptions) {
228
- const {emails} = options;
330
+ const {email} = options;
331
+ const resource = `/lookup/orgid/${this.webex.internal.device.orgId}/emails`;
229
332
 
230
333
  return this._request({
231
- dataPath: 'lookupResult.entities',
232
- resource: `/lookup/orgid/${this.webex.internal.device.orgId}/emails`,
334
+ dataPath: LOOKUP_DATA_PATH,
335
+ foundPath: LOOKUP_FOUND_PATH,
336
+ resource,
233
337
  params: {
234
- lookupValues: emails,
338
+ [LOOKUP_REQUEST_KEY]: [email],
235
339
  },
340
+ }).then(({resultArray, foundArray}) => {
341
+ if (foundArray[0] === email) {
342
+ return resultArray[0];
343
+ }
344
+
345
+ return null;
236
346
  });
237
347
  },
238
348
 
@@ -248,14 +358,14 @@ const DSS = WebexPlugin.extend({
248
358
  const {requestedTypes, resultSize, queryString} = options;
249
359
 
250
360
  return this._request({
251
- dataPath: 'directoryEntities',
361
+ dataPath: SEARCH_DATA_PATH,
252
362
  resource: `/search/orgid/${this.webex.internal.device.orgId}/entities`,
253
363
  params: {
254
364
  queryString,
255
365
  resultSize,
256
366
  requestedTypes,
257
367
  },
258
- });
368
+ }).then(({resultArray}) => resultArray);
259
369
  },
260
370
  });
261
371
 
package/src/index.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import {registerInternalPlugin} from '@webex/webex-core';
2
2
 
3
3
  import DSS from './dss';
4
+ import config from './config';
4
5
 
5
- registerInternalPlugin('dss', DSS);
6
+ registerInternalPlugin('dss', DSS, {config});
6
7
 
7
8
  export {default} from './dss';