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

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
@@ -155,13 +155,13 @@ var DSS = _webexCore.WebexPlugin.extend({
155
155
  },
156
156
 
157
157
  /**
158
- * Makes the request to the directory service
159
- * @param {Object} options
160
- * @param {string} options.resource the URL to query
161
- * @param {string} options.params additional params for the body of the request
162
- * @param {string} options.dataPath to path to get the data in the result object
163
- * @returns {Promise} Resolves with an array of entities found
164
- */
158
+ * Makes the request to the directory service
159
+ * @param {Object} options
160
+ * @param {string} options.resource the URL to query
161
+ * @param {string} options.params additional params for the body of the request
162
+ * @param {string} options.dataPath to path to get the data in the result object
163
+ * @returns {Promise} Resolves with an array of entities found
164
+ */
165
165
  _request: function _request(options) {
166
166
  var _this4 = this;
167
167
 
@@ -286,7 +286,7 @@ var DSS = _webexCore.WebexPlugin.extend({
286
286
  }
287
287
  });
288
288
  },
289
- version: "3.0.0-beta.13"
289
+ version: "3.0.0-beta.15"
290
290
  });
291
291
 
292
292
  var _default = DSS;
package/dist/dss.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["DSS","WebexPlugin","extend","namespace","registered","register","webex","canAuthorize","logger","error","reject","Error","info","resolve","internal","mercury","connect","then","listenForEvents","trigger","DSS_REGISTERED","catch","message","unregister","stopListeningForEvents","disconnect","DSS_UNREGISTERED","on","DSS_LOOKUP_MERCURY_EVENT","envelope","_handleEvent","data","DSS_SEARCH_MERCURY_EVENT","off","_getResultEventName","requestId","DSS_RESULT","DSS_LOOKUP_RESULT","_request","options","resource","params","dataPath","uuid","v4","eventName","result","expectedSeqNums","listenTo","resultData","sequence","finished","map","String","done","resultArray","forEach","index","seqResult","push","stopListening","request","service","DSS_SERVICE_NAME","method","contentType","body","lookupDetail","id","device","orgId","lookup","ids","entityProviderType","lookupValues","lookupByEmail","emails","search","requestedTypes","resultSize","queryString"],"sources":["dss.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\n/*!\n * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.\n */\nimport uuid from 'uuid';\nimport {WebexPlugin} from '@webex/webex-core';\nimport '@webex/internal-plugin-mercury';\nimport {range, isEqual, get} from 'lodash';\nimport type {SearchOptions, LookupDetailOptions, LookupOptions, LookupByEmailOptions} from './types';\n\nimport {\n DSS_REGISTERED,\n DSS_UNREGISTERED,\n DSS_LOOKUP_MERCURY_EVENT,\n DSS_LOOKUP_RESULT,\n DSS_SERVICE_NAME,\n DSS_SEARCH_MERCURY_EVENT,\n DSS_RESULT,\n} from './constants';\n\nconst DSS = WebexPlugin.extend({\n namespace: 'DSS',\n\n /**\n * registered value indicating events registration is successful\n * @instance\n * @type {Boolean}\n * @memberof DSS\n */\n registered: false,\n\n /**\n * Explicitly sets up the DSS plugin by connecting to mercury, and listening for DSS events.\n * @returns {Promise}\n * @public\n * @memberof DSS\n */\n register() {\n if (!this.webex.canAuthorize) {\n this.logger.error('DSS->register#ERROR, Unable to register, SDK cannot authorize');\n\n return Promise.reject(new Error('SDK cannot authorize'));\n }\n\n if (this.registered) {\n this.logger.info('dss->register#INFO, DSS plugin already registered');\n\n return Promise.resolve();\n }\n\n return this.webex.internal.mercury.connect()\n .then(() => {\n this.listenForEvents();\n this.trigger(DSS_REGISTERED);\n this.registered = true;\n })\n .catch((error) => {\n this.logger.error(`DSS->register#ERROR, Unable to register, ${error.message}`);\n\n return Promise.reject(error);\n });\n },\n\n /**\n * Explicitly tears down the DSS plugin by disconnecting from mercury, and stops listening to DSS events\n * @returns {Promise}\n * @public\n * @memberof DSS\n */\n unregister() {\n if (!this.registered) {\n this.logger.info('DSS->unregister#INFO, DSS plugin already unregistered');\n\n return Promise.resolve();\n }\n\n this.stopListeningForEvents();\n\n return this.webex.internal.mercury.disconnect()\n .then(() => {\n this.trigger(DSS_UNREGISTERED);\n this.registered = false;\n });\n },\n\n /**\n * registers for DSS events through mercury\n * @returns {undefined}\n * @private\n */\n listenForEvents() {\n this.webex.internal.mercury.on(DSS_LOOKUP_MERCURY_EVENT, (envelope) => {\n this._handleEvent(envelope.data);\n });\n this.webex.internal.mercury.on(DSS_SEARCH_MERCURY_EVENT, (envelope) => {\n this._handleEvent(envelope.data);\n });\n },\n\n /**\n * unregisteres all the DSS events from mercury\n * @returns {undefined}\n * @private\n */\n stopListeningForEvents() {\n this.webex.internal.mercury.off(DSS_LOOKUP_MERCURY_EVENT);\n this.webex.internal.mercury.off(DSS_SEARCH_MERCURY_EVENT);\n },\n\n /**\n * @param {UUID} requestId the id of the request\n * @returns {string}\n */\n _getResultEventName(requestId) {\n return `${DSS_RESULT}${requestId}`;\n },\n\n /**\n * @param {Object} data the event data\n * @returns {undefined}\n */\n _handleEvent(data) {\n this.trigger(this._getResultEventName(data.requestId), data);\n this.trigger(DSS_LOOKUP_RESULT, data);\n },\n\n /**\n * Makes the request to the directory service\n * @param {Object} options\n * @param {string} options.resource the URL to query\n * @param {string} options.params additional params for the body of the request\n * @param {string} options.dataPath to path to get the data in the result object\n * @returns {Promise} Resolves with an array of entities found\n */\n _request(options) {\n const {resource, params, dataPath} = options;\n\n const requestId = uuid.v4();\n const eventName = this._getResultEventName(requestId);\n const result = {};\n let expectedSeqNums;\n\n return new Promise((resolve) => {\n this.listenTo(this, eventName, (data) => {\n const resultData = get(data, dataPath);\n\n result[data.sequence] = resultData;\n\n if (data.finished) {\n expectedSeqNums = range(data.sequence + 1).map(String);\n }\n\n const done = isEqual(expectedSeqNums, Object.keys(result));\n\n if (done) {\n const resultArray = [];\n expectedSeqNums.forEach((index) => {\n const seqResult = result[index];\n if (seqResult) {\n resultArray.push(...seqResult);\n }\n })\n\n resolve(resultArray);\n this.stopListening(this, eventName);\n }\n });\n this.webex.request({\n service: DSS_SERVICE_NAME,\n resource,\n method: 'POST',\n contentType: 'application/json',\n body: {requestId, ...params}\n });\n });\n },\n\n /**\n * Retrieves detailed information about an entity\n * @param {Object} options\n * @param {UUID} options.id the id of the entity to lookup\n * @returns {Promise} Resolves with an array of entities found\n */\n lookupDetail(options: LookupDetailOptions) {\n const {id} = options;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource: `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`\n });\n },\n\n /**\n * Retrieves basic information about a list entities within an organization\n * @param {Object} options\n * @param {UUID} options.ids the id of the entity to lookup\n * @param {UUID} options.entityProviderType the provider to query (optional)\n * @returns {Promise} Resolves with an array of entities found\n */\n lookup(options: LookupOptions) {\n const {ids, entityProviderType} = options;\n\n const resource = entityProviderType ? `/lookup/orgid/${this.webex.internal.device.orgId}/entityprovidertype/${entityProviderType}` : `/lookup/orgid/${this.webex.internal.device.orgId}/identities`;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource,\n params: {\n lookupValues: ids,\n }\n });\n },\n\n /**\n * Retrieves basic information about a list entities within an organization\n * @param {Object} options\n * @param {UUID} options.emails the emails of the entities to lookup\n * @returns {Promise} Resolves with an array of entities found\n */\n lookupByEmail(options: LookupByEmailOptions) {\n const {emails} = options;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource: `/lookup/orgid/${this.webex.internal.device.orgId}/emails`,\n params: {\n lookupValues: emails,\n }\n });\n },\n\n /**\n * Search for information about entities\n * @param {Object} options\n * @param {SearchType[]} options.requestedTypes an array of search types from: PERSON, CALLING_SERVICE, EXTERNAL_CALLING, ROOM, ROBOT\n * @param {string[]} options.queryString A query string that will be transformed into a Directory search filter query. It is used to search the following fields: username, givenName, familyName, displayName and email\n * @param {number} options.resultSize The maximum number of results returned from each provider\n * @returns {Promise} Resolves with an array of entities found\n */\n search(options: SearchOptions) {\n const {\n requestedTypes, resultSize, queryString\n } = options;\n\n return this._request({\n dataPath: 'directoryEntities',\n resource: `/search/orgid/${this.webex.internal.device.orgId}/entities`,\n params: {\n queryString,\n resultSize,\n requestedTypes\n }\n });\n }\n\n});\n\nexport default DSS;\n"],"mappings":";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AAQ,0BAAmB,KAAKlC,KAAL,CAAWQ,QAAX,CAAoBuD,MAApB,CAA2BC,KAA9C,YAFW;MAGnB7B,MAAM,EAAE;QACNiC,YAAY,EAAEE;MADR;IAHW,CAAd,CAAP;EAOD,CAjN4B;;EAmN7B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,MA3N6B,kBA2NtBtC,OA3NsB,EA2NE;IAC7B,IACEuC,cADF,GAEIvC,OAFJ,CACEuC,cADF;IAAA,IACkBC,UADlB,GAEIxC,OAFJ,CACkBwC,UADlB;IAAA,IAC8BC,WAD9B,GAEIzC,OAFJ,CAC8ByC,WAD9B;IAIA,OAAO,KAAK1C,QAAL,CAAc;MACnBI,QAAQ,EAAE,mBADS;MAEnBF,QAAQ,0BAAmB,KAAKlC,KAAL,CAAWQ,QAAX,CAAoBuD,MAApB,CAA2BC,KAA9C,cAFW;MAGnB7B,MAAM,EAAE;QACNuC,WAAW,EAAXA,WADM;QAEND,UAAU,EAAVA,UAFM;QAGND,cAAc,EAAdA;MAHM;IAHW,CAAd,CAAP;EASD,CAzO4B;EAAA;AAAA,CAAnB,CAAZ;;eA6Oe9E,G"}
1
+ {"version":3,"names":["DSS","WebexPlugin","extend","namespace","registered","register","webex","canAuthorize","logger","error","reject","Error","info","resolve","internal","mercury","connect","then","listenForEvents","trigger","DSS_REGISTERED","catch","message","unregister","stopListeningForEvents","disconnect","DSS_UNREGISTERED","on","DSS_LOOKUP_MERCURY_EVENT","envelope","_handleEvent","data","DSS_SEARCH_MERCURY_EVENT","off","_getResultEventName","requestId","DSS_RESULT","DSS_LOOKUP_RESULT","_request","options","resource","params","dataPath","uuid","v4","eventName","result","expectedSeqNums","listenTo","resultData","sequence","finished","map","String","done","resultArray","forEach","index","seqResult","push","stopListening","request","service","DSS_SERVICE_NAME","method","contentType","body","lookupDetail","id","device","orgId","lookup","ids","entityProviderType","lookupValues","lookupByEmail","emails","search","requestedTypes","resultSize","queryString"],"sources":["dss.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\n/*!\n * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.\n */\nimport uuid from 'uuid';\nimport {WebexPlugin} from '@webex/webex-core';\nimport '@webex/internal-plugin-mercury';\nimport {range, isEqual, get} from 'lodash';\nimport type {\n SearchOptions,\n LookupDetailOptions,\n LookupOptions,\n LookupByEmailOptions,\n} from './types';\n\nimport {\n DSS_REGISTERED,\n DSS_UNREGISTERED,\n DSS_LOOKUP_MERCURY_EVENT,\n DSS_LOOKUP_RESULT,\n DSS_SERVICE_NAME,\n DSS_SEARCH_MERCURY_EVENT,\n DSS_RESULT,\n} from './constants';\n\nconst DSS = WebexPlugin.extend({\n namespace: 'DSS',\n\n /**\n * registered value indicating events registration is successful\n * @instance\n * @type {Boolean}\n * @memberof DSS\n */\n registered: false,\n\n /**\n * Explicitly sets up the DSS plugin by connecting to mercury, and listening for DSS events.\n * @returns {Promise}\n * @public\n * @memberof DSS\n */\n register() {\n if (!this.webex.canAuthorize) {\n this.logger.error('DSS->register#ERROR, Unable to register, SDK cannot authorize');\n\n return Promise.reject(new Error('SDK cannot authorize'));\n }\n\n if (this.registered) {\n this.logger.info('dss->register#INFO, DSS plugin already registered');\n\n return Promise.resolve();\n }\n\n return this.webex.internal.mercury\n .connect()\n .then(() => {\n this.listenForEvents();\n this.trigger(DSS_REGISTERED);\n this.registered = true;\n })\n .catch((error) => {\n this.logger.error(`DSS->register#ERROR, Unable to register, ${error.message}`);\n\n return Promise.reject(error);\n });\n },\n\n /**\n * Explicitly tears down the DSS plugin by disconnecting from mercury, and stops listening to DSS events\n * @returns {Promise}\n * @public\n * @memberof DSS\n */\n unregister() {\n if (!this.registered) {\n this.logger.info('DSS->unregister#INFO, DSS plugin already unregistered');\n\n return Promise.resolve();\n }\n\n this.stopListeningForEvents();\n\n return this.webex.internal.mercury.disconnect().then(() => {\n this.trigger(DSS_UNREGISTERED);\n this.registered = false;\n });\n },\n\n /**\n * registers for DSS events through mercury\n * @returns {undefined}\n * @private\n */\n listenForEvents() {\n this.webex.internal.mercury.on(DSS_LOOKUP_MERCURY_EVENT, (envelope) => {\n this._handleEvent(envelope.data);\n });\n this.webex.internal.mercury.on(DSS_SEARCH_MERCURY_EVENT, (envelope) => {\n this._handleEvent(envelope.data);\n });\n },\n\n /**\n * unregisteres all the DSS events from mercury\n * @returns {undefined}\n * @private\n */\n stopListeningForEvents() {\n this.webex.internal.mercury.off(DSS_LOOKUP_MERCURY_EVENT);\n this.webex.internal.mercury.off(DSS_SEARCH_MERCURY_EVENT);\n },\n\n /**\n * @param {UUID} requestId the id of the request\n * @returns {string}\n */\n _getResultEventName(requestId) {\n return `${DSS_RESULT}${requestId}`;\n },\n\n /**\n * @param {Object} data the event data\n * @returns {undefined}\n */\n _handleEvent(data) {\n this.trigger(this._getResultEventName(data.requestId), data);\n this.trigger(DSS_LOOKUP_RESULT, data);\n },\n\n /**\n * Makes the request to the directory service\n * @param {Object} options\n * @param {string} options.resource the URL to query\n * @param {string} options.params additional params for the body of the request\n * @param {string} options.dataPath to path to get the data in the result object\n * @returns {Promise} Resolves with an array of entities found\n */\n _request(options) {\n const {resource, params, dataPath} = options;\n\n const requestId = uuid.v4();\n const eventName = this._getResultEventName(requestId);\n const result = {};\n let expectedSeqNums;\n\n return new Promise((resolve) => {\n this.listenTo(this, eventName, (data) => {\n const resultData = get(data, dataPath);\n\n result[data.sequence] = resultData;\n\n if (data.finished) {\n expectedSeqNums = range(data.sequence + 1).map(String);\n }\n\n const done = isEqual(expectedSeqNums, Object.keys(result));\n\n if (done) {\n const resultArray = [];\n expectedSeqNums.forEach((index) => {\n const seqResult = result[index];\n if (seqResult) {\n resultArray.push(...seqResult);\n }\n });\n\n resolve(resultArray);\n this.stopListening(this, eventName);\n }\n });\n this.webex.request({\n service: DSS_SERVICE_NAME,\n resource,\n method: 'POST',\n contentType: 'application/json',\n body: {requestId, ...params},\n });\n });\n },\n\n /**\n * Retrieves detailed information about an entity\n * @param {Object} options\n * @param {UUID} options.id the id of the entity to lookup\n * @returns {Promise} Resolves with an array of entities found\n */\n lookupDetail(options: LookupDetailOptions) {\n const {id} = options;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource: `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`,\n });\n },\n\n /**\n * Retrieves basic information about a list entities within an organization\n * @param {Object} options\n * @param {UUID} options.ids the id of the entity to lookup\n * @param {UUID} options.entityProviderType the provider to query (optional)\n * @returns {Promise} Resolves with an array of entities found\n */\n lookup(options: LookupOptions) {\n const {ids, entityProviderType} = options;\n\n const resource = entityProviderType\n ? `/lookup/orgid/${this.webex.internal.device.orgId}/entityprovidertype/${entityProviderType}`\n : `/lookup/orgid/${this.webex.internal.device.orgId}/identities`;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource,\n params: {\n lookupValues: ids,\n },\n });\n },\n\n /**\n * Retrieves basic information about a list entities within an organization\n * @param {Object} options\n * @param {UUID} options.emails the emails of the entities to lookup\n * @returns {Promise} Resolves with an array of entities found\n */\n lookupByEmail(options: LookupByEmailOptions) {\n const {emails} = options;\n\n return this._request({\n dataPath: 'lookupResult.entities',\n resource: `/lookup/orgid/${this.webex.internal.device.orgId}/emails`,\n params: {\n lookupValues: emails,\n },\n });\n },\n\n /**\n * Search for information about entities\n * @param {Object} options\n * @param {SearchType[]} options.requestedTypes an array of search types from: PERSON, CALLING_SERVICE, EXTERNAL_CALLING, ROOM, ROBOT\n * @param {string[]} options.queryString A query string that will be transformed into a Directory search filter query. It is used to search the following fields: username, givenName, familyName, displayName and email\n * @param {number} options.resultSize The maximum number of results returned from each provider\n * @returns {Promise} Resolves with an array of entities found\n */\n search(options: SearchOptions) {\n const {requestedTypes, resultSize, queryString} = options;\n\n return this._request({\n dataPath: 'directoryEntities',\n resource: `/search/orgid/${this.webex.internal.device.orgId}/entities`,\n params: {\n queryString,\n resultSize,\n requestedTypes,\n },\n });\n },\n});\n\nexport default DSS;\n"],"mappings":";;;;;;;;;;;;;;;;;;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KAAL,CAAWQ,QAAX,CAAoBuD,MAApB,CAA2BC,KAA9C,YAFW;MAGnB7B,MAAM,EAAE;QACNiC,YAAY,EAAEE;MADR;IAHW,CAAd,CAAP;EAOD,CAnN4B;;EAqN7B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,MA7N6B,kBA6NtBtC,OA7NsB,EA6NE;IAC7B,IAAOuC,cAAP,GAAkDvC,OAAlD,CAAOuC,cAAP;IAAA,IAAuBC,UAAvB,GAAkDxC,OAAlD,CAAuBwC,UAAvB;IAAA,IAAmCC,WAAnC,GAAkDzC,OAAlD,CAAmCyC,WAAnC;IAEA,OAAO,KAAK1C,QAAL,CAAc;MACnBI,QAAQ,EAAE,mBADS;MAEnBF,QAAQ,0BAAmB,KAAKlC,KAAL,CAAWQ,QAAX,CAAoBuD,MAApB,CAA2BC,KAA9C,cAFW;MAGnB7B,MAAM,EAAE;QACNuC,WAAW,EAAXA,WADM;QAEND,UAAU,EAAVA,UAFM;QAGND,cAAc,EAAdA;MAHM;IAHW,CAAd,CAAP;EASD,CAzO4B;EAAA;AAAA,CAAnB,CAAZ;;eA4Oe9E,G"}
package/dist/types.js CHANGED
@@ -7,6 +7,7 @@ _Object$defineProperty(exports, "__esModule", {
7
7
  });
