diff --git a/x-pack/plugins/reporting/common/constants.ts b/x-pack/plugins/reporting/common/constants.ts index 07a239494da23..16e40bab65a46 100644 --- a/x-pack/plugins/reporting/common/constants.ts +++ b/x-pack/plugins/reporting/common/constants.ts @@ -11,13 +11,6 @@ export const BROWSER_TYPE = 'chromium'; export const JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY = 'xpack.reporting.jobCompletionNotifications'; -export const API_BASE_URL = '/api/reporting'; // "Generation URL" from share menu -export const API_BASE_URL_V1 = '/api/reporting/v1'; // -export const API_BASE_GENERATE_V1 = `${API_BASE_URL_V1}/generate`; -export const API_LIST_URL = '/api/reporting/jobs'; -export const API_GENERATE_IMMEDIATE = `${API_BASE_URL_V1}/generate/immediate/csv/saved-object`; -export const API_DIAGNOSE_URL = `${API_BASE_URL}/diagnose`; - export const CONTENT_TYPE_CSV = 'text/csv'; export const CSV_REPORTING_ACTION = 'downloadCsvReport'; export const CSV_BOM_CHARS = '\ufeff'; @@ -57,15 +50,49 @@ export const UI_SETTINGS_CUSTOM_PDF_LOGO = 'xpackReporting:customPdfLogo'; export const UI_SETTINGS_CSV_SEPARATOR = 'csv:separator'; export const UI_SETTINGS_CSV_QUOTE_VALUES = 'csv:quoteValues'; +export const LAYOUT_TYPES = { + PRESERVE_LAYOUT: 'preserve_layout', + PRINT: 'print', +}; + +// Export Type Definitions +export const CSV_REPORT_TYPE = 'CSV'; +export const PDF_REPORT_TYPE = 'printablePdf'; +export const PNG_REPORT_TYPE = 'PNG'; + export const PDF_JOB_TYPE = 'printable_pdf'; export const PNG_JOB_TYPE = 'PNG'; export const CSV_JOB_TYPE = 'csv'; export const CSV_FROM_SAVEDOBJECT_JOB_TYPE = 'csv_from_savedobject'; export const USES_HEADLESS_JOB_TYPES = [PDF_JOB_TYPE, PNG_JOB_TYPE]; +// Licenses export const LICENSE_TYPE_TRIAL = 'trial'; export const LICENSE_TYPE_BASIC = 'basic'; export const LICENSE_TYPE_STANDARD = 'standard'; export const LICENSE_TYPE_GOLD = 'gold'; export const LICENSE_TYPE_PLATINUM = 'platinum'; export const LICENSE_TYPE_ENTERPRISE = 'enterprise'; + +// Routes +export const API_BASE_URL = '/api/reporting'; // "Generation URL" from share menu +export const API_BASE_GENERATE = `${API_BASE_URL}/generate`; +export const API_LIST_URL = `${API_BASE_URL}/jobs`; +export const API_DIAGNOSE_URL = `${API_BASE_URL}/diagnose`; + +// hacky endpoint +export const API_BASE_URL_V1 = '/api/reporting/v1'; // +export const API_GENERATE_IMMEDIATE = `${API_BASE_URL_V1}/generate/immediate/csv/saved-object`; + +// Management UI route +export const REPORTING_MANAGEMENT_HOME = '/app/management/insightsAndAlerting/reporting'; + +// Statuses +export enum JOB_STATUSES { + PENDING = 'pending', + PROCESSING = 'processing', + COMPLETED = 'completed', + FAILED = 'failed', + CANCELLED = 'cancelled', + WARNINGS = 'completed_with_warnings', +} diff --git a/x-pack/plugins/reporting/common/index.ts b/x-pack/plugins/reporting/common/index.ts index cda8934fc8bf6..0be6ab6682774 100644 --- a/x-pack/plugins/reporting/common/index.ts +++ b/x-pack/plugins/reporting/common/index.ts @@ -4,5 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ +import { LayoutSelectorDictionary } from './types'; + export { CancellationToken } from './cancellation_token'; export { Poller } from './poller'; + +export const getDefaultLayoutSelectors = (): LayoutSelectorDictionary => ({ + screenshot: '[data-shared-items-container]', + renderComplete: '[data-shared-item]', + itemsCountAttribute: 'data-shared-items-count', + timefilterDurationAttribute: 'data-shared-timefilter-duration', +}); diff --git a/x-pack/plugins/reporting/common/poller.ts b/x-pack/plugins/reporting/common/poller.ts index 2127a876f4a27..017dbac13e29b 100644 --- a/x-pack/plugins/reporting/common/poller.ts +++ b/x-pack/plugins/reporting/common/poller.ts @@ -5,7 +5,16 @@ */ import _ from 'lodash'; -import { PollerOptions } from './types'; + +interface PollerOptions { + functionToPoll: () => Promise; + pollFrequencyInMillis: number; + trailing?: boolean; + continuePollingOnError?: boolean; + pollFrequencyErrorMultiplier?: number; + successFunction?: (...args: any) => any; + errorFunction?: (error: Error) => any; +} // @TODO Maybe move to observables someday export class Poller { diff --git a/x-pack/plugins/reporting/common/types.ts b/x-pack/plugins/reporting/common/types.ts index 24c126bfe0571..abd0bee7fb6ea 100644 --- a/x-pack/plugins/reporting/common/types.ts +++ b/x-pack/plugins/reporting/common/types.ts @@ -4,15 +4,94 @@ * you may not use this file except in compliance with the Elastic License. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -export { ReportingConfigType } from '../server/config'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutParams } from '../server/lib/layouts'; -export { LayoutParams }; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -export { ReportDocument, ReportSource } from '../server/lib/store/report'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -export { BaseParams } from '../server/types'; +export interface PageSizeParams { + pageMarginTop: number; + pageMarginBottom: number; + pageMarginWidth: number; + tableBorderWidth: number; + headingHeight: number; + subheadingHeight: number; +} + +export interface LayoutSelectorDictionary { + screenshot: string; + renderComplete: string; + itemsCountAttribute: string; + timefilterDurationAttribute: string; +} + +export interface PdfImageSize { + width: number; + height?: number; +} + +export interface Size { + width: number; + height: number; +} + +export interface LayoutParams { + id: string; + dimensions?: Size; + selectors?: LayoutSelectorDictionary; +} + +export interface ReportDocumentHead { + _id: string; + _index: string; + _seq_no: unknown; + _primary_term: unknown; +} + +export interface TaskRunResult { + content_type: string | null; + content: string | null; + csv_contains_formulas?: boolean; + size: number; + max_size_reached?: boolean; + warnings?: string[]; +} + +export interface ReportSource { + jobtype: string; + kibana_name: string; + kibana_id: string; + created_by: string | false; + payload: { + headers: string; // encrypted headers + browserTimezone?: string; // may use timezone from advanced settings + objectType: string; + title: string; + layout?: LayoutParams; + }; + meta: { objectType: string; layout?: string }; + browser_type: string; + max_attempts: number; + timeout: number; + + status: JobStatus; + attempts: number; + output: TaskRunResult | null; + started_at?: string; + completed_at?: string; + created_at: string; + priority?: number; + process_expiration?: string; +} + +/* + * The document created by Reporting to store in the .reporting index + */ +export interface ReportDocument extends ReportDocumentHead { + _source: ReportSource; +} + +export interface BaseParams { + browserTimezone?: string; // browserTimezone is optional: it is not in old POST URLs that were generated prior to being added to this interface + layout?: LayoutParams; + objectType: string; + title: string; +} export type JobId = string; export type JobStatus = @@ -59,18 +138,28 @@ export interface ReportApiJSON { status: string; } -export interface PollerOptions { - functionToPoll: () => Promise; - pollFrequencyInMillis: number; - trailing?: boolean; - continuePollingOnError?: boolean; - pollFrequencyErrorMultiplier?: number; - successFunction?: (...args: any) => any; - errorFunction?: (error: Error) => any; -} - export interface LicenseCheckResults { enableLinks: boolean; showLinks: boolean; message: string; } + +export interface JobSummary { + id: JobId; + status: JobStatus; + title: string; + jobtype: string; + maxSizeReached?: boolean; + csvContainsFormulas?: boolean; +} + +export interface JobSummarySet { + completed: JobSummary[]; + failed: JobSummary[]; +} + +type DownloadLink = string; +export type DownloadReportFn = (jobId: JobId) => DownloadLink; + +type ManagementLink = string; +export type ManagementLinkFn = () => ManagementLink; diff --git a/x-pack/plugins/reporting/constants.ts b/x-pack/plugins/reporting/constants.ts deleted file mode 100644 index 772c52dde4a15..0000000000000 --- a/x-pack/plugins/reporting/constants.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY = - 'xpack.reporting.jobCompletionNotifications'; - -// Routes -export const API_BASE_URL = '/api/reporting'; -export const API_LIST_URL = `${API_BASE_URL}/jobs`; -export const API_BASE_GENERATE = `${API_BASE_URL}/generate`; -export const API_GENERATE_IMMEDIATE = `${API_BASE_URL}/v1/generate/immediate/csv/saved-object`; -export const REPORTING_MANAGEMENT_HOME = '/app/management/insightsAndAlerting/reporting'; - -// Statuses -export const JOB_STATUS_FAILED = 'failed'; -export const JOB_STATUS_COMPLETED = 'completed'; -export const JOB_STATUS_WARNINGS = 'completed_with_warnings'; - -export enum JobStatuses { - PENDING = 'pending', - PROCESSING = 'processing', - COMPLETED = 'completed', - FAILED = 'failed', - CANCELLED = 'cancelled', - WARNINGS = 'completed_with_warnings', -} - -// Types -export const PDF_JOB_TYPE = 'printable_pdf'; -export const PNG_JOB_TYPE = 'PNG'; -export const CSV_JOB_TYPE = 'csv'; -export const CSV_FROM_SAVEDOBJECT_JOB_TYPE = 'csv_from_savedobject'; -export const USES_HEADLESS_JOB_TYPES = [PDF_JOB_TYPE, PNG_JOB_TYPE]; - -// Actions -export const CSV_REPORTING_ACTION = 'downloadCsvReport'; diff --git a/x-pack/plugins/reporting/public/components/buttons/report_download_button.tsx b/x-pack/plugins/reporting/public/components/buttons/report_download_button.tsx index 6c13264ebcb1f..4bd86d15949e8 100644 --- a/x-pack/plugins/reporting/public/components/buttons/report_download_button.tsx +++ b/x-pack/plugins/reporting/public/components/buttons/report_download_button.tsx @@ -6,7 +6,7 @@ import { EuiButtonIcon, EuiToolTip } from '@elastic/eui'; import React, { FunctionComponent } from 'react'; -import { JobStatuses } from '../../../constants'; +import { JOB_STATUSES } from '../../../common/constants'; import { Job as ListingJob, Props as ListingProps } from '../report_listing'; type Props = { record: ListingJob } & ListingProps; @@ -14,7 +14,7 @@ type Props = { record: ListingJob } & ListingProps; export const ReportDownloadButton: FunctionComponent = (props: Props) => { const { record, apiClient, intl } = props; - if (record.status !== JobStatuses.COMPLETED && record.status !== JobStatuses.WARNINGS) { + if (record.status !== JOB_STATUSES.COMPLETED && record.status !== JOB_STATUSES.WARNINGS) { return null; } diff --git a/x-pack/plugins/reporting/public/components/buttons/report_error_button.tsx b/x-pack/plugins/reporting/public/components/buttons/report_error_button.tsx index 4eee86cd79ce7..2864802f843f4 100644 --- a/x-pack/plugins/reporting/public/components/buttons/report_error_button.tsx +++ b/x-pack/plugins/reporting/public/components/buttons/report_error_button.tsx @@ -7,7 +7,7 @@ import { EuiButtonIcon, EuiCallOut, EuiPopover } from '@elastic/eui'; import { InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { Component } from 'react'; -import { JobStatuses } from '../../../constants'; +import { JOB_STATUSES } from '../../../common/constants'; import { JobContent, ReportingAPIClient } from '../../lib/reporting_api_client'; import { Job as ListingJob } from '../report_listing'; @@ -43,7 +43,7 @@ class ReportErrorButtonUi extends Component { public render() { const { record, intl } = this.props; - if (record.status !== JobStatuses.FAILED) { + if (record.status !== JOB_STATUSES.FAILED) { return null; } diff --git a/x-pack/plugins/reporting/public/components/buttons/report_info_button.tsx b/x-pack/plugins/reporting/public/components/buttons/report_info_button.tsx index 068cb7d44b0a1..0e249f156f587 100644 --- a/x-pack/plugins/reporting/public/components/buttons/report_info_button.tsx +++ b/x-pack/plugins/reporting/public/components/buttons/report_info_button.tsx @@ -17,8 +17,8 @@ import { } from '@elastic/eui'; import { get } from 'lodash'; import React, { Component, Fragment } from 'react'; +import { USES_HEADLESS_JOB_TYPES } from '../../../common/constants'; import { ReportApiJSON } from '../../../common/types'; -import { USES_HEADLESS_JOB_TYPES } from '../../../constants'; import { ReportingAPIClient } from '../../lib/reporting_api_client'; interface Props { diff --git a/x-pack/plugins/reporting/public/components/index.ts b/x-pack/plugins/reporting/public/components/index.ts index 354ef189704ad..370e90c8d2d08 100644 --- a/x-pack/plugins/reporting/public/components/index.ts +++ b/x-pack/plugins/reporting/public/components/index.ts @@ -9,3 +9,4 @@ export { getFailureToast } from './job_failure'; export { getWarningFormulasToast } from './job_warning_formulas'; export { getWarningMaxSizeToast } from './job_warning_max_size'; export { getGeneralErrorToast } from './general_error'; +export { ScreenCapturePanelContent } from './screen_capture_panel_content'; diff --git a/x-pack/plugins/reporting/public/components/job_download_button.tsx b/x-pack/plugins/reporting/public/components/job_download_button.tsx index 8cf3ce8644add..7dff2cafa047b 100644 --- a/x-pack/plugins/reporting/public/components/job_download_button.tsx +++ b/x-pack/plugins/reporting/public/components/job_download_button.tsx @@ -7,8 +7,7 @@ import { EuiButton } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import { JobSummary } from '../'; -import { JobId } from '../../common/types'; +import { JobId, JobSummary } from '../../common/types'; interface Props { getUrl: (jobId: JobId) => string; diff --git a/x-pack/plugins/reporting/public/components/job_failure.tsx b/x-pack/plugins/reporting/public/components/job_failure.tsx index 8d8f32f692343..e9c3a448cfe41 100644 --- a/x-pack/plugins/reporting/public/components/job_failure.tsx +++ b/x-pack/plugins/reporting/public/components/job_failure.tsx @@ -9,8 +9,8 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { Fragment } from 'react'; import { ToastInput } from 'src/core/public'; -import { JobSummary, ManagementLinkFn } from '../'; import { toMountPoint } from '../../../../../src/plugins/kibana_react/public'; +import { JobSummary, ManagementLinkFn } from '../../common/types'; export const getFailureToast = ( errorText: string, diff --git a/x-pack/plugins/reporting/public/components/job_success.tsx b/x-pack/plugins/reporting/public/components/job_success.tsx index 05cf2c4c5784a..f03914b2be2f2 100644 --- a/x-pack/plugins/reporting/public/components/job_success.tsx +++ b/x-pack/plugins/reporting/public/components/job_success.tsx @@ -7,9 +7,8 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { Fragment } from 'react'; import { ToastInput } from 'src/core/public'; -import { JobSummary } from '../'; import { toMountPoint } from '../../../../../src/plugins/kibana_react/public'; -import { JobId } from '../../common/types'; +import { JobId, JobSummary } from '../../common/types'; import { DownloadButton } from './job_download_button'; import { ReportLink } from './report_link'; diff --git a/x-pack/plugins/reporting/public/components/job_warning_formulas.tsx b/x-pack/plugins/reporting/public/components/job_warning_formulas.tsx index 8cccc94e98dcd..338c718a060c1 100644 --- a/x-pack/plugins/reporting/public/components/job_warning_formulas.tsx +++ b/x-pack/plugins/reporting/public/components/job_warning_formulas.tsx @@ -7,9 +7,8 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { Fragment } from 'react'; import { ToastInput } from 'src/core/public'; -import { JobSummary } from '../'; import { toMountPoint } from '../../../../../src/plugins/kibana_react/public'; -import { JobId } from '../../common/types'; +import { JobId, JobSummary } from '../../common/types'; import { DownloadButton } from './job_download_button'; import { ReportLink } from './report_link'; diff --git a/x-pack/plugins/reporting/public/components/job_warning_max_size.tsx b/x-pack/plugins/reporting/public/components/job_warning_max_size.tsx index c350eef0e5a54..cab743e2006df 100644 --- a/x-pack/plugins/reporting/public/components/job_warning_max_size.tsx +++ b/x-pack/plugins/reporting/public/components/job_warning_max_size.tsx @@ -7,9 +7,8 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { Fragment } from 'react'; import { ToastInput } from 'src/core/public'; -import { JobSummary } from '../'; import { toMountPoint } from '../../../../../src/plugins/kibana_react/public'; -import { JobId } from '../../common/types'; +import { JobId, JobSummary } from '../../common/types'; import { DownloadButton } from './job_download_button'; import { ReportLink } from './report_link'; diff --git a/x-pack/plugins/reporting/public/components/report_listing.tsx b/x-pack/plugins/reporting/public/components/report_listing.tsx index a512b1305b8e0..ac6d03a407c28 100644 --- a/x-pack/plugins/reporting/public/components/report_listing.tsx +++ b/x-pack/plugins/reporting/public/components/report_listing.tsx @@ -22,9 +22,9 @@ import { Component, default as React, Fragment } from 'react'; import { Subscription } from 'rxjs'; import { ApplicationStart, ToastsSetup } from 'src/core/public'; import { ILicense, LicensingPluginSetup } from '../../../licensing/public'; +import { JOB_STATUSES as JobStatuses } from '../../common/constants'; import { Poller } from '../../common/poller'; import { durationToNumber } from '../../common/schema_utils'; -import { JobStatuses } from '../../constants'; import { checkLicense } from '../lib/license_check'; import { JobQueueEntry, ReportingAPIClient } from '../lib/reporting_api_client'; import { ClientConfigType } from '../plugin'; diff --git a/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx b/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx index 18895f9e623eb..7f48b5d9101ba 100644 --- a/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx +++ b/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx @@ -10,6 +10,7 @@ import React, { Component, ReactElement } from 'react'; import { ToastsSetup } from 'src/core/public'; import url from 'url'; import { toMountPoint } from '../../../../../src/plugins/kibana_react/public'; +import { CSV_REPORT_TYPE, PDF_REPORT_TYPE, PNG_REPORT_TYPE } from '../../common/constants'; import { BaseParams } from '../../common/types'; import { ReportingAPIClient } from '../lib/reporting_api_client'; @@ -165,12 +166,12 @@ class ReportingPanelContentUi extends Component { private prettyPrintReportingType = () => { switch (this.props.reportType) { - case 'printablePdf': + case PDF_REPORT_TYPE: return 'PDF'; case 'csv': - return 'CSV'; + return CSV_REPORT_TYPE; case 'png': - return 'PNG'; + return PNG_REPORT_TYPE; default: return this.props.reportType; } diff --git a/x-pack/plugins/reporting/public/index.ts b/x-pack/plugins/reporting/public/index.ts index 251fd14ee4d57..f15a5ca481757 100644 --- a/x-pack/plugins/reporting/public/index.ts +++ b/x-pack/plugins/reporting/public/index.ts @@ -5,33 +5,21 @@ */ import { PluginInitializerContext } from 'src/core/public'; -import { ReportingPublicPlugin } from './plugin'; +import { ScreenCapturePanelContent } from './components/screen_capture_panel_content'; import * as jobCompletionNotifications from './lib/job_completion_notifications'; -import { JobId, JobStatus } from '../common/types'; +import { ReportingAPIClient } from './lib/reporting_api_client'; +import { ReportingPublicPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { - return new ReportingPublicPlugin(initializerContext); +export interface ReportingSetup { + components: { + ScreenCapturePanel: typeof ScreenCapturePanelContent; + }; } -export { ReportingPublicPlugin as Plugin }; -export { jobCompletionNotifications }; +export type ReportingStart = ReportingSetup; -export interface JobSummary { - id: JobId; - status: JobStatus; - title: string; - jobtype: string; - maxSizeReached?: boolean; - csvContainsFormulas?: boolean; -} +export { ReportingAPIClient, ReportingPublicPlugin as Plugin, jobCompletionNotifications }; -export interface JobSummarySet { - completed: JobSummary[]; - failed: JobSummary[]; +export function plugin(initializerContext: PluginInitializerContext) { + return new ReportingPublicPlugin(initializerContext); } - -type DownloadLink = string; -export type DownloadReportFn = (jobId: JobId) => DownloadLink; - -type ManagementLink = string; -export type ManagementLinkFn = () => ManagementLink; diff --git a/x-pack/plugins/reporting/public/lib/job_completion_notifications.ts b/x-pack/plugins/reporting/public/lib/job_completion_notifications.ts index 06694361b757d..39a7c9f84b8e5 100644 --- a/x-pack/plugins/reporting/public/lib/job_completion_notifications.ts +++ b/x-pack/plugins/reporting/public/lib/job_completion_notifications.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY } from '../../constants'; +import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY } from '../../common/constants'; type JobId = string; diff --git a/x-pack/plugins/reporting/public/lib/reporting_api_client.ts b/x-pack/plugins/reporting/public/lib/reporting_api_client.ts index 2853caaaaa1b5..71b57d0c0124e 100644 --- a/x-pack/plugins/reporting/public/lib/reporting_api_client.ts +++ b/x-pack/plugins/reporting/public/lib/reporting_api_client.ts @@ -7,14 +7,20 @@ import { stringify } from 'query-string'; import rison from 'rison-node'; import { HttpSetup } from 'src/core/public'; -import { DownloadReportFn, ManagementLinkFn } from '../'; -import { JobId, ReportApiJSON, ReportDocument, ReportSource } from '../../common/types'; import { API_BASE_GENERATE, API_BASE_URL, API_LIST_URL, REPORTING_MANAGEMENT_HOME, -} from '../../constants'; +} from '../../common/constants'; +import { + DownloadReportFn, + JobId, + ManagementLinkFn, + ReportApiJSON, + ReportDocument, + ReportSource, +} from '../../common/types'; import { add } from './job_completion_notifications'; export interface JobQueueEntry { diff --git a/x-pack/plugins/reporting/public/lib/stream_handler.test.ts b/x-pack/plugins/reporting/public/lib/stream_handler.test.ts index f91517e4397f9..31d324bd77159 100644 --- a/x-pack/plugins/reporting/public/lib/stream_handler.test.ts +++ b/x-pack/plugins/reporting/public/lib/stream_handler.test.ts @@ -6,8 +6,7 @@ import sinon, { stub } from 'sinon'; import { NotificationsStart } from 'src/core/public'; -import { JobSummary } from '../'; -import { ReportDocument } from '../../common/types'; +import { JobSummary, ReportDocument } from '../../common/types'; import { ReportingAPIClient } from './reporting_api_client'; import { ReportingNotifierStreamHandler } from './stream_handler'; diff --git a/x-pack/plugins/reporting/public/lib/stream_handler.ts b/x-pack/plugins/reporting/public/lib/stream_handler.ts index d97c0a7a2d11e..4b2305b60c413 100644 --- a/x-pack/plugins/reporting/public/lib/stream_handler.ts +++ b/x-pack/plugins/reporting/public/lib/stream_handler.ts @@ -8,14 +8,8 @@ import { i18n } from '@kbn/i18n'; import * as Rx from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { NotificationsSetup } from 'src/core/public'; -import { JobSummarySet, JobSummary } from '../'; -import { JobId, ReportDocument } from '../../common/types'; -import { - JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY, - JOB_STATUS_COMPLETED, - JOB_STATUS_FAILED, - JOB_STATUS_WARNINGS, -} from '../../constants'; +import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY, JOB_STATUSES } from '../../common/constants'; +import { JobId, JobSummary, JobSummarySet, ReportDocument } from '../../common/types'; import { getFailureToast, getGeneralErrorToast, @@ -107,9 +101,9 @@ export class ReportingNotifierStreamHandler { _source: { status: jobStatus }, } = job; if (storedJobs.includes(jobId)) { - if (jobStatus === JOB_STATUS_COMPLETED || jobStatus === JOB_STATUS_WARNINGS) { + if (jobStatus === JOB_STATUSES.COMPLETED || jobStatus === JOB_STATUSES.WARNINGS) { completedJobs.push(getReportStatus(job)); - } else if (jobStatus === JOB_STATUS_FAILED) { + } else if (jobStatus === JOB_STATUSES.FAILED) { failedJobs.push(getReportStatus(job)); } else { pending.push(jobId); diff --git a/x-pack/plugins/reporting/public/panel_actions/get_csv_panel_action.tsx b/x-pack/plugins/reporting/public/panel_actions/get_csv_panel_action.tsx index 1e3f7e34bebdb..9a4832b114e40 100644 --- a/x-pack/plugins/reporting/public/panel_actions/get_csv_panel_action.tsx +++ b/x-pack/plugins/reporting/public/panel_actions/get_csv_panel_action.tsx @@ -9,20 +9,18 @@ import _ from 'lodash'; import moment from 'moment-timezone'; import { CoreSetup } from 'src/core/public'; import { - UiActionsActionDefinition as ActionDefinition, + ISearchEmbeddable, + SEARCH_EMBEDDABLE_TYPE, +} from '../../../../../src/plugins/discover/public'; +import { IEmbeddable, ViewMode } from '../../../../../src/plugins/embeddable/public'; +import { IncompatibleActionError, + UiActionsActionDefinition as ActionDefinition, } from '../../../../../src/plugins/ui_actions/public'; import { LicensingPluginSetup } from '../../../licensing/public'; +import { API_GENERATE_IMMEDIATE, CSV_REPORTING_ACTION } from '../../common/constants'; import { checkLicense } from '../lib/license_check'; -import { ViewMode, IEmbeddable } from '../../../../../src/plugins/embeddable/public'; -import { - ISearchEmbeddable, - SEARCH_EMBEDDABLE_TYPE, -} from '../../../../../src/plugins/discover/public'; - -import { API_GENERATE_IMMEDIATE, CSV_REPORTING_ACTION } from '../../constants'; - function isSavedSearchEmbeddable( embeddable: IEmbeddable | ISearchEmbeddable ): embeddable is ISearchEmbeddable { diff --git a/x-pack/plugins/reporting/public/plugin.ts b/x-pack/plugins/reporting/public/plugin.ts index 33f4fd4abf72c..52362b4c68734 100644 --- a/x-pack/plugins/reporting/public/plugin.ts +++ b/x-pack/plugins/reporting/public/plugin.ts @@ -24,11 +24,14 @@ import { import { ManagementSetup, ManagementStart } from '../../../../src/plugins/management/public'; import { SharePluginSetup, SharePluginStart } from '../../../../src/plugins/share/public'; import { LicensingPluginSetup, LicensingPluginStart } from '../../licensing/public'; +import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY } from '../common/constants'; import { durationToNumber } from '../common/schema_utils'; -import { JobId, ReportingConfigType } from '../common/types'; -import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY } from '../constants'; -import { JobSummarySet } from './'; -import { getGeneralErrorToast } from './components'; +import { JobId, JobSummarySet } from '../common/types'; +import { ReportingSetup, ReportingStart } from './'; +import { + getGeneralErrorToast, + ScreenCapturePanelContent as ScreenCapturePanel, +} from './components'; import { ReportingAPIClient } from './lib/reporting_api_client'; import { ReportingNotifierStreamHandler as StreamHandler } from './lib/stream_handler'; import { GetCsvReportPanelAction } from './panel_actions/get_csv_panel_action'; @@ -36,7 +39,12 @@ import { csvReportingProvider } from './share_context_menu/register_csv_reportin import { reportingPDFPNGProvider } from './share_context_menu/register_pdf_png_reporting'; export interface ClientConfigType { - poll: ReportingConfigType['poll']; + poll: { + jobsRefresh: { + interval: number; + intervalErrorMultiplier: number; + }; + }; } function getStored(): JobId[] { @@ -75,8 +83,13 @@ export interface ReportingPublicPluginStartDendencies { export class ReportingPublicPlugin implements - Plugin { - private config: ClientConfigType; + Plugin< + ReportingSetup, + ReportingStart, + ReportingPublicPluginSetupDendencies, + ReportingPublicPluginStartDendencies + > { + private readonly contract: ReportingStart = { components: { ScreenCapturePanel } }; private readonly stop$ = new Rx.ReplaySubject(1); private readonly title = i18n.translate('xpack.reporting.management.reportingTitle', { defaultMessage: 'Reporting', @@ -84,6 +97,7 @@ export class ReportingPublicPlugin private readonly breadcrumbText = i18n.translate('xpack.reporting.breadcrumb', { defaultMessage: 'Reporting', }); + private config: ClientConfigType; constructor(initializerContext: PluginInitializerContext) { this.config = initializerContext.config.get(); @@ -149,6 +163,8 @@ export class ReportingPublicPlugin uiSettings, }) ); + + return this.contract; } public start(core: CoreStart) { @@ -166,6 +182,8 @@ export class ReportingPublicPlugin catchError((err) => handleError(notifications, err)) ) .subscribe(); + + return this.contract; } public stop() { diff --git a/x-pack/plugins/reporting/server/export_types/csv/create_job.ts b/x-pack/plugins/reporting/server/export_types/csv/create_job.ts index 5b98a198b7d1a..43243d265e926 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/create_job.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/create_job.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CSV_JOB_TYPE } from '../../../constants'; +import { CSV_JOB_TYPE } from '../../../common/constants'; import { cryptoFactory } from '../../lib'; import { CreateJobFn, CreateJobFnFactory } from '../../types'; import { IndexPatternSavedObject, JobParamsCSV, TaskPayloadCSV } from './types'; diff --git a/x-pack/plugins/reporting/server/export_types/csv/index.ts b/x-pack/plugins/reporting/server/export_types/csv/index.ts index e66cfef18c6e2..f7b7ff5709fe6 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/index.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/index.ts @@ -5,6 +5,7 @@ */ import { + CSV_JOB_TYPE as jobType, LICENSE_TYPE_BASIC, LICENSE_TYPE_ENTERPRISE, LICENSE_TYPE_GOLD, @@ -12,7 +13,6 @@ import { LICENSE_TYPE_STANDARD, LICENSE_TYPE_TRIAL, } from '../../../common/constants'; -import { CSV_JOB_TYPE as jobType } from '../../../constants'; import { CreateJobFn, ExportTypeDefinition, RunTaskFn } from '../../types'; import { createJobFnFactory } from './create_job'; import { runTaskFnFactory } from './execute_job'; diff --git a/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/index.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/index.ts index abe9fbf3e3950..2c163aeb57a64 100644 --- a/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/index.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/index.ts @@ -5,6 +5,7 @@ */ import { + CSV_FROM_SAVEDOBJECT_JOB_TYPE, LICENSE_TYPE_BASIC, LICENSE_TYPE_ENTERPRISE, LICENSE_TYPE_GOLD, @@ -12,7 +13,6 @@ import { LICENSE_TYPE_STANDARD, LICENSE_TYPE_TRIAL, } from '../../../common/constants'; -import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../constants'; import { ExportTypeDefinition } from '../../types'; import { createJobFnFactory, ImmediateCreateJobFn } from './create_job'; import { ImmediateExecuteFn, runTaskFnFactory } from './execute_job'; diff --git a/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/metadata.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/metadata.ts index a0fd8a29fdcc4..fda360103a115 100644 --- a/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/metadata.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/metadata.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../constants'; +import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../common/constants'; export const metadata = { id: CSV_FROM_SAVEDOBJECT_JOB_TYPE, diff --git a/x-pack/plugins/reporting/server/export_types/png/create_job/index.ts b/x-pack/plugins/reporting/server/export_types/png/create_job/index.ts index b1fcdbe05fd67..010b6f431db7e 100644 --- a/x-pack/plugins/reporting/server/export_types/png/create_job/index.ts +++ b/x-pack/plugins/reporting/server/export_types/png/create_job/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PNG_JOB_TYPE } from '../../../../constants'; +import { PNG_JOB_TYPE } from '../../../../common/constants'; import { cryptoFactory } from '../../../lib'; import { CreateJobFn, CreateJobFnFactory } from '../../../types'; import { validateUrls } from '../../common'; diff --git a/x-pack/plugins/reporting/server/export_types/printable_pdf/create_job/index.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/create_job/index.ts index dcd33a0fc8d53..a529cb864b6f7 100644 --- a/x-pack/plugins/reporting/server/export_types/printable_pdf/create_job/index.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/create_job/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PDF_JOB_TYPE } from '../../../../constants'; +import { PDF_JOB_TYPE } from '../../../../common/constants'; import { cryptoFactory } from '../../../lib'; import { CreateJobFn, CreateJobFnFactory } from '../../../types'; import { validateUrls } from '../../common'; diff --git a/x-pack/plugins/reporting/server/lib/layouts/create_layout.ts b/x-pack/plugins/reporting/server/lib/layouts/create_layout.ts index e69b8d61dec0d..c90f67b81317e 100644 --- a/x-pack/plugins/reporting/server/lib/layouts/create_layout.ts +++ b/x-pack/plugins/reporting/server/lib/layouts/create_layout.ts @@ -4,8 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ +import { LAYOUT_TYPES } from '../../../common/constants'; import { CaptureConfig } from '../../types'; -import { LayoutInstance, LayoutParams, LayoutTypes } from './'; +import { LayoutInstance, LayoutParams } from './'; import { PreserveLayout } from './preserve_layout'; import { PrintLayout } from './print_layout'; @@ -13,7 +14,7 @@ export function createLayout( captureConfig: CaptureConfig, layoutParams?: LayoutParams ): LayoutInstance { - if (layoutParams && layoutParams.dimensions && layoutParams.id === LayoutTypes.PRESERVE_LAYOUT) { + if (layoutParams && layoutParams.dimensions && layoutParams.id === LAYOUT_TYPES.PRESERVE_LAYOUT) { return new PreserveLayout(layoutParams.dimensions); } diff --git a/x-pack/plugins/reporting/server/lib/layouts/index.ts b/x-pack/plugins/reporting/server/lib/layouts/index.ts index c091339a60582..8bfe79aeb8a21 100644 --- a/x-pack/plugins/reporting/server/lib/layouts/index.ts +++ b/x-pack/plugins/reporting/server/lib/layouts/index.ts @@ -4,59 +4,23 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HeadlessChromiumDriver } from '../../browsers'; import { LevelLogger } from '../'; +import { LayoutSelectorDictionary, Size } from '../../../common/types'; +import { HeadlessChromiumDriver } from '../../browsers'; import { Layout } from './layout'; +export { + LayoutParams, + LayoutSelectorDictionary, + PageSizeParams, + PdfImageSize, + Size, +} from '../../../common/types'; export { createLayout } from './create_layout'; export { Layout } from './layout'; export { PreserveLayout } from './preserve_layout'; export { PrintLayout } from './print_layout'; -export const LayoutTypes = { - PRESERVE_LAYOUT: 'preserve_layout', - PRINT: 'print', -}; - -export const getDefaultLayoutSelectors = (): LayoutSelectorDictionary => ({ - screenshot: '[data-shared-items-container]', - renderComplete: '[data-shared-item]', - itemsCountAttribute: 'data-shared-items-count', - timefilterDurationAttribute: 'data-shared-timefilter-duration', -}); - -export interface PageSizeParams { - pageMarginTop: number; - pageMarginBottom: number; - pageMarginWidth: number; - tableBorderWidth: number; - headingHeight: number; - subheadingHeight: number; -} - -export interface LayoutSelectorDictionary { - screenshot: string; - renderComplete: string; - itemsCountAttribute: string; - timefilterDurationAttribute: string; -} - -export interface PdfImageSize { - width: number; - height?: number; -} - -export interface Size { - width: number; - height: number; -} - -export interface LayoutParams { - id: string; - dimensions?: Size; - selectors?: LayoutSelectorDictionary; -} - interface LayoutSelectors { // Fields that are not part of Layout: the instances // independently implement these fields on their own diff --git a/x-pack/plugins/reporting/server/lib/layouts/preserve_layout.ts b/x-pack/plugins/reporting/server/lib/layouts/preserve_layout.ts index faddaae64ce5d..549e898d8a13e 100644 --- a/x-pack/plugins/reporting/server/lib/layouts/preserve_layout.ts +++ b/x-pack/plugins/reporting/server/lib/layouts/preserve_layout.ts @@ -6,15 +6,10 @@ import path from 'path'; import { CustomPageSize } from 'pdfmake/interfaces'; -import { - getDefaultLayoutSelectors, - Layout, - LayoutInstance, - LayoutSelectorDictionary, - LayoutTypes, - PageSizeParams, - Size, -} from './'; +import { getDefaultLayoutSelectors } from '../../../common'; +import { LAYOUT_TYPES } from '../../../common/constants'; +import { LayoutSelectorDictionary, PageSizeParams, Size } from '../../../common/types'; +import { Layout, LayoutInstance } from './'; // We use a zoom of two to bump up the resolution of the screenshot a bit. const ZOOM: number = 2; @@ -28,7 +23,7 @@ export class PreserveLayout extends Layout implements LayoutInstance { private readonly scaledWidth: number; constructor(size: Size, layoutSelectors?: LayoutSelectorDictionary) { - super(LayoutTypes.PRESERVE_LAYOUT); + super(LAYOUT_TYPES.PRESERVE_LAYOUT); this.height = size.height; this.width = size.width; this.scaledHeight = size.height * ZOOM; diff --git a/x-pack/plugins/reporting/server/lib/layouts/print_layout.ts b/x-pack/plugins/reporting/server/lib/layouts/print_layout.ts index e979cdeeb71fe..8db1fa7ff6347 100644 --- a/x-pack/plugins/reporting/server/lib/layouts/print_layout.ts +++ b/x-pack/plugins/reporting/server/lib/layouts/print_layout.ts @@ -8,16 +8,12 @@ import path from 'path'; import { PageOrientation, PredefinedPageSize } from 'pdfmake/interfaces'; import { EvaluateFn, SerializableOrJSHandle } from 'puppeteer'; import { LevelLogger } from '../'; +import { getDefaultLayoutSelectors } from '../../../common'; +import { LAYOUT_TYPES } from '../../../common/constants'; +import { LayoutSelectorDictionary, Size } from '../../../common/types'; import { HeadlessChromiumDriver } from '../../browsers'; import { CaptureConfig } from '../../types'; -import { - getDefaultLayoutSelectors, - LayoutInstance, - LayoutSelectorDictionary, - LayoutTypes, - Size, -} from './'; -import { Layout } from './layout'; +import { Layout, LayoutInstance } from './'; export class PrintLayout extends Layout implements LayoutInstance { public readonly selectors: LayoutSelectorDictionary = { @@ -28,7 +24,7 @@ export class PrintLayout extends Layout implements LayoutInstance { private captureConfig: CaptureConfig; constructor(captureConfig: CaptureConfig) { - super(LayoutTypes.PRINT); + super(LAYOUT_TYPES.PRINT); this.captureConfig = captureConfig; } diff --git a/x-pack/plugins/reporting/server/lib/store/index.ts b/x-pack/plugins/reporting/server/lib/store/index.ts index a48f266120323..17f0fb5bf0389 100644 --- a/x-pack/plugins/reporting/server/lib/store/index.ts +++ b/x-pack/plugins/reporting/server/lib/store/index.ts @@ -4,5 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -export { Report, ReportDocument } from './report'; +export { ReportDocument } from '../../../common/types'; +export { Report } from './report'; export { ReportingStore } from './store'; diff --git a/x-pack/plugins/reporting/server/lib/store/report.ts b/x-pack/plugins/reporting/server/lib/store/report.ts index d82b90f4025ed..2e4473ef8f2ea 100644 --- a/x-pack/plugins/reporting/server/lib/store/report.ts +++ b/x-pack/plugins/reporting/server/lib/store/report.ts @@ -7,51 +7,8 @@ import moment from 'moment'; // @ts-ignore no module definition import Puid from 'puid'; -import { JobStatus, ReportApiJSON } from '../../../common/types'; -import { JobStatuses } from '../../../constants'; -import { LayoutParams } from '../layouts'; -import { TaskRunResult } from '../tasks'; - -interface ReportDocumentHead { - _id: string; - _index: string; - _seq_no: unknown; - _primary_term: unknown; -} - -/* - * The document created by Reporting to store in the .reporting index - */ -export interface ReportDocument extends ReportDocumentHead { - _source: ReportSource; -} - -export interface ReportSource { - jobtype: string; - kibana_name: string; - kibana_id: string; - created_by: string | false; - payload: { - headers: string; // encrypted headers - browserTimezone?: string; // may use timezone from advanced settings - objectType: string; - title: string; - layout?: LayoutParams; - }; - meta: { objectType: string; layout?: string }; - browser_type: string; - max_attempts: number; - timeout: number; - - status: JobStatus; - attempts: number; - output: TaskRunResult | null; - started_at?: string; - completed_at?: string; - created_at: string; - priority?: number; - process_expiration?: string; -} +import { JOB_STATUSES } from '../../../common/constants'; +import { ReportApiJSON, ReportDocumentHead, ReportSource } from '../../../common/types'; const puid = new Puid(); @@ -107,7 +64,7 @@ export class Report implements Partial { this.browser_type = opts.browser_type; this.priority = opts.priority; - this.status = opts.status || JobStatuses.PENDING; + this.status = opts.status || JOB_STATUSES.PENDING; this.output = opts.output || null; } @@ -175,3 +132,5 @@ export class Report implements Partial { }; } } + +export { ReportApiJSON, ReportSource }; diff --git a/x-pack/plugins/reporting/server/lib/tasks/index.ts b/x-pack/plugins/reporting/server/lib/tasks/index.ts index 0dd9945985bfb..c866c81c9793c 100644 --- a/x-pack/plugins/reporting/server/lib/tasks/index.ts +++ b/x-pack/plugins/reporting/server/lib/tasks/index.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import { ReportSource, TaskRunResult } from '../../../common/types'; import { BasePayload } from '../../types'; -import { ReportSource } from '../store/report'; /* * The document created by Reporting to store as task parameters for Task @@ -22,11 +22,4 @@ export interface ReportTaskParams { meta: ReportSource['meta']; } -export interface TaskRunResult { - content_type: string | null; - content: string | null; - csv_contains_formulas?: boolean; - size: number; - max_size_reached?: boolean; - warnings?: string[]; -} +export { TaskRunResult }; diff --git a/x-pack/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts b/x-pack/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts index 400fbb16f54dc..6ac5875acd34c 100644 --- a/x-pack/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts +++ b/x-pack/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts @@ -7,7 +7,6 @@ import { schema } from '@kbn/config-schema'; import { KibanaRequest } from 'src/core/server'; import { ReportingCore } from '../'; -import { API_BASE_GENERATE_V1 } from '../../common/constants'; import { createJobFnFactory } from '../export_types/csv_from_savedobject/create_job'; import { runTaskFnFactory } from '../export_types/csv_from_savedobject/execute_job'; import { @@ -20,6 +19,9 @@ import { authorizedUserPreRoutingFactory } from './lib/authorized_user_pre_routi import { getJobParamsFromRequest } from './lib/get_job_params_from_request'; import { HandlerErrorFunction } from './types'; +const API_BASE_URL_V1 = '/api/reporting/v1'; +const API_BASE_GENERATE_V1 = `${API_BASE_URL_V1}/generate`; + export type CsvFromSavedObjectRequest = KibanaRequest< JobParamsPanelCsv, unknown, diff --git a/x-pack/plugins/reporting/server/test_helpers/create_mock_layoutinstance.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_layoutinstance.ts index c9dbbda9fd68d..12a3ac5c762c7 100644 --- a/x-pack/plugins/reporting/server/test_helpers/create_mock_layoutinstance.ts +++ b/x-pack/plugins/reporting/server/test_helpers/create_mock_layoutinstance.ts @@ -4,12 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { createLayout, LayoutInstance, LayoutTypes } from '../lib/layouts'; +import { LAYOUT_TYPES } from '../../common/constants'; +import { createLayout, LayoutInstance } from '../lib/layouts'; import { CaptureConfig } from '../types'; export const createMockLayoutInstance = (captureConfig: CaptureConfig) => { const mockLayout = createLayout(captureConfig, { - id: LayoutTypes.PRESERVE_LAYOUT, + id: LAYOUT_TYPES.PRESERVE_LAYOUT, dimensions: { height: 100, width: 100 }, }) as LayoutInstance; mockLayout.selectors = { diff --git a/x-pack/plugins/reporting/server/types.ts b/x-pack/plugins/reporting/server/types.ts index eb046a3eab075..8cd26df032f64 100644 --- a/x-pack/plugins/reporting/server/types.ts +++ b/x-pack/plugins/reporting/server/types.ts @@ -8,15 +8,15 @@ import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { DataPluginStart } from 'src/plugins/data/server/plugin'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; -import { SpacesPluginSetup } from '../../spaces/server'; -import { CancellationToken } from '../../../plugins/reporting/common'; import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server'; import { LicensingPluginSetup } from '../../licensing/server'; import { AuthenticatedUser, SecurityPluginSetup } from '../../security/server'; +import { SpacesPluginSetup } from '../../spaces/server'; +import { CancellationToken } from '../common'; +import { BaseParams } from '../common/types'; import { ReportingConfigType } from './config'; import { ReportingCore } from './core'; import { LevelLogger } from './lib'; -import { LayoutParams } from './lib/layouts'; import { ReportTaskParams, TaskRunResult } from './lib/tasks'; /* @@ -47,12 +47,7 @@ export type ReportingUser = { username: AuthenticatedUser['username'] } | false; export type CaptureConfig = ReportingConfigType['capture']; export type ScrollConfig = ReportingConfigType['csv']['scroll']; -export interface BaseParams { - browserTimezone?: string; // browserTimezone is optional: it is not in old POST URLs that were generated prior to being added to this interface - layout?: LayoutParams; - objectType: string; - title: string; -} +export { BaseParams }; // base params decorated with encrypted headers that come into runJob functions export interface BasePayload extends BaseParams {