From 207cdeebd934011e2c79972e486ab153ee210ceb Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Mon, 13 Nov 2023 15:13:39 -0700 Subject: [PATCH] fix circular graph --- packages/kbn-generate-csv/src/generate_csv.ts | 2 +- packages/kbn-generate-csv/tsconfig.json | 1 - packages/kbn-generate-csv/types.ts | 18 +++++++ packages/kbn-reporting/common/constants.ts | 54 ------------------- packages/kbn-reporting/common/tsconfig.json | 3 -- .../common/constants/export_types.ts | 54 +++++++++++++++++++ .../reporting/common/constants/index.ts | 1 + .../plugins/reporting/common/test/fixtures.ts | 19 +++---- .../plugins/reporting/public/lib/job.test.ts | 3 +- x-pack/plugins/reporting/public/lib/job.tsx | 4 +- .../components/report_info_flyout_content.tsx | 2 +- x-pack/plugins/reporting/public/types.ts | 12 ++--- .../reporting/server/lib/tasks/index.ts | 3 +- .../server/usage/get_export_stats.ts | 2 +- 14 files changed, 94 insertions(+), 84 deletions(-) create mode 100644 packages/kbn-generate-csv/types.ts create mode 100644 x-pack/plugins/reporting/common/constants/export_types.ts diff --git a/packages/kbn-generate-csv/src/generate_csv.ts b/packages/kbn-generate-csv/src/generate_csv.ts index d36a9b9da1231..59e69e9989c8e 100644 --- a/packages/kbn-generate-csv/src/generate_csv.ts +++ b/packages/kbn-generate-csv/src/generate_csv.ts @@ -28,12 +28,12 @@ import { } from '@kbn/reporting-common'; import type { TaskRunResult } from '@kbn/reporting-common/types'; import type { ReportingConfigType } from '@kbn/reporting-server'; -import { JobParamsCSV } from '@kbn/reporting-export-types-csv-common'; import { CONTENT_TYPE_CSV } from './constants'; import { CsvExportSettings, getExportSettings } from './get_export_settings'; import { i18nTexts } from './i18n_texts'; import { MaxSizeStringBuilder } from './max_size_string_builder'; +import { JobParamsCSV } from '../types'; interface Clients { es: IScopedClusterClient; diff --git a/packages/kbn-generate-csv/tsconfig.json b/packages/kbn-generate-csv/tsconfig.json index f84c03931dd31..a747ee469ad63 100644 --- a/packages/kbn-generate-csv/tsconfig.json +++ b/packages/kbn-generate-csv/tsconfig.json @@ -24,7 +24,6 @@ "@kbn/config-schema", "@kbn/i18n", "@kbn/reporting-common", - "@kbn/reporting-export-types-csv-common", "@kbn/reporting-server", ] } diff --git a/packages/kbn-generate-csv/types.ts b/packages/kbn-generate-csv/types.ts new file mode 100644 index 0000000000000..6d7461609afe2 --- /dev/null +++ b/packages/kbn-generate-csv/types.ts @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { SerializedSearchSourceFields } from '@kbn/data-plugin/public'; + +/** + * Duplicated from @kbn/reporting-export-types-csv-common to reduce dependencies + */ +export interface JobParamsCSV { + browserTimezone?: string; + searchSource: SerializedSearchSourceFields; + columns?: string[]; +} diff --git a/packages/kbn-reporting/common/constants.ts b/packages/kbn-reporting/common/constants.ts index 26aafa77ed4a8..02926a53a14eb 100644 --- a/packages/kbn-reporting/common/constants.ts +++ b/packages/kbn-reporting/common/constants.ts @@ -8,27 +8,6 @@ export const PLUGIN_ID = 'reporting'; -// Export Type Sets -import { - CSV_JOB_TYPE, - CSV_JOB_TYPE_DEPRECATED, - CSV_JOB_TYPE_V2, - CSV_REPORT_TYPE, - CSV_REPORT_TYPE_V2, -} from '@kbn/reporting-export-types-csv-common'; -import { - PDF_JOB_TYPE, - PDF_JOB_TYPE_V2, - PDF_REPORT_TYPE, - PDF_REPORT_TYPE_V2, -} from '@kbn/reporting-export-types-pdf-common'; -import { - PNG_JOB_TYPE, - PNG_JOB_TYPE_V2, - PNG_REPORT_TYPE, - PNG_REPORT_TYPE_V2, -} from '@kbn/reporting-export-types-png-common'; - export const ALLOWED_JOB_CONTENT_TYPES = [ 'application/json', 'application/pdf', @@ -37,39 +16,6 @@ export const ALLOWED_JOB_CONTENT_TYPES = [ 'text/plain', ]; -export const reportTypes = [ - CSV_REPORT_TYPE, - CSV_REPORT_TYPE_V2, - PDF_REPORT_TYPE, - PDF_REPORT_TYPE_V2, - PNG_REPORT_TYPE, - PNG_REPORT_TYPE_V2, -]; - -export const jobTypes = [ - CSV_JOB_TYPE, - CSV_JOB_TYPE_V2, - PDF_JOB_TYPE, - PDF_JOB_TYPE_V2, - PNG_JOB_TYPE, - PNG_JOB_TYPE_V2, -]; - -type ReportTypeDeclaration = typeof reportTypes; -export type ReportTypes = ReportTypeDeclaration[keyof ReportTypeDeclaration]; - -type JobTypeDeclaration = typeof jobTypes; -export type JobTypes = JobTypeDeclaration[keyof JobTypeDeclaration]; - -export const USES_HEADLESS_JOB_TYPES = [ - PDF_JOB_TYPE, - PNG_JOB_TYPE, - PDF_JOB_TYPE_V2, - PNG_JOB_TYPE_V2, -]; - -export const DEPRECATED_JOB_TYPES = [CSV_JOB_TYPE_DEPRECATED]; - // APM export const REPORTING_TRANSACTION_TYPE = PLUGIN_ID; diff --git a/packages/kbn-reporting/common/tsconfig.json b/packages/kbn-reporting/common/tsconfig.json index 556abebb8a93c..80ed6308f02ff 100644 --- a/packages/kbn-reporting/common/tsconfig.json +++ b/packages/kbn-reporting/common/tsconfig.json @@ -19,8 +19,5 @@ "@kbn/utility-types", "@kbn/screenshotting-plugin", "@kbn/i18n", - "@kbn/reporting-export-types-csv-common", - "@kbn/reporting-export-types-pdf-common", - "@kbn/reporting-export-types-png-common", ] } diff --git a/x-pack/plugins/reporting/common/constants/export_types.ts b/x-pack/plugins/reporting/common/constants/export_types.ts new file mode 100644 index 0000000000000..20f8a63204e75 --- /dev/null +++ b/x-pack/plugins/reporting/common/constants/export_types.ts @@ -0,0 +1,54 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +// Export Type Sets +import { + CSV_JOB_TYPE, + CSV_JOB_TYPE_DEPRECATED, + CSV_JOB_TYPE_V2, + CSV_REPORT_TYPE, + CSV_REPORT_TYPE_V2, +} from '@kbn/reporting-export-types-csv-common'; +import { + PDF_JOB_TYPE, + PDF_JOB_TYPE_V2, + PDF_REPORT_TYPE, + PDF_REPORT_TYPE_V2, +} from '@kbn/reporting-export-types-pdf-common'; +import { + PNG_JOB_TYPE, + PNG_JOB_TYPE_V2, + PNG_REPORT_TYPE, + PNG_REPORT_TYPE_V2, +} from '@kbn/reporting-export-types-png-common'; + +export const reportTypes = [ + CSV_REPORT_TYPE, + CSV_REPORT_TYPE_V2, + PDF_REPORT_TYPE, + PDF_REPORT_TYPE_V2, + PNG_REPORT_TYPE, + PNG_REPORT_TYPE_V2, +]; + +export const jobTypes = [ + CSV_JOB_TYPE, + CSV_JOB_TYPE_V2, + PDF_JOB_TYPE, + PDF_JOB_TYPE_V2, + PNG_JOB_TYPE, + PNG_JOB_TYPE_V2, +]; + +export const USES_HEADLESS_JOB_TYPES = [ + PDF_JOB_TYPE, + PNG_JOB_TYPE, + PDF_JOB_TYPE_V2, + PNG_JOB_TYPE_V2, +]; + +export const DEPRECATED_JOB_TYPES = [CSV_JOB_TYPE_DEPRECATED]; diff --git a/x-pack/plugins/reporting/common/constants/index.ts b/x-pack/plugins/reporting/common/constants/index.ts index 1424ee18b7be8..44e90356027bc 100644 --- a/x-pack/plugins/reporting/common/constants/index.ts +++ b/x-pack/plugins/reporting/common/constants/index.ts @@ -6,6 +6,7 @@ */ export * from './routes'; +export * from './export_types'; // Test Subjects export const REPORT_TABLE_ID = 'reportJobListing'; diff --git a/x-pack/plugins/reporting/common/test/fixtures.ts b/x-pack/plugins/reporting/common/test/fixtures.ts index 1628fb9e6af80..823785c4eb273 100644 --- a/x-pack/plugins/reporting/common/test/fixtures.ts +++ b/x-pack/plugins/reporting/common/test/fixtures.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { JOB_STATUS } from '@kbn/reporting-common'; import { ReportApiJSON } from '@kbn/reporting-common/types'; import type { ReportMock } from './types'; @@ -43,7 +44,7 @@ export const mockJobs: ReportApiJSON[] = [ }, ], } as any, - status: 'pending', + status: JOB_STATUS.PENDING, }), buildMockReport({ id: 'k90e51pk1ieucbae0c3t8wo1', @@ -56,7 +57,7 @@ export const mockJobs: ReportApiJSON[] = [ title: 'My Canvas Workpad', }, started_at: '2020-04-14T21:01:14.526Z', - status: 'processing', + status: JOB_STATUS.PROCESSING, }), buildMockReport({ id: 'k90cmthd1gv8cbae0c2le8bo', @@ -71,7 +72,7 @@ export const mockJobs: ReportApiJSON[] = [ title: 'My Canvas Workpad', }, started_at: '2020-04-14T20:19:04.073Z', - status: 'completed', + status: JOB_STATUS.COMPLETED, }), buildMockReport({ id: 'k906958e1d4wcbae0c9hip1a', @@ -92,7 +93,7 @@ export const mockJobs: ReportApiJSON[] = [ title: 'My Canvas Workpad', }, started_at: '2020-04-14T17:20:29.444Z', - status: 'completed_with_warnings', + status: JOB_STATUS.WARNINGS, }), buildMockReport({ id: 'k9067y2a1d4wcbae0cad38n0', @@ -107,7 +108,7 @@ export const mockJobs: ReportApiJSON[] = [ title: 'My Canvas Workpad', }, started_at: '2020-04-14T17:19:39.883Z', - status: 'completed', + status: JOB_STATUS.COMPLETED, }), buildMockReport({ id: 'k9067s1m1d4wcbae0cdnvcms', @@ -122,7 +123,7 @@ export const mockJobs: ReportApiJSON[] = [ title: 'My Canvas Workpad', }, started_at: '2020-04-14T17:19:25.247Z', - status: 'completed', + status: JOB_STATUS.COMPLETED, }), buildMockReport({ id: 'k9065q3s1d4wcbae0c00fxlh', @@ -137,7 +138,7 @@ export const mockJobs: ReportApiJSON[] = [ title: 'My Canvas Workpad', }, started_at: '2020-04-14T17:17:50.379Z', - status: 'completed', + status: JOB_STATUS.COMPLETED, }), buildMockReport({ id: 'k905zdw11d34cbae0c3y6tzh', @@ -153,7 +154,7 @@ export const mockJobs: ReportApiJSON[] = [ isDeprecated: true, }, started_at: '2020-04-14T17:12:52.431Z', - status: 'completed', + status: JOB_STATUS.COMPLETED, }), buildMockReport({ id: 'k8t4ylcb07mi9d006214ifyg', @@ -169,6 +170,6 @@ export const mockJobs: ReportApiJSON[] = [ isDeprecated: true, }, started_at: '2020-04-09T19:09:54.570Z', - status: 'completed', + status: JOB_STATUS.COMPLETED, }), ]; diff --git a/x-pack/plugins/reporting/public/lib/job.test.ts b/x-pack/plugins/reporting/public/lib/job.test.ts index d8be3b3e7060b..3f1e64d57daf8 100644 --- a/x-pack/plugins/reporting/public/lib/job.test.ts +++ b/x-pack/plugins/reporting/public/lib/job.test.ts @@ -5,8 +5,7 @@ * 2.0. */ -import { jobTypes } from '@kbn/reporting-common'; - +import { jobTypes } from '../../common/constants'; import { mockJobs } from '../../common/test'; import { Job } from './job'; diff --git a/x-pack/plugins/reporting/public/lib/job.tsx b/x-pack/plugins/reporting/public/lib/job.tsx index 38fd9b70b0a74..9aadb06bf5cc8 100644 --- a/x-pack/plugins/reporting/public/lib/job.tsx +++ b/x-pack/plugins/reporting/public/lib/job.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { EuiText, EuiTextColor } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { JOB_STATUS, JobTypes } from '@kbn/reporting-common'; +import { JOB_STATUS } from '@kbn/reporting-common'; import type { BaseParamsV2, JobId, @@ -21,6 +21,8 @@ import type { TaskRunResult, } from '@kbn/reporting-common/types'; +import { JobTypes } from '../../common/types'; + const { COMPLETED, FAILED, PENDING, PROCESSING, WARNINGS } = JOB_STATUS; type ReportPayload = ReportSource['payload']; diff --git a/x-pack/plugins/reporting/public/management/components/report_info_flyout_content.tsx b/x-pack/plugins/reporting/public/management/components/report_info_flyout_content.tsx index 04a18a9572946..ca47477133f6f 100644 --- a/x-pack/plugins/reporting/public/management/components/report_info_flyout_content.tsx +++ b/x-pack/plugins/reporting/public/management/components/report_info_flyout_content.tsx @@ -16,9 +16,9 @@ import { EuiTitle, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { USES_HEADLESS_JOB_TYPES } from '@kbn/reporting-common'; import { VisualReportingSoftDisabledError } from '@kbn/reporting-common/errors'; +import { USES_HEADLESS_JOB_TYPES } from '../../../common/constants'; import type { Job } from '../../lib/job'; import { sharedI18nTexts } from '../../shared_i18n_texts'; import { useKibana } from '../../shared_imports'; diff --git a/x-pack/plugins/reporting/public/types.ts b/x-pack/plugins/reporting/public/types.ts index 705232e6f32e3..5b88f2abbf5bd 100644 --- a/x-pack/plugins/reporting/public/types.ts +++ b/x-pack/plugins/reporting/public/types.ts @@ -6,19 +6,13 @@ */ import type { CoreSetup, CoreStart } from '@kbn/core/public'; - -import type { - JobId, - JobStatus, - ReportOutput, - ReportSource, - TaskRunResult, -} from '@kbn/reporting-common/types'; +import { JOB_STATUS } from '@kbn/reporting-common'; +import type { JobId, ReportOutput, ReportSource, TaskRunResult } from '@kbn/reporting-common/types'; /* Notifier Toasts */ export interface JobSummary { id: JobId; - status: JobStatus; + status: JOB_STATUS; jobtype: ReportSource['jobtype']; title: ReportSource['payload']['title']; errorCode?: ReportOutput['error_code']; diff --git a/x-pack/plugins/reporting/server/lib/tasks/index.ts b/x-pack/plugins/reporting/server/lib/tasks/index.ts index 7708f31f7147f..54493aee6de58 100644 --- a/x-pack/plugins/reporting/server/lib/tasks/index.ts +++ b/x-pack/plugins/reporting/server/lib/tasks/index.ts @@ -6,8 +6,7 @@ */ import { TaskRunCreatorFunction } from '@kbn/task-manager-plugin/server'; -import { BasePayload } from '@kbn/reporting-common/types'; -import { ReportSource } from '../../../common/types'; +import { BasePayload, ReportSource } from '@kbn/reporting-common/types'; export const REPORTING_EXECUTE_TYPE = 'report:execute'; export const REPORTING_MONITOR_TYPE = 'reports:monitor'; diff --git a/x-pack/plugins/reporting/server/usage/get_export_stats.ts b/x-pack/plugins/reporting/server/usage/get_export_stats.ts index 29d73232df884..4e2b1b6ceafc3 100644 --- a/x-pack/plugins/reporting/server/usage/get_export_stats.ts +++ b/x-pack/plugins/reporting/server/usage/get_export_stats.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { DEPRECATED_JOB_TYPES } from '@kbn/reporting-common'; +import { DEPRECATED_JOB_TYPES } from '../../common/constants'; import { ExportTypesHandler } from './get_export_type_handler'; import { AvailableTotal,