8
8
 
9
9
  exports.SearchType = exports.EntityProviderType = void 0;
10
+ // eslint-disable-next-line no-shadow
10
11
  var EntityProviderType;
11
12
  exports.EntityProviderType = EntityProviderType;
12
13
 
@@ -17,6 +18,7 @@ exports.EntityProviderType = EntityProviderType;
17
18
  EntityProviderType["CSDM"] = "CSDM";
18
19
  })(EntityProviderType || (exports.EntityProviderType = EntityProviderType = {}));
19
20
 
21
+ // eslint-disable-next-line no-shadow
20
22
  var SearchType;
21
23
  exports.SearchType = SearchType;
22
24
 
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["EntityProviderType","SearchType"],"sources":["types.ts"],"sourcesContent":["export interface LookupDetailOptions {\n id: string;\n}\n\nexport enum EntityProviderType {\n CI_USER = 'CI_USER',\n CI_MACHINE ='CI_MACHINE',\n CONTACTS = 'CONTACTS',\n CSDM = 'CSDM'\n}\n\nexport interface LookupOptions {\n ids: string[];\n entityProviderType?: EntityProviderType;\n}\n\nexport interface LookupByEmailOptions {\n emails: string[];\n}\n\nexport enum SearchType {\n PERSON = 'PERSON', \n CALLING_SERVICE = 'CALLING_SERVICE',\n EXTERNAL_CALLING = 'EXTERNAL_CALLING',\n ROOM = 'ROOM',\n ROBOT = 'ROBOT'\n}\n\nexport interface SearchOptions {\n requestedTypes: SearchType[],\n resultSize: number,\n queryString: string,\n}\n"],"mappings":";;;;;;;;;IAIYA,kB;;;WAAAA,kB;EAAAA,kB;EAAAA,kB;EAAAA,kB;EAAAA,kB;GAAAA,kB,kCAAAA,kB;;IAgBAC,U;;;WAAAA,U;EAAAA,U;EAAAA,U;EAAAA,U;EAAAA,U;EAAAA,U;GAAAA,U,0BAAAA,U"}
1
+ {"version":3,"names":["EntityProviderType","SearchType"],"sources":["types.ts"],"sourcesContent":["export interface LookupDetailOptions {\n id: string;\n}\n\n// eslint-disable-next-line no-shadow\nexport enum EntityProviderType {\n CI_USER = 'CI_USER',\n CI_MACHINE = 'CI_MACHINE',\n CONTACTS = 'CONTACTS',\n CSDM = 'CSDM',\n}\n\nexport interface LookupOptions {\n ids: string[];\n entityProviderType?: EntityProviderType;\n}\n\nexport interface LookupByEmailOptions {\n emails: string[];\n}\n\n// eslint-disable-next-line no-shadow\nexport enum SearchType {\n PERSON = 'PERSON',\n CALLING_SERVICE = 'CALLING_SERVICE',\n EXTERNAL_CALLING = 'EXTERNAL_CALLING',\n ROOM = 'ROOM',\n ROBOT = 'ROBOT',\n}\n\nexport interface SearchOptions {\n requestedTypes: SearchType[];\n resultSize: number;\n queryString: string;\n}\n"],"mappings":";;;;;;;;;AAIA;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/internal-plugin-dss",
3
- "version": "3.0.0-beta.13",
3
+ "version": "3.0.0-beta.15",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "Colin Read <coread@cisco.com>",
@@ -21,14 +21,14 @@
21
21
  ]
