Skip to content

Commit

Permalink
Merge pull request #12 from tsullivan/reporting-packages
Browse files Browse the repository at this point in the history
Reporting packages
  • Loading branch information
rshen91 committed Nov 10, 2023
2 parents b941070 + ce671f1 commit 8614d36
Show file tree
Hide file tree
Showing 164 changed files with 980 additions and 820 deletions.
12 changes: 7 additions & 5 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ x-pack/examples/gen_ai_streaming_response_example @elastic/response-ops
packages/kbn-generate @elastic/kibana-operations
packages/kbn-generate-console-definitions @elastic/platform-deployment-management
packages/kbn-generate-csv @elastic/appex-sharedux
packages/kbn-generate-csv-types @elastic/appex-sharedux
packages/kbn-get-repo-files @elastic/kibana-operations
x-pack/plugins/global_search_bar @elastic/appex-sharedux
x-pack/plugins/global_search @elastic/appex-sharedux
Expand Down Expand Up @@ -589,14 +588,17 @@ packages/kbn-repo-path @elastic/kibana-operations
packages/kbn-repo-source-classifier @elastic/kibana-operations
packages/kbn-repo-source-classifier-cli @elastic/kibana-operations
packages/kbn-reporting/common @elastic/appex-sharedux
packages/kbn-reporting/config_server @elastic/appex-sharedux
x-pack/examples/reporting_example @elastic/appex-sharedux
packages/kbn-reporting/export_types/csv @elastic/appex-sharedux
packages/kbn-reporting/export_types/deprecated @elastic/appex-sharedux
packages/kbn-reporting/export_types_helpers_public @elastic/appex-sharedux
packages/kbn-reporting/export_types_helpers_server @elastic/appex-sharedux
packages/kbn-reporting/export_types/printable_pdf_v2 @elastic/appex-sharedux
packages/kbn-reporting/export_types/csv_common @elastic/appex-sharedux
packages/kbn-reporting/export_types/pdf @elastic/appex-sharedux
packages/kbn-reporting/export_types/pdf_common @elastic/appex-sharedux
packages/kbn-reporting/export_types/png @elastic/appex-sharedux
packages/kbn-reporting/export_types/png_common @elastic/appex-sharedux
packages/kbn-reporting/mocks_server @elastic/appex-sharedux
x-pack/plugins/reporting @elastic/appex-sharedux
packages/kbn-reporting/server @elastic/appex-sharedux
packages/kbn-resizable-layout @elastic/kibana-data-discovery
examples/resizable_layout_examples @elastic/kibana-data-discovery
x-pack/test/plugin_functional/plugins/resolver_test @elastic/security-solution
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@
"@kbn/gen-ai-streaming-response-example-plugin": "link:x-pack/examples/gen_ai_streaming_response_example",
"@kbn/generate-console-definitions": "link:packages/kbn-generate-console-definitions",
"@kbn/generate-csv": "link:packages/kbn-generate-csv",
"@kbn/generate-csv-types": "link:packages/kbn-generate-csv-types",
"@kbn/global-search-bar-plugin": "link:x-pack/plugins/global_search_bar",
"@kbn/global-search-plugin": "link:x-pack/plugins/global_search",
"@kbn/global-search-providers-plugin": "link:x-pack/plugins/global_search_providers",
Expand Down Expand Up @@ -594,14 +593,17 @@
"@kbn/repo-info": "link:packages/kbn-repo-info",
"@kbn/repo-packages": "link:packages/kbn-repo-packages",
"@kbn/reporting-common": "link:packages/kbn-reporting/common",
"@kbn/reporting-config-server": "link:packages/kbn-reporting/config_server",
"@kbn/reporting-example-plugin": "link:x-pack/examples/reporting_example",
"@kbn/reporting-export-types-csv": "link:packages/kbn-reporting/export_types/csv",
"@kbn/reporting-export-types-deprecated": "link:packages/kbn-reporting/export_types/deprecated",
"@kbn/reporting-export-types-helpers-public": "link:packages/kbn-reporting/export_types_helpers_public",
"@kbn/reporting-export-types-helpers-server": "link:packages/kbn-reporting/export_types_helpers_server",
"@kbn/reporting-export-types-pdf": "link:packages/kbn-reporting/export_types/printable_pdf_v2",
"@kbn/reporting-export-types-csv-common": "link:packages/kbn-reporting/export_types/csv_common",
"@kbn/reporting-export-types-pdf": "link:packages/kbn-reporting/export_types/pdf",
"@kbn/reporting-export-types-pdf-common": "link:packages/kbn-reporting/export_types/pdf_common",
"@kbn/reporting-export-types-png": "link:packages/kbn-reporting/export_types/png",
"@kbn/reporting-export-types-png-common": "link:packages/kbn-reporting/export_types/png_common",
"@kbn/reporting-mocks-server": "link:packages/kbn-reporting/mocks_server",
"@kbn/reporting-plugin": "link:x-pack/plugins/reporting",
"@kbn/reporting-server": "link:packages/kbn-reporting/server",
"@kbn/resizable-layout": "link:packages/kbn-resizable-layout",
"@kbn/resizable-layout-examples-plugin": "link:examples/resizable_layout_examples",
"@kbn/resolver-test-plugin": "link:x-pack/test/plugin_functional/plugins/resolver_test",
Expand Down
3 changes: 0 additions & 3 deletions packages/kbn-generate-csv-types/README.md

This file was deleted.

35 changes: 0 additions & 35 deletions packages/kbn-generate-csv-types/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/kbn-generate-csv/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
* Side Public License, v 1.
*/

/**
* These can not be imported from reporting-common due to potential for circular dependency
*/
export const CSV_BOM_CHARS = '\ufeff';
export const CONTENT_TYPE_CSV = 'text/csv';
export const UI_SETTINGS_CSV_SEPARATOR = 'csv:separator';
Expand Down
52 changes: 27 additions & 25 deletions packages/kbn-generate-csv/src/generate_csv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,24 @@ import { searchSourceInstanceMock } from '@kbn/data-plugin/common/search/search_
import { IScopedSearchClient } from '@kbn/data-plugin/server';
import { dataPluginMock } from '@kbn/data-plugin/server/mocks';
import { FieldFormatsRegistry } from '@kbn/field-formats-plugin/common';
import { CsvConfig, JobParams } from '@kbn/generate-csv-types';
import { CancellationToken } from '@kbn/reporting-common';
import { ReportingConfigType } from '@kbn/reporting-config-server';
import { JobParamsCSV } from '@kbn/reporting-export-types-csv-common';
import {
UI_SETTINGS_CSV_QUOTE_VALUES,
UI_SETTINGS_CSV_SEPARATOR,
UI_SETTINGS_DATEFORMAT_TZ,
} from './constants';
import { CsvGenerator } from './generate_csv';

const createMockJob = (baseObj: any = {}): JobParams => ({
const createMockJob = (baseObj: any = {}): JobParamsCSV => ({
...baseObj,
});

const createMockCancellationToken = () => new CancellationToken();

describe('CsvGenerator', () => {
let mockEsClient: IScopedClusterClient;
let mockDataClient: IScopedSearchClient;
let mockConfig: CsvConfig;
let mockConfig: ReportingConfigType['csv'];
let mockLogger: jest.Mocked<Logger>;
let uiSettingsClient: IUiSettingsClient;
let stream: jest.Mocked<Writable>;
Expand Down Expand Up @@ -118,6 +117,7 @@ describe('CsvGenerator', () => {
maxSizeBytes: 180000,
useByteOrderMarkEncoding: false,
scroll: { size: 500, duration: '30s' },
enablePanelActionDownload: true,
};

searchSourceMock.getField = jest.fn((key: string) => {
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -227,7 +227,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand All @@ -244,6 +244,7 @@ describe('CsvGenerator', () => {
maxSizeBytes: TEST_MAX_SIZE,
useByteOrderMarkEncoding: false,
scroll: { size: 500, duration: '30s' },
enablePanelActionDownload: true,
};

mockDataClient.search = jest.fn().mockImplementation(() =>
Expand Down Expand Up @@ -275,7 +276,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -334,7 +335,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -404,7 +405,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -442,7 +443,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -489,7 +490,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -543,7 +544,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -585,7 +586,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -623,7 +624,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -661,7 +662,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -701,7 +702,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -739,7 +740,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand All @@ -757,6 +758,7 @@ describe('CsvGenerator', () => {
maxSizeBytes: 180000,
useByteOrderMarkEncoding: false,
scroll: { size: 500, duration: '30s' },
enablePanelActionDownload: true,
};
mockDataClient.search = jest.fn().mockImplementation(() =>
Rx.of({
Expand Down Expand Up @@ -784,7 +786,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -813,7 +815,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -871,7 +873,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -915,7 +917,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -964,7 +966,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down Expand Up @@ -1023,7 +1025,7 @@ describe('CsvGenerator', () => {
searchSourceStart: mockSearchSourceService,
fieldFormatsRegistry: mockFieldFormatsRegistry,
},
createMockCancellationToken(),
new CancellationToken(),
mockLogger,
stream
);
Expand Down
9 changes: 5 additions & 4 deletions packages/kbn-generate-csv/src/generate_csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import type {
FieldFormatConfig,
IFieldFormatsRegistry,
} from '@kbn/field-formats-plugin/common';
import { CsvConfig, JobParams } from '@kbn/generate-csv-types';
import type { TaskRunResult } from '@kbn/reporting-common/types';
import {
AuthenticationExpiredError,
CancellationToken,
ReportingError,
byteSizeValueToNumber,
} from '@kbn/reporting-common';
import type { TaskRunResult } from '@kbn/reporting-common/types';
import { ReportingConfigType } from '@kbn/reporting-config-server';
import { JobParamsCSV } from '@kbn/reporting-export-types-csv-common';

import { CONTENT_TYPE_CSV } from './constants';
import { CsvExportSettings, getExportSettings } from './get_export_settings';
Expand All @@ -51,8 +52,8 @@ export class CsvGenerator {
private csvRowCount = 0;

constructor(
private job: Omit<JobParams, 'version'>,
private config: CsvConfig,
private job: Omit<JobParamsCSV, 'version'>,
private config: ReportingConfigType['csv'],
private clients: Clients,
private dependencies: Dependencies,
private cancellationToken: CancellationToken,
Expand Down
Loading

0 comments on commit 8614d36

Please sign in to comment.