@webex/internal-plugin-dss 3.0.0-beta.42 → 3.0.0-beta.420

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;AAQqB;AAAA;AAErB,IAAMA,GAAG,GAAGC,sBAAW,CAACC,MAAM,CAAC;EAC7BC,SAAS,EAAE,KAAK;EAEhB;AACF;AACA;AACA;AACA;AACA;EACEC,UAAU,EAAE,KAAK;EAEjB;AACF;AACA;AACA;AACA;AACA;EACEC,QAAQ,sBAAG;IAAA;IACT,IAAI,CAAC,IAAI,CAACC,KAAK,CAACC,YAAY,EAAE;MAC5B,IAAI,CAACC,MAAM,CAACC,KAAK,CAAC,+DAA+D,CAAC;MAElF,OAAO,iBAAQC,MAAM,CAAC,IAAIC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1D;IAEA,IAAI,IAAI,CAACP,UAAU,EAAE;MACnB,IAAI,CAACI,MAAM,CAACI,IAAI,CAAC,mDAAmD,CAAC;MAErE,OAAO,iBAAQC,OAAO,EAAE;IAC1B;IAEA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U;QACVD,cAAc,EAAdA;MACF;IACF,CAAC,CAAC;EACJ,CAAC;EAAA;AACH,CAAC,CAAC;AAAC,eAEY9E,GAAG;AAAA"}
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","timeout","config","requestTimeout","uuid","v4","eventName","result","expectedSeqNums","notFoundArray","timer","Timer","stopListening","DssTimeoutError","listenTo","reset","resultData","found","sequence","finished","map","String","done","cancel","resultArray","foundArray","forEach","index","seqResult","push","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","lookup","entityProviderType","shouldBatch","lookupByEmail","email","search","requestedTypes","resultSize","queryString","SEARCH_DATA_PATH","searchPlaces","isOnlySchedulableRooms"],"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 * @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 {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 /**\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;AACA;AACA;AAGA;AAQA;AAcA;AACA;AAA6C;AAAA;AAG7C,IAAMA,GAAG,GAAGC,sBAAW,CAACC,MAAM,CAAC;EAC7BC,SA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mB,IAAI,CAAClC,KAAK,CAACQ,QAAQ,CAACiF,MAAM,CAACC,KAAK,cAAW;MACtEvD,MAAM,EAAE;QACNgE,WAAW,EAAXA,WAAW;QACXD,UAAU,EAAVA,UAAU;QACVD,cAAc,EAAdA;MACF;IACF,CAAC,CAAC,CAACtF,IAAI,CAAC;MAAA,IAAEmD,WAAW,SAAXA,WAAW;MAAA,OAAMA,WAAW;IAAA,EAAC;EACzC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACEuC,YAAY,wBAACpE,OAA2B,EAAE;IAAA;IACxC,IAAOiE,UAAU,GAAyCjE,OAAO,CAA1DiE,UAAU;MAAEC,WAAW,GAA4BlE,OAAO,CAA9CkE,WAAW;MAAEG,sBAAsB,GAAIrE,OAAO,CAAjCqE,sBAAsB;IAEtD,OAAO,IAAI,CAACtE,QAAQ,CAAC;MACnBI,QAAQ,EAAE,mBAAmB;MAC7BF,QAAQ,0BAAmB,IAAI,CAAClC,KAAK,CAACQ,QAAQ,CAACiF,MAAM,CAACC,KAAK,YAAS;MACpEvD,MAAM,EAAE;QACNgE,WAAW,EAAXA,WAAW;QACXD,UAAU,EAAVA,UAAU;QACVI,sBAAsB,EAAtBA;MACF;IACF,CAAC,CAAC,CAACvF,KAAK,CAAC,UAACZ,KAAK,EAAK;MAClB,MAAI,CAACD,MAAM,CAACC,KAAK,0DAAmDA,KAAK,CAACa,OAAO,EAAG;MAEpF,OAAO,iBAAQZ,MAAM,CAACD,KAAK,CAAC;IAC9B,CAAC,CAAC;EACJ,CAAC;EAAA;AACH,CAAC,CAAC;AAAC,eAEYb,GAAG;AAAA"}
package/dist/index.js CHANGED
@@ -13,5 +13,8 @@ _Object$defineProperty(exports, "default", {
13
13
  });
14
14
  var _webexCore = require("@webex/webex-core");
15
15
  var _dss = _interopRequireDefault(require("./dss"));
16
- (0, _webexCore.registerInternalPlugin)('dss', _dss.default);
16
+ var _config = _interopRequireDefault(require("./config"));
17
+ (0, _webexCore.registerInternalPlugin)('dss', _dss.default, {
18
+ config: _config.default
19
+ });
17
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,iCAAsB,EAAC,KAAK,EAAEC,YAAG,CAAC"}
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
@@ -5,7 +5,6 @@ _Object$defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.SearchType = exports.EntityProviderType = void 0;
8
- // eslint-disable-next-line no-shadow
9
8
  var EntityProviderType;
10
9
  exports.EntityProviderType = EntityProviderType;
11
10
  (function (EntityProviderType) {
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;AAAA,IACYA,kBAAkB;AAAA;AAAA,WAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;AAAA,GAAlBA,kBAAkB,kCAAlBA,kBAAkB;AAgB9B;AAAA,IACYC,UAAU;AAAA;AAAA,WAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;AAAA,GAAVA,UAAU,0BAAVA,UAAU"}
1
+ {"version":3,"names":["EntityProviderType","SearchType"],"sources":["types.ts"],"sourcesContent":["export interface RequestOptions {\n resource: string;\n dataPath: string;\n foundPath?: string;\n notFoundPath?: string;\n params?: Record<string, unknown>;\n}\n\nexport interface RequestResult {\n foundArray?: any[];\n notFoundArray?: any[];\n resultArray: any[];\n}\n\nexport 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 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\nexport interface BatcherOptions {\n resource: string;\n lookupValue: string;\n}\n\nexport interface SearchPlaceOptions {\n resultSize: number;\n queryString: string;\n isOnlySchedulableRooms: boolean;\n}\n"],"mappings":";;;;;;;IAkBYA,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.42",
3
+ "version": "3.0.0-beta.420",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "Colin Read <coread@cisco.com>",
@@ -21,14 +21,17 @@
21
21
  ]
22
22
  },
23
23
  "dependencies": {
24
- "@webex/internal-plugin-mercury": "3.0.0-beta.42",
25
- "@webex/webex-core": "3.0.0-beta.42",
24
+ "@webex/common": "3.0.0-beta.420",
25
+ "@webex/common-timers": "3.0.0-beta.420",
26
+ "@webex/internal-plugin-mercury": "3.0.0-beta.420",
27
+ "@webex/webex-core": "3.0.0-beta.420",
26
28
  "lodash": "^4.17.21",
27
29
  "uuid": "^3.3.2"
28
30
  },
29
31
  "devDependencies": {
30
- "@webex/internal-plugin-dss": "3.0.0-beta.42",
31
- "@webex/test-helper-chai": "3.0.0-beta.42",
32
- "@webex/test-helper-mock-webex": "3.0.0-beta.42"
32
+ "@webex/internal-plugin-dss": "3.0.0-beta.420",
33
+ "@webex/test-helper-chai": "3.0.0-beta.420",
34
+ "@webex/test-helper-mock-webex": "3.0.0-beta.420",
35
+ "sinon": "^9.2.4"
33
36
  }
34
37
  }
package/src/config.ts ADDED
@@ -0,0 +1,31 @@
1
+ /*!
2
+ * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ export default {
6
+ dss: {
7
+ /**
8
+ * Timeout before DSS request fails, in milliseconds.
9
+ * @type {Number}
10
+ */
11
+ requestTimeout: 6000,
12
+
13
+ /**
14
+ * Debounce wait (ms) before sending a dss request (gap between lookups that will trigger a request)
15
+ * @type {Number}
16
+ */
17
+ batcherWait: 50,
18
+
19
+ /**
20
+ * Maximum queue size before sending a dss request
21
+ * @type {Number}
22
+ */
23
+ batcherMaxCalls: 50,
24
+
25
+ /**
26
+ * Debounce max wait (ms) before sending a dss request (time from first lookup that will trigger a request)
27
+ * @type {Number}
28
+ */
29
+ batcherMaxWait: 150,
30
+ },
31
+ };
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: unknown) {
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;
@@ -0,0 +1,36 @@
1
+ import {Exception} from '@webex/common';
2
+ import {RequestOptions} from './types';
3
+
4
+ interface DssTimeoutErrorParams extends Required<Pick<RequestOptions, 'resource' | 'params'>> {
5
+ requestId: string;
6
+ timeout: number;
7
+ }
8
+
9
+ /**
10
+ * Thrown when an expected DSS respond is not received in a timely manner.
11
+ */
12
+ export class DssTimeoutError extends Exception {
13
+ /**
14
+ * Construct DssTimeoutError
15
+ * @param {DssTimeoutErrorParams} details
16
+ */
17
+ // eslint-disable-next-line no-useless-constructor
18
+ constructor(details: DssTimeoutErrorParams) {
19
+ super(details);
20
+ }
21
+
22
+ /**
23
+ * Parse Error details
24
+ *
25
+ * @param {DssTimeoutErrorParams} details
26
+ * @returns {string}
27
+ */
28
+ parse(details: DssTimeoutErrorParams) {
29
+ return (
30
+ `The DSS did not respond within ${details.timeout} ms.` +
31
+ `\n Request Id: ${details.requestId}` +
32
+ `\n Resource: ${details.resource}` +
33
+ `\n Params: ${JSON.stringify(details.params)}`
34
+ );
35
+ }
36
+ }