22
22
  },
23
23
  "dependencies": {
24
- "@webex/internal-plugin-mercury": "3.0.0-beta.13",
25
- "@webex/webex-core": "3.0.0-beta.13",
24
+ "@webex/internal-plugin-mercury": "3.0.0-beta.15",
25
+ "@webex/webex-core": "3.0.0-beta.15",
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.13",
31
- "@webex/test-helper-chai": "3.0.0-beta.13",
32
- "@webex/test-helper-mock-webex": "3.0.0-beta.13"
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"
33
33
  }
34
34
  }
package/src/dss.ts CHANGED
@@ -6,7 +6,12 @@ import uuid from 'uuid';
6
6
  import {WebexPlugin} from '@webex/webex-core';
7
7
  import '@webex/internal-plugin-mercury';
8
8
  import {range, isEqual, get} from 'lodash';
9
- import type {SearchOptions, LookupDetailOptions, LookupOptions, LookupByEmailOptions} from './types';
9
+ import type {
10
+ SearchOptions,
11
+ LookupDetailOptions,
12
+ LookupOptions,
13
+ LookupByEmailOptions,
14
+ } from './types';
10
15
 
11
16
  import {
12
17
  DSS_REGISTERED,
@@ -48,7 +53,8 @@ const DSS = WebexPlugin.extend({
48
53
  return Promise.resolve();
49
54
  }
50
55
 
51
- return this.webex.internal.mercury.connect()
56
+ return this.webex.internal.mercury
57
+ .connect()
52
58
  .then(() => {
53
59
  this.listenForEvents();
54
60
  this.trigger(DSS_REGISTERED);
@@ -76,11 +82,10 @@ const DSS = WebexPlugin.extend({
76
82
 
77
83
  this.stopListeningForEvents();
78
84
 
79
- return this.webex.internal.mercury.disconnect()
80
- .then(() => {
81
- this.trigger(DSS_UNREGISTERED);
82
- this.registered = false;
83
- });
85
+ return this.webex.internal.mercury.disconnect().then(() => {
86
+ this.trigger(DSS_UNREGISTERED);
87
+ this.registered = false;
88
+ });
84
89
  },
85
90
 
86
91
  /**
@@ -125,13 +130,13 @@ const DSS = WebexPlugin.extend({
125
130
  },
126
131
 
127
132
  /**
128
- * Makes the request to the directory service
129
- * @param {Object} options
130
- * @param {string} options.resource the URL to query
131
- * @param {string} options.params additional params for the body of the request
132
- * @param {string} options.dataPath to path to get the data in the result object
133
- * @returns {Promise} Resolves with an array of entities found
134
- */
133
+ * Makes the request to the directory service
134
+ * @param {Object} options
135
+ * @param {string} options.resource the URL to query
136
+ * @param {string} options.params additional params for the body of the request
137
+ * @param {string} options.dataPath to path to get the data in the result object
138
+ * @returns {Promise} Resolves with an array of entities found
139
+ */
135
140
  _request(options) {
136
141
  const {resource, params, dataPath} = options;
137
142
 
@@ -159,7 +164,7 @@ const DSS = WebexPlugin.extend({
159
164
  if (seqResult) {
160
165
  resultArray.push(...seqResult);
161
166
  }
162
- })
167
+ });
163
168
 
164
169
  resolve(resultArray);
165
170
  this.stopListening(this, eventName);
@@ -170,7 +175,7 @@ const DSS = WebexPlugin.extend({
170
175
  resource,
171
176
  method: 'POST',
172
177
  contentType: 'application/json',
173
- body: {requestId, ...params}
178
+ body: {requestId, ...params},
174
179
  });
175
180
  });
176
181
  },
@@ -186,7 +191,7 @@ const DSS = WebexPlugin.extend({
186
191
 
187
192
  return this._request({
188
193
  dataPath: 'lookupResult.entities',
189
- resource: `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`
194
+ resource: `/lookup/orgid/${this.webex.internal.device.orgId}/identity/${id}/detail`,
190
195
  });
191
196
  },
192
197
 
@@ -200,14 +205,16 @@ const DSS = WebexPlugin.extend({
200
205
  lookup(options: LookupOptions) {
201
206
  const {ids, entityProviderType} = options;
202
207
 
203
- const resource = entityProviderType ? `/lookup/orgid/${this.webex.internal.device.orgId}/entityprovidertype/${entityProviderType}` : `/lookup/orgid/${this.webex.internal.device.orgId}/identities`;
208
+ const resource = entityProviderType
209
+ ? `/lookup/orgid/${this.webex.internal.device.orgId}/entityprovidertype/${entityProviderType}`
210
+ : `/lookup/orgid/${this.webex.internal.device.orgId}/identities`;
204
211
 
205
212
  return this._request({
206
213
  dataPath: 'lookupResult.entities',
207
214
  resource,
208
215
  params: {
209
216
  lookupValues: ids,
210
- }
217
+ },
211
218
  });
212
219
  },
213
220
 
@@ -225,7 +232,7 @@ const DSS = WebexPlugin.extend({
225
232
  resource: `/lookup/orgid/${this.webex.internal.device.orgId}/emails`,
226
233
  params: {
227
234
  lookupValues: emails,
228
- }
235
+ },
229
236
  });
230
237
  },
231
238
 
@@ -238,9 +245,7 @@ const DSS = WebexPlugin.extend({
238
245
  * @returns {Promise} Resolves with an array of entities found
239
246
  */
240
247
  search(options: SearchOptions) {
241
- const {
242
- requestedTypes, resultSize, queryString
243
- } = options;
248
+ const {requestedTypes, resultSize, queryString} = options;
244
249
 
245
250
  return this._request({
246
251
  dataPath: 'directoryEntities',
@@ -248,11 +253,10 @@ const DSS = WebexPlugin.extend({
248
253
  params: {
249
254
  queryString,
250
255
  resultSize,
251
- requestedTypes
252
- }
256
+ requestedTypes,
257
+ },
253
258
  });
254
- }
255
-
259
+ },
256
260
  });
257
261
 
258
262
  export default DSS;
package/src/types.ts CHANGED
@@ -2,11 +2,12 @@ export interface LookupDetailOptions {
2
2
  id: string;
3
3
  }
4
4
 
5
+ // eslint-disable-next-line no-shadow
5
6
  export enum EntityProviderType {
6
7
  CI_USER = 'CI_USER',
7
- CI_MACHINE ='CI_MACHINE',
8
+ CI_MACHINE = 'CI_MACHINE',
8
9
  CONTACTS = 'CONTACTS',
9
- CSDM = 'CSDM'
10
+ CSDM = 'CSDM',
10
11
  }
11
12
 
12
13
  export interface LookupOptions {
@@ -18,16 +19,17 @@ export interface LookupByEmailOptions {
18
19
  emails: string[];
19
20
  }
20
21
 
22
+ // eslint-disable-next-line no-shadow
21
23
  export enum SearchType {
22
- PERSON = 'PERSON',
24
+ PERSON = 'PERSON',
23
25
  CALLING_SERVICE = 'CALLING_SERVICE',
24
26
  EXTERNAL_CALLING = 'EXTERNAL_CALLING',
25
27
  ROOM = 'ROOM',
26
- ROBOT = 'ROBOT'
28
+ ROBOT = 'ROBOT',
27
29
  }
28
30
 
29
31
  export interface SearchOptions {
30
- requestedTypes: SearchType[],
31
- resultSize: number,
32
- queryString: string,
32
+ requestedTypes: SearchType[];
33
+ resultSize: number;
34
+ queryString: string;
33
35
  }
@@ -2,16 +2,16 @@
2
2
  * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.
3
3
  */
4
4
 
5
- import { assert } from "@webex/test-helper-chai";
6
- import DSS from "@webex/internal-plugin-dss";
7
- import MockWebex from "@webex/test-helper-mock-webex";
8
- import sinon from "sinon";
9
- import { expect } from "chai";
10
- import { set } from "lodash";
11
- import uuid from "uuid";
12
-
13
- describe("plugin-dss", () => {
14
- describe("DSS", () => {
5
+ import {assert} from '@webex/test-helper-chai';
6
+ import DSS from '@webex/internal-plugin-dss';
7
+ import MockWebex from '@webex/test-helper-mock-webex';
8
+ import sinon from 'sinon';
9
+ import {expect} from 'chai';
10
+ import {set} from 'lodash';
11
+ import uuid from 'uuid';
12
+
13
+ describe('plugin-dss', () => {
14
+ describe('DSS', () => {
15
15
  let webex;
16
16
  let uuidStub;
17
17
  let mercuryCallbacks;
@@ -24,10 +24,10 @@ describe("plugin-dss", () => {
24
24
  },
25
25
  });
26
26
 
27
- uuidStub = sinon.stub(uuid, "v4").returns("randomid");
27
+ uuidStub = sinon.stub(uuid, 'v4').returns('randomid');
28
28
 
29
29
  webex.canAuthorize = true;
30
- webex.internal.device.orgId = "userOrgId";
30
+ webex.internal.device.orgId = 'userOrgId';
31
31
 
32
32
  mercuryCallbacks = {};
33
33
 
@@ -45,50 +45,50 @@ describe("plugin-dss", () => {
45
45
  uuidStub.restore();
46
46
  });
47
47
 
48
- describe("#register()", () => {
49
- it("registers correctly", async () => {
48
+ describe('#register()', () => {
49
+ it('registers correctly', async () => {
50
50
  await webex.internal.dss.register();
51
51
 
52
52
  assert.callCount(webex.internal.mercury.on, 2);
53
53
 
54
54
  const firstCallArgs = webex.internal.mercury.on.getCall(0).args;
55
- expect(firstCallArgs[0]).to.equal("event:directory.lookup");
56
- expect(firstCallArgs[1]).to.be.a("function");
55
+ expect(firstCallArgs[0]).to.equal('event:directory.lookup');
56
+ expect(firstCallArgs[1]).to.be.a('function');
57
57
 
58
58
  const secondCallArgs = webex.internal.mercury.on.getCall(1).args;
59
- expect(secondCallArgs[0]).to.equal("event:directory.search");
60
- expect(secondCallArgs[1]).to.be.a("function");
59
+ expect(secondCallArgs[0]).to.equal('event:directory.search');
60
+ expect(secondCallArgs[1]).to.be.a('function');
61
61
 
62
62
  assert.equal(webex.internal.dss.registered, true);
63
63
  });
64
64
 
65
- it("rejects when it cannot authorize", async () => {
65
+ it('rejects when it cannot authorize', async () => {
66
66
  webex.canAuthorize = false;
67
67
  await expect(webex.internal.dss.register()).to.be.rejectedWith(
68
68
  Error,
69
- "SDK cannot authorize"
69
+ 'SDK cannot authorize'
70
70
  );
71
71
  assert.equal(webex.internal.dss.registered, false);
72
72
  });
73
73
  });
74
74
 
75
- describe("#unregister()", () => {
76
- it("unregisters correctly", async () => {
75
+ describe('#unregister()', () => {
76
+ it('unregisters correctly', async () => {
77
77
  webex.internal.dss.registered = true;
78
78
  await webex.internal.dss.unregister();
79
79
 
80
80
  assert.callCount(webex.internal.mercury.off, 2);
81
81
 
82
82
  const firstCallArgs = webex.internal.mercury.off.getCall(0).args;
83
- expect(firstCallArgs[0]).to.equal("event:directory.lookup");
83
+ expect(firstCallArgs[0]).to.equal('event:directory.lookup');
84
84
 
85
85
  const secondCallArgs = webex.internal.mercury.off.getCall(1).args;
86
- expect(secondCallArgs[0]).to.equal("event:directory.search");
86
+ expect(secondCallArgs[0]).to.equal('event:directory.search');
87
87
 
88
88
  assert.equal(webex.internal.dss.registered, false);
89
89
  });
90
90
 
91
- it("handles unregister when it is not registered", async () => {
91
+ it('handles unregister when it is not registered', async () => {
92
92
  const result = await webex.internal.dss.unregister();
93
93
  await expect(result).equal(undefined);
94
94
  assert.equal(webex.internal.dss.registered, false);
@@ -104,34 +104,27 @@ describe("plugin-dss", () => {
104
104
  (data as any).finished = finished;
105
105
  }
106
106
  set(data, dataPath, [`data${sequence}`]);
107
- return { data };
107
+ return {data};
108
108
  };
109
109
 
110
- const testRequest = async ({
111
- method,
112
- resource,
113
- params,
114
- bodyParams,
115
- dataPath,
116
- event,
117
- }) => {
110
+ const testRequest = async ({method, resource, params, bodyParams, dataPath, event}) => {
118
111
  webex.request = sinon.stub();
119
112
 
120
113
  await webex.internal.dss.register();
121
114
 
122
115
  const promise = webex.internal.dss[method](params);
123
116
 
124
- const requestId = "randomid";
117
+ const requestId = 'randomid';
125
118
 
126
119
  expect(webex.request.getCall(0).args).to.deep.equal([
127
120
  {
128
- service: "directorySearch",
121
+ service: 'directorySearch',
129
122
  body: {
130
123
  requestId,
131
124
  ...bodyParams,
132
125
  },
133
- contentType: "application/json",
134
- method: "POST",
126
+ contentType: 'application/json',
127
+ method: 'POST',
135
128
  resource,
136
129
  },
137
130
  ]);
@@ -141,241 +134,225 @@ describe("plugin-dss", () => {
141
134
  mercuryCallbacks[event](createData(requestId, 0, false, dataPath));
142
135
 
143
136
  const result = await promise;
144
- expect(result).to.deep.equal(["data0", "data1", "data2"]);
137
+ expect(result).to.deep.equal(['data0', 'data1', 'data2']);
145
138
  };
146
139
 
147
- describe("#lookupDetail", () => {
148
- it("calls _request correctly", async () => {
149
- webex.internal.device.orgId = "userOrgId";
150
- webex.internal.dss._request = sinon
151
- .stub()
152
- .returns(Promise.resolve("some return value"));
140
+ describe('#lookupDetail', () => {
141
+ it('calls _request correctly', async () => {
142
+ webex.internal.device.orgId = 'userOrgId';
143
+ webex.internal.dss._request = sinon.stub().returns(Promise.resolve('some return value'));
153
144
 
154
- const result = await webex.internal.dss.lookupDetail({ id: "test id" });
145
+ const result = await webex.internal.dss.lookupDetail({id: 'test id'});
155
146
  expect(webex.internal.dss._request.getCall(0).args).to.deep.equal([
156
147
  {
157
- dataPath: "lookupResult.entities",
148
+ dataPath: 'lookupResult.entities',
158
149
  resource: '/lookup/orgid/userOrgId/identity/test id/detail',
159
150
  },
160
151
  ]);
161
- expect(result).to.equal("some return value");
152
+ expect(result).to.equal('some return value');
162
153
  });
163
154
 
164
- it("works correctly", async () => {
155
+ it('works correctly', async () => {
165
156
  await testRequest({
166
- method: "lookupDetail",
167
- dataPath: "lookupResult.entities",
168
- event: "event:directory.lookup",
157
+ method: 'lookupDetail',
158
+ dataPath: 'lookupResult.entities',
159
+ event: 'event:directory.lookup',
169
160
  resource: '/lookup/orgid/userOrgId/identity/test id/detail',
170
161
  params: {
171
- id: "test id",
162
+ id: 'test id',
172
163
  },
173
164
  bodyParams: {},
174
165
  });
175
166
  });
176
167
  });
177
168
 
178
- describe("#lookup", () => {
179
- it("calls _request correctly", async () => {
180
- webex.internal.device.orgId = "userOrgId";
181
- webex.internal.dss._request = sinon
182
- .stub()
183
- .returns(Promise.resolve("some return value"));
169
+ describe('#lookup', () => {
170
+ it('calls _request correctly', async () => {
171
+ webex.internal.device.orgId = 'userOrgId';
172
+ webex.internal.dss._request = sinon.stub().returns(Promise.resolve('some return value'));
184
173
 
185
- const result = await webex.internal.dss.lookup({ ids: ["id1", "id2"] });
174
+ const result = await webex.internal.dss.lookup({ids: ['id1', 'id2']});
186
175
  expect(webex.internal.dss._request.getCall(0).args).to.deep.equal([
187
176
  {
188
- dataPath: "lookupResult.entities",
177
+ dataPath: 'lookupResult.entities',
189
178
  resource: '/lookup/orgid/userOrgId/identities',
190
179
  params: {
191
- lookupValues: ["id1", "id2"],
180
+ lookupValues: ['id1', 'id2'],
192
181
  },
193
182
  },
194
183
  ]);
195
- expect(result).to.equal("some return value");
184
+ expect(result).to.equal('some return value');
196
185
  });
197
186
 
198
- it("calls _request correctly with entityProviderType", async () => {
199
- webex.internal.device.orgId = "userOrgId";
200
- webex.internal.dss._request = sinon
201
- .stub()
202
- .returns(Promise.resolve("some return value"));
187
+ it('calls _request correctly with entityProviderType', async () => {
188
+ webex.internal.device.orgId = 'userOrgId';
189
+ webex.internal.dss._request = sinon.stub().returns(Promise.resolve('some return value'));
203
190
 
204
- const result = await webex.internal.dss.lookup({ ids: ["id1", "id2"], entityProviderType: 'CI_USER' });
191
+ const result = await webex.internal.dss.lookup({
192
+ ids: ['id1', 'id2'],
193
+ entityProviderType: 'CI_USER',
194
+ });
205
195
  expect(webex.internal.dss._request.getCall(0).args).to.deep.equal([
206
196
  {
207
- dataPath: "lookupResult.entities",
197
+ dataPath: 'lookupResult.entities',
208
198
  resource: '/lookup/orgid/userOrgId/entityprovidertype/CI_USER',
209
199
  params: {
210
- lookupValues: ["id1", "id2"],
200
+ lookupValues: ['id1', 'id2'],
211
201
  },
212
202
  },
213
203
  ]);
214
- expect(result).to.equal("some return value");
204
+ expect(result).to.equal('some return value');
215
205
  });
216
206
 
217
- it("works correctly", async () => {
207
+ it('works correctly', async () => {
218
208
  await testRequest({
219
- method: "lookup",
220
- dataPath: "lookupResult.entities",
221
- event: "event:directory.lookup",
209
+ method: 'lookup',
210
+ dataPath: 'lookupResult.entities',
211
+ event: 'event:directory.lookup',
222
212
  resource: '/lookup/orgid/userOrgId/identities',
223
213
  params: {
224
- ids: ["id1", "id2"],
214
+ ids: ['id1', 'id2'],
225
215
  },
226
216
  bodyParams: {
227
- lookupValues: ["id1", "id2"],
217
+ lookupValues: ['id1', 'id2'],
228
218
  },
229
219
  });
230
220
  });
231
221
  });
232
222
 
233
- describe("#lookupByEmail", () => {
234
- it("calls _request correctly", async () => {
235
- webex.internal.device.orgId = "userOrgId";
236
- webex.internal.dss._request = sinon
237
- .stub()
238
- .returns(Promise.resolve("some return value"));
223
+ describe('#lookupByEmail', () => {
224
+ it('calls _request correctly', async () => {
225
+ webex.internal.device.orgId = 'userOrgId';
226
+ webex.internal.dss._request = sinon.stub().returns(Promise.resolve('some return value'));
239
227
 
240
228
  const result = await webex.internal.dss.lookupByEmail({
241
- emails: ["email1", "email2"],
229
+ emails: ['email1', 'email2'],
242
230
  });
243
231
  expect(webex.internal.dss._request.getCall(0).args).to.deep.equal([
244
232
  {
245
- dataPath: "lookupResult.entities",
233
+ dataPath: 'lookupResult.entities',
246
234
  resource: '/lookup/orgid/userOrgId/emails',
247
235
  params: {
248
- lookupValues: ["email1", "email2"],
236
+ lookupValues: ['email1', 'email2'],
249
237
  },
250
238
  },
251
239
  ]);
252
- expect(result).to.equal("some return value");
240
+ expect(result).to.equal('some return value');
253
241
  });
254
242
 
255
- it("works correctly", async () => {
243
+ it('works correctly', async () => {
256
244
  await testRequest({
257
- method: "lookupByEmail",
258
- dataPath: "lookupResult.entities",
259
- event: "event:directory.lookup",
245
+ method: 'lookupByEmail',
246
+ dataPath: 'lookupResult.entities',
247
+ event: 'event:directory.lookup',
260
248
  resource: '/lookup/orgid/userOrgId/emails',
261
249
  params: {
262
- emails: ["email1", "email2"],
250
+ emails: ['email1', 'email2'],
263
251
  },
264
252
  bodyParams: {
265
- lookupValues: ["email1", "email2"],
253
+ lookupValues: ['email1', 'email2'],
266
254
  },
267
255
  });
268
256
  });
269
257
  });
270
258
 
271
- describe("#search", () => {
272
- it("calls _request correctly", async () => {
273
- webex.internal.device.orgId = "userOrgId";
274
- webex.internal.dss._request = sinon
275
- .stub()
276
- .returns(Promise.resolve("some return value"));
259
+ describe('#search', () => {
260
+ it('calls _request correctly', async () => {
261
+ webex.internal.device.orgId = 'userOrgId';
262
+ webex.internal.dss._request = sinon.stub().returns(Promise.resolve('some return value'));
277
263
 
278
264
  const result = await webex.internal.dss.search({
279
- requestedTypes: ["PERSON", "ROBOT"],
265
+ requestedTypes: ['PERSON', 'ROBOT'],
280
266
  resultSize: 100,
281
- queryString: "query",
267
+ queryString: 'query',
282
268
  });
283
269
  expect(webex.internal.dss._request.getCall(0).args).to.deep.equal([
284
270
  {
285
- dataPath: "directoryEntities",
271
+ dataPath: 'directoryEntities',
286
272
  resource: '/search/orgid/userOrgId/entities',
287
273
  params: {
288
- queryString: "query",
274
+ queryString: 'query',
289
275
  resultSize: 100,
290
- requestedTypes: ["PERSON", "ROBOT"],
276
+ requestedTypes: ['PERSON', 'ROBOT'],
291
277
  },
292
278
  },
293
279
  ]);
294
- expect(result).to.equal("some return value");
280
+ expect(result).to.equal('some return value');
295
281
  });
296
282
 
297
- it("works correctly", async () => {
283
+ it('works correctly', async () => {
298
284
  await testRequest({
299
- method: "search",
300
- event: "event:directory.search",
301
- dataPath: "directoryEntities",
285
+ method: 'search',
286
+ event: 'event:directory.search',
287
+ dataPath: 'directoryEntities',
302
288
  resource: '/search/orgid/userOrgId/entities',
303
289
  params: {
304
- requestedTypes: ["PERSON", "ROBOT"],
290
+ requestedTypes: ['PERSON', 'ROBOT'],
305
291
  resultSize: 100,
306
- queryString: "query",
292
+ queryString: 'query',
307
293
  },
308
294
  bodyParams: {
309
- requestedTypes: ["PERSON", "ROBOT"],
295
+ requestedTypes: ['PERSON', 'ROBOT'],
310
296
  resultSize: 100,
311
- queryString: "query",
297
+ queryString: 'query',
312
298
  },
313
299
  });
314
300
  });
315
301
  });
316
302
 
317
- describe("#_request", () => {
318
- it("handles a request correctly", async () => {
303
+ describe('#_request', () => {
304
+ it('handles a request correctly', async () => {
319
305
  webex.request = sinon.stub();
320
- uuid.v4.returns("randomid");
306
+ uuid.v4.returns('randomid');
321
307
  const promise = webex.internal.dss._request({
322
- resource: "/search/orgid/userOrgId/entities",
323
- params: { some: "param" },
324
- dataPath: "a.b.c",
308
+ resource: '/search/orgid/userOrgId/entities',
309
+ params: {some: 'param'},
310
+ dataPath: 'a.b.c',
325
311
  });
326
312
 
327
313
  expect(webex.request.getCall(0).args).to.deep.equal([
328
314
  {
329
- service: "directorySearch",
315
+ service: 'directorySearch',
330
316
  body: {
331
- requestId: "randomid",
332
- some: "param",
317
+ requestId: 'randomid',
318
+ some: 'param',
333
319
  },
334
- contentType: "application/json",
335
- method: "POST",
336
- resource: "/search/orgid/userOrgId/entities",
320
+ contentType: 'application/json',
321
+ method: 'POST',
322
+ resource: '/search/orgid/userOrgId/entities',
337
323
  },
338
324
  ]);
339
325
 
340
- webex.internal.dss.trigger(
341
- webex.internal.dss._getResultEventName("randomid"),
342
- {
343
- sequence: 1,
344
- a: {
345
- b: {
346
- c: ["data1"],
347
- },
326
+ webex.internal.dss.trigger(webex.internal.dss._getResultEventName('randomid'), {
327
+ sequence: 1,
328
+ a: {
329
+ b: {
330
+ c: ['data1'],
348
331
  },
349
- }
350
- );
332
+ },
333
+ });
351
334
 
352
- webex.internal.dss.trigger(
353
- webex.internal.dss._getResultEventName("randomid"),
354
- {
355
- sequence: 2,
356
- finished: true,
357
- a: {
358
- b: {
359
- c: ["data2"],
360
- },
335
+ webex.internal.dss.trigger(webex.internal.dss._getResultEventName('randomid'), {
336
+ sequence: 2,
337
+ finished: true,
338
+ a: {
339
+ b: {
340
+ c: ['data2'],
361
341
  },
362
- }
363
- );
342
+ },
343
+ });
364
344
 
365
- webex.internal.dss.trigger(
366
- webex.internal.dss._getResultEventName("randomid"),
367
- {
368
- sequence: 0,
369
- a: {
370
- b: {
371
- c: ["data0"],
372
- },
345
+ webex.internal.dss.trigger(webex.internal.dss._getResultEventName('randomid'), {
346
+ sequence: 0,
347
+ a: {
348
+ b: {
349
+ c: ['data0'],
373
350
  },
374
- }
375
- );
351
+ },
352
+ });
376
353
 
377
354
  const result = await promise;
378
- expect(result).to.deep.equal(["data0", "data1", "data2"]);
355
+ expect(result).to.deep.equal(['data0', 'data1', 'data2']);
379
356
  });
380
357
  });
381
358
  });