@webex/internal-plugin-ediscovery 3.0.0-beta.9 → 3.0.0-bnr.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"names":["createOneFlightKey","reportId","options","key","String","offset","size","types","EDiscovery","WebexPlugin","extend","waitForValue","oneFlight","keyFactory","containerId","namespace","session","contentContainerCache","type","default","createReport","reportRequest","Error","config","defaultOptions","body","request","method","service","resource","timeout","timeoutMs","_handleReportRequestError","reason","errorCode","InvalidEmailAddressError","getErrorCode","invalidEmails","JSON","parse","message","length","invalidEmailAddressError","reject","logger","warn","error","getReport","getReports","qs","deleteReport","restartReport","getContent","_createRequestOptions","requestOptions","getContentContainer","reportUUID","res","_writeToContentContainerCache","getContentContainerByContainerId","has","get","statusCode","containers","set","container","clearCache","clear","_getReportIdFromUrl","reportUrl","uuids","match","_isUrl","string","test","isUrl","substring","lastIndexOf","url","getClientConfig","postAuditLog"],"sources":["ediscovery.js"],"sourcesContent":["/* eslint-disable prefer-template */\n/* eslint-disable no-useless-escape */\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nimport {waitForValue, WebexPlugin} from '@webex/webex-core';\nimport {oneFlight} from '@webex/common';\n\nimport {InvalidEmailAddressError} from './ediscovery-error';\n\n/**\n * Creates a unique oneflight key for a request from the reportId and options params\n * It is important that the offset params are included if present to ensure paged requests get back the correct data\n * @param {Object} reportId - A set of criteria for determining the focus of the search\n * @param {Object} options - optional parameters for this method\n * @returns {String} oneFlight key which is a composite of the request parameters\n */\nfunction createOneFlightKey(reportId, options) {\n let key = String(reportId);\n\n if (options) {\n if (options.offset) {\n key += String(options.offset);\n }\n if (options.size) {\n key += String(options.size);\n }\n if (options.types) {\n key += String(options.types);\n }\n }\n\n return key;\n}\n\n/**\n * @class EDiscovery is used by compliance officers to run compliance reports\n *\n */\nconst EDiscovery = WebexPlugin.extend({\n namespace: 'EDiscovery',\n\n session: {\n contentContainerCache: {\n type: 'object',\n default() {\n return new Map();\n }\n }\n },\n\n @waitForValue('@')\n /**\n * Creates a compliance report with a specific set of search parameters\n * @param {Object} reportRequest - A set of criteria for determining the focus of the search\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity>} Http response containing the new report record\n */\n async createReport(reportRequest, options) {\n if (!reportRequest) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n const body = reportRequest;\n\n try {\n return await this.request({\n method: 'POST',\n service: 'ediscovery',\n resource: 'reports',\n timeout: options.timeoutMs,\n body\n });\n }\n catch (reason) {\n return this._handleReportRequestError(reason);\n }\n },\n\n /**\n * Checks the error from createReport and ensures the appropriate error is sent to the client\n * @param {Error} reason - Error response thrown by the request to createReport\n * @returns {Promise<Error>} Promise rejection containing the error\n */\n _handleReportRequestError(reason) {\n if (reason.body.errorCode === InvalidEmailAddressError.getErrorCode()) {\n try {\n const invalidEmails = JSON.parse(reason.body.message);\n\n if (Array.isArray(invalidEmails) && invalidEmails.length) {\n const invalidEmailAddressError = new InvalidEmailAddressError(invalidEmails);\n\n return Promise.reject(invalidEmailAddressError);\n }\n\n this.logger.warn('InvalidEmailAddress error received but the list could not be parsed to the correct format.');\n }\n catch (error) {\n // assume syntax error and continue\n this.logger.error('InvalidEmailAddress error received but an error occured while parsing the emails.');\n }\n }\n\n return Promise.reject(reason);\n },\n\n @waitForValue('@')\n /**\n * Retrieves information relating to a specified report\n * @param {UUID} reportId - Id of the report being requested\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity<ReportRecord>>} Http response containing the specified report record\n */\n async getReport(reportId, options) {\n if (!reportId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'GET',\n service: 'ediscovery',\n resource: `reports/${reportId}`,\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n /**\n * Retrieves all the compliance officers reports\n * @param {Object} options - optional parameters for this method\n * @param {number} options.offset - start position from which to retrieve records\n * @param {number} options.size - the number of records to retrieve\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity<Array<ReportRecord>>>} Http Response containing a list of report records\n */\n async getReports(options) {\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'GET',\n service: 'ediscovery',\n resource: 'reports',\n qs: {offset: options.offset, size: options.size},\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n /**\n * Deletes a specified report\n * @param {UUID} reportId - Id of the report being requested for deletion\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity>} HttpResponse indicating if delete was successful\n */\n async deleteReport(reportId, options) {\n if (!reportId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'DELETE',\n service: 'ediscovery',\n resource: `reports/${reportId}`,\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n /**\n * Restarts a completed or cancelled report so that it begins again from scratch\n * @param {UUID} reportId - Id of the report being requested\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity<ReportRecord>>} Http response containing the report record\n */\n async restartReport(reportId, options) {\n if (!reportId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'PUT',\n service: 'ediscovery',\n resource: `reports/${reportId}`,\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n @oneFlight({keyFactory: (reportId, options) => createOneFlightKey(reportId, options)})\n /**\n * Retrieves content associated with a report\n * @param {UUID|string} reportId - UUID or url of the report which contains the content\n * @param {Object} options - optional parameters for this method\n * @param {number} options.offset - start position from which to retrieve records\n * @param {number} options.size - the number of records to retrieve\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity<[Activity]>>} Http response containing the activities\n */\n async getContent(reportId, options) {\n if (!reportId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n const [requestOptions] = this._createRequestOptions(reportId, '/contents');\n\n return this.request({\n method: 'GET',\n ...requestOptions,\n qs: {offset: options.offset, size: options.size},\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n @oneFlight({keyFactory: (reportId, options) => createOneFlightKey(reportId, options)})\n /**\n * Retrieves a list of content containers relevant to a specified report\n * @param {UUID|string} reportId - UUID or url of the report being requested\n * @param {Object} options - optional parameters for this method\n * @param {number} options.offset - start position from which to retrieve records\n * @param {number} options.size - the number of records to retrieve\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @param {Set<Object>} options.types - Set of ContentContainerTypes to be retrieved\n * @returns {Promise<ResponseEntity<ContentContainer>>} Http response containing the content containers\n */\n async getContentContainer(reportId, options) {\n if (!reportId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n const [requestOptions, reportUUID] = this._createRequestOptions(reportId, '/contents/container');\n\n const res = await this.request({\n method: 'GET',\n ...requestOptions,\n qs: {offset: options.offset, size: options.size},\n timeout: options.timeoutMs,\n types: options.types\n });\n\n await this._writeToContentContainerCache(reportUUID, res.body);\n\n return res;\n },\n\n @waitForValue('@')\n @oneFlight({keyFactory: (reportId, containerId) => String(reportId + containerId)})\n /**\n * Retrieves information for a specific content container relevant to a specified report\n * @param {UUID|string} reportId - UUID or url of the report being requested\n * @param {UUID} containerId - Id of the contenyt container being requested\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity<ContentContainer>>} Http response containing the specified content container\n */\n async getContentContainerByContainerId(reportId, containerId, options) {\n if (!reportId || !containerId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n const [requestOptions, reportUUID] = this._createRequestOptions(reportId, `/contents/container/${containerId}`);\n\n // If this content container has already been cached then it can be retrieved from there instead of making a network call to ediscovery\n if (this.contentContainerCache.has(reportUUID) && this.contentContainerCache.get(reportUUID).has(containerId)) {\n return {body: this.contentContainerCache.get(reportUUID).get(containerId), statusCode: 200};\n }\n\n this.logger.warn(`Cache miss for container ${containerId} in contentContainerCache`);\n\n const res = await this.request({\n method: 'GET',\n ...requestOptions,\n qs: {offset: options.offset, size: options.size},\n timeout: options.timeoutMs\n });\n\n await this._writeToContentContainerCache(reportUUID, [res.body]);\n\n return res;\n },\n\n /**\n * The results of a getContentContainer or getContentContainerByContainerId request are written to the contentContainerCache\n * since information for a container is likely to be accessed very frequently when decrypting activities\n * @param {UUID} reportId - Id of the report which contains the relevant content summary\n * @param {Array<Object>} containers - List of the container objects to be written to the cache\n * @returns {Promise} - Promise resolution indicating operation is complete\n */\n _writeToContentContainerCache(reportId, containers) {\n if (!reportId || !containers || !containers.length) {\n return;\n }\n\n if (!this.contentContainerCache.has(reportId)) {\n this.contentContainerCache.set(reportId, new Map());\n }\n\n for (const container of containers) {\n if (container && container.containerId) {\n try {\n this.contentContainerCache.get(reportId).set(container.containerId, container);\n }\n catch (error) {\n this.logger.error(`Error adding ${container.containerId} to contentContainerCache: ${error}`);\n }\n }\n else {\n this.logger.error('Error adding undefined container to contentContainerCache');\n }\n }\n },\n\n /**\n * Wipe the cache used by eDiscovery to store the space summaries and content containers.\n * Good practice to clear it down when finished with a report to save RAM.\n * @returns {undefined}\n */\n clearCache() {\n this.contentContainerCache.clear();\n },\n\n /**\n * Retrieves a uuid string from a report url\n * @param {String} reportUrl - full destination address (including report id parameter) for the http request being sent\n * e.g. 'http://ediscovery-intb.wbx2.com/ediscovery/api/v1/reports/3b10e625-2bd5-4efa-b866-58d6c93c505c'\n * @returns {String} - uuid of the report\n */\n _getReportIdFromUrl(reportUrl) {\n if (reportUrl) {\n const uuids = reportUrl.match(/[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/);\n\n if (uuids && uuids.length > 0) {\n return uuids[0];\n }\n }\n\n return '';\n },\n\n _isUrl(string) {\n // Regex found from `https://ihateregex.io/expr/url`\n return /https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&\\/\\/=]*)/g.test(string);\n },\n\n /**\n * Create the appropriate request options based on whether the reportId is a url or a uuid.\n * @param {UUID|string} reportId - May be either a url for the report or a uuid.\n * e.g. 'http://ediscovery-intb.wbx2.com/ediscovery/api/v1/reports/3b10e625-2bd5-4efa-b866-58d6c93c505c' or '3b10e625-2bd5-4efa-b866-58d6c93c505c'.\n * @param {String} resource - The resource on the remote server to request\n * @returns {[Options, uuid]} - The options to pass to `request` and the report uuid.\n */\n _createRequestOptions(reportId, resource) {\n let requestOptions;\n let reportUUID;\n const isUrl = this._isUrl(reportId);\n\n if (isUrl) {\n reportUUID = this._getReportIdFromUrl(reportId);\n\n if (!reportUUID) {\n throw Error('Report url does not contain a report id');\n }\n\n // Ensure the url is formatted to\n // https://ediscovery.intb1.ciscospark.com/ediscovery/api/v1/reports/16bf0d01-b1f7-483b-89a2-915144158fb9\n // index.js for example passes the url in as\n // https://ediscovery.intb1.ciscospark.com/ediscovery/api/v1/reports/16bf0d01-b1f7-483b-89a2-915144158fb9/contents\n const reportUrl = reportId.substring(0, reportId.lastIndexOf(reportUUID) + reportUUID.length);\n\n requestOptions = {\n url: reportUrl + resource\n };\n }\n else {\n requestOptions = {\n service: 'ediscovery',\n resource: `reports/${reportId}/${resource}`\n };\n reportUUID = reportId;\n }\n\n return [requestOptions, reportUUID];\n },\n\n @waitForValue('@')\n /**\n * Retrieves a config object from the service which can be used by the client for optimal performance, e.g. content page size\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<Config>} Http response containing the config object\n */\n async getClientConfig(options) {\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'GET',\n service: 'ediscovery',\n resource: 'reports/clientconfig',\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n /**\n * Submits an audit event to the eDiscovery service for admin use. Only expected to be used for\n * the getContentContainer API\n * @param {UUID} reportId - Id of the report to send an audit log for\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<Config>} Http response containing the config object\n */\n async postAuditLog(reportId, options) {\n if (!reportId) {\n throw Error('No report ID specified');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'POST',\n service: 'ediscovery',\n resource: `reports/${reportId}/audit/summary-download`,\n timeout: options.timeoutMs\n });\n }\n\n});\n\nexport default EDiscovery;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;AACA;;AAEA;;;;;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,kBAAT,CAA4BC,QAA5B,EAAsCC,OAAtC,EAA+C;EAC7C,IAAIC,GAAG,GAAGC,MAAM,CAACH,QAAD,CAAhB;;EAEA,IAAIC,OAAJ,EAAa;IACX,IAAIA,OAAO,CAACG,MAAZ,EAAoB;MAClBF,GAAG,IAAIC,MAAM,CAACF,OAAO,CAACG,MAAT,CAAb;IACD;;IACD,IAAIH,OAAO,CAACI,IAAZ,EAAkB;MAChBH,GAAG,IAAIC,MAAM,CAACF,OAAO,CAACI,IAAT,CAAb;IAC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28CAAnB;;gBAiaevB,U"}
1
+ {"version":3,"names":["createOneFlightKey","reportId","options","key","String","offset","size","types","EDiscovery","WebexPlugin","extend","waitForValue","oneFlight","keyFactory","containerId","namespace","session","contentContainerCache","type","default","createReport","reportRequest","Error","config","defaultOptions","body","request","method","service","resource","timeout","timeoutMs","_handleReportRequestError","reason","errorCode","InvalidEmailAddressError","getErrorCode","invalidEmails","JSON","parse","message","length","invalidEmailAddressError","reject","logger","warn","error","getReport","getReports","qs","deleteReport","restartReport","getContent","_createRequestOptions","requestOptions","getContentContainer","reportUUID","res","_writeToContentContainerCache","getContentContainerByContainerId","has","get","statusCode","containers","set","container","clearCache","clear","_getReportIdFromUrl","reportUrl","uuids","match","_isUrl","string","test","isUrl","substring","lastIndexOf","url","getClientConfig","postAuditLog"],"sources":["ediscovery.js"],"sourcesContent":["/* eslint-disable */\n\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nimport {waitForValue, WebexPlugin} from '@webex/webex-core';\nimport {oneFlight} from '@webex/common';\n\nimport {InvalidEmailAddressError} from './ediscovery-error';\n\n/**\n * Creates a unique oneflight key for a request from the reportId and options params\n * It is important that the offset params are included if present to ensure paged requests get back the correct data\n * @param {Object} reportId - A set of criteria for determining the focus of the search\n * @param {Object} options - optional parameters for this method\n * @returns {String} oneFlight key which is a composite of the request parameters\n */\nfunction createOneFlightKey(reportId, options) {\n let key = String(reportId);\n\n if (options) {\n if (options.offset) {\n key += String(options.offset);\n }\n if (options.size) {\n key += String(options.size);\n }\n if (options.types) {\n key += String(options.types);\n }\n }\n\n return key;\n}\n\n/**\n * @class EDiscovery is used by compliance officers to run compliance reports\n *\n */\nconst EDiscovery = WebexPlugin.extend({\n namespace: 'EDiscovery',\n\n session: {\n contentContainerCache: {\n type: 'object',\n default() {\n return new Map();\n }\n }\n },\n\n @waitForValue('@')\n /**\n * Creates a compliance report with a specific set of search parameters\n * @param {Object} reportRequest - A set of criteria for determining the focus of the search\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity>} Http response containing the new report record\n */\n async createReport(reportRequest, options) {\n if (!reportRequest) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n const body = reportRequest;\n\n try {\n return await this.request({\n method: 'POST',\n service: 'ediscovery',\n resource: 'reports',\n timeout: options.timeoutMs,\n body\n });\n }\n catch (reason) {\n return this._handleReportRequestError(reason);\n }\n },\n\n /**\n * Checks the error from createReport and ensures the appropriate error is sent to the client\n * @param {Error} reason - Error response thrown by the request to createReport\n * @returns {Promise<Error>} Promise rejection containing the error\n */\n _handleReportRequestError(reason) {\n if (reason.body.errorCode === InvalidEmailAddressError.getErrorCode()) {\n try {\n const invalidEmails = JSON.parse(reason.body.message);\n\n if (Array.isArray(invalidEmails) && invalidEmails.length) {\n const invalidEmailAddressError = new InvalidEmailAddressError(invalidEmails);\n\n return Promise.reject(invalidEmailAddressError);\n }\n\n this.logger.warn('InvalidEmailAddress error received but the list could not be parsed to the correct format.');\n }\n catch (error) {\n // assume syntax error and continue\n this.logger.error('InvalidEmailAddress error received but an error occured while parsing the emails.');\n }\n }\n\n return Promise.reject(reason);\n },\n\n @waitForValue('@')\n /**\n * Retrieves information relating to a specified report\n * @param {UUID} reportId - Id of the report being requested\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity<ReportRecord>>} Http response containing the specified report record\n */\n async getReport(reportId, options) {\n if (!reportId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'GET',\n service: 'ediscovery',\n resource: `reports/${reportId}`,\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n /**\n * Retrieves all the compliance officers reports\n * @param {Object} options - optional parameters for this method\n * @param {number} options.offset - start position from which to retrieve records\n * @param {number} options.size - the number of records to retrieve\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity<Array<ReportRecord>>>} Http Response containing a list of report records\n */\n async getReports(options) {\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'GET',\n service: 'ediscovery',\n resource: 'reports',\n qs: {offset: options.offset, size: options.size},\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n /**\n * Deletes a specified report\n * @param {UUID} reportId - Id of the report being requested for deletion\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity>} HttpResponse indicating if delete was successful\n */\n async deleteReport(reportId, options) {\n if (!reportId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'DELETE',\n service: 'ediscovery',\n resource: `reports/${reportId}`,\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n /**\n * Restarts a completed or cancelled report so that it begins again from scratch\n * @param {UUID} reportId - Id of the report being requested\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity<ReportRecord>>} Http response containing the report record\n */\n async restartReport(reportId, options) {\n if (!reportId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'PUT',\n service: 'ediscovery',\n resource: `reports/${reportId}`,\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n @oneFlight({keyFactory: (reportId, options) => createOneFlightKey(reportId, options)})\n /**\n * Retrieves content associated with a report\n * @param {UUID|string} reportId - UUID or url of the report which contains the content\n * @param {Object} options - optional parameters for this method\n * @param {number} options.offset - start position from which to retrieve records\n * @param {number} options.size - the number of records to retrieve\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity<[Activity]>>} Http response containing the activities\n */\n async getContent(reportId, options) {\n if (!reportId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n const [requestOptions] = this._createRequestOptions(reportId, '/contents');\n\n return this.request({\n method: 'GET',\n ...requestOptions,\n qs: {offset: options.offset, size: options.size},\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n @oneFlight({keyFactory: (reportId, options) => createOneFlightKey(reportId, options)})\n /**\n * Retrieves a list of content containers relevant to a specified report\n * @param {UUID|string} reportId - UUID or url of the report being requested\n * @param {Object} options - optional parameters for this method\n * @param {number} options.offset - start position from which to retrieve records\n * @param {number} options.size - the number of records to retrieve\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @param {Set<Object>} options.types - Set of ContentContainerTypes to be retrieved\n * @returns {Promise<ResponseEntity<ContentContainer>>} Http response containing the content containers\n */\n async getContentContainer(reportId, options) {\n if (!reportId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n const [requestOptions, reportUUID] = this._createRequestOptions(reportId, '/contents/container');\n\n const res = await this.request({\n method: 'GET',\n ...requestOptions,\n qs: {offset: options.offset, size: options.size},\n timeout: options.timeoutMs,\n types: options.types\n });\n\n await this._writeToContentContainerCache(reportUUID, res.body);\n\n return res;\n },\n\n @waitForValue('@')\n @oneFlight({keyFactory: (reportId, containerId) => String(reportId + containerId)})\n /**\n * Retrieves information for a specific content container relevant to a specified report\n * @param {UUID|string} reportId - UUID or url of the report being requested\n * @param {UUID} containerId - Id of the contenyt container being requested\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<ResponseEntity<ContentContainer>>} Http response containing the specified content container\n */\n async getContentContainerByContainerId(reportId, containerId, options) {\n if (!reportId || !containerId) {\n throw Error('Undefined parameter');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n const [requestOptions, reportUUID] = this._createRequestOptions(reportId, `/contents/container/${containerId}`);\n\n // If this content container has already been cached then it can be retrieved from there instead of making a network call to ediscovery\n if (this.contentContainerCache.has(reportUUID) && this.contentContainerCache.get(reportUUID).has(containerId)) {\n return {body: this.contentContainerCache.get(reportUUID).get(containerId), statusCode: 200};\n }\n\n this.logger.warn(`Cache miss for container ${containerId} in contentContainerCache`);\n\n const res = await this.request({\n method: 'GET',\n ...requestOptions,\n qs: {offset: options.offset, size: options.size},\n timeout: options.timeoutMs\n });\n\n await this._writeToContentContainerCache(reportUUID, [res.body]);\n\n return res;\n },\n\n /**\n * The results of a getContentContainer or getContentContainerByContainerId request are written to the contentContainerCache\n * since information for a container is likely to be accessed very frequently when decrypting activities\n * @param {UUID} reportId - Id of the report which contains the relevant content summary\n * @param {Array<Object>} containers - List of the container objects to be written to the cache\n * @returns {Promise} - Promise resolution indicating operation is complete\n */\n _writeToContentContainerCache(reportId, containers) {\n if (!reportId || !containers || !containers.length) {\n return;\n }\n\n if (!this.contentContainerCache.has(reportId)) {\n this.contentContainerCache.set(reportId, new Map());\n }\n\n for (const container of containers) {\n if (container && container.containerId) {\n try {\n this.contentContainerCache.get(reportId).set(container.containerId, container);\n }\n catch (error) {\n this.logger.error(`Error adding ${container.containerId} to contentContainerCache: ${error}`);\n }\n }\n else {\n this.logger.error('Error adding undefined container to contentContainerCache');\n }\n }\n },\n\n /**\n * Wipe the cache used by eDiscovery to store the space summaries and content containers.\n * Good practice to clear it down when finished with a report to save RAM.\n * @returns {undefined}\n */\n clearCache() {\n this.contentContainerCache.clear();\n },\n\n /**\n * Retrieves a uuid string from a report url\n * @param {String} reportUrl - full destination address (including report id parameter) for the http request being sent\n * e.g. 'http://ediscovery-intb.wbx2.com/ediscovery/api/v1/reports/3b10e625-2bd5-4efa-b866-58d6c93c505c'\n * @returns {String} - uuid of the report\n */\n _getReportIdFromUrl(reportUrl) {\n if (reportUrl) {\n const uuids = reportUrl.match(/[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/);\n\n if (uuids && uuids.length > 0) {\n return uuids[0];\n }\n }\n\n return '';\n },\n\n _isUrl(string) {\n // Regex found from `https://ihateregex.io/expr/url`\n return /https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&\\/\\/=]*)/g.test(string);\n },\n\n /**\n * Create the appropriate request options based on whether the reportId is a url or a uuid.\n * @param {UUID|string} reportId - May be either a url for the report or a uuid.\n * e.g. 'http://ediscovery-intb.wbx2.com/ediscovery/api/v1/reports/3b10e625-2bd5-4efa-b866-58d6c93c505c' or '3b10e625-2bd5-4efa-b866-58d6c93c505c'.\n * @param {String} resource - The resource on the remote server to request\n * @returns {[Options, uuid]} - The options to pass to `request` and the report uuid.\n */\n _createRequestOptions(reportId, resource) {\n let requestOptions;\n let reportUUID;\n const isUrl = this._isUrl(reportId);\n\n if (isUrl) {\n reportUUID = this._getReportIdFromUrl(reportId);\n\n if (!reportUUID) {\n throw Error('Report url does not contain a report id');\n }\n\n // Ensure the url is formatted to\n // https://ediscovery.intb1.ciscospark.com/ediscovery/api/v1/reports/16bf0d01-b1f7-483b-89a2-915144158fb9\n // index.js for example passes the url in as\n // https://ediscovery.intb1.ciscospark.com/ediscovery/api/v1/reports/16bf0d01-b1f7-483b-89a2-915144158fb9/contents\n const reportUrl = reportId.substring(0, reportId.lastIndexOf(reportUUID) + reportUUID.length);\n\n requestOptions = {\n url: reportUrl + resource\n };\n }\n else {\n requestOptions = {\n service: 'ediscovery',\n resource: `reports/${reportId}/${resource}`\n };\n reportUUID = reportId;\n }\n\n return [requestOptions, reportUUID];\n },\n\n @waitForValue('@')\n /**\n * Retrieves a config object from the service which can be used by the client for optimal performance, e.g. content page size\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<Config>} Http response containing the config object\n */\n async getClientConfig(options) {\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'GET',\n service: 'ediscovery',\n resource: 'reports/clientconfig',\n timeout: options.timeoutMs\n });\n },\n\n @waitForValue('@')\n /**\n * Submits an audit event to the eDiscovery service for admin use. Only expected to be used for\n * the getContentContainer API\n * @param {UUID} reportId - Id of the report to send an audit log for\n * @param {Object} options - optional parameters for this method\n * @param {number} options.timeoutMs - connection timeout in milliseconds, defaults to 30s\n * @returns {Promise<Config>} Http response containing the config object\n */\n async postAuditLog(reportId, options) {\n if (!reportId) {\n throw Error('No report ID specified');\n }\n\n // use spread operator to set default options\n options = {...this.config.defaultOptions, ...options};\n\n return this.request({\n method: 'POST',\n service: 'ediscovery',\n resource: `reports/${reportId}/audit/summary-download`,\n timeout: options.timeoutMs\n });\n }\n\n});\n\nexport default EDiscovery;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;AACA;AAEA;AAA4D;AAAA;AAAA;AAAA;AAAA;AAAA;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,kBAAkB,CAACC,QAAQ,EAAEC,OAAO,EAAE;EAC7C,IAAIC,GAAG,GAAGC,MAAM,CAACH,QAAQ,CAAC;EAE1B,IAAIC,OAAO,EAAE;IACX,IAAIA,OAAO,CAACG,MAAM,EAAE;MAClBF,GAAG,IAAIC,MAAM,CAACF,OAAO,CAACG,MAAM,CAAC;IAC/B;IACA,IAAIH,OAAO,CAACI,IAAI,EAAE;MAChBH,GAAG,IAAIC,MAAM,CAACF,OAAO,CAACI,IAAI,CAAC;IAC7B;IACA,IAAIJ,OAAO,CAACK,KAAK,EAAE;MACjBJ,GAAG,IAAIC,MAAM,CAACF,OAAO,CAACK,KAAK,CAAC;IAC9B;EACF;EAEA,OAAOJ,GAAG;AACZ;;AAEA;AACA;AACA;AACA;AACA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,KAAK,CAAC,wBAAwB,CAAC;UAAA;YAGvC;YACApB,OAAO,mCAAO,OAAI,CAACqB,MAAM,CAACC,cAAc,GAAKtB,OAAO,CAAC;YAAC,mCAE/C,OAAI,CAACwB,OAAO,CAAC;cAClBC,MAAM,EAAE,MAAM;cACdC,OAAO,EAAE,YAAY;cACrBC,QAAQ,oBAAa5B,QAAQ,4BAAyB;cACtD6B,OAAO,EAAE5B,OAAO,CAAC6B;YACnB,CAAC,CAAC;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EACJ,CAAC;EAAA;AAEH,CAAC,28CAAC;AAAC,gBAEYvB,UAAU;AAAA"}
package/dist/index.js CHANGED
@@ -1,76 +1,55 @@
1
1
  "use strict";
2
2
 
3
3
  var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
4
-
5
4
  var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
6
-
7
5
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
8
-
9
6
  var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
10
-
11
7
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
12
-
13
8
  _Object$defineProperty(exports, "__esModule", {
14
9
  value: true
15
10
  });
16
-
17
11
  _Object$defineProperty(exports, "EdiscoveryError", {
18
12
  enumerable: true,
19
13
  get: function get() {
20
14
  return _ediscoveryError.EdiscoveryError;
21
15
  }
22
16
  });
23
-
24
17
  _Object$defineProperty(exports, "InvalidEmailAddressError", {
25
18
  enumerable: true,
26
19
  get: function get() {
27
20
  return _ediscoveryError.InvalidEmailAddressError;
28
21
  }
29
22
  });
30
-
31
23
  _Object$defineProperty(exports, "ReportRequest", {
32
24
  enumerable: true,
33
25
  get: function get() {
34
26
  return _reportRequest.default;
35
27
  }
36
28
  });
37
-
38
29
  _Object$defineProperty(exports, "config", {
39
30
  enumerable: true,
40
31
  get: function get() {
41
32
  return _config.config;
42
33
  }
43
34
  });
44
-
45
35
  exports.default = void 0;
46
-
47
36
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
48
-
49
37
  var _has2 = _interopRequireDefault(require("lodash/has"));
50
-
51
38
  require("@webex/internal-plugin-encryption");
52
-
53
39
  require("@webex/internal-plugin-conversation");
54
-
55
40
  var _webexCore = require("@webex/webex-core");
56
-
57
41
  var _ediscovery = _interopRequireDefault(require("./ediscovery"));
58
-
59
42
  var _transforms = _interopRequireDefault(require("./transforms"));
60
-
61
43
  var _config = _interopRequireWildcard(require("./config"));
62
-
63
44
  var _reportRequest = _interopRequireDefault(require("./report-request"));
64
-
65
45
  var _ediscoveryError = require("./ediscovery-error");
66
-
67
46
  function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
68
-
69
47
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
70
-
71
48
  /*!
72
49
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
73
50
  */
51
+ /* eslint-disable */
52
+
74
53
  (0, _webexCore.registerInternalPlugin)('ediscovery', _ediscovery.default, {
75
54
  config: _config.default,
76
55
  payloadTransformer: {
@@ -151,7 +130,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
151
130
  if (!object || !object.body) {
152
131
  return _promise.default.resolve();
153
132
  }
154
-
155
133
  return _promise.default.all(object.body.map(function (item) {
156
134
  return ctx.transform('decryptReportRequest', {
157
135
  body: item
@@ -176,9 +154,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
176
154
  fn: function fn(ctx, object) {
177
155
  if (!object || !object.body) {
178
156
  return _promise.default.resolve();
179
- } // Always use the report url as this'll resolve correctly for remote reports
180
-
157
+ }
181
158
 
159
+ // Always use the report url as this'll resolve correctly for remote reports
182
160
  return _promise.default.all(object.body.map(function (item) {
183
161
  return ctx.transform('decryptReportContent', {
184
162
  body: item
@@ -198,7 +176,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
198
176
  if (!object || !object.body) {
199
177
  return _promise.default.resolve();
200
178
  }
201
-
202
179
  return _promise.default.all(object.body.map(function (item) {
203
180
  return ctx.transform('decryptReportContentContainer', {
204
181
  body: item
@@ -209,6 +186,5 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
209
186
  }
210
187
  });
211
188
  var _default = _ediscovery.default; // eslint-disable-next-line import/named
212
-
213
189
  exports.default = _default;
214
190
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["registerInternalPlugin","EDiscovery","config","payloadTransformer","predicates","name","direction","test","ctx","object","resolve","extract","transforms","fn","Transforms","decryptReportRequest","body","all","map","item","transform","encryptReportRequest","reportId","decryptReportContent","options","uri","decryptReportContentContainer"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport '@webex/internal-plugin-encryption';\nimport '@webex/internal-plugin-conversation';\n\nimport {registerInternalPlugin} from '@webex/webex-core';\nimport {has} from 'lodash';\n\nimport EDiscovery from './ediscovery';\nimport Transforms from './transforms';\nimport config from './config';\n\nregisterInternalPlugin('ediscovery', EDiscovery, {\n config,\n payloadTransformer: {\n predicates: [\n {\n name: 'decryptReportRequest',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body.reportRequest'));\n },\n extract(object) {\n return Promise.resolve(object);\n }\n },\n {\n name: 'decryptReportRequestArray',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body[0].reportRequest'));\n },\n extract(object) {\n return Promise.resolve(object);\n }\n },\n {\n name: 'encryptReportRequest',\n direction: 'outbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body.keywords') || has(object, 'body.spaceNames') || has(object, 'body.emails'));\n },\n extract(object) {\n return Promise.resolve(object);\n }\n },\n {\n name: 'decryptReportContent',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body.activityId'));\n },\n extract(object) {\n return Promise.resolve(object);\n }\n },\n {\n name: 'decryptReportContentArray',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body[0].activityId'));\n },\n extract(object) {\n return Promise.resolve(object);\n }\n },\n {\n name: 'decryptReportContentContainer',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body.containerId'));\n },\n extract(object) {\n return Promise.resolve(object);\n }\n },\n {\n name: 'decryptReportContentContainerArray',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body[0].containerId'));\n },\n extract(object) {\n return Promise.resolve(object);\n }\n }\n ],\n transforms: [\n {\n name: 'decryptReportRequest',\n direction: 'inbound',\n fn(ctx, object) {\n return Transforms.decryptReportRequest(ctx, object);\n }\n },\n {\n name: 'decryptReportRequestArray',\n direction: 'inbound',\n fn(ctx, object) {\n if (!object || !object.body) {\n return Promise.resolve();\n }\n\n return Promise.all(object.body.map((item) => ctx.transform('decryptReportRequest', {body: item})));\n }\n },\n {\n name: 'encryptReportRequest',\n direction: 'outbound',\n fn(ctx, object) {\n return Transforms.encryptReportRequest(ctx, object);\n }\n },\n {\n name: 'decryptReportContent',\n direction: 'inbound',\n fn(ctx, object, reportId) {\n return Transforms.decryptReportContent(ctx, object, reportId);\n }\n },\n {\n name: 'decryptReportContentArray',\n direction: 'inbound',\n fn(ctx, object) {\n if (!object || !object.body) {\n return Promise.resolve();\n }\n\n // Always use the report url as this'll resolve correctly for remote reports\n return Promise.all(object.body.map((item) => ctx.transform('decryptReportContent', {body: item}, object.options.uri)));\n }\n },\n {\n name: 'decryptReportContentContainer',\n direction: 'inbound',\n fn(ctx, object) {\n return Transforms.decryptReportContentContainer(ctx, object);\n }\n },\n {\n name: 'decryptReportContentContainerArray',\n direction: 'inbound',\n fn(ctx, object) {\n if (!object || !object.body) {\n return Promise.resolve();\n }\n\n return Promise.all(object.body.map((item) => ctx.transform('decryptReportContentContainer', {body: item})));\n }\n }\n ]\n }\n});\n\nexport default EDiscovery;\n\n// eslint-disable-next-line import/named\nexport {config} from './config';\nexport {default as ReportRequest} from './report-request';\nexport {EdiscoveryError, InvalidEmailAddressError} from './ediscovery-error';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;AAEA;;AAGA;;AACA;;AACA;;AAoJA;;AACA;;;;;;AAjKA;AACA;AACA;AAYA,IAAAA,iCAAA,EAAuB,YAAvB,EAAqCC,mBAArC,EAAiD;EAC/CC,MAAM,EAANA,eAD+C;EAE/CC,kBAAkB,EAAE;IAClBC,UAAU,EAAE,CACV;MACEC,IAAI,EAAE,sBADR;MAEEC,SAAS,EAAE,SAFb;MAGEC,IAHF,gBAGOC,GAHP,EAGYC,MAHZ,EAGoB;QAChB,OAAO,iBAAQC,OAAR,CAAgB,mBAAID,MAAJ,EAAY,oBAAZ,CAAhB,CAAP;MACD,CALH;MAMEE,OANF,mBAMUF,MANV,EAMkB;QACd,OAAO,iBAAQC,OAAR,CAAgBD,MAAhB,CAAP;MACD;I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,EAA6B;UAC3B,OAAO,iBAAQN,OAAR,EAAP;QACD;;QAED,OAAO,iBAAQO,GAAR,CAAYR,MAAM,CAACO,IAAP,CAAYE,GAAZ,CAAgB,UAACC,IAAD;UAAA,OAAUX,GAAG,CAACY,SAAJ,CAAc,+BAAd,EAA+C;YAACJ,IAAI,EAAEG;UAAP,CAA/C,CAAV;QAAA,CAAhB,CAAZ,CAAP;MACD;IATH,CApDU;EAzEM;AAF2B,CAAjD;eA8IelB,mB,EAEf"}
1
+ {"version":3,"names":["registerInternalPlugin","EDiscovery","config","payloadTransformer","predicates","name","direction","test","ctx","object","resolve","extract","transforms","fn","Transforms","decryptReportRequest","body","all","map","item","transform","encryptReportRequest","reportId","decryptReportContent","options","uri","decryptReportContentContainer"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n/* eslint-disable */\n\nimport '@webex/internal-plugin-encryption';\nimport '@webex/internal-plugin-conversation';\n\nimport {registerInternalPlugin} from '@webex/webex-core';\nimport {has} from 'lodash';\n\nimport EDiscovery from './ediscovery';\nimport Transforms from './transforms';\nimport config from './config';\n\nregisterInternalPlugin('ediscovery', EDiscovery, {\n config,\n payloadTransformer: {\n predicates: [\n {\n name: 'decryptReportRequest',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body.reportRequest'));\n },\n extract(object) {\n return Promise.resolve(object);\n },\n },\n {\n name: 'decryptReportRequestArray',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body[0].reportRequest'));\n },\n extract(object) {\n return Promise.resolve(object);\n },\n },\n {\n name: 'encryptReportRequest',\n direction: 'outbound',\n test(ctx, object) {\n return Promise.resolve(\n has(object, 'body.keywords') ||\n has(object, 'body.spaceNames') ||\n has(object, 'body.emails')\n );\n },\n extract(object) {\n return Promise.resolve(object);\n },\n },\n {\n name: 'decryptReportContent',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body.activityId'));\n },\n extract(object) {\n return Promise.resolve(object);\n },\n },\n {\n name: 'decryptReportContentArray',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body[0].activityId'));\n },\n extract(object) {\n return Promise.resolve(object);\n },\n },\n {\n name: 'decryptReportContentContainer',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body.containerId'));\n },\n extract(object) {\n return Promise.resolve(object);\n },\n },\n {\n name: 'decryptReportContentContainerArray',\n direction: 'inbound',\n test(ctx, object) {\n return Promise.resolve(has(object, 'body[0].containerId'));\n },\n extract(object) {\n return Promise.resolve(object);\n },\n },\n ],\n transforms: [\n {\n name: 'decryptReportRequest',\n direction: 'inbound',\n fn(ctx, object) {\n return Transforms.decryptReportRequest(ctx, object);\n },\n },\n {\n name: 'decryptReportRequestArray',\n direction: 'inbound',\n fn(ctx, object) {\n if (!object || !object.body) {\n return Promise.resolve();\n }\n\n return Promise.all(\n object.body.map((item) => ctx.transform('decryptReportRequest', {body: item}))\n );\n },\n },\n {\n name: 'encryptReportRequest',\n direction: 'outbound',\n fn(ctx, object) {\n return Transforms.encryptReportRequest(ctx, object);\n },\n },\n {\n name: 'decryptReportContent',\n direction: 'inbound',\n fn(ctx, object, reportId) {\n return Transforms.decryptReportContent(ctx, object, reportId);\n },\n },\n {\n name: 'decryptReportContentArray',\n direction: 'inbound',\n fn(ctx, object) {\n if (!object || !object.body) {\n return Promise.resolve();\n }\n\n // Always use the report url as this'll resolve correctly for remote reports\n return Promise.all(\n object.body.map((item) =>\n ctx.transform('decryptReportContent', {body: item}, object.options.uri)\n )\n );\n },\n },\n {\n name: 'decryptReportContentContainer',\n direction: 'inbound',\n fn(ctx, object) {\n return Transforms.decryptReportContentContainer(ctx, object);\n },\n },\n {\n name: 'decryptReportContentContainerArray',\n direction: 'inbound',\n fn(ctx, object) {\n if (!object || !object.body) {\n return Promise.resolve();\n }\n\n return Promise.all(\n object.body.map((item) => ctx.transform('decryptReportContentContainer', {body: item}))\n );\n },\n },\n ],\n },\n});\n\nexport default EDiscovery;\n\n// eslint-disable-next-line import/named\nexport {config} from './config';\nexport {default as ReportRequest} from './report-request';\nexport {EdiscoveryError, InvalidEmailAddressError} from './ediscovery-error';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;AACA;AAEA;AAGA;AACA;AACA;AAgKA;AACA;AAA6E;AAAA;AA9K7E;AACA;AACA;AACA;;AAYA,IAAAA,iCAAsB,EAAC,YAAY,EAAEC,mBAAU,EAAE;EAC/CC,MAAM,EAANA,eAAM;EACNC,kBAAkB,EAAE;IAClBC,UAAU,EAAE,CACV;MACEC,IAAI,EAAE,sBAAsB;MAC5BC,SAAS,EAAE,SAAS;MACpBC,IAAI,gBAACC,GAAG,EAAEC,MAAM,EAAE;QAChB,OAAO,iBAAQC,OAAO,CAAC,mBAAID,MAAM,EAAE,oBAAoB,CAAC,CAAC;MAC3D,CAAC;MACDE,OAAO,mBAACF,MAAM,EAAE;QACd,OAAO,iBAAQC,OAAO,CAACD,MAAM,CAAC;MAChC;IACF,CAAC,EACD;MACEJ,IAAI,EAAE,2BAA2B;MACjCC,SAAS,EAAE,SAAS;MACpBC,IAAI,gBAACC,GAAG,EAAEC,MAAM,EAAE;QAChB,OAAO,iBAAQC,OAAO,CAAC,mBAAID,MAAM,EAAE,uBAAuB,CAAC,CAAC;MAC9D,CAAC;MACDE,OAAO,mBAACF,MAAM,EAAE;QACd,OAAO,iBAAQC,OAAO,CAACD,MAAM,CAAC;MAChC;IACF,CAAC,EACD;MACEJ,IAAI,EAAE,sBAAsB;MAC5BC,SAAS,EAAE,UAAU;MACrBC,IAAI,gBAACC,GAAG,EAAEC,MAAM,EAAE;QAChB,OAAO,iBAAQC,OAAO,CACpB,mBAAID,MAAM,EAAE,eAAe,CAAC,IAC1B,mBAAIA,MAAM,EAAE,iBAAiB,CAAC,IAC9B,mBAAIA,MAAM,EAAE,aAAa,CAAC,CAC7B;MACH,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GAAG,CAChBR,MAAM,CAACO,IAAI,CAACE,GAAG,CAAC,UAACC,IAAI;UAAA,OACnBX,GAAG,CAACY,SAAS,CAAC,sBAAsB,EAAE;YAACJ,IAAI,EAAEG;UAAI,CAAC,EAAEV,MAAM,CAACe,OAAO,CAACC,GAAG,CAAC;QAAA,EACxE,CACF;MACH;IACF,CAAC,EACD;MACEpB,IAAI,EAAE,+BAA+B;MACrCC,SAAS,EAAE,SAAS;MACpBO,EAAE,cAACL,GAAG,EAAEC,MAAM,EAAE;QACd,OAAOK,mBAAU,CAACY,6BAA6B,CAAClB,GAAG,EAAEC,MAAM,CAAC;MAC9D;IACF,CAAC,EACD;MACEJ,IAAI,EAAE,oCAAoC;MAC1CC,SAAS,EAAE,SAAS;MACpBO,EAAE,cAACL,GAAG,EAAEC,MAAM,EAAE;QACd,IAAI,CAACA,MAAM,IAAI,CAACA,MAAM,CAACO,IAAI,EAAE;UAC3B,OAAO,iBAAQN,OAAO,EAAE;QAC1B;QAEA,OAAO,iBAAQO,GAAG,CAChBR,MAAM,CAACO,IAAI,CAACE,GAAG,CAAC,UAACC,IAAI;UAAA,OAAKX,GAAG,CAACY,SAAS,CAAC,+BAA+B,EAAE;YAACJ,IAAI,EAAEG;UAAI,CAAC,CAAC;QAAA,EAAC,CACxF;MACH;IACF,CAAC;EAEL;AACF,CAAC,CAAC;AAAC,eAEYlB,mBAAU,EAEzB;AAAA"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @class EDiscovery is used by compliance officers to run compliance reports
3
+ *
4
+ */
5
+ declare const EDiscovery: any;
6
+ export default EDiscovery;
7
+
8
+ /**
9
+ * General ediscovery error
10
+ */
11
+ export declare class EdiscoveryError {
12
+ }
13
+
14
+ /**
15
+ * InvalidEmailAddressError is thrown when an email address has been supplied as a parameter and cannot be found in CI
16
+ */
17
+ export declare class InvalidEmailAddressError extends EdiscoveryError {
18
+ static getErrorCode(): number;
19
+ }
20
+
21
+ /**
22
+ * Creates a report request object with a specific set of search parameters
23
+ * @param {String} name - A label to identify the report
24
+ * @param {String} description - A textual summary of the reports purpose
25
+ * @param {Array<String>} emails - A list of user emails relevant to the report
26
+ * @param {Array<String>} userIds - A list of UUIDs relevant to the report
27
+ * @param {Array<String>} keywords - A list of search terms relevant to the report
28
+ * @param {Array<String>} spaceNames - A list of space names relevant to the report
29
+ * @param {Object} range - Contains the start time and end time defining the search period
30
+ * @returns {Object} ReportRequest - Contains all search parameters
31
+ */
32
+ export declare class ReportRequest {
33
+ constructor(name?: string, description?: string, emails?: any[], userIds?: any[], keywords?: any[], encryptionKeyUrl?: string, spaceNames?: any[], range?: {
34
+ startTime: string;
35
+ endTime: string;
36
+ });
37
+ name: string;
38
+ description: string;
39
+ emails: any[];
40
+ userIds: any[];
41
+ keywords: any[];
42
+ encryptionKeyUrl: string;
43
+ spaceNames: any[];
44
+ range: {
45
+ startTime: string;
46
+ endTime: string;
47
+ };
48
+ }
49
+
50
+ export { }
@@ -1,19 +1,13 @@
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
  exports.default = void 0;
12
-
13
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
14
-
15
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
16
-
17
11
  /**
18
12
  * Creates a report request object with a specific set of search parameters
19
13
  * @param {String} name - A label to identify the report
@@ -1 +1 @@
1
- {"version":3,"names":["ReportRequest","name","description","emails","userIds","keywords","encryptionKeyUrl","spaceNames","range","startTime","endTime"],"sources":["report-request.js"],"sourcesContent":["/**\n * Creates a report request object with a specific set of search parameters\n * @param {String} name - A label to identify the report\n * @param {String} description - A textual summary of the reports purpose\n * @param {Array<String>} emails - A list of user emails relevant to the report\n * @param {Array<String>} userIds - A list of UUIDs relevant to the report\n * @param {Array<String>} keywords - A list of search terms relevant to the report\n * @param {Array<String>} spaceNames - A list of space names relevant to the report\n * @param {Object} range - Contains the start time and end time defining the search period\n * @returns {Object} ReportRequest - Contains all search parameters\n */\nclass ReportRequest {\n constructor(name = '', description = '', emails = [], userIds = [], keywords = [], encryptionKeyUrl = '', spaceNames = [], range = {startTime: '2020-01-01T00:00:00', endTime: '2020-01-01T23:59:59'}) {\n this.name = name;\n this.description = description;\n this.emails = emails;\n this.userIds = userIds;\n this.keywords = keywords;\n this.encryptionKeyUrl = encryptionKeyUrl;\n this.spaceNames = spaceNames;\n this.range = range;\n }\n}\n\nexport default ReportRequest;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACMA,a,2CACJ,yBAAuM;EAAA,IAA3LC,IAA2L,uEAApL,EAAoL;EAAA,IAAhLC,WAAgL,uEAAlK,EAAkK;EAAA,IAA9JC,MAA8J,uEAArJ,EAAqJ;EAAA,IAAjJC,OAAiJ,uEAAvI,EAAuI;EAAA,IAAnIC,QAAmI,uEAAxH,EAAwH;EAAA,IAApHC,gBAAoH,uEAAjG,EAAiG;EAAA,IAA7FC,UAA6F,uEAAhF,EAAgF;EAAA,IAA5EC,KAA4E,uEAApE;IAACC,SAAS,EAAE,qBAAZ;IAAmCC,OAAO,EAAE;EAA5C,CAAoE;EAAA;EACrM,KAAKT,IAAL,GAAYA,IAAZ;EACA,KAAKC,WAAL,GAAmBA,WAAnB;EACA,KAAKC,MAAL,GAAcA,MAAd;EACA,KAAKC,OAAL,GAAeA,OAAf;EACA,KAAKC,QAAL,GAAgBA,QAAhB;EACA,KAAKC,gBAAL,GAAwBA,gBAAxB;EACA,KAAKC,UAAL,GAAkBA,UAAlB;EACA,KAAKC,KAAL,GAAaA,KAAb;AACD,C;eAGYR,a"}
1
+ {"version":3,"names":["ReportRequest","name","description","emails","userIds","keywords","encryptionKeyUrl","spaceNames","range","startTime","endTime"],"sources":["report-request.js"],"sourcesContent":["/**\n * Creates a report request object with a specific set of search parameters\n * @param {String} name - A label to identify the report\n * @param {String} description - A textual summary of the reports purpose\n * @param {Array<String>} emails - A list of user emails relevant to the report\n * @param {Array<String>} userIds - A list of UUIDs relevant to the report\n * @param {Array<String>} keywords - A list of search terms relevant to the report\n * @param {Array<String>} spaceNames - A list of space names relevant to the report\n * @param {Object} range - Contains the start time and end time defining the search period\n * @returns {Object} ReportRequest - Contains all search parameters\n */\nclass ReportRequest {\n constructor(\n name = '',\n description = '',\n emails = [],\n userIds = [],\n keywords = [],\n encryptionKeyUrl = '',\n spaceNames = [],\n range = {startTime: '2020-01-01T00:00:00', endTime: '2020-01-01T23:59:59'}\n ) {\n this.name = name;\n this.description = description;\n this.emails = emails;\n this.userIds = userIds;\n this.keywords = keywords;\n this.encryptionKeyUrl = encryptionKeyUrl;\n this.spaceNames = spaceNames;\n this.range = range;\n }\n}\n\nexport default ReportRequest;\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVA,IAWMA,aAAa,2CACjB,yBASE;EAAA,IARAC,IAAI,uEAAG,EAAE;EAAA,IACTC,WAAW,uEAAG,EAAE;EAAA,IAChBC,MAAM,uEAAG,EAAE;EAAA,IACXC,OAAO,uEAAG,EAAE;EAAA,IACZC,QAAQ,uEAAG,EAAE;EAAA,IACbC,gBAAgB,uEAAG,EAAE;EAAA,IACrBC,UAAU,uEAAG,EAAE;EAAA,IACfC,KAAK,uEAAG;IAACC,SAAS,EAAE,qBAAqB;IAAEC,OAAO,EAAE;EAAqB,CAAC;EAAA;EAE1E,IAAI,CAACT,IAAI,GAAGA,IAAI;EAChB,IAAI,CAACC,WAAW,GAAGA,WAAW;EAC9B,IAAI,CAACC,MAAM,GAAGA,MAAM;EACpB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACtB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;EACxB,IAAI,CAACC,gBAAgB,GAAGA,gBAAgB;EACxC,IAAI,CAACC,UAAU,GAAGA,UAAU;EAC5B,IAAI,CAACC,KAAK,GAAGA,KAAK;AACpB,CAAC;AAAA,eAGYR,aAAa;AAAA"}
package/dist/retry.js CHANGED
@@ -1,75 +1,59 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
-
5
4
  var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
6
-
7
5
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
8
-
9
6
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
10
-
11
7
  var retryErrors = [429, 502, 503, 504];
12
-
13
8
  function requestWithRetries(_x, _x2, _x3) {
14
9
  return _requestWithRetries.apply(this, arguments);
15
10
  }
16
-
17
11
  function _requestWithRetries() {
18
12
  _requestWithRetries = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(ctx, func, args) {
19
13
  var retryCount,
20
- retryIntervalInSeconds,
21
- maxRetries,
22
- _args = arguments;
14
+ retryIntervalInSeconds,
15
+ maxRetries,
16
+ _args = arguments;
23
17
  return _regenerator.default.wrap(function _callee$(_context) {
24
- while (1) {
25
- switch (_context.prev = _context.next) {
26
- case 0:
27
- retryCount = _args.length > 3 && _args[3] !== undefined ? _args[3] : 0;
28
- retryIntervalInSeconds = _args.length > 4 && _args[4] !== undefined ? _args[4] : 0;
29
- maxRetries = _args.length > 5 && _args[5] !== undefined ? _args[5] : 3;
30
- _context.next = 5;
31
- return timeout(retryIntervalInSeconds);
32
-
33
- case 5:
34
- return _context.abrupt("return", func.apply(ctx, args).catch(function (reason) {
35
- if (retryErrors.includes(reason.statusCode) && retryCount < maxRetries) {
36
- retryCount += 1;
37
-
38
- var _retryIntervalInSeconds = Math.pow(retryCount + 1, 2); // 4, 9 and 16 second delays as default
39
-
40
-
41
- if (reason.headers && reason.headers['retry-after']) {
42
- _retryIntervalInSeconds = reason.headers['retry-after'];
43
- }
44
-
45
- console.error("Request #".concat(retryCount, " error: ").concat(reason.statusCode, ". Attempting retry #").concat(retryCount, " in ").concat(_retryIntervalInSeconds, " seconds"));
46
- return requestWithRetries(ctx, func, args, retryCount, _retryIntervalInSeconds, maxRetries);
18
+ while (1) switch (_context.prev = _context.next) {
19
+ case 0:
20
+ retryCount = _args.length > 3 && _args[3] !== undefined ? _args[3] : 0;
21
+ retryIntervalInSeconds = _args.length > 4 && _args[4] !== undefined ? _args[4] : 0;
22
+ maxRetries = _args.length > 5 && _args[5] !== undefined ? _args[5] : 3;
23
+ _context.next = 5;
24
+ return timeout(retryIntervalInSeconds);
25
+ case 5:
26
+ return _context.abrupt("return", func.apply(ctx, args).catch(function (reason) {
27
+ if (retryErrors.includes(reason.statusCode) && retryCount < maxRetries) {
28
+ retryCount += 1;
29
+ // eslint-disable-next-line no-shadow
30
+ var _retryIntervalInSeconds = Math.pow(retryCount + 1, 2); // 4, 9 and 16 second delays as default
31
+
32
+ if (reason.headers && reason.headers['retry-after']) {
33
+ _retryIntervalInSeconds = reason.headers['retry-after'];
47
34
  }
48
-
49
- return _promise.default.reject(reason);
50
- }));
51
-
52
- case 6:
53
- case "end":
54
- return _context.stop();
55
- }
35
+ console.error("Request #".concat(retryCount, " error: ").concat(reason.statusCode, ". Attempting retry #").concat(retryCount, " in ").concat(_retryIntervalInSeconds, " seconds"));
36
+ return requestWithRetries(ctx, func, args, retryCount, _retryIntervalInSeconds, maxRetries);
37
+ }
38
+ return _promise.default.reject(reason);
39
+ }));
40
+ case 6:
41
+ case "end":
42
+ return _context.stop();
56
43
  }
57
44
  }, _callee);
58
45
  }));
59
46
  return _requestWithRetries.apply(this, arguments);
60
47
  }
61
-
62
48
  function timeout(sec) {
63
49
  // return immediately if timeout is zero or undefined
64
50
  if (!sec) {
65
51
  return _promise.default.resolve();
66
52
  }
67
-
68
53
  return new _promise.default(function (resolve) {
69
54
  return setTimeout(resolve, sec * 1000);
70
55
  });
71
56
  }
72
-
73
57
  module.exports.requestWithRetries = requestWithRetries;
74
58
  module.exports.timeout = timeout;
75
59
  //# sourceMappingURL=retry.js.map
package/dist/retry.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["retryErrors","requestWithRetries","ctx","func","args","retryCount","retryIntervalInSeconds","maxRetries","timeout","apply","catch","reason","includes","statusCode","headers","console","error","reject","sec","resolve","setTimeout","module","exports"],"sources":["retry.js"],"sourcesContent":["const retryErrors = [429, 502, 503, 504];\n\nasync function requestWithRetries(ctx, func, args, retryCount = 0, retryIntervalInSeconds = 0, maxRetries = 3) {\n await timeout(retryIntervalInSeconds);\n\n return func.apply(ctx, args)\n .catch((reason) => {\n if (retryErrors.includes(reason.statusCode) && retryCount < maxRetries) {\n retryCount += 1;\n let retryIntervalInSeconds = (retryCount + 1) ** 2; // 4, 9 and 16 second delays as default\n\n if (reason.headers && reason.headers['retry-after']) {\n retryIntervalInSeconds = reason.headers['retry-after'];\n }\n console.error(`Request #${retryCount} error: ${reason.statusCode}. Attempting retry #${retryCount} in ${retryIntervalInSeconds} seconds`);\n\n return requestWithRetries(ctx, func, args, retryCount, retryIntervalInSeconds, maxRetries);\n }\n\n return Promise.reject(reason);\n });\n}\n\nfunction timeout(sec) {\n // return immediately if timeout is zero or undefined\n if (!sec) {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => setTimeout(resolve, sec * 1000));\n}\n\nmodule.exports.requestWithRetries = requestWithRetries;\nmodule.exports.timeout = timeout;\n"],"mappings":";;;;;;;;;;AAAA,IAAMA,WAAW,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgB,GAAhB,CAApB;;SAEeC,kB;;;;;gGAAf,iBAAkCC,GAAlC,EAAuCC,IAAvC,EAA6CC,IAA7C;IAAA;IAAA;IAAA;IAAA;IAAA;MAAA;QAAA;UAAA;YAAmDC,UAA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M,CAACC,OAAP,CAAed,OAAf,GAAyBA,OAAzB"}
1
+ {"version":3,"names":["retryErrors","requestWithRetries","ctx","func","args","retryCount","retryIntervalInSeconds","maxRetries","timeout","apply","catch","reason","includes","statusCode","headers","console","error","reject","sec","resolve","setTimeout","module","exports"],"sources":["retry.js"],"sourcesContent":["const retryErrors = [429, 502, 503, 504];\n\nasync function requestWithRetries(\n ctx,\n func,\n args,\n retryCount = 0,\n retryIntervalInSeconds = 0,\n maxRetries = 3\n) {\n await timeout(retryIntervalInSeconds);\n\n return func.apply(ctx, args).catch((reason) => {\n if (retryErrors.includes(reason.statusCode) && retryCount < maxRetries) {\n retryCount += 1;\n // eslint-disable-next-line no-shadow\n let retryIntervalInSeconds = (retryCount + 1) ** 2; // 4, 9 and 16 second delays as default\n\n if (reason.headers && reason.headers['retry-after']) {\n retryIntervalInSeconds = reason.headers['retry-after'];\n }\n console.error(\n `Request #${retryCount} error: ${reason.statusCode}. Attempting retry #${retryCount} in ${retryIntervalInSeconds} seconds`\n );\n\n return requestWithRetries(ctx, func, args, retryCount, retryIntervalInSeconds, maxRetries);\n }\n\n return Promise.reject(reason);\n });\n}\n\nfunction timeout(sec) {\n // return immediately if timeout is zero or undefined\n if (!sec) {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => setTimeout(resolve, sec * 1000));\n}\n\nmodule.exports.requestWithRetries = requestWithRetries;\nmodule.exports.timeout = timeout;\n"],"mappings":";;;;;;AAAA,IAAMA,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAAC,SAE1BC,kBAAkB;EAAA;AAAA;AAAA;EAAA,8FAAjC,iBACEC,GAAG,EACHC,IAAI,EACJC,IAAI;IAAA;MAAA;MAAA;MAAA;IAAA;MAAA;QAAA;UACJC,UAAU,2DAAG,CAAC;UACdC,sBAAsB,2DAAG,CAAC;UAC1BC,UAAU,2DAAG,CAAC;UAAA;UAAA,OAERC,OAAO,CAACF,sBAAsB,CAAC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