diff --git a/x-pack/plugins/reporting/export_types/common/execute_job/add_forcenow_querystring.js b/x-pack/plugins/reporting/export_types/common/execute_job/add_forcenow_querystring.js index dc0849de9d2301d..980831fcfce6efe 100644 --- a/x-pack/plugins/reporting/export_types/common/execute_job/add_forcenow_querystring.js +++ b/x-pack/plugins/reporting/export_types/common/execute_job/add_forcenow_querystring.js @@ -6,8 +6,8 @@ import url from 'url'; import { getAbsoluteUrlFactory } from './get_absolute_url'; -function getSavedObjectAbsoluteUrl(job, relativeUrl) { - const getAbsoluteUrl = getAbsoluteUrlFactory(job.server); +function getSavedObjectAbsoluteUrl(job, relativeUrl, server) { + const getAbsoluteUrl = getAbsoluteUrlFactory(server); if (relativeUrl) { const { pathname: path, hash, search } = url.parse(relativeUrl); @@ -17,13 +17,13 @@ function getSavedObjectAbsoluteUrl(job, relativeUrl) { throw new Error(`Unable to generate report. Url is not defined.`); } -export const addForceNowQuerystring = async ({ job, conditionalHeaders, logo, }) => { +export const addForceNowQuerystring = async ({ job, conditionalHeaders, logo, server }) => { //if no URLS then its from PNG which should only have one so put it in the array and process as PDF does if (!job.urls) { if (!job.relativeUrl) { throw new Error(`Unable to generate report. Url is not defined.`);} - job.urls = [getSavedObjectAbsoluteUrl(job, job.relativeUrl)]; + job.urls = [getSavedObjectAbsoluteUrl(job, job.relativeUrl, server)]; } const urls = job.urls.map(jobUrl => { @@ -48,6 +48,6 @@ export const addForceNowQuerystring = async ({ job, conditionalHeaders, logo, }); }); - return { job, conditionalHeaders, logo, urls }; + return { job, conditionalHeaders, logo, urls, server }; }; \ No newline at end of file diff --git a/x-pack/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.js b/x-pack/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.js index 9a8b724198c9d60..814afc323dc3fe8 100644 --- a/x-pack/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.js +++ b/x-pack/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.js @@ -5,8 +5,8 @@ */ import { cryptoFactory } from '../../../server/lib/crypto'; -export const decryptJobHeaders = async (job) => { - const crypto = cryptoFactory(job.server); +export const decryptJobHeaders = async ({ job, server }) => { + const crypto = cryptoFactory(server); const decryptedHeaders = await crypto.decrypt(job.headers); - return { job, decryptedHeaders }; + return { job, decryptedHeaders, server }; }; diff --git a/x-pack/plugins/reporting/export_types/common/execute_job/get_conditional_headers.js b/x-pack/plugins/reporting/export_types/common/execute_job/get_conditional_headers.js index db7bb6697592d21..e029499ebcdf663 100644 --- a/x-pack/plugins/reporting/export_types/common/execute_job/get_conditional_headers.js +++ b/x-pack/plugins/reporting/export_types/common/execute_job/get_conditional_headers.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -export const getConditionalHeaders = ({ job, filteredHeaders }) => { - const config = job.server.config(); +export const getConditionalHeaders = ({ job, filteredHeaders, server }) => { + const config = server.config(); const conditionalHeaders = { headers: filteredHeaders, @@ -13,9 +13,9 @@ export const getConditionalHeaders = ({ job, filteredHeaders }) => { hostname: config.get('xpack.reporting.kibanaServer.hostname') || config.get('server.host'), port: config.get('xpack.reporting.kibanaServer.port') || config.get('server.port'), basePath: config.get('server.basePath'), - protocol: config.get('xpack.reporting.kibanaServer.protocol') || job.server.info.protocol, + protocol: config.get('xpack.reporting.kibanaServer.protocol') || server.info.protocol, } }; - return { job, conditionalHeaders }; + return { job, conditionalHeaders, server }; }; \ No newline at end of file diff --git a/x-pack/plugins/reporting/export_types/common/execute_job/get_custom_logo.js b/x-pack/plugins/reporting/export_types/common/execute_job/get_custom_logo.js index 38cf1c6fb20ba23..16f3e86cf40e348 100644 --- a/x-pack/plugins/reporting/export_types/common/execute_job/get_custom_logo.js +++ b/x-pack/plugins/reporting/export_types/common/execute_job/get_custom_logo.js @@ -5,8 +5,8 @@ */ import { UI_SETTINGS_CUSTOM_PDF_LOGO } from '../../../common/constants'; -export const getCustomLogo = async ({ job, conditionalHeaders }) => { - const serverBasePath = job.server.config().get('server.basePath'); +export const getCustomLogo = async ({ job, conditionalHeaders, server }) => { + const serverBasePath = server.config().get('server.basePath'); const fakeRequest = { headers: conditionalHeaders.headers, @@ -16,14 +16,14 @@ export const getCustomLogo = async ({ job, conditionalHeaders }) => { getBasePath: () => job.basePath || serverBasePath }; - const savedObjects = job.server.savedObjects; + const savedObjects = server.savedObjects; const savedObjectsClient = savedObjects.getScopedSavedObjectsClient(fakeRequest); - const uiSettings = job.server.uiSettingsServiceFactory({ + const uiSettings = server.uiSettingsServiceFactory({ savedObjectsClient }); const logo = await uiSettings.get(UI_SETTINGS_CUSTOM_PDF_LOGO); - return { job, conditionalHeaders, logo }; + return { job, conditionalHeaders, logo, server }; }; \ No newline at end of file diff --git a/x-pack/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.js b/x-pack/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.js index e4538e4f1c8cbbc..b21035cd3ade905 100644 --- a/x-pack/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.js +++ b/x-pack/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.js @@ -6,7 +6,7 @@ import { omit } from 'lodash'; import { KBN_SCREENSHOT_HEADER_BLACKLIST } from '../../../common/constants'; -export const omitBlacklistedHeaders = ({ job, decryptedHeaders }) => { +export const omitBlacklistedHeaders = ({ job, decryptedHeaders, server }) => { const filteredHeaders = omit(decryptedHeaders, KBN_SCREENSHOT_HEADER_BLACKLIST); - return { job, filteredHeaders }; + return { job, filteredHeaders, server }; }; \ No newline at end of file diff --git a/x-pack/plugins/reporting/export_types/png/server/execute_job/index.js b/x-pack/plugins/reporting/export_types/png/server/execute_job/index.js index fb94acae6802335..d9edbd7e0c6de5c 100644 --- a/x-pack/plugins/reporting/export_types/png/server/execute_job/index.js +++ b/x-pack/plugins/reporting/export_types/png/server/execute_job/index.js @@ -14,8 +14,7 @@ function executeJobFn(server) { const generatePngObservable = generatePngObservableFactory(server); return function executeJob(jobToExecute, cancellationToken) { - jobToExecute.server = server; - const process$ = Rx.of(jobToExecute).pipe( + const process$ = Rx.of({ job: jobToExecute, server }).pipe( mergeMap(decryptJobHeaders), catchError(() => Rx.throwError('Failed to decrypt report job data. Please re-generate this report.')), map(omitBlacklistedHeaders), diff --git a/x-pack/plugins/reporting/export_types/printable_pdf/server/execute_job/index.js b/x-pack/plugins/reporting/export_types/printable_pdf/server/execute_job/index.js index 62c5c4b8cc43a1e..996fb179c9e09f9 100644 --- a/x-pack/plugins/reporting/export_types/printable_pdf/server/execute_job/index.js +++ b/x-pack/plugins/reporting/export_types/printable_pdf/server/execute_job/index.js @@ -18,8 +18,7 @@ function executeJobFn(server) { const compatibilityShim = compatibilityShimFactory(server); return compatibilityShim(function executeJob(jobToExecute, cancellationToken) { - jobToExecute.server = server; - const process$ = Rx.of(jobToExecute).pipe( + const process$ = Rx.of({ job: jobToExecute, server }).pipe( mergeMap(decryptJobHeaders), catchError(() => Rx.throwError('Failed to decrypt report job data. Please re-generate this report.')), map(omitBlacklistedHeaders),