From 57bf1ccd579710e010099447d72b149c031290c6 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Mon, 1 Jun 2020 13:37:31 -0700 Subject: [PATCH 01/16] [Reporting] Move code out of Legacy --- x-pack/index.js | 2 - x-pack/legacy/plugins/reporting/index.ts | 49 --------- .../legacy/plugins/reporting/server/index.ts | 17 --- .../legacy/plugins/reporting/server/legacy.ts | 61 ----------- .../lib/esqueue/__tests__/fixtures/queue.js | 11 -- .../legacy/plugins/reporting/server/plugin.ts | 81 --------------- x-pack/plugins/reporting/.gitignore | 1 + .../{legacy => }/plugins/reporting/README.md | 0 .../plugins/reporting/common/constants.ts | 0 .../reporting/common/get_absolute_url.test.ts | 0 .../reporting/common/get_absolute_url.ts | 0 x-pack/plugins/reporting/common/index.ts | 1 + x-pack/plugins/reporting/common/types.ts | 2 +- .../reporting/common/validate_urls.test.ts | 0 .../plugins/reporting/common/validate_urls.ts | 0 x-pack/plugins/reporting/kibana.json | 4 +- x-pack/plugins/reporting/public/plugin.tsx | 4 +- .../chromium/driver/chromium_driver.ts | 2 +- .../server/browsers/chromium/driver/index.ts | 0 .../browsers/chromium/driver_factory/args.ts | 0 .../browsers/chromium/driver_factory/index.ts | 0 .../server/browsers/chromium/index.ts | 0 .../server/browsers/chromium/paths.ts | 0 .../server/browsers/chromium/puppeteer.ts | 0 .../browsers/create_browser_driver_factory.ts | 3 +- .../server/browsers/download/checksum.ts | 0 .../server/browsers/download/clean.ts | 0 .../server/browsers/download/download.test.ts | 0 .../server/browsers/download/download.ts | 0 .../browsers/download/ensure_downloaded.ts | 0 .../server/browsers/download/index.ts | 0 .../server/browsers/download/util.ts | 0 .../extract/__tests__/__fixtures__/file.md | 0 .../__tests__/__fixtures__/file.md.zip | Bin .../browsers/extract/__tests__/extract.js | 0 .../server/browsers/extract/extract.js | 0 .../server/browsers/extract/extract_error.js | 0 .../server/browsers/extract/index.js | 0 .../server/browsers/extract/unzip.js | 0 .../reporting/server/browsers/index.ts | 0 .../reporting/server/browsers/install.ts | 0 .../server/browsers/network_policy.test.ts | 0 .../server/browsers/network_policy.ts | 0 .../server/browsers/safe_child_process.ts | 0 .../reporting/server/config/config.ts} | 16 ++- .../server/config/create_config.test.ts | 25 +++-- .../reporting/server/config/create_config.ts | 17 +-- .../plugins/reporting/server/config/index.ts | 9 +- .../plugins/reporting/server/config/schema.ts | 2 +- .../plugins/reporting/server/core.ts | 14 +-- .../server}/export_types/common/constants.ts | 0 .../execute_job/decrypt_job_headers.test.ts | 2 +- .../common/execute_job/decrypt_job_headers.ts | 2 +- .../get_conditional_headers.test.ts | 5 +- .../execute_job/get_conditional_headers.ts | 4 +- .../execute_job/get_custom_logo.test.ts | 2 +- .../common/execute_job/get_custom_logo.ts | 6 +- .../common/execute_job/get_full_urls.test.ts | 2 +- .../common/execute_job/get_full_urls.ts | 8 +- .../export_types/common/execute_job/index.ts | 0 .../omit_blacklisted_headers.test.ts | 0 .../execute_job/omit_blacklisted_headers.ts | 2 +- .../common/layouts/create_layout.ts | 2 +- .../export_types/common/layouts/index.ts | 4 +- .../export_types/common/layouts/layout.ts | 0 .../common/layouts/preserve_layout.css | 0 .../common/layouts/preserve_layout.ts | 0 .../export_types/common/layouts/print.css | 0 .../common/layouts/print_layout.ts | 6 +- .../common/lib/screenshots/constants.ts | 0 .../screenshots/get_element_position_data.ts | 6 +- .../lib/screenshots/get_number_of_items.ts | 6 +- .../common/lib/screenshots/get_screenshots.ts | 6 +- .../common/lib/screenshots/get_time_range.ts | 4 +- .../common/lib/screenshots/index.ts | 0 .../common/lib/screenshots/inject_css.ts | 4 +- .../common/lib/screenshots/observable.test.ts | 10 +- .../common/lib/screenshots/observable.ts | 4 +- .../common/lib/screenshots/open_url.ts | 6 +- .../common/lib/screenshots/wait_for_render.ts | 6 +- .../screenshots/wait_for_visualizations.ts | 6 +- .../server}/export_types/csv/index.ts | 10 +- .../server}/export_types/csv/metadata.ts | 0 .../export_types/csv/server/create_job.ts | 6 +- .../csv/server/execute_job.test.ts | 6 +- .../export_types/csv/server/execute_job.ts | 10 +- .../csv/server/lib/cell_has_formula.ts | 2 +- .../lib/check_cells_for_formulas.test.ts | 0 .../server/lib/check_cells_for_formulas.ts | 0 .../csv/server/lib/escape_value.test.ts | 0 .../csv/server/lib/escape_value.ts | 0 .../csv/server/lib/field_format_map.test.ts | 0 .../csv/server/lib/field_format_map.ts | 0 .../csv/server/lib/flatten_hit.test.ts | 0 .../csv/server/lib/flatten_hit.ts | 0 .../csv/server/lib/format_csv_values.test.ts | 0 .../csv/server/lib/format_csv_values.ts | 0 .../csv/server/lib/generate_csv.ts | 2 +- .../csv/server/lib/hit_iterator.test.ts | 4 +- .../csv/server/lib/hit_iterator.ts | 4 +- .../lib/max_size_string_builder.test.ts | 0 .../csv/server/lib/max_size_string_builder.ts | 0 .../server}/export_types/csv/types.d.ts | 2 +- .../csv_from_savedobject/index.ts | 6 +- .../csv_from_savedobject/metadata.ts | 2 +- .../server/create_job/create_job.ts | 8 +- .../server/create_job/create_job_search.ts | 2 +- .../server/create_job/index.ts | 0 .../server/execute_job.ts | 8 +- .../server/lib/generate_csv.ts | 4 +- .../server/lib/generate_csv_search.ts | 4 +- .../server/lib/get_data_source.ts | 0 .../server/lib/get_filters.test.ts | 2 +- .../server/lib/get_filters.ts | 2 +- .../server/lib/get_job_params_from_request.ts | 0 .../csv_from_savedobject/server/lib/index.ts | 0 .../csv_from_savedobject/types.d.ts | 3 +- .../server}/export_types/png/index.ts | 8 +- .../server}/export_types/png/metadata.ts | 0 .../png/server/create_job/index.ts | 6 +- .../png/server/execute_job/index.test.ts | 4 +- .../png/server/execute_job/index.ts | 8 +- .../png/server/lib/generate_png.ts | 6 +- .../server}/export_types/png/types.d.ts | 2 +- .../export_types/printable_pdf/index.ts | 8 +- .../export_types/printable_pdf/metadata.ts | 0 .../printable_pdf/server/create_job/index.ts | 6 +- .../server/execute_job/index.test.ts | 4 +- .../printable_pdf/server/execute_job/index.ts | 10 +- .../printable_pdf/server/lib/generate_pdf.ts | 6 +- .../lib/pdf/assets/fonts/noto/LICENSE_OFL.txt | 0 .../fonts/noto/NotoSansCJKtc-Medium.ttf | Bin .../fonts/noto/NotoSansCJKtc-Regular.ttf | Bin .../server/lib/pdf/assets/fonts/noto/index.js | 0 .../lib/pdf/assets/fonts/roboto/LICENSE.txt | 0 .../pdf/assets/fonts/roboto/Roboto-Italic.ttf | Bin .../pdf/assets/fonts/roboto/Roboto-Medium.ttf | Bin .../assets/fonts/roboto/Roboto-Regular.ttf | Bin .../server/lib/pdf/assets/img/logo-grey.png | Bin .../printable_pdf/server/lib/pdf/index.js | 0 .../printable_pdf/server/lib/tracker.ts | 0 .../printable_pdf/server/lib/uri_encode.js | 0 .../export_types/printable_pdf/types.d.ts | 2 +- x-pack/plugins/reporting/server/index.ts | 17 ++- .../lib/__tests__/export_types_registry.js | 0 .../server/lib/check_license.test.ts | 2 +- .../reporting/server/lib/check_license.ts | 2 +- .../reporting/server/lib/create_queue.ts | 0 .../server/lib/create_tagged_logger.ts | 0 .../server/lib/create_worker.test.ts | 2 +- .../reporting/server/lib/create_worker.ts | 2 +- .../plugins/reporting/server/lib/crypto.ts | 0 .../reporting/server/lib/enqueue_job.ts | 2 +- .../lib/esqueue/__tests__/fixtures/job.js | 6 ++ .../fixtures/legacy_elasticsearch.js | 0 .../lib/esqueue/__tests__/fixtures/queue.js} | 12 ++- .../lib/esqueue/__tests__/fixtures/worker.js | 6 ++ .../esqueue/__tests__/helpers/create_index.js | 0 .../lib/esqueue/__tests__/helpers/errors.js | 0 .../__tests__/helpers/index_timestamp.js | 0 .../server/lib/esqueue/__tests__/index.js | 0 .../server/lib/esqueue/__tests__/job.js | 0 .../server/lib/esqueue/__tests__/worker.js | 0 .../lib/esqueue/constants/default_settings.js | 0 .../server/lib/esqueue/constants/events.js | 0 .../server/lib/esqueue/constants/index.js | 0 .../server/lib/esqueue/constants/statuses.ts | 0 .../lib/esqueue/helpers/create_index.js | 0 .../server/lib/esqueue/helpers/errors.js | 0 .../lib/esqueue/helpers/index_timestamp.js | 0 .../reporting/server/lib/esqueue/index.js | 0 .../reporting/server/lib/esqueue/job.js | 0 .../reporting/server/lib/esqueue/worker.js | 3 +- .../server/lib/export_types_registry.ts | 8 +- .../plugins/reporting/server/lib/get_user.ts | 4 +- .../plugins/reporting/server/lib/index.ts | 0 .../reporting/server/lib/jobs_query.ts | 2 +- .../reporting/server/lib/level_logger.ts | 0 .../plugins/reporting/server/lib/trace.ts | 0 .../reporting/server/lib/validate/index.ts | 0 .../server/lib/validate/validate_browser.ts | 0 .../validate_max_content_length.test.js | 0 .../validate/validate_max_content_length.ts | 0 x-pack/plugins/reporting/server/plugin.ts | 97 +++++++++++++----- .../server/routes/generate_from_jobparams.ts | 0 .../routes/generate_from_savedobject.ts | 2 +- .../generate_from_savedobject_immediate.ts | 9 +- .../server/routes/generation.test.ts | 6 +- .../reporting/server/routes/generation.ts | 0 .../plugins/reporting/server/routes/index.ts | 0 .../reporting/server/routes/jobs.test.ts | 12 +-- .../plugins/reporting/server/routes/jobs.ts | 0 .../lib/authorized_user_pre_routing.test.ts | 2 +- .../routes/lib/authorized_user_pre_routing.ts | 2 +- .../server/routes/lib/get_document_payload.ts | 0 .../server/routes/lib/job_response_handler.ts | 2 +- .../reporting/server/routes/types.d.ts | 4 +- .../plugins/reporting/server/services.ts | 4 +- .../create_mock_browserdriverfactory.ts | 8 +- .../create_mock_layoutinstance.ts | 2 +- .../create_mock_reportingplugin.ts | 27 +++-- .../test_helpers/create_mock_server.ts | 0 .../reporting/server}/test_helpers/index.ts | 0 .../plugins/reporting/server/types.ts | 29 ++---- .../reporting_usage_collector.test.ts.snap | 0 .../server/usage/decorate_range_stats.ts | 0 .../server/usage/get_export_type_handler.ts | 0 .../server/usage/get_reporting_usage.ts | 0 .../plugins/reporting/server/usage/index.ts | 2 +- .../usage/reporting_usage_collector.test.ts | 2 +- .../server/usage/reporting_usage_collector.ts | 0 .../plugins/reporting/server/usage/types.ts | 0 x-pack/tasks/prepare.ts | 2 +- .../reporting_api_integration/services.ts | 2 +- 214 files changed, 345 insertions(+), 518 deletions(-) delete mode 100644 x-pack/legacy/plugins/reporting/index.ts delete mode 100644 x-pack/legacy/plugins/reporting/server/index.ts delete mode 100644 x-pack/legacy/plugins/reporting/server/legacy.ts delete mode 100644 x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js delete mode 100644 x-pack/legacy/plugins/reporting/server/plugin.ts create mode 100644 x-pack/plugins/reporting/.gitignore rename x-pack/{legacy => }/plugins/reporting/README.md (100%) rename x-pack/{legacy => }/plugins/reporting/common/constants.ts (100%) rename x-pack/{legacy => }/plugins/reporting/common/get_absolute_url.test.ts (100%) rename x-pack/{legacy => }/plugins/reporting/common/get_absolute_url.ts (100%) rename x-pack/{legacy => }/plugins/reporting/common/validate_urls.test.ts (100%) rename x-pack/{legacy => }/plugins/reporting/common/validate_urls.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts (99%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/chromium/driver/index.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/chromium/driver_factory/args.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/chromium/driver_factory/index.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/chromium/index.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/chromium/paths.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/chromium/puppeteer.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/create_browser_driver_factory.ts (92%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/download/checksum.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/download/clean.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/download/download.test.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/download/download.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/download/ensure_downloaded.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/download/index.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/download/util.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md.zip (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/extract/__tests__/extract.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/extract/extract.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/extract/extract_error.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/extract/index.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/extract/unzip.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/index.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/install.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/network_policy.test.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/network_policy.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/browsers/safe_child_process.ts (100%) rename x-pack/{legacy/plugins/reporting/server/config/index.ts => plugins/reporting/server/config/config.ts} (84%) rename x-pack/{legacy => }/plugins/reporting/server/core.ts (93%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/constants.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/execute_job/decrypt_job_headers.test.ts (96%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/execute_job/decrypt_job_headers.ts (95%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/execute_job/get_conditional_headers.test.ts (97%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/execute_job/get_conditional_headers.ts (89%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/execute_job/get_custom_logo.test.ts (97%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/execute_job/get_custom_logo.ts (87%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/execute_job/get_full_urls.test.ts (99%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/execute_job/get_full_urls.ts (93%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/execute_job/index.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/execute_job/omit_blacklisted_headers.test.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/execute_job/omit_blacklisted_headers.ts (95%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/layouts/create_layout.ts (93%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/layouts/index.ts (93%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/layouts/layout.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/layouts/preserve_layout.css (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/layouts/preserve_layout.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/layouts/print.css (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/layouts/print_layout.ts (94%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/constants.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/get_element_position_data.ts (94%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/get_number_of_items.ts (93%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/get_screenshots.ts (89%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/get_time_range.ts (90%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/index.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/inject_css.ts (92%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/observable.test.ts (98%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/observable.ts (98%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/open_url.ts (83%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/wait_for_render.ts (93%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/common/lib/screenshots/wait_for_visualizations.ts (91%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/index.ts (85%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/metadata.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/create_job.ts (87%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/execute_job.test.ts (99%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/execute_job.ts (95%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/cell_has_formula.ts (85%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/check_cells_for_formulas.test.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/check_cells_for_formulas.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/escape_value.test.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/escape_value.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/field_format_map.test.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/field_format_map.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/flatten_hit.test.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/flatten_hit.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/format_csv_values.test.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/format_csv_values.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/generate_csv.ts (98%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/hit_iterator.test.ts (97%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/hit_iterator.ts (96%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/max_size_string_builder.test.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/server/lib/max_size_string_builder.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv/types.d.ts (96%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/index.ts (89%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/metadata.ts (82%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/server/create_job/create_job.ts (92%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/server/create_job/create_job_search.ts (95%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/server/create_job/index.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/server/execute_job.ts (96%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/server/lib/generate_csv.ts (92%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts (98%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/server/lib/get_data_source.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/server/lib/get_filters.test.ts (98%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/server/lib/get_filters.ts (96%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/server/lib/get_job_params_from_request.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/server/lib/index.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/csv_from_savedobject/types.d.ts (95%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/png/index.ts (88%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/png/metadata.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/png/server/create_job/index.ts (88%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/png/server/execute_job/index.test.ts (97%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/png/server/execute_job/index.ts (93%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/png/server/lib/generate_png.ts (93%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/png/types.d.ts (93%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/index.ts (88%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/metadata.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/create_job/index.ts (89%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/execute_job/index.test.ts (97%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/execute_job/index.ts (92%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/generate_pdf.ts (96%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/LICENSE_OFL.txt (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/index.js (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/LICENSE.txt (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/pdf/index.js (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/tracker.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/server/lib/uri_encode.js (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/export_types/printable_pdf/types.d.ts (94%) rename x-pack/{legacy => }/plugins/reporting/server/lib/__tests__/export_types_registry.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/check_license.test.ts (99%) rename x-pack/{legacy => }/plugins/reporting/server/lib/check_license.ts (97%) rename x-pack/{legacy => }/plugins/reporting/server/lib/create_queue.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/create_tagged_logger.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/create_worker.test.ts (98%) rename x-pack/{legacy => }/plugins/reporting/server/lib/create_worker.ts (97%) rename x-pack/{legacy => }/plugins/reporting/server/lib/crypto.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/enqueue_job.ts (97%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js (57%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/__tests__/fixtures/legacy_elasticsearch.js (100%) rename x-pack/{legacy/plugins/reporting/reporting.d.ts => plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js} (58%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js (55%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/__tests__/helpers/index_timestamp.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/__tests__/index.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/__tests__/job.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/__tests__/worker.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/constants/default_settings.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/constants/events.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/constants/index.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/constants/statuses.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/helpers/create_index.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/helpers/errors.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/helpers/index_timestamp.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/index.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/job.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/esqueue/worker.js (99%) rename x-pack/{legacy => }/plugins/reporting/server/lib/export_types_registry.ts (91%) rename x-pack/{legacy => }/plugins/reporting/server/lib/get_user.ts (74%) rename x-pack/{legacy => }/plugins/reporting/server/lib/index.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/jobs_query.ts (98%) rename x-pack/{legacy => }/plugins/reporting/server/lib/level_logger.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/trace.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/validate/index.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/validate/validate_browser.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/validate/validate_max_content_length.test.js (100%) rename x-pack/{legacy => }/plugins/reporting/server/lib/validate/validate_max_content_length.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/routes/generate_from_jobparams.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/routes/generate_from_savedobject.ts (96%) rename x-pack/{legacy => }/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts (90%) rename x-pack/{legacy => }/plugins/reporting/server/routes/generation.test.ts (97%) rename x-pack/{legacy => }/plugins/reporting/server/routes/generation.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/routes/index.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/routes/jobs.test.ts (99%) rename x-pack/{legacy => }/plugins/reporting/server/routes/jobs.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts (98%) rename x-pack/{legacy => }/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts (95%) rename x-pack/{legacy => }/plugins/reporting/server/routes/lib/get_document_payload.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/routes/lib/job_response_handler.ts (97%) rename x-pack/{legacy => }/plugins/reporting/server/routes/types.d.ts (82%) rename x-pack/{legacy => }/plugins/reporting/server/services.ts (67%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/test_helpers/create_mock_browserdriverfactory.ts (96%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/test_helpers/create_mock_layoutinstance.ts (93%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/test_helpers/create_mock_reportingplugin.ts (70%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/test_helpers/create_mock_server.ts (100%) rename x-pack/{legacy/plugins/reporting => plugins/reporting/server}/test_helpers/index.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/types.ts (85%) rename x-pack/{legacy => }/plugins/reporting/server/usage/__snapshots__/reporting_usage_collector.test.ts.snap (100%) rename x-pack/{legacy => }/plugins/reporting/server/usage/decorate_range_stats.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/usage/get_export_type_handler.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/usage/get_reporting_usage.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/usage/index.ts (87%) rename x-pack/{legacy => }/plugins/reporting/server/usage/reporting_usage_collector.test.ts (99%) rename x-pack/{legacy => }/plugins/reporting/server/usage/reporting_usage_collector.ts (100%) rename x-pack/{legacy => }/plugins/reporting/server/usage/types.ts (100%) diff --git a/x-pack/index.js b/x-pack/index.js index 9cf63854d4093..8096774d7a491 100644 --- a/x-pack/index.js +++ b/x-pack/index.js @@ -6,7 +6,6 @@ import { xpackMain } from './legacy/plugins/xpack_main'; import { monitoring } from './legacy/plugins/monitoring'; -import { reporting } from './legacy/plugins/reporting'; import { security } from './legacy/plugins/security'; import { dashboardMode } from './legacy/plugins/dashboard_mode'; import { beats } from './legacy/plugins/beats_management'; @@ -18,7 +17,6 @@ module.exports = function (kibana) { return [ xpackMain(kibana), monitoring(kibana), - reporting(kibana), spaces(kibana), security(kibana), dashboardMode(kibana), diff --git a/x-pack/legacy/plugins/reporting/index.ts b/x-pack/legacy/plugins/reporting/index.ts deleted file mode 100644 index 1ae971b6566b0..0000000000000 --- a/x-pack/legacy/plugins/reporting/index.ts +++ /dev/null @@ -1,49 +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. - */ - -import { i18n } from '@kbn/i18n'; -import { Legacy } from 'kibana'; -import { resolve } from 'path'; -import { PLUGIN_ID, UI_SETTINGS_CUSTOM_PDF_LOGO } from './common/constants'; -import { legacyInit } from './server/legacy'; - -export type ReportingPluginSpecOptions = Legacy.PluginSpecOptions; - -const kbToBase64Length = (kb: number) => Math.floor((kb * 1024 * 8) / 6); - -export const reporting = (kibana: any) => { - return new kibana.Plugin({ - id: PLUGIN_ID, - publicDir: resolve(__dirname, 'public'), - require: ['kibana', 'elasticsearch', 'xpack_main'], - - uiExports: { - uiSettingDefaults: { - [UI_SETTINGS_CUSTOM_PDF_LOGO]: { - name: i18n.translate('xpack.reporting.pdfFooterImageLabel', { - defaultMessage: 'PDF footer image', - }), - value: null, - description: i18n.translate('xpack.reporting.pdfFooterImageDescription', { - defaultMessage: `Custom image to use in the PDF's footer`, - }), - type: 'image', - validation: { - maxSize: { - length: kbToBase64Length(200), - description: '200 kB', - }, - }, - category: [PLUGIN_ID], - }, - }, - }, - - async init(server: Legacy.Server) { - return legacyInit(server, this); - }, - } as ReportingPluginSpecOptions); -}; diff --git a/x-pack/legacy/plugins/reporting/server/index.ts b/x-pack/legacy/plugins/reporting/server/index.ts deleted file mode 100644 index 2388eac48f8cc..0000000000000 --- a/x-pack/legacy/plugins/reporting/server/index.ts +++ /dev/null @@ -1,17 +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. - */ - -import { PluginInitializerContext } from 'src/core/server'; -import { ReportingConfig } from './config'; -import { ReportingCore } from './core'; -import { ReportingPlugin as Plugin } from './plugin'; - -export const plugin = (context: PluginInitializerContext, config: ReportingConfig) => { - return new Plugin(context, config); -}; - -export { ReportingPlugin } from './plugin'; -export { ReportingConfig, ReportingCore }; diff --git a/x-pack/legacy/plugins/reporting/server/legacy.ts b/x-pack/legacy/plugins/reporting/server/legacy.ts deleted file mode 100644 index 14abd53cc83d9..0000000000000 --- a/x-pack/legacy/plugins/reporting/server/legacy.ts +++ /dev/null @@ -1,61 +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. - */ - -import { Legacy } from 'kibana'; -import { take } from 'rxjs/operators'; -import { PluginInitializerContext } from 'src/core/server'; -import { LicensingPluginSetup } from '../../../../plugins/licensing/server'; -import { ReportingPluginSpecOptions } from '../'; -import { PluginsSetup } from '../../../../plugins/reporting/server'; -import { SecurityPluginSetup } from '../../../../plugins/security/server'; -import { buildConfig } from './config'; -import { plugin } from './index'; -import { LegacySetup, ReportingStartDeps } from './types'; - -const buildLegacyDependencies = ( - server: Legacy.Server, - reportingPlugin: ReportingPluginSpecOptions -): LegacySetup => ({ - route: server.route.bind(server), - plugins: { - xpack_main: server.plugins.xpack_main, - reporting: reportingPlugin, - }, -}); - -/* - * Starts the New Platform instance of Reporting using legacy dependencies - */ -export const legacyInit = async ( - server: Legacy.Server, - reportingLegacyPlugin: ReportingPluginSpecOptions -) => { - const { core: coreSetup } = server.newPlatform.setup; - const { config$ } = (server.newPlatform.setup.plugins.reporting as PluginsSetup).__legacy; - const reportingConfig = await config$.pipe(take(1)).toPromise(); - const __LEGACY = buildLegacyDependencies(server, reportingLegacyPlugin); - - const pluginInstance = plugin( - server.newPlatform.coreContext as PluginInitializerContext, - buildConfig(coreSetup, server, reportingConfig) - ); - - await pluginInstance.setup(coreSetup, { - elasticsearch: coreSetup.elasticsearch, - licensing: server.newPlatform.setup.plugins.licensing as LicensingPluginSetup, - security: server.newPlatform.setup.plugins.security as SecurityPluginSetup, - usageCollection: server.newPlatform.setup.plugins.usageCollection, - __LEGACY, - }); - - // Schedule to call the "start" hook only after start dependencies are ready - coreSetup.getStartServices().then(([core, plugins]) => - pluginInstance.start(core, { - data: (plugins as ReportingStartDeps).data, - __LEGACY, - }) - ); -}; diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js b/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js deleted file mode 100644 index 6bdd922555fa9..0000000000000 --- a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js +++ /dev/null @@ -1,11 +0,0 @@ -import events from 'events'; - -export class QueueMock extends events.EventEmitter { - constructor() { - super(); - } - - setClient(client) { - this.client = client; - } -} diff --git a/x-pack/legacy/plugins/reporting/server/plugin.ts b/x-pack/legacy/plugins/reporting/server/plugin.ts deleted file mode 100644 index 5a407ad3e4c4a..0000000000000 --- a/x-pack/legacy/plugins/reporting/server/plugin.ts +++ /dev/null @@ -1,81 +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. - */ - -import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/server'; -import { createBrowserDriverFactory } from './browsers'; -import { ReportingConfig } from './config'; -import { ReportingCore } from './core'; -import { registerRoutes } from './routes'; -import { createQueueFactory, enqueueJobFactory, LevelLogger, runValidations } from './lib'; -import { setFieldFormats } from './services'; -import { ReportingSetup, ReportingSetupDeps, ReportingStart, ReportingStartDeps } from './types'; -import { registerReportingUsageCollector } from './usage'; -// @ts-ignore no module definition -import { mirrorPluginStatus } from '../../../server/lib/mirror_plugin_status'; - -export class ReportingPlugin - implements Plugin { - private config: ReportingConfig; - private logger: LevelLogger; - private reportingCore: ReportingCore; - - constructor(context: PluginInitializerContext, config: ReportingConfig) { - this.config = config; - this.logger = new LevelLogger(context.logger.get('reporting')); - this.reportingCore = new ReportingCore(this.config); - } - - public async setup(core: CoreSetup, plugins: ReportingSetupDeps) { - const { config } = this; - const { elasticsearch, __LEGACY, licensing, security } = plugins; - const router = core.http.createRouter(); - const basePath = core.http.basePath.get; - const { xpack_main: xpackMainLegacy, reporting: reportingLegacy } = __LEGACY.plugins; - - // legacy plugin status - mirrorPluginStatus(xpackMainLegacy, reportingLegacy); - - const browserDriverFactory = await createBrowserDriverFactory(config, this.logger); - const deps = { - browserDriverFactory, - elasticsearch, - licensing, - basePath, - router, - security, - }; - - runValidations(config, elasticsearch, browserDriverFactory, this.logger); - - this.reportingCore.pluginSetup(deps); - registerReportingUsageCollector(this.reportingCore, plugins); - registerRoutes(this.reportingCore, this.logger); - - return {}; - } - - public async start(core: CoreStart, plugins: ReportingStartDeps) { - const { reportingCore, logger } = this; - - const esqueue = await createQueueFactory(reportingCore, logger); - const enqueueJob = enqueueJobFactory(reportingCore, logger); - - this.reportingCore.pluginStart({ - savedObjects: core.savedObjects, - uiSettings: core.uiSettings, - esqueue, - enqueueJob, - }); - - setFieldFormats(plugins.data.fieldFormats); - - return {}; - } - - public getReportingCore() { - return this.reportingCore; - } -} diff --git a/x-pack/plugins/reporting/.gitignore b/x-pack/plugins/reporting/.gitignore new file mode 100644 index 0000000000000..41d357b60e1f0 --- /dev/null +++ b/x-pack/plugins/reporting/.gitignore @@ -0,0 +1 @@ +.chromium diff --git a/x-pack/legacy/plugins/reporting/README.md b/x-pack/plugins/reporting/README.md similarity index 100% rename from x-pack/legacy/plugins/reporting/README.md rename to x-pack/plugins/reporting/README.md diff --git a/x-pack/legacy/plugins/reporting/common/constants.ts b/x-pack/plugins/reporting/common/constants.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/common/constants.ts rename to x-pack/plugins/reporting/common/constants.ts diff --git a/x-pack/legacy/plugins/reporting/common/get_absolute_url.test.ts b/x-pack/plugins/reporting/common/get_absolute_url.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/common/get_absolute_url.test.ts rename to x-pack/plugins/reporting/common/get_absolute_url.test.ts diff --git a/x-pack/legacy/plugins/reporting/common/get_absolute_url.ts b/x-pack/plugins/reporting/common/get_absolute_url.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/common/get_absolute_url.ts rename to x-pack/plugins/reporting/common/get_absolute_url.ts diff --git a/x-pack/plugins/reporting/common/index.ts b/x-pack/plugins/reporting/common/index.ts index 36c896fb4f7b8..cda8934fc8bf6 100644 --- a/x-pack/plugins/reporting/common/index.ts +++ b/x-pack/plugins/reporting/common/index.ts @@ -5,3 +5,4 @@ */ export { CancellationToken } from './cancellation_token'; +export { Poller } from './poller'; diff --git a/x-pack/plugins/reporting/common/types.ts b/x-pack/plugins/reporting/common/types.ts index 5b9ddfb1bbdea..2b9e9299852f5 100644 --- a/x-pack/plugins/reporting/common/types.ts +++ b/x-pack/plugins/reporting/common/types.ts @@ -5,7 +5,7 @@ */ // eslint-disable-next-line @kbn/eslint/no-restricted-paths -export { ConfigType } from '../server/config'; +export { ReportingConfigType } from '../server/config'; export type JobId = string; export type JobStatus = diff --git a/x-pack/legacy/plugins/reporting/common/validate_urls.test.ts b/x-pack/plugins/reporting/common/validate_urls.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/common/validate_urls.test.ts rename to x-pack/plugins/reporting/common/validate_urls.test.ts diff --git a/x-pack/legacy/plugins/reporting/common/validate_urls.ts b/x-pack/plugins/reporting/common/validate_urls.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/common/validate_urls.ts rename to x-pack/plugins/reporting/common/validate_urls.ts diff --git a/x-pack/plugins/reporting/kibana.json b/x-pack/plugins/reporting/kibana.json index e44bd92c42391..282419fde4c24 100644 --- a/x-pack/plugins/reporting/kibana.json +++ b/x-pack/plugins/reporting/kibana.json @@ -12,9 +12,7 @@ "licensing", "uiActions", "embeddable", - "share", - "kibanaLegacy", - "licensing" + "share" ], "server": true, "ui": true diff --git a/x-pack/plugins/reporting/public/plugin.tsx b/x-pack/plugins/reporting/public/plugin.tsx index 7495e46de47d9..cd82ef3f19455 100644 --- a/x-pack/plugins/reporting/public/plugin.tsx +++ b/x-pack/plugins/reporting/public/plugin.tsx @@ -26,7 +26,7 @@ import { import { ManagementSectionId, ManagementSetup } from '../../../../src/plugins/management/public'; import { SharePluginSetup } from '../../../../src/plugins/share/public'; import { LicensingPluginSetup } from '../../licensing/public'; -import { ConfigType, JobId, JobStatusBuckets } from '../common/types'; +import { ReportingConfigType, JobId, JobStatusBuckets } from '../common/types'; import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY } from '../constants'; import { getGeneralErrorToast } from './components'; import { ReportListing } from './components/report_listing'; @@ -37,7 +37,7 @@ import { csvReportingProvider } from './share_context_menu/register_csv_reportin import { reportingPDFPNGProvider } from './share_context_menu/register_pdf_png_reporting'; export interface ClientConfigType { - poll: ConfigType['poll']; + poll: ReportingConfigType['poll']; } function getStored(): JobId[] { diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts similarity index 99% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts rename to x-pack/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts index 6480fb4413f04..898b123e976fd 100644 --- a/x-pack/legacy/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts +++ b/x-pack/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts @@ -9,7 +9,7 @@ import { map, trunc } from 'lodash'; import open from 'opn'; import { ElementHandle, EvaluateFn, Page, Response, SerializableOrJSHandle } from 'puppeteer'; import { parse as parseUrl } from 'url'; -import { ViewZoomWidthHeight } from '../../../../export_types/common/layouts/layout'; +import { ViewZoomWidthHeight } from '../../../export_types/common/layouts/layout'; import { LevelLogger } from '../../../lib'; import { ConditionalHeaders, ElementPosition } from '../../../types'; import { allowRequest, NetworkPolicy } from '../../network_policy'; diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/driver/index.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/driver/index.ts rename to x-pack/plugins/reporting/server/browsers/chromium/driver/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/driver_factory/args.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver_factory/args.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/driver_factory/args.ts rename to x-pack/plugins/reporting/server/browsers/chromium/driver_factory/args.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/driver_factory/index.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/driver_factory/index.ts rename to x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/index.ts b/x-pack/plugins/reporting/server/browsers/chromium/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/index.ts rename to x-pack/plugins/reporting/server/browsers/chromium/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/paths.ts b/x-pack/plugins/reporting/server/browsers/chromium/paths.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/paths.ts rename to x-pack/plugins/reporting/server/browsers/chromium/paths.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/chromium/puppeteer.ts b/x-pack/plugins/reporting/server/browsers/chromium/puppeteer.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/chromium/puppeteer.ts rename to x-pack/plugins/reporting/server/browsers/chromium/puppeteer.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/create_browser_driver_factory.ts b/x-pack/plugins/reporting/server/browsers/create_browser_driver_factory.ts similarity index 92% rename from x-pack/legacy/plugins/reporting/server/browsers/create_browser_driver_factory.ts rename to x-pack/plugins/reporting/server/browsers/create_browser_driver_factory.ts index 7b4407890652c..ff74f4eec45df 100644 --- a/x-pack/legacy/plugins/reporting/server/browsers/create_browser_driver_factory.ts +++ b/x-pack/plugins/reporting/server/browsers/create_browser_driver_factory.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { first } from 'rxjs/operators'; import { ReportingConfig } from '../'; import { LevelLogger } from '../lib'; import { HeadlessChromiumDriverFactory } from './chromium/driver_factory'; @@ -19,7 +20,7 @@ export async function createBrowserDriverFactory( const browserConfig = captureConfig.browser.chromium; const browserAutoDownload = captureConfig.browser.autoDownload; const browserType = captureConfig.browser.type; - const dataDir = config.kbnConfig.get('path', 'data'); + const dataDir = await config.kbnConfig.get('path', 'data').pipe(first()).toPromise(); if (browserConfig.disableSandbox) { logger.warning(`Enabling the Chromium sandbox provides an additional layer of protection.`); diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/checksum.ts b/x-pack/plugins/reporting/server/browsers/download/checksum.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/download/checksum.ts rename to x-pack/plugins/reporting/server/browsers/download/checksum.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/clean.ts b/x-pack/plugins/reporting/server/browsers/download/clean.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/download/clean.ts rename to x-pack/plugins/reporting/server/browsers/download/clean.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/download.test.ts b/x-pack/plugins/reporting/server/browsers/download/download.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/download/download.test.ts rename to x-pack/plugins/reporting/server/browsers/download/download.test.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/download.ts b/x-pack/plugins/reporting/server/browsers/download/download.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/download/download.ts rename to x-pack/plugins/reporting/server/browsers/download/download.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/ensure_downloaded.ts b/x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/download/ensure_downloaded.ts rename to x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/index.ts b/x-pack/plugins/reporting/server/browsers/download/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/download/index.ts rename to x-pack/plugins/reporting/server/browsers/download/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/download/util.ts b/x-pack/plugins/reporting/server/browsers/download/util.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/download/util.ts rename to x-pack/plugins/reporting/server/browsers/download/util.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md b/x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md rename to x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md.zip b/x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md.zip similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md.zip rename to x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md.zip diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/extract.js b/x-pack/plugins/reporting/server/browsers/extract/__tests__/extract.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/__tests__/extract.js rename to x-pack/plugins/reporting/server/browsers/extract/__tests__/extract.js diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/extract.js b/x-pack/plugins/reporting/server/browsers/extract/extract.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/extract.js rename to x-pack/plugins/reporting/server/browsers/extract/extract.js diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/extract_error.js b/x-pack/plugins/reporting/server/browsers/extract/extract_error.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/extract_error.js rename to x-pack/plugins/reporting/server/browsers/extract/extract_error.js diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/index.js b/x-pack/plugins/reporting/server/browsers/extract/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/index.js rename to x-pack/plugins/reporting/server/browsers/extract/index.js diff --git a/x-pack/legacy/plugins/reporting/server/browsers/extract/unzip.js b/x-pack/plugins/reporting/server/browsers/extract/unzip.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/extract/unzip.js rename to x-pack/plugins/reporting/server/browsers/extract/unzip.js diff --git a/x-pack/legacy/plugins/reporting/server/browsers/index.ts b/x-pack/plugins/reporting/server/browsers/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/index.ts rename to x-pack/plugins/reporting/server/browsers/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/install.ts b/x-pack/plugins/reporting/server/browsers/install.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/install.ts rename to x-pack/plugins/reporting/server/browsers/install.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/network_policy.test.ts b/x-pack/plugins/reporting/server/browsers/network_policy.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/network_policy.test.ts rename to x-pack/plugins/reporting/server/browsers/network_policy.test.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/network_policy.ts b/x-pack/plugins/reporting/server/browsers/network_policy.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/network_policy.ts rename to x-pack/plugins/reporting/server/browsers/network_policy.ts diff --git a/x-pack/legacy/plugins/reporting/server/browsers/safe_child_process.ts b/x-pack/plugins/reporting/server/browsers/safe_child_process.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/browsers/safe_child_process.ts rename to x-pack/plugins/reporting/server/browsers/safe_child_process.ts diff --git a/x-pack/legacy/plugins/reporting/server/config/index.ts b/x-pack/plugins/reporting/server/config/config.ts similarity index 84% rename from x-pack/legacy/plugins/reporting/server/config/index.ts rename to x-pack/plugins/reporting/server/config/config.ts index 3ec5aab4d451b..4142ab6f0ae43 100644 --- a/x-pack/legacy/plugins/reporting/server/config/index.ts +++ b/x-pack/plugins/reporting/server/config/config.ts @@ -4,10 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Legacy } from 'kibana'; +import { Observable } from 'rxjs'; import { get } from 'lodash'; -import { CoreSetup } from 'src/core/server'; -import { ConfigType as ReportingConfigType } from '../../../../../plugins/reporting/server'; +import { map } from 'rxjs/operators'; +import { CoreSetup, PluginInitializerContext } from 'src/core/server'; +import { ReportingConfigType } from './schema'; // make config.get() aware of the value type it returns interface Config { @@ -39,7 +40,7 @@ interface Config { } interface KbnServerConfigType { - path: { data: string }; + path: { data: Observable }; server: { basePath: string; host: string; @@ -55,17 +56,16 @@ export interface ReportingConfig extends Config { } export const buildConfig = ( + initContext: PluginInitializerContext, core: CoreSetup, - server: Legacy.Server, reportingConfig: ReportingConfigType ): ReportingConfig => { - const config = server.config(); const { http } = core; const serverInfo = http.getServerInfo(); const kbnConfig = { path: { - data: config.get('path.data'), + data: initContext.config.legacy.globalConfig$.pipe(map((c) => c.path.data)), }, server: { basePath: core.http.basePath.serverBasePath, @@ -84,5 +84,3 @@ export const buildConfig = ( }, }; }; - -export { ReportingConfigType }; diff --git a/x-pack/plugins/reporting/server/config/create_config.test.ts b/x-pack/plugins/reporting/server/config/create_config.test.ts index 3107866be6496..7e9fd19b776cc 100644 --- a/x-pack/plugins/reporting/server/config/create_config.test.ts +++ b/x-pack/plugins/reporting/server/config/create_config.test.ts @@ -5,9 +5,10 @@ */ import * as Rx from 'rxjs'; -import { CoreSetup, Logger, PluginInitializerContext } from 'src/core/server'; -import { ConfigType as ReportingConfigType } from './schema'; +import { CoreSetup, PluginInitializerContext } from 'src/core/server'; +import { ReportingConfigType } from './schema'; import { createConfig$ } from './create_config'; +import { LevelLogger } from '../lib'; interface KibanaServer { host?: string; @@ -37,14 +38,16 @@ const makeMockCoreSetup = (serverInfo: KibanaServer): CoreSetup => describe('Reporting server createConfig$', () => { let mockCoreSetup: CoreSetup; let mockInitContext: PluginInitializerContext; - let mockLogger: Logger; + let mockConfig$: any; + let mockLogger: LevelLogger; beforeEach(() => { mockCoreSetup = makeMockCoreSetup({ host: 'kibanaHost', port: 5601, protocol: 'http' }); mockInitContext = makeMockInitContext({ kibanaServer: {}, }); - mockLogger = ({ warn: jest.fn(), debug: jest.fn() } as unknown) as Logger; + mockConfig$ = mockInitContext.config.create(); + mockLogger = ({ warn: jest.fn(), debug: jest.fn() } as unknown) as LevelLogger; }); afterEach(() => { @@ -52,7 +55,7 @@ describe('Reporting server createConfig$', () => { }); it('creates random encryption key and default config using host, protocol, and port from server info', async () => { - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.encryptionKey).toMatch(/\S{32,}/); // random 32 characters expect(result.kibanaServer).toMatchInlineSnapshot(` @@ -73,7 +76,7 @@ describe('Reporting server createConfig$', () => { encryptionKey: 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', kibanaServer: {}, }); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.encryptionKey).toMatch('iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii'); expect((mockLogger.warn as any).mock.calls.length).toBe(0); @@ -88,7 +91,7 @@ describe('Reporting server createConfig$', () => { protocol: 'httpsa', }, }); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result).toMatchInlineSnapshot(` Object { @@ -115,7 +118,7 @@ describe('Reporting server createConfig$', () => { encryptionKey: 'aaaaaaaaaaaaabbbbbbbbbbbbaaaaaaaaa', kibanaServer: { hostname: '0' }, }); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.kibanaServer).toMatchInlineSnapshot(` Object { @@ -136,7 +139,7 @@ describe('Reporting server createConfig$', () => { encryptionKey: '888888888888888888888888888888888', capture: { browser: { chromium: { disableSandbox: false } } }, } as ReportingConfigType); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.capture.browser.chromium).toMatchObject({ disableSandbox: false }); expect((mockLogger.warn as any).mock.calls.length).toBe(0); @@ -147,7 +150,7 @@ describe('Reporting server createConfig$', () => { encryptionKey: '888888888888888888888888888888888', capture: { browser: { chromium: { disableSandbox: true } } }, } as ReportingConfigType); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.capture.browser.chromium).toMatchObject({ disableSandbox: true }); expect((mockLogger.warn as any).mock.calls.length).toBe(0); @@ -157,7 +160,7 @@ describe('Reporting server createConfig$', () => { mockInitContext = makeMockInitContext({ encryptionKey: '888888888888888888888888888888888', } as ReportingConfigType); - const result = await createConfig$(mockCoreSetup, mockInitContext, mockLogger).toPromise(); + const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.capture.browser.chromium).toMatchObject({ disableSandbox: expect.any(Boolean) }); expect((mockLogger.warn as any).mock.calls.length).toBe(0); diff --git a/x-pack/plugins/reporting/server/config/create_config.ts b/x-pack/plugins/reporting/server/config/create_config.ts index d363494ddb9a6..2f244a134f014 100644 --- a/x-pack/plugins/reporting/server/config/create_config.ts +++ b/x-pack/plugins/reporting/server/config/create_config.ts @@ -5,22 +5,27 @@ */ import { i18n } from '@kbn/i18n/'; -import { TypeOf } from '@kbn/config-schema'; import crypto from 'crypto'; import { capitalize } from 'lodash'; +import { Observable } from 'rxjs'; import { map, mergeMap } from 'rxjs/operators'; -import { CoreSetup, Logger, PluginInitializerContext } from 'src/core/server'; +import { CoreSetup } from 'src/core/server'; +import { LevelLogger } from '../lib'; import { getDefaultChromiumSandboxDisabled } from './default_chromium_sandbox_disabled'; -import { ConfigSchema } from './schema'; +import { ReportingConfigType } from './schema'; /* - * Set up dynamic config defaults + * Set up computed config defaults * - xpack.capture.browser.chromium.disableSandbox * - xpack.kibanaServer * - xpack.reporting.encryptionKey */ -export function createConfig$(core: CoreSetup, context: PluginInitializerContext, logger: Logger) { - return context.config.create>().pipe( +export function createConfig$( + core: CoreSetup, + config$: Observable, + logger: LevelLogger +) { + return config$.pipe( map((config) => { // encryption key let encryptionKey = config.encryptionKey; diff --git a/x-pack/plugins/reporting/server/config/index.ts b/x-pack/plugins/reporting/server/config/index.ts index a0d7618322c65..caa64a7414005 100644 --- a/x-pack/plugins/reporting/server/config/index.ts +++ b/x-pack/plugins/reporting/server/config/index.ts @@ -5,11 +5,12 @@ */ import { PluginConfigDescriptor } from 'kibana/server'; -import { ConfigSchema, ConfigType } from './schema'; - +import { ConfigSchema, ReportingConfigType } from './schema'; +export { buildConfig } from './config'; export { createConfig$ } from './create_config'; +export { ConfigSchema, ReportingConfigType }; -export const config: PluginConfigDescriptor = { +export const config: PluginConfigDescriptor = { exposeToBrowser: { poll: true }, schema: ConfigSchema, deprecations: ({ unused }) => [ @@ -20,5 +21,3 @@ export const config: PluginConfigDescriptor = { unused('kibanaApp'), ], }; - -export { ConfigSchema, ConfigType }; diff --git a/x-pack/plugins/reporting/server/config/schema.ts b/x-pack/plugins/reporting/server/config/schema.ts index 402fddcb5e014..dfabfa98f8cbf 100644 --- a/x-pack/plugins/reporting/server/config/schema.ts +++ b/x-pack/plugins/reporting/server/config/schema.ts @@ -172,4 +172,4 @@ export const ConfigSchema = schema.object({ poll: PollSchema, }); -export type ConfigType = TypeOf; +export type ReportingConfigType = TypeOf; diff --git a/x-pack/legacy/plugins/reporting/server/core.ts b/x-pack/plugins/reporting/server/core.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/server/core.ts rename to x-pack/plugins/reporting/server/core.ts index b89ef9e06b961..edf49d74e184d 100644 --- a/x-pack/legacy/plugins/reporting/server/core.ts +++ b/x-pack/plugins/reporting/server/core.ts @@ -5,22 +5,22 @@ */ import * as Rx from 'rxjs'; -import { first, mapTo, map } from 'rxjs/operators'; +import { first, map, mapTo } from 'rxjs/operators'; import { + BasePath, ElasticsearchServiceSetup, + IRouter, KibanaRequest, + SavedObjectsClientContract, SavedObjectsServiceStart, UiSettingsServiceStart, - IRouter, - SavedObjectsClientContract, - BasePath, } from 'src/core/server'; -import { SecurityPluginSetup } from '../../../../plugins/security/server'; -import { LicensingPluginSetup } from '../../../../plugins/licensing/server'; -import { screenshotsObservableFactory } from '../export_types/common/lib/screenshots'; +import { LicensingPluginSetup } from '../../licensing/server'; +import { SecurityPluginSetup } from '../../security/server'; import { ScreenshotsObservableFn } from '../server/types'; import { ReportingConfig } from './'; import { HeadlessChromiumDriverFactory } from './browsers/chromium/driver_factory'; +import { screenshotsObservableFactory } from './export_types/common/lib/screenshots'; import { checkLicense, getExportTypesRegistry } from './lib'; import { ESQueueInstance } from './lib/create_queue'; import { EnqueueJobFn } from './lib/enqueue_job'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/constants.ts b/x-pack/plugins/reporting/server/export_types/common/constants.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/constants.ts rename to x-pack/plugins/reporting/server/export_types/common/constants.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.test.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.test.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.test.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.test.ts index fe3ac16b79fe0..4998d936c9b16 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { cryptoFactory, LevelLogger } from '../../../server/lib'; +import { cryptoFactory, LevelLogger } from '../../../lib'; import { decryptJobHeaders } from './decrypt_job_headers'; const encryptHeaders = async (encryptionKey: string, headers: Record) => { diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.ts index a13c1fa2a9efb..e5124c80601d7 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/decrypt_job_headers.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/decrypt_job_headers.ts @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { cryptoFactory, LevelLogger } from '../../../server/lib'; +import { cryptoFactory, LevelLogger } from '../../../lib'; interface HasEncryptedHeaders { headers?: string; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.test.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.test.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.test.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.test.ts index 5067d5f5e5dd8..5d651ad5f8aea 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.test.ts @@ -5,9 +5,10 @@ */ import sinon from 'sinon'; -import { ReportingConfig, ReportingCore } from '../../../server'; -import { JobDocPayload } from '../../../server/types'; +import { ReportingConfig } from '../../../'; +import { ReportingCore } from '../../../core'; import { createMockReportingCore } from '../../../test_helpers'; +import { JobDocPayload } from '../../../types'; import { JobDocPayloadPDF } from '../../printable_pdf/types'; import { getConditionalHeaders, getCustomLogo } from './index'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.ts similarity index 89% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.ts index 808d5db5c57d5..6854f678aa975 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_conditional_headers.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_conditional_headers.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ReportingConfig } from '../../../server'; -import { ConditionalHeaders } from '../../../server/types'; +import { ReportingConfig } from '../../../'; +import { ConditionalHeaders } from '../../../types'; export const getConditionalHeaders = ({ config, diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.test.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.test.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.test.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.test.ts index 2cbde69c81316..bd6eb4644d87f 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ReportingCore } from '../../../server'; +import { ReportingCore } from '../../../core'; import { createMockReportingCore } from '../../../test_helpers'; import { JobDocPayloadPDF } from '../../printable_pdf/types'; import { getConditionalHeaders, getCustomLogo } from './index'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.ts similarity index 87% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.ts index 777de317af41e..85d1272fc22ce 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_custom_logo.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_custom_logo.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { UI_SETTINGS_CUSTOM_PDF_LOGO } from '../../../common/constants'; -import { ReportingConfig, ReportingCore } from '../../../server'; -import { ConditionalHeaders } from '../../../server/types'; +import { ReportingConfig, ReportingCore } from '../../../'; +import { UI_SETTINGS_CUSTOM_PDF_LOGO } from '../../../../common/constants'; +import { ConditionalHeaders } from '../../../types'; import { JobDocPayloadPDF } from '../../printable_pdf/types'; // Logo is PDF only export const getCustomLogo = async ({ diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.test.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.test.ts similarity index 99% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.test.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.test.ts index 5f55617724ff6..cacea41477ea4 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ReportingConfig } from '../../../server'; +import { ReportingConfig } from '../../../'; import { JobDocPayloadPNG } from '../../png/types'; import { JobDocPayloadPDF } from '../../printable_pdf/types'; import { getFullUrls } from './get_full_urls'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.ts index 90f3a3b2c9c24..bcd7f122748cb 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/get_full_urls.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/get_full_urls.ts @@ -7,12 +7,12 @@ import { format as urlFormat, parse as urlParse, - UrlWithStringQuery, UrlWithParsedQuery, + UrlWithStringQuery, } from 'url'; -import { getAbsoluteUrlFactory } from '../../../common/get_absolute_url'; -import { validateUrls } from '../../../common/validate_urls'; -import { ReportingConfig } from '../../../server'; +import { ReportingConfig } from '../../..'; +import { getAbsoluteUrlFactory } from '../../../../common/get_absolute_url'; +import { validateUrls } from '../../../../common/validate_urls'; import { JobDocPayloadPNG } from '../../png/types'; import { JobDocPayloadPDF } from '../../printable_pdf/types'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/index.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/index.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/index.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.test.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/omit_blacklisted_headers.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.test.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/omit_blacklisted_headers.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.ts b/x-pack/plugins/reporting/server/export_types/common/execute_job/omit_blacklisted_headers.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.ts rename to x-pack/plugins/reporting/server/export_types/common/execute_job/omit_blacklisted_headers.ts index 0e5974225b932..5147881a980ea 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/execute_job/omit_blacklisted_headers.ts +++ b/x-pack/plugins/reporting/server/export_types/common/execute_job/omit_blacklisted_headers.ts @@ -7,7 +7,7 @@ import { omit } from 'lodash'; import { KBN_SCREENSHOT_HEADER_BLACKLIST, KBN_SCREENSHOT_HEADER_BLACKLIST_STARTS_WITH_PATTERN, -} from '../../../common/constants'; +} from '../../../../common/constants'; export const omitBlacklistedHeaders = ({ job, diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/create_layout.ts b/x-pack/plugins/reporting/server/export_types/common/layouts/create_layout.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/create_layout.ts rename to x-pack/plugins/reporting/server/export_types/common/layouts/create_layout.ts index d33760fcb4f89..216a59d41cec0 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/layouts/create_layout.ts +++ b/x-pack/plugins/reporting/server/export_types/common/layouts/create_layout.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CaptureConfig } from '../../../server/types'; +import { CaptureConfig } from '../../../types'; import { LayoutParams, LayoutTypes } from './'; import { Layout } from './layout'; import { PreserveLayout } from './preserve_layout'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/index.ts b/x-pack/plugins/reporting/server/export_types/common/layouts/index.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/index.ts rename to x-pack/plugins/reporting/server/export_types/common/layouts/index.ts index 993b8f6cdc9ab..23e4c095afe61 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/layouts/index.ts +++ b/x-pack/plugins/reporting/server/export_types/common/layouts/index.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HeadlessChromiumDriver } from '../../../server/browsers'; -import { LevelLogger } from '../../../server/lib'; +import { HeadlessChromiumDriver } from '../../../browsers'; +import { LevelLogger } from '../../../lib'; import { Layout } from './layout'; export { createLayout } from './create_layout'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/layout.ts b/x-pack/plugins/reporting/server/export_types/common/layouts/layout.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/layout.ts rename to x-pack/plugins/reporting/server/export_types/common/layouts/layout.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/preserve_layout.css b/x-pack/plugins/reporting/server/export_types/common/layouts/preserve_layout.css similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/preserve_layout.css rename to x-pack/plugins/reporting/server/export_types/common/layouts/preserve_layout.css diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/preserve_layout.ts b/x-pack/plugins/reporting/server/export_types/common/layouts/preserve_layout.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/preserve_layout.ts rename to x-pack/plugins/reporting/server/export_types/common/layouts/preserve_layout.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/print.css b/x-pack/plugins/reporting/server/export_types/common/layouts/print.css similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/print.css rename to x-pack/plugins/reporting/server/export_types/common/layouts/print.css diff --git a/x-pack/legacy/plugins/reporting/export_types/common/layouts/print_layout.ts b/x-pack/plugins/reporting/server/export_types/common/layouts/print_layout.ts similarity index 94% rename from x-pack/legacy/plugins/reporting/export_types/common/layouts/print_layout.ts rename to x-pack/plugins/reporting/server/export_types/common/layouts/print_layout.ts index 759f07a33e2b6..30c83771aa3c9 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/layouts/print_layout.ts +++ b/x-pack/plugins/reporting/server/export_types/common/layouts/print_layout.ts @@ -6,9 +6,9 @@ import path from 'path'; import { EvaluateFn, SerializableOrJSHandle } from 'puppeteer'; -import { LevelLogger } from '../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../server/browsers'; -import { CaptureConfig } from '../../../server/types'; +import { CaptureConfig } from '../../../types'; +import { HeadlessChromiumDriver } from '../../../browsers'; +import { LevelLogger } from '../../../lib'; import { getDefaultLayoutSelectors, LayoutSelectorDictionary, Size, LayoutTypes } from './'; import { Layout } from './layout'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/constants.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/constants.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/constants.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/constants.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_element_position_data.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_element_position_data.ts similarity index 94% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_element_position_data.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_element_position_data.ts index d02e852a3c1b6..140d76f8d1cd6 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_element_position_data.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_element_position_data.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { AttributesMap, ElementsPositionAndAttribute } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { AttributesMap, ElementsPositionAndAttribute } from '../../../../types'; import { LayoutInstance } from '../../layouts'; import { CONTEXT_ELEMENTATTRIBUTES } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_number_of_items.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_number_of_items.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_number_of_items.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_number_of_items.ts index 9e446f499ab3a..42eb91ecba830 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_number_of_items.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_number_of_items.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { CaptureConfig } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { CaptureConfig } from '../../../../types'; import { LayoutInstance } from '../../layouts'; import { CONTEXT_GETNUMBEROFITEMS, CONTEXT_READMETADATA } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_screenshots.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_screenshots.ts similarity index 89% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_screenshots.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_screenshots.ts index 578a4dd0b975c..05c315b8341a3 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_screenshots.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_screenshots.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { ElementsPositionAndAttribute, Screenshot } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { ElementsPositionAndAttribute, Screenshot } from '../../../../types'; export const getScreenshots = async ( browser: HeadlessChromiumDriver, diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_time_range.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_time_range.ts similarity index 90% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_time_range.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_time_range.ts index 74926918584fe..ba68a5fec4e4c 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/get_time_range.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/get_time_range.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; import { LayoutInstance } from '../../layouts'; import { CONTEXT_GETTIMERANGE } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/index.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/index.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/index.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/inject_css.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/inject_css.ts similarity index 92% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/inject_css.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/inject_css.ts index 8a198880a7768..d72afacc1bef3 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/inject_css.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/inject_css.ts @@ -7,8 +7,8 @@ import { i18n } from '@kbn/i18n'; import fs from 'fs'; import { promisify } from 'util'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; import { Layout } from '../../layouts/layout'; import { CONTEXT_INJECTCSS } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.test.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.test.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts index cc8b438310430..4492e7b903394 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts @@ -18,16 +18,12 @@ jest.mock('../../../../server/browsers/chromium/puppeteer', () => ({ import * as Rx from 'rxjs'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { loggingServiceMock } from '../../../../../../../../src/core/server/mocks'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { LevelLogger } from '../../../../server/lib'; -import { - CaptureConfig, - ConditionalHeaders, - ElementsPositionAndAttribute, -} from '../../../../server/types'; import { createMockBrowserDriverFactory, createMockLayoutInstance } from '../../../../test_helpers'; import * as contexts from './constants'; import { screenshotsObservableFactory } from './observable'; +import { LevelLogger } from '../../../../lib'; +import { CaptureConfig, ConditionalHeaders, ElementsPositionAndAttribute } from '../../../../types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; /* * Mocks diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.ts index bb11d1d3b7b63..028bff4aaa5ee 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/observable.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.ts @@ -16,14 +16,14 @@ import { tap, toArray, } from 'rxjs/operators'; -import { HeadlessChromiumDriverFactory } from '../../../../server/browsers'; +import { HeadlessChromiumDriverFactory } from '../../../../browsers'; import { CaptureConfig, ElementsPositionAndAttribute, ScreenshotObservableOpts, ScreenshotResults, ScreenshotsObservableFn, -} from '../../../../server/types'; +} from '../../../../types'; import { DEFAULT_PAGELOAD_SELECTOR } from '../../constants'; import { getElementPositionAndAttributes } from './get_element_position_data'; import { getNumberOfItems } from './get_number_of_items'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/open_url.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/open_url.ts similarity index 83% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/open_url.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/open_url.ts index 3cf962b8178fd..bd7e8c508c118 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/open_url.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/open_url.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { CaptureConfig, ConditionalHeaders } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { CaptureConfig, ConditionalHeaders } from '../../../../types'; export const openUrl = async ( captureConfig: CaptureConfig, diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_render.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_render.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_render.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_render.ts index c31c55ea8dec6..b6519e914430a 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_render.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_render.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { CaptureConfig } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { CaptureConfig } from '../../../../types'; import { LayoutInstance } from '../../layouts'; import { CONTEXT_WAITFORRENDER } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_visualizations.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_visualizations.ts similarity index 91% rename from x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_visualizations.ts rename to x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_visualizations.ts index ff84d06956dbc..75a7b6516473c 100644 --- a/x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_visualizations.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/wait_for_visualizations.ts @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { LevelLogger, startTrace } from '../../../../server/lib'; -import { HeadlessChromiumDriver } from '../../../../server/browsers'; -import { CaptureConfig } from '../../../../server/types'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger, startTrace } from '../../../../lib'; +import { CaptureConfig } from '../../../../types'; import { LayoutInstance } from '../../layouts'; import { CONTEXT_WAITFORELEMENTSTOBEINDOM } from './constants'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/index.ts b/x-pack/plugins/reporting/server/export_types/csv/index.ts similarity index 85% rename from x-pack/legacy/plugins/reporting/export_types/csv/index.ts rename to x-pack/plugins/reporting/server/export_types/csv/index.ts index cdb4c36dba3df..8642a6d5758a8 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/index.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/index.ts @@ -5,19 +5,15 @@ */ import { - CSV_JOB_TYPE as jobType, LICENSE_TYPE_BASIC, LICENSE_TYPE_ENTERPRISE, LICENSE_TYPE_GOLD, LICENSE_TYPE_PLATINUM, LICENSE_TYPE_STANDARD, LICENSE_TYPE_TRIAL, -} from '../../common/constants'; -import { - ESQueueCreateJobFn, - ESQueueWorkerExecuteFn, - ExportTypeDefinition, -} from '../../server/types'; +} from '../../../common/constants'; +import { CSV_JOB_TYPE as jobType } from '../../../constants'; +import { ESQueueCreateJobFn, ESQueueWorkerExecuteFn, ExportTypeDefinition } from '../../types'; import { metadata } from './metadata'; import { createJobFactory } from './server/create_job'; import { executeJobFactory } from './server/execute_job'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/metadata.ts b/x-pack/plugins/reporting/server/export_types/csv/metadata.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/metadata.ts rename to x-pack/plugins/reporting/server/export_types/csv/metadata.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/create_job.ts b/x-pack/plugins/reporting/server/export_types/csv/server/create_job.ts similarity index 87% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/create_job.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/create_job.ts index c76b4afe727da..acf7f0505a735 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/create_job.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/create_job.ts @@ -5,9 +5,9 @@ */ import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { ReportingCore } from '../../../server'; -import { cryptoFactory } from '../../../server/lib'; -import { CreateJobFactory, ESQueueCreateJobFn } from '../../../server/types'; +import { ReportingCore } from '../../../'; +import { cryptoFactory } from '../../../lib'; +import { CreateJobFactory, ESQueueCreateJobFn } from '../../../types'; import { JobParamsDiscoverCsv } from '../types'; export const createJobFactory: CreateJobFactory CSV_FORMULA_CHARS.some((formulaChar) => startsWith(val, formulaChar)); diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/check_cells_for_formulas.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/check_cells_for_formulas.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/check_cells_for_formulas.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/check_cells_for_formulas.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/escape_value.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/escape_value.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/escape_value.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/escape_value.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/field_format_map.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/field_format_map.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/field_format_map.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/field_format_map.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/field_format_map.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/field_format_map.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/field_format_map.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/field_format_map.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/flatten_hit.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/flatten_hit.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/flatten_hit.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/flatten_hit.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/flatten_hit.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/flatten_hit.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/flatten_hit.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/flatten_hit.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/format_csv_values.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/format_csv_values.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/format_csv_values.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/format_csv_values.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/format_csv_values.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/format_csv_values.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/format_csv_values.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/format_csv_values.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/generate_csv.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/generate_csv.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/generate_csv.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/generate_csv.ts index a8fdd8d1a5bbc..019fa3c9c8e9d 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/generate_csv.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/lib/generate_csv.ts @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { LevelLogger } from '../../../../server/lib'; +import { LevelLogger } from '../../../../lib'; import { GenerateCsvParams, SavedSearchGeneratorResult } from '../../types'; import { createFlattenHit } from './flatten_hit'; import { createFormatCsvValues } from './format_csv_values'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.test.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.test.ts index 7ef4f502b34a3..0c4cd9c4cd193 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.test.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.test.ts @@ -7,8 +7,8 @@ import expect from '@kbn/expect'; import sinon from 'sinon'; import { CancellationToken } from '../../../../../../../plugins/reporting/common'; -import { LevelLogger } from '../../../../server/lib'; -import { ScrollConfig } from '../../../../server/types'; +import { LevelLogger } from '../../../../lib'; +import { ScrollConfig } from '../../../../types'; import { createHitIterator } from './hit_iterator'; const mockLogger = { diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.ts index 803161910443e..94ec7558d9c7d 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/hit_iterator.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.ts @@ -7,8 +7,8 @@ import { i18n } from '@kbn/i18n'; import { SearchParams, SearchResponse } from 'elasticsearch'; import { CancellationToken } from '../../../../../../../plugins/reporting/common'; -import { LevelLogger } from '../../../../server/lib'; -import { ScrollConfig } from '../../../../server/types'; +import { LevelLogger } from '../../../../lib'; +import { ScrollConfig } from '../../../../types'; async function parseResponse(request: SearchResponse) { const response = await request; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/max_size_string_builder.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/max_size_string_builder.test.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/max_size_string_builder.test.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/max_size_string_builder.test.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/max_size_string_builder.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/max_size_string_builder.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv/server/lib/max_size_string_builder.ts rename to x-pack/plugins/reporting/server/export_types/csv/server/lib/max_size_string_builder.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts b/x-pack/plugins/reporting/server/export_types/csv/types.d.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts rename to x-pack/plugins/reporting/server/export_types/csv/types.d.ts index 0f6223d8553de..7dcc55117a653 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/types.d.ts @@ -5,7 +5,7 @@ */ import { CancellationToken } from '../../../../../plugins/reporting/common'; -import { JobDocPayload, JobParamPostPayload, ScrollConfig } from '../../server/types'; +import { JobParamPostPayload, JobDocPayload, ScrollConfig } from '../../types'; export type RawValue = string | object | null | undefined; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/index.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/index.ts similarity index 89% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/index.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/index.ts index 570b91600cbe0..65802ee5bb7fb 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/index.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/index.ts @@ -5,15 +5,15 @@ */ import { - CSV_FROM_SAVEDOBJECT_JOB_TYPE, LICENSE_TYPE_BASIC, LICENSE_TYPE_ENTERPRISE, LICENSE_TYPE_GOLD, LICENSE_TYPE_PLATINUM, LICENSE_TYPE_STANDARD, LICENSE_TYPE_TRIAL, -} from '../../common/constants'; -import { ExportTypeDefinition } from '../../server/types'; +} from '../../../common/constants'; +import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../constants'; +import { ExportTypeDefinition } from '../../types'; import { metadata } from './metadata'; import { createJobFactory, ImmediateCreateJobFn } from './server/create_job'; import { executeJobFactory, ImmediateExecuteFn } from './server/execute_job'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/metadata.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/metadata.ts similarity index 82% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/metadata.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/metadata.ts index fcef889e52fe4..a0fd8a29fdcc4 100644 --- a/x-pack/legacy/plugins/reporting/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 '../../common/constants'; +import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../constants'; export const metadata = { id: CSV_FROM_SAVEDOBJECT_JOB_TYPE, diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job.ts similarity index 92% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job.ts index d23f60d9c2480..c187da5104d3f 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job.ts @@ -7,10 +7,10 @@ import { notFound, notImplemented } from 'boom'; import { get } from 'lodash'; import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../../common/constants'; -import { ReportingCore } from '../../../../server'; -import { cryptoFactory, LevelLogger } from '../../../../server/lib'; -import { CreateJobFactory, TimeRangeParams } from '../../../../server/types'; +import { ReportingCore } from '../../../..'; +import { CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../../../common/constants'; +import { cryptoFactory, LevelLogger } from '../../../../lib'; +import { CreateJobFactory, TimeRangeParams } from '../../../../types'; import { JobDocPayloadPanelCsv, JobParamsPanelCsv, diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job_search.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job_search.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job_search.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job_search.ts index 19204ef81c5eb..02abfb90091a1 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/create_job_search.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/create_job_search.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TimeRangeParams } from '../../../../server/types'; +import { TimeRangeParams } from '../../../../types'; import { SavedObjectMeta, SavedObjectReference, diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/index.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/create_job/index.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/create_job/index.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/execute_job.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/execute_job.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/execute_job.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/execute_job.ts index 4ef7b8514b363..d555100b6320d 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/execute_job.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/execute_job.ts @@ -6,10 +6,10 @@ import { i18n } from '@kbn/i18n'; import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { CONTENT_TYPE_CSV, CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../common/constants'; -import { ReportingCore } from '../../../server'; -import { cryptoFactory, LevelLogger } from '../../../server/lib'; -import { ExecuteJobFactory, JobDocOutput, JobDocPayload } from '../../../server/types'; +import { ReportingCore } from '../../..'; +import { CONTENT_TYPE_CSV, CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../../../common/constants'; +import { cryptoFactory, LevelLogger } from '../../../lib'; +import { ExecuteJobFactory, JobDocOutput, JobDocPayload } from '../../../types'; import { CsvResultFromSearch } from '../../csv/types'; import { FakeRequest, JobDocPayloadPanelCsv, JobParamsPanelCsv, SearchPanel } from '../types'; import { createGenerateCsv } from './lib'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv.ts similarity index 92% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv.ts index 2397da9337890..dd0fb34668e9e 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv.ts @@ -6,8 +6,8 @@ import { badRequest } from 'boom'; import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { LevelLogger } from '../../../../server/lib'; -import { ReportingCore } from '../../../../server'; +import { ReportingCore } from '../../../..'; +import { LevelLogger } from '../../../../lib'; import { FakeRequest, JobParamsPanelCsv, SearchPanel, VisPanel } from '../../types'; import { generateCsvSearch } from './generate_csv_search'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts index 848623ede5b2f..0df01e8addb03 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { ReportingCore } from '../../../../'; import { IUiSettingsClient, KibanaRequest, @@ -17,8 +18,7 @@ import { Query, } from '../../../../../../../../src/plugins/data/server'; import { CancellationToken } from '../../../../../../../plugins/reporting/common'; -import { LevelLogger } from '../../../../server/lib'; -import { ReportingCore } from '../../../../server'; +import { LevelLogger } from '../../../../lib'; import { createGenerateCsv } from '../../../csv/server/lib/generate_csv'; import { CsvResultFromSearch, diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_data_source.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_data_source.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_data_source.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_data_source.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.test.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.test.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.test.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.test.ts index 110ce91ddfd79..b5d564d93d0d6 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.test.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TimeRangeParams } from '../../../../server/types'; +import { TimeRangeParams } from '../../../../types'; import { QueryFilter, SavedSearchObjectAttributes, SearchSourceFilter } from '../../types'; import { getFilters } from './get_filters'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.ts index 4695bbd922581..26631548cc797 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_filters.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_filters.ts @@ -6,7 +6,7 @@ import { badRequest } from 'boom'; import moment from 'moment-timezone'; -import { TimeRangeParams } from '../../../../server/types'; +import { TimeRangeParams } from '../../../../types'; import { Filter, QueryFilter, SavedSearchObjectAttributes, SearchSourceFilter } from '../../types'; export function getFilters( diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_job_params_from_request.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_job_params_from_request.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/get_job_params_from_request.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/get_job_params_from_request.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/index.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/index.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/index.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/types.d.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/types.d.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/types.d.ts rename to x-pack/plugins/reporting/server/export_types/csv_from_savedobject/types.d.ts index f838268078503..36ae5b1dac05e 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/types.d.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/types.d.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { JobDocPayload, JobParamPostPayload, TimeRangeParams } from '../../server/types'; +import { JobParamPostPayload, JobDocPayload, TimeRangeParams } from '../../types'; export interface FakeRequest { headers: Record; @@ -101,7 +101,6 @@ export interface SavedObject { /* This object is passed to different helpers in different parts of the code - packages/kbn-es-query/src/es_query/build_es_query - - x-pack/legacy/plugins/reporting/export_types/csv/server/lib/field_format_map The structure has redundant parts and json-parsed / json-unparsed versions of the same data */ export interface IndexPatternSavedObject { diff --git a/x-pack/legacy/plugins/reporting/export_types/png/index.ts b/x-pack/plugins/reporting/server/export_types/png/index.ts similarity index 88% rename from x-pack/legacy/plugins/reporting/export_types/png/index.ts rename to x-pack/plugins/reporting/server/export_types/png/index.ts index 04f56185d4910..a3b51e365e772 100644 --- a/x-pack/legacy/plugins/reporting/export_types/png/index.ts +++ b/x-pack/plugins/reporting/server/export_types/png/index.ts @@ -11,12 +11,8 @@ import { LICENSE_TYPE_STANDARD, LICENSE_TYPE_TRIAL, PNG_JOB_TYPE as jobType, -} from '../../common/constants'; -import { - ESQueueCreateJobFn, - ESQueueWorkerExecuteFn, - ExportTypeDefinition, -} from '../../server/types'; +} from '../../../common/constants'; +import { ESQueueCreateJobFn, ESQueueWorkerExecuteFn, ExportTypeDefinition } from '../..//types'; import { metadata } from './metadata'; import { createJobFactory } from './server/create_job'; import { executeJobFactory } from './server/execute_job'; diff --git a/x-pack/legacy/plugins/reporting/export_types/png/metadata.ts b/x-pack/plugins/reporting/server/export_types/png/metadata.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/png/metadata.ts rename to x-pack/plugins/reporting/server/export_types/png/metadata.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/png/server/create_job/index.ts b/x-pack/plugins/reporting/server/export_types/png/server/create_job/index.ts similarity index 88% rename from x-pack/legacy/plugins/reporting/export_types/png/server/create_job/index.ts rename to x-pack/plugins/reporting/server/export_types/png/server/create_job/index.ts index ab492c21256eb..3f1556fb29782 100644 --- a/x-pack/legacy/plugins/reporting/export_types/png/server/create_job/index.ts +++ b/x-pack/plugins/reporting/server/export_types/png/server/create_job/index.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { validateUrls } from '../../../../common/validate_urls'; -import { cryptoFactory } from '../../../../server/lib'; -import { CreateJobFactory, ESQueueCreateJobFn } from '../../../../server/types'; +import { validateUrls } from '../../../../../common/validate_urls'; +import { cryptoFactory } from '../../../../lib'; +import { CreateJobFactory, ESQueueCreateJobFn } from '../../../../types'; import { JobParamsPNG } from '../../types'; export const createJobFactory: CreateJobFactory ({ generatePdfObservableFactory: jest.fn( import * as Rx from 'rxjs'; import { CancellationToken } from '../../../../../../../plugins/reporting/common'; -import { ReportingCore } from '../../../../server'; -import { cryptoFactory, LevelLogger } from '../../../../server/lib'; +import { ReportingCore } from '../../../../../server'; +import { cryptoFactory, LevelLogger } from '../../../../../server/lib'; import { createMockReportingCore } from '../../../../test_helpers'; import { JobDocPayloadPDF } from '../../types'; import { generatePdfObservableFactory } from '../lib/generate_pdf'; diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/execute_job/index.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.ts similarity index 92% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/execute_job/index.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.ts index b0b2d02305b9b..a4d84b2f9f1e0 100644 --- a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/execute_job/index.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.ts @@ -7,17 +7,17 @@ import apm from 'elastic-apm-node'; import * as Rx from 'rxjs'; import { catchError, map, mergeMap, takeUntil } from 'rxjs/operators'; -import { PDF_JOB_TYPE } from '../../../../common/constants'; -import { ReportingCore } from '../../../../server'; -import { LevelLogger } from '../../../../server/lib'; -import { ESQueueWorkerExecuteFn, ExecuteJobFactory, JobDocOutput } from '../../../../server/types'; +import { ReportingCore } from '../../../..'; +import { PDF_JOB_TYPE } from '../../../../../common/constants'; +import { LevelLogger } from '../../../../lib'; +import { ESQueueWorkerExecuteFn, ExecuteJobFactory, JobDocOutput } from '../../../../types'; import { decryptJobHeaders, getConditionalHeaders, getCustomLogo, getFullUrls, omitBlacklistedHeaders, -} from '../../../common/execute_job/'; +} from '../../../common/execute_job'; import { JobDocPayloadPDF } from '../../types'; import { generatePdfObservableFactory } from '../lib/generate_pdf'; diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/generate_pdf.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/generate_pdf.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/generate_pdf.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/generate_pdf.ts index 3b626c8f0da44..366949a033757 100644 --- a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/generate_pdf.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/generate_pdf.ts @@ -7,9 +7,9 @@ import { groupBy } from 'lodash'; import * as Rx from 'rxjs'; import { mergeMap } from 'rxjs/operators'; -import { ReportingCore } from '../../../../server'; -import { LevelLogger } from '../../../../server/lib'; -import { ConditionalHeaders, ScreenshotResults } from '../../../../server/types'; +import { ReportingCore } from '../../../../'; +import { LevelLogger } from '../../../../lib'; +import { ConditionalHeaders, ScreenshotResults } from '../../../../types'; import { createLayout, LayoutInstance, LayoutParams } from '../../../common/layouts'; // @ts-ignore untyped module import { pdf } from './pdf'; diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/LICENSE_OFL.txt b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/LICENSE_OFL.txt similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/LICENSE_OFL.txt rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/LICENSE_OFL.txt diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/index.js b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/index.js rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/index.js diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/LICENSE.txt b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/LICENSE.txt similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/LICENSE.txt rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/LICENSE.txt diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/index.js b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/index.js rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/index.js diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/tracker.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/tracker.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/tracker.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/tracker.ts diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/uri_encode.js b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/uri_encode.js similarity index 100% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/uri_encode.js rename to x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/uri_encode.js diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/types.d.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/types.d.ts similarity index 94% rename from x-pack/legacy/plugins/reporting/export_types/printable_pdf/types.d.ts rename to x-pack/plugins/reporting/server/export_types/printable_pdf/types.d.ts index 0df01fdc16d1c..087ef5a6ca82c 100644 --- a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/types.d.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/types.d.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { JobDocPayload } from '../../server/types'; +import { JobDocPayload } from '../../../server/types'; import { LayoutInstance, LayoutParams } from '../common/layouts'; // Job params: structure of incoming user request data, after being parsed from RISON diff --git a/x-pack/plugins/reporting/server/index.ts b/x-pack/plugins/reporting/server/index.ts index 9d34eba70d0f4..c78e042d019e8 100644 --- a/x-pack/plugins/reporting/server/index.ts +++ b/x-pack/plugins/reporting/server/index.ts @@ -4,11 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PluginInitializerContext } from 'src/core/server'; +import { PluginInitializerContext } from 'kibana/server'; import { ReportingPlugin } from './plugin'; +import { ReportingConfigType } from './config'; -export { config, ConfigSchema, ConfigType } from './config'; -export { PluginsSetup } from './plugin'; +export const plugin = (initContext: PluginInitializerContext) => + new ReportingPlugin(initContext); -export const plugin = (initializerContext: PluginInitializerContext) => - new ReportingPlugin(initializerContext); +export { ReportingPlugin as Plugin }; +export { config } from './config'; +export { ReportingSetupDeps as PluginSetup } from './types'; +export { ReportingStartDeps as PluginStart } from './types'; + +// internal imports +export { ReportingCore } from './core'; +export { ReportingConfig } from './config/config'; diff --git a/x-pack/legacy/plugins/reporting/server/lib/__tests__/export_types_registry.js b/x-pack/plugins/reporting/server/lib/__tests__/export_types_registry.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/__tests__/export_types_registry.js rename to x-pack/plugins/reporting/server/lib/__tests__/export_types_registry.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/check_license.test.ts b/x-pack/plugins/reporting/server/lib/check_license.test.ts similarity index 99% rename from x-pack/legacy/plugins/reporting/server/lib/check_license.test.ts rename to x-pack/plugins/reporting/server/lib/check_license.test.ts index 366a8d94286f1..aa9f86533ef61 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/check_license.test.ts +++ b/x-pack/plugins/reporting/server/lib/check_license.test.ts @@ -5,7 +5,7 @@ */ import { checkLicense } from './check_license'; -import { ILicense } from '../../../../../plugins/licensing/server'; +import { ILicense } from '../../../licensing/server'; import { ExportTypesRegistry } from './export_types_registry'; describe('check_license', () => { diff --git a/x-pack/legacy/plugins/reporting/server/lib/check_license.ts b/x-pack/plugins/reporting/server/lib/check_license.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/server/lib/check_license.ts rename to x-pack/plugins/reporting/server/lib/check_license.ts index 1b4eeaa0bae3e..a764aa1f1eec6 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/check_license.ts +++ b/x-pack/plugins/reporting/server/lib/check_license.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ILicense } from '../../../../../plugins/licensing/server'; +import { ILicense } from '../../../licensing/server'; import { ExportTypeDefinition } from '../types'; import { ExportTypesRegistry } from './export_types_registry'; diff --git a/x-pack/legacy/plugins/reporting/server/lib/create_queue.ts b/x-pack/plugins/reporting/server/lib/create_queue.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/create_queue.ts rename to x-pack/plugins/reporting/server/lib/create_queue.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/create_tagged_logger.ts b/x-pack/plugins/reporting/server/lib/create_tagged_logger.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/create_tagged_logger.ts rename to x-pack/plugins/reporting/server/lib/create_tagged_logger.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/create_worker.test.ts b/x-pack/plugins/reporting/server/lib/create_worker.test.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/server/lib/create_worker.test.ts rename to x-pack/plugins/reporting/server/lib/create_worker.test.ts index 1193091075e3e..505da9067d6b9 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/create_worker.test.ts +++ b/x-pack/plugins/reporting/server/lib/create_worker.test.ts @@ -6,7 +6,7 @@ import * as sinon from 'sinon'; import { ReportingConfig, ReportingCore } from '../../server'; -import { createMockReportingCore } from '../../test_helpers'; +import { createMockReportingCore } from '../test_helpers'; import { createWorkerFactory } from './create_worker'; // @ts-ignore import { Esqueue } from './esqueue'; diff --git a/x-pack/legacy/plugins/reporting/server/lib/create_worker.ts b/x-pack/plugins/reporting/server/lib/create_worker.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/server/lib/create_worker.ts rename to x-pack/plugins/reporting/server/lib/create_worker.ts index 57bd61aee7195..c9e865668bb30 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/create_worker.ts +++ b/x-pack/plugins/reporting/server/lib/create_worker.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CancellationToken } from '../../../../../plugins/reporting/common'; +import { CancellationToken } from '../../common'; import { PLUGIN_ID } from '../../common/constants'; import { ReportingCore } from '../../server'; import { LevelLogger } from '../../server/lib'; diff --git a/x-pack/legacy/plugins/reporting/server/lib/crypto.ts b/x-pack/plugins/reporting/server/lib/crypto.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/crypto.ts rename to x-pack/plugins/reporting/server/lib/crypto.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/enqueue_job.ts b/x-pack/plugins/reporting/server/lib/enqueue_job.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/server/lib/enqueue_job.ts rename to x-pack/plugins/reporting/server/lib/enqueue_job.ts index 6367c8a1da98a..3837f593df5b2 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/enqueue_job.ts +++ b/x-pack/plugins/reporting/server/lib/enqueue_job.ts @@ -6,7 +6,7 @@ import { EventEmitter } from 'events'; import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { AuthenticatedUser } from '../../../../../plugins/security/server'; +import { AuthenticatedUser } from '../../../security/server'; import { ESQueueCreateJobFn } from '../../server/types'; import { ReportingCore } from '../core'; // @ts-ignore diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js similarity index 57% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js index 2d0ac86fd96f1..9cc62800d439f 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js @@ -1,3 +1,9 @@ +/* + * 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. + */ + import events from 'events'; export class JobMock extends events.EventEmitter { diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/legacy_elasticsearch.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/legacy_elasticsearch.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/legacy_elasticsearch.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/legacy_elasticsearch.js diff --git a/x-pack/legacy/plugins/reporting/reporting.d.ts b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js similarity index 58% rename from x-pack/legacy/plugins/reporting/reporting.d.ts rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js index ec65c15f53864..974cb4a5e2a6e 100644 --- a/x-pack/legacy/plugins/reporting/reporting.d.ts +++ b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js @@ -4,4 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -export { ReportingPlugin } from './server/plugin'; +import events from 'events'; + +export class QueueMock extends events.EventEmitter { + constructor() { + super(); + } + + setClient(client) { + this.client = client; + } +} diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js similarity index 55% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js index 09c94b44a8145..fe8a859ccb445 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js @@ -1,3 +1,9 @@ +/* + * 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. + */ + import events from 'events'; export class WorkerMock extends events.EventEmitter { diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/index_timestamp.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/index_timestamp.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/helpers/index_timestamp.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/index_timestamp.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/index.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/index.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/index.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/job.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/job.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/job.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/job.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/worker.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/worker.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/__tests__/worker.js rename to x-pack/plugins/reporting/server/lib/esqueue/__tests__/worker.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/default_settings.js b/x-pack/plugins/reporting/server/lib/esqueue/constants/default_settings.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/default_settings.js rename to x-pack/plugins/reporting/server/lib/esqueue/constants/default_settings.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/events.js b/x-pack/plugins/reporting/server/lib/esqueue/constants/events.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/events.js rename to x-pack/plugins/reporting/server/lib/esqueue/constants/events.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/index.js b/x-pack/plugins/reporting/server/lib/esqueue/constants/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/index.js rename to x-pack/plugins/reporting/server/lib/esqueue/constants/index.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/statuses.ts b/x-pack/plugins/reporting/server/lib/esqueue/constants/statuses.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/constants/statuses.ts rename to x-pack/plugins/reporting/server/lib/esqueue/constants/statuses.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/create_index.js b/x-pack/plugins/reporting/server/lib/esqueue/helpers/create_index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/create_index.js rename to x-pack/plugins/reporting/server/lib/esqueue/helpers/create_index.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/errors.js b/x-pack/plugins/reporting/server/lib/esqueue/helpers/errors.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/errors.js rename to x-pack/plugins/reporting/server/lib/esqueue/helpers/errors.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/index_timestamp.js b/x-pack/plugins/reporting/server/lib/esqueue/helpers/index_timestamp.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/helpers/index_timestamp.js rename to x-pack/plugins/reporting/server/lib/esqueue/helpers/index_timestamp.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/index.js b/x-pack/plugins/reporting/server/lib/esqueue/index.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/index.js rename to x-pack/plugins/reporting/server/lib/esqueue/index.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/job.js b/x-pack/plugins/reporting/server/lib/esqueue/job.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/job.js rename to x-pack/plugins/reporting/server/lib/esqueue/job.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/esqueue/worker.js b/x-pack/plugins/reporting/server/lib/esqueue/worker.js similarity index 99% rename from x-pack/legacy/plugins/reporting/server/lib/esqueue/worker.js rename to x-pack/plugins/reporting/server/lib/esqueue/worker.js index f852ac9c92404..b26ed731c6831 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/esqueue/worker.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/worker.js @@ -7,8 +7,7 @@ import events from 'events'; import moment from 'moment'; import Puid from 'puid'; -import { CancellationToken } from '../../../../../../plugins/reporting/common'; -import { Poller } from '../../../../../common/poller'; +import { CancellationToken, Poller } from '../../../common'; import { constants } from './constants'; import { UnspecifiedWorkerError, WorkerTimeoutError } from './helpers/errors'; diff --git a/x-pack/legacy/plugins/reporting/server/lib/export_types_registry.ts b/x-pack/plugins/reporting/server/lib/export_types_registry.ts similarity index 91% rename from x-pack/legacy/plugins/reporting/server/lib/export_types_registry.ts rename to x-pack/plugins/reporting/server/lib/export_types_registry.ts index 0d5459a7c106b..893a2635561ff 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/export_types_registry.ts +++ b/x-pack/plugins/reporting/server/lib/export_types_registry.ts @@ -6,10 +6,10 @@ import { isString } from 'lodash'; import memoizeOne from 'memoize-one'; -import { getExportType as getTypeCsv } from '../../export_types/csv'; -import { getExportType as getTypeCsvFromSavedObject } from '../../export_types/csv_from_savedobject'; -import { getExportType as getTypePng } from '../../export_types/png'; -import { getExportType as getTypePrintablePdf } from '../../export_types/printable_pdf'; +import { getExportType as getTypeCsv } from '../export_types/csv'; +import { getExportType as getTypeCsvFromSavedObject } from '../export_types/csv_from_savedobject'; +import { getExportType as getTypePng } from '../export_types/png'; +import { getExportType as getTypePrintablePdf } from '../export_types/printable_pdf'; import { ExportTypeDefinition } from '../types'; type GetCallbackFn = ( diff --git a/x-pack/legacy/plugins/reporting/server/lib/get_user.ts b/x-pack/plugins/reporting/server/lib/get_user.ts similarity index 74% rename from x-pack/legacy/plugins/reporting/server/lib/get_user.ts rename to x-pack/plugins/reporting/server/lib/get_user.ts index 164ffc5742d04..49d15a7c55100 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/get_user.ts +++ b/x-pack/plugins/reporting/server/lib/get_user.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SecurityPluginSetup } from '../../../../../plugins/security/server'; -import { KibanaRequest } from '../../../../../../src/core/server'; +import { KibanaRequest } from 'kibana/server'; +import { SecurityPluginSetup } from '../../../security/server'; export function getUserFactory(security?: SecurityPluginSetup) { return (request: KibanaRequest) => { diff --git a/x-pack/legacy/plugins/reporting/server/lib/index.ts b/x-pack/plugins/reporting/server/lib/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/index.ts rename to x-pack/plugins/reporting/server/lib/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/jobs_query.ts b/x-pack/plugins/reporting/server/lib/jobs_query.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/server/lib/jobs_query.ts rename to x-pack/plugins/reporting/server/lib/jobs_query.ts index 06c4a7714099e..8784d8ff35d25 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/jobs_query.ts +++ b/x-pack/plugins/reporting/server/lib/jobs_query.ts @@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n'; import { errors as elasticsearchErrors } from 'elasticsearch'; import { ElasticsearchServiceSetup } from 'kibana/server'; import { get } from 'lodash'; -import { AuthenticatedUser } from '../../../../../plugins/security/server'; +import { AuthenticatedUser } from '../../../security/server'; import { ReportingConfig } from '../'; import { JobSource } from '../types'; diff --git a/x-pack/legacy/plugins/reporting/server/lib/level_logger.ts b/x-pack/plugins/reporting/server/lib/level_logger.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/level_logger.ts rename to x-pack/plugins/reporting/server/lib/level_logger.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/trace.ts b/x-pack/plugins/reporting/server/lib/trace.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/trace.ts rename to x-pack/plugins/reporting/server/lib/trace.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/validate/index.ts b/x-pack/plugins/reporting/server/lib/validate/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/validate/index.ts rename to x-pack/plugins/reporting/server/lib/validate/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/validate/validate_browser.ts b/x-pack/plugins/reporting/server/lib/validate/validate_browser.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/validate/validate_browser.ts rename to x-pack/plugins/reporting/server/lib/validate/validate_browser.ts diff --git a/x-pack/legacy/plugins/reporting/server/lib/validate/validate_max_content_length.test.js b/x-pack/plugins/reporting/server/lib/validate/validate_max_content_length.test.js similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/validate/validate_max_content_length.test.js rename to x-pack/plugins/reporting/server/lib/validate/validate_max_content_length.test.js diff --git a/x-pack/legacy/plugins/reporting/server/lib/validate/validate_max_content_length.ts b/x-pack/plugins/reporting/server/lib/validate/validate_max_content_length.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/lib/validate/validate_max_content_length.ts rename to x-pack/plugins/reporting/server/lib/validate/validate_max_content_length.ts diff --git a/x-pack/plugins/reporting/server/plugin.ts b/x-pack/plugins/reporting/server/plugin.ts index 905ed2b237c86..8e0e3a14ceec8 100644 --- a/x-pack/plugins/reporting/server/plugin.ts +++ b/x-pack/plugins/reporting/server/plugin.ts @@ -6,33 +6,84 @@ import { Observable } from 'rxjs'; import { first } from 'rxjs/operators'; -import { CoreSetup, Logger, Plugin, PluginInitializerContext } from 'src/core/server'; -import { ConfigType, createConfig$ } from './config'; - -export interface PluginsSetup { - /** @deprecated */ - __legacy: { - config$: Observable; - }; -} +import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/server'; +import { ReportingCore } from './core'; +import { ReportingConfigType } from './config'; +import { createBrowserDriverFactory } from './browsers'; +import { buildConfig, createConfig$ } from './config'; +import { createQueueFactory, enqueueJobFactory, LevelLogger, runValidations } from './lib'; +import { registerRoutes } from './routes'; +import { setFieldFormats } from './services'; +import { ReportingSetup, ReportingSetupDeps, ReportingStart, ReportingStartDeps } from './types'; +import { registerReportingUsageCollector } from './usage'; -export class ReportingPlugin implements Plugin { - private readonly log: Logger; +export class ReportingPlugin + implements Plugin { + private readonly initializerContext: PluginInitializerContext; + private logger: LevelLogger; + private reportingCore: ReportingCore | null = null; + private config$: Observable; - constructor(private readonly initializerContext: PluginInitializerContext) { - this.log = this.initializerContext.logger.get(); + constructor(context: PluginInitializerContext) { + this.logger = new LevelLogger(context.logger.get('reporting')); + this.initializerContext = context; + this.config$ = context.config.create(); } - public async setup(core: CoreSetup): Promise { - return { - __legacy: { - config$: createConfig$(core, this.initializerContext, this.log).pipe(first()), - }, - }; + public async setup(core: CoreSetup, plugins: ReportingSetupDeps) { + const { elasticsearch, licensing, security } = plugins; + const { initializerContext: initContext } = this; + const router = core.http.createRouter(); + const basePath = core.http.basePath.get; + + const coreConfig = await createConfig$(core, this.config$, this.logger) + .pipe(first()) + .toPromise(); // apply computed defaults to config + const reportingConfig = buildConfig(initContext, core, coreConfig); // combine kbnServer configs + this.reportingCore = new ReportingCore(reportingConfig); + + const browserDriverFactory = await createBrowserDriverFactory(reportingConfig, this.logger); + + this.reportingCore.pluginSetup({ + browserDriverFactory, + elasticsearch, + licensing, + basePath, + router, + security, + }); + + runValidations(reportingConfig, elasticsearch, browserDriverFactory, this.logger); + registerReportingUsageCollector(this.reportingCore, plugins); + registerRoutes(this.reportingCore, this.logger); + + return {}; } - public start() {} - public stop() {} -} + public async start(core: CoreStart, plugins: ReportingStartDeps) { + const { logger } = this; + const reportingCore = this.getReportingCore(); -export { ConfigType }; + const esqueue = await createQueueFactory(reportingCore, logger); + const enqueueJob = enqueueJobFactory(reportingCore, logger); + + reportingCore.pluginStart({ + savedObjects: core.savedObjects, + uiSettings: core.uiSettings, + esqueue, + enqueueJob, + }); + + setFieldFormats(plugins.data.fieldFormats); + logger.info('reporting plugin started'); + + return {}; + } + + public getReportingCore() { + if (!this.reportingCore) { + throw new Error('Setup is not ready'); + } + return this.reportingCore; + } +} diff --git a/x-pack/legacy/plugins/reporting/server/routes/generate_from_jobparams.ts b/x-pack/plugins/reporting/server/routes/generate_from_jobparams.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/routes/generate_from_jobparams.ts rename to x-pack/plugins/reporting/server/routes/generate_from_jobparams.ts diff --git a/x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject.ts b/x-pack/plugins/reporting/server/routes/generate_from_savedobject.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject.ts rename to x-pack/plugins/reporting/server/routes/generate_from_savedobject.ts index 4bc143b911572..b8326406743b7 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject.ts +++ b/x-pack/plugins/reporting/server/routes/generate_from_savedobject.ts @@ -9,7 +9,7 @@ import { get } from 'lodash'; import { HandlerErrorFunction, HandlerFunction, QueuedJobPayload } from './types'; import { ReportingCore } from '../'; import { API_BASE_GENERATE_V1, CSV_FROM_SAVEDOBJECT_JOB_TYPE } from '../../common/constants'; -import { getJobParamsFromRequest } from '../../export_types/csv_from_savedobject/server/lib/get_job_params_from_request'; +import { getJobParamsFromRequest } from '../export_types/csv_from_savedobject/server/lib/get_job_params_from_request'; import { authorizedUserPreRoutingFactory } from './lib/authorized_user_pre_routing'; /* diff --git a/x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts b/x-pack/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts similarity index 90% rename from x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts rename to x-pack/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts index 8a6d4553dfa9c..1221f67855410 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts +++ b/x-pack/plugins/reporting/server/routes/generate_from_savedobject_immediate.ts @@ -6,14 +6,15 @@ import { schema } from '@kbn/config-schema'; import { ReportingCore } from '../'; -import { HandlerErrorFunction } from './types'; import { API_BASE_GENERATE_V1 } from '../../common/constants'; -import { createJobFactory, executeJobFactory } from '../../export_types/csv_from_savedobject'; -import { getJobParamsFromRequest } from '../../export_types/csv_from_savedobject/server/lib/get_job_params_from_request'; -import { JobDocPayloadPanelCsv } from '../../export_types/csv_from_savedobject/types'; +import { createJobFactory } from '../export_types/csv_from_savedobject/server/create_job'; +import { executeJobFactory } from '../export_types/csv_from_savedobject/server/execute_job'; +import { getJobParamsFromRequest } from '../export_types/csv_from_savedobject/server/lib/get_job_params_from_request'; +import { JobDocPayloadPanelCsv } from '../export_types/csv_from_savedobject/types'; import { LevelLogger as Logger } from '../lib'; import { JobDocOutput } from '../types'; import { authorizedUserPreRoutingFactory } from './lib/authorized_user_pre_routing'; +import { HandlerErrorFunction } from './types'; /* * This function registers API Endpoints for immediate Reporting jobs. The API inputs are: diff --git a/x-pack/legacy/plugins/reporting/server/routes/generation.test.ts b/x-pack/plugins/reporting/server/routes/generation.test.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/server/routes/generation.test.ts rename to x-pack/plugins/reporting/server/routes/generation.test.ts index 87ac71e250d0c..a96957447dfeb 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/generation.test.ts +++ b/x-pack/plugins/reporting/server/routes/generation.test.ts @@ -9,7 +9,7 @@ import { UnwrapPromise } from '@kbn/utility-types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { setupServer } from 'src/core/server/saved_objects/routes/integration_tests/test_utils'; import { registerJobGenerationRoutes } from './generation'; -import { createMockReportingCore } from '../../test_helpers'; +import { createMockReportingCore } from '../test_helpers'; import { ReportingCore } from '..'; import { ExportTypesRegistry } from '../lib/export_types_registry'; import { ExportTypeDefinition } from '../types'; @@ -51,9 +51,7 @@ describe('POST /api/reporting/generate', () => { ({ server, httpSetup } = await setupServer()); const mockDeps = ({ elasticsearch: { - legacy: { - client: { callAsInternalUser: jest.fn() }, - }, + adminClient: { callAsInternalUser: jest.fn() }, }, security: { authc: { diff --git a/x-pack/legacy/plugins/reporting/server/routes/generation.ts b/x-pack/plugins/reporting/server/routes/generation.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/routes/generation.ts rename to x-pack/plugins/reporting/server/routes/generation.ts diff --git a/x-pack/legacy/plugins/reporting/server/routes/index.ts b/x-pack/plugins/reporting/server/routes/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/routes/index.ts rename to x-pack/plugins/reporting/server/routes/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/routes/jobs.test.ts b/x-pack/plugins/reporting/server/routes/jobs.test.ts similarity index 99% rename from x-pack/legacy/plugins/reporting/server/routes/jobs.test.ts rename to x-pack/plugins/reporting/server/routes/jobs.test.ts index 0911f48f82ca4..d13b3e72ca8e7 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/jobs.test.ts +++ b/x-pack/plugins/reporting/server/routes/jobs.test.ts @@ -4,18 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -import supertest from 'supertest'; import { UnwrapPromise } from '@kbn/utility-types'; +import { of } from 'rxjs'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { setupServer } from 'src/core/server/saved_objects/routes/integration_tests/test_utils'; -import { registerJobInfoRoutes } from './jobs'; -import { createMockReportingCore } from '../../test_helpers'; +import supertest from 'supertest'; import { ReportingCore } from '..'; +import { ReportingInternalSetup } from '../core'; +import { LevelLogger } from '../lib'; import { ExportTypesRegistry } from '../lib/export_types_registry'; +import { createMockReportingCore } from '../test_helpers'; import { ExportTypeDefinition } from '../types'; -import { LevelLogger } from '../lib'; -import { ReportingInternalSetup } from '../core'; -import { of } from 'rxjs'; +import { registerJobInfoRoutes } from './jobs'; type setupServerReturn = UnwrapPromise>; diff --git a/x-pack/legacy/plugins/reporting/server/routes/jobs.ts b/x-pack/plugins/reporting/server/routes/jobs.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/routes/jobs.ts rename to x-pack/plugins/reporting/server/routes/jobs.ts diff --git a/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts b/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts similarity index 98% rename from x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts rename to x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts index 4cb7af3d0d409..76d253418121f 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts +++ b/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts @@ -8,7 +8,7 @@ import { KibanaRequest, RequestHandlerContext, KibanaResponseFactory } from 'kib import sinon from 'sinon'; import { coreMock, httpServerMock } from 'src/core/server/mocks'; import { ReportingConfig, ReportingCore } from '../../'; -import { createMockReportingCore } from '../../../test_helpers'; +import { createMockReportingCore } from '../../test_helpers'; import { authorizedUserPreRoutingFactory } from './authorized_user_pre_routing'; import { ReportingInternalSetup } from '../../core'; diff --git a/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts b/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts similarity index 95% rename from x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts rename to x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts index 87582ca3ca239..2ad974c9dd8e1 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts +++ b/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts @@ -5,7 +5,7 @@ */ import { RequestHandler, RouteMethod } from 'src/core/server'; -import { AuthenticatedUser } from '../../../../../../plugins/security/server'; +import { AuthenticatedUser } from '../../../../security/server'; import { getUserFactory } from '../../lib/get_user'; import { ReportingCore } from '../../core'; diff --git a/x-pack/legacy/plugins/reporting/server/routes/lib/get_document_payload.ts b/x-pack/plugins/reporting/server/routes/lib/get_document_payload.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/routes/lib/get_document_payload.ts rename to x-pack/plugins/reporting/server/routes/lib/get_document_payload.ts diff --git a/x-pack/legacy/plugins/reporting/server/routes/lib/job_response_handler.ts b/x-pack/plugins/reporting/server/routes/lib/job_response_handler.ts similarity index 97% rename from x-pack/legacy/plugins/reporting/server/routes/lib/job_response_handler.ts rename to x-pack/plugins/reporting/server/routes/lib/job_response_handler.ts index 990af2d0aca80..1a2e10cf355a2 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/lib/job_response_handler.ts +++ b/x-pack/plugins/reporting/server/routes/lib/job_response_handler.ts @@ -5,7 +5,7 @@ */ import { ElasticsearchServiceSetup, kibanaResponseFactory } from 'kibana/server'; -import { AuthenticatedUser } from '../../../../../../plugins/security/server'; +import { AuthenticatedUser } from '../../../../security/server'; import { ReportingConfig } from '../../'; import { WHITELISTED_JOB_CONTENT_TYPES } from '../../../common/constants'; import { ExportTypesRegistry } from '../../lib/export_types_registry'; diff --git a/x-pack/legacy/plugins/reporting/server/routes/types.d.ts b/x-pack/plugins/reporting/server/routes/types.d.ts similarity index 82% rename from x-pack/legacy/plugins/reporting/server/routes/types.d.ts rename to x-pack/plugins/reporting/server/routes/types.d.ts index afa3fd3358fc1..5eceed0a7f2ab 100644 --- a/x-pack/legacy/plugins/reporting/server/routes/types.d.ts +++ b/x-pack/plugins/reporting/server/routes/types.d.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { KibanaResponseFactory, KibanaRequest, RequestHandlerContext } from 'src/core/server'; -import { AuthenticatedUser } from '../../../../../plugins/security/common/model/authenticated_user'; +import { KibanaRequest, KibanaResponseFactory, RequestHandlerContext } from 'src/core/server'; +import { AuthenticatedUser } from '../../../security/server'; import { JobDocPayload } from '../types'; export type HandlerFunction = ( diff --git a/x-pack/legacy/plugins/reporting/server/services.ts b/x-pack/plugins/reporting/server/services.ts similarity index 67% rename from x-pack/legacy/plugins/reporting/server/services.ts rename to x-pack/plugins/reporting/server/services.ts index 7d15d2e1af1ae..9f4897a69f4ed 100644 --- a/x-pack/legacy/plugins/reporting/server/services.ts +++ b/x-pack/plugins/reporting/server/services.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { createGetterSetter } from '../../../../../src/plugins/kibana_utils/server'; -import { PluginStart as DataPluginStart } from '../../../../../src/plugins/data/server'; +import { createGetterSetter } from '../../../../src/plugins/kibana_utils/server'; +import { PluginStart as DataPluginStart } from '../../../../src/plugins/data/server'; export const [getFieldFormats, setFieldFormats] = createGetterSetter< DataPluginStart['fieldFormats'] diff --git a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_browserdriverfactory.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts similarity index 96% rename from x-pack/legacy/plugins/reporting/test_helpers/create_mock_browserdriverfactory.ts rename to x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts index 260c94c31df1c..6eaaeddd63500 100644 --- a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_browserdriverfactory.ts +++ b/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts @@ -7,10 +7,10 @@ import { Page } from 'puppeteer'; import * as Rx from 'rxjs'; import * as contexts from '../export_types/common/lib/screenshots/constants'; -import { HeadlessChromiumDriver, HeadlessChromiumDriverFactory } from '../server/browsers'; -import { createDriverFactory } from '../server/browsers/chromium'; -import { LevelLogger } from '../server/lib'; -import { CaptureConfig, ElementsPositionAndAttribute } from '../server/types'; +import { HeadlessChromiumDriver, HeadlessChromiumDriverFactory } from '../../server/browsers'; +import { createDriverFactory } from '../../server/browsers/chromium'; +import { LevelLogger } from '../../server/lib'; +import { CaptureConfig, ElementsPositionAndAttribute } from '../../server/types'; interface CreateMockBrowserDriverFactoryOpts { evaluate: jest.Mock, any[]>; diff --git a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_layoutinstance.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_layoutinstance.ts similarity index 93% rename from x-pack/legacy/plugins/reporting/test_helpers/create_mock_layoutinstance.ts rename to x-pack/plugins/reporting/server/test_helpers/create_mock_layoutinstance.ts index 7f4330e7f6bc6..bac7df1af2d46 100644 --- a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_layoutinstance.ts +++ b/x-pack/plugins/reporting/server/test_helpers/create_mock_layoutinstance.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import { CaptureConfig } from '../../server/types'; import { createLayout, LayoutInstance, LayoutTypes } from '../export_types/common/layouts'; -import { CaptureConfig } from '../server/types'; export const createMockLayoutInstance = (captureConfig: CaptureConfig) => { const mockLayout = createLayout(captureConfig, { diff --git a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_reportingplugin.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts similarity index 70% rename from x-pack/legacy/plugins/reporting/test_helpers/create_mock_reportingplugin.ts rename to x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts index f6dbccdfe3980..e3e6aa812132f 100644 --- a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_reportingplugin.ts +++ b/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts @@ -4,21 +4,20 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../server/routes'); -jest.mock('../server/usage'); -jest.mock('../server/browsers'); -jest.mock('../server/browsers'); -jest.mock('../server/lib/create_queue'); -jest.mock('../server/lib/enqueue_job'); -jest.mock('../server/lib/validate'); +jest.mock('../routes'); +jest.mock('../usage'); +jest.mock('../browsers'); +jest.mock('../browsers'); +jest.mock('../lib/create_queue'); +jest.mock('../lib/enqueue_job'); +jest.mock('../lib/validate'); import { of } from 'rxjs'; -import { EventEmitter } from 'events'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { coreMock } from 'src/core/server/mocks'; -import { ReportingConfig, ReportingCore, ReportingPlugin } from '../server'; -import { ReportingSetupDeps, ReportingStartDeps } from '../server/types'; -import { ReportingInternalSetup } from '../server/core'; +import { ReportingConfig, ReportingCore } from '../'; +import { ReportingInternalSetup } from '../core'; +import { ReportingPlugin } from '../plugin'; +import { ReportingSetupDeps, ReportingStartDeps } from '../types'; const createMockSetupDeps = (setupMock?: any): ReportingSetupDeps => { return { @@ -28,18 +27,16 @@ const createMockSetupDeps = (setupMock?: any): ReportingSetupDeps => { license$: of({ isAvailable: true, isActive: true, type: 'basic' }), } as any, usageCollection: {} as any, - __LEGACY: { plugins: { xpack_main: { status: new EventEmitter() } } } as any, }; }; export const createMockStartDeps = (startMock?: any): ReportingStartDeps => ({ data: startMock.data, - __LEGACY: {} as any, }); const createMockReportingPlugin = async (config: ReportingConfig): Promise => { config = config || {}; - const plugin = new ReportingPlugin(coreMock.createPluginInitializerContext(config), config); + const plugin = new ReportingPlugin(coreMock.createPluginInitializerContext(config)); const setupMock = coreMock.createSetup(); const coreStartMock = coreMock.createStart(); const startMock = { diff --git a/x-pack/legacy/plugins/reporting/test_helpers/create_mock_server.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_server.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/test_helpers/create_mock_server.ts rename to x-pack/plugins/reporting/server/test_helpers/create_mock_server.ts diff --git a/x-pack/legacy/plugins/reporting/test_helpers/index.ts b/x-pack/plugins/reporting/server/test_helpers/index.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/test_helpers/index.ts rename to x-pack/plugins/reporting/server/test_helpers/index.ts diff --git a/x-pack/legacy/plugins/reporting/server/types.ts b/x-pack/plugins/reporting/server/types.ts similarity index 85% rename from x-pack/legacy/plugins/reporting/server/types.ts rename to x-pack/plugins/reporting/server/types.ts index 2ccc209c3ce50..ad67677f3814d 100644 --- a/x-pack/legacy/plugins/reporting/server/types.ts +++ b/x-pack/plugins/reporting/server/types.ts @@ -4,22 +4,19 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Legacy } from 'kibana'; -import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; import { ElasticsearchServiceSetup } from 'kibana/server'; import * as Rx from 'rxjs'; +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 { LicensingPluginSetup } from '../../../../plugins/licensing/server'; -import { ReportingPluginSpecOptions } from '../'; -import { CancellationToken } from '../../../../plugins/reporting/common'; -import { JobStatus } from '../../../../plugins/reporting/common/types'; -import { SecurityPluginSetup } from '../../../../plugins/security/server'; -import { XPackMainPlugin } from '../../xpack_main/server/xpack_main'; -import { LayoutInstance } from '../export_types/common/layouts'; +import { CancellationToken } from '../../../plugins/reporting/common'; +import { LicensingPluginSetup } from '../../licensing/server'; +import { SecurityPluginSetup } from '../../security/server'; +import { JobStatus } from '../common/types'; import { ReportingConfigType } from './config'; import { ReportingCore } from './core'; +import { LayoutInstance } from './export_types/common/layouts'; import { LevelLogger } from './lib'; /* @@ -165,27 +162,15 @@ export interface ReportingSetupDeps { licensing: LicensingPluginSetup; security: SecurityPluginSetup; usageCollection?: UsageCollectionSetup; - __LEGACY: LegacySetup; } export interface ReportingStartDeps { data: DataPluginStart; - __LEGACY: LegacySetup; } export type ReportingStart = object; export type ReportingSetup = object; -export interface LegacySetup { - plugins: { - xpack_main: XPackMainPlugin & { - status?: any; - }; - reporting: ReportingPluginSpecOptions; - }; - route: Legacy.Server['route']; -} - /* * Internal Types */ @@ -202,8 +187,6 @@ export type ESQueueWorkerExecuteFn = ( cancellationToken?: CancellationToken ) => Promise; -export type ServerFacade = LegacySetup; - export type CaptureConfig = ReportingConfigType['capture']; export type ScrollConfig = ReportingConfigType['csv']['scroll']; diff --git a/x-pack/legacy/plugins/reporting/server/usage/__snapshots__/reporting_usage_collector.test.ts.snap b/x-pack/plugins/reporting/server/usage/__snapshots__/reporting_usage_collector.test.ts.snap similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/__snapshots__/reporting_usage_collector.test.ts.snap rename to x-pack/plugins/reporting/server/usage/__snapshots__/reporting_usage_collector.test.ts.snap diff --git a/x-pack/legacy/plugins/reporting/server/usage/decorate_range_stats.ts b/x-pack/plugins/reporting/server/usage/decorate_range_stats.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/decorate_range_stats.ts rename to x-pack/plugins/reporting/server/usage/decorate_range_stats.ts diff --git a/x-pack/legacy/plugins/reporting/server/usage/get_export_type_handler.ts b/x-pack/plugins/reporting/server/usage/get_export_type_handler.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/get_export_type_handler.ts rename to x-pack/plugins/reporting/server/usage/get_export_type_handler.ts diff --git a/x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage.ts b/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage.ts rename to x-pack/plugins/reporting/server/usage/get_reporting_usage.ts diff --git a/x-pack/legacy/plugins/reporting/server/usage/index.ts b/x-pack/plugins/reporting/server/usage/index.ts similarity index 87% rename from x-pack/legacy/plugins/reporting/server/usage/index.ts rename to x-pack/plugins/reporting/server/usage/index.ts index d00a8570a024f..a426451db2282 100644 --- a/x-pack/legacy/plugins/reporting/server/usage/index.ts +++ b/x-pack/plugins/reporting/server/usage/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { LicenseType } from '../../../../../plugins/licensing/server'; +import { LicenseType } from '../../../licensing/server'; export interface FeaturesAvailability { isAvailable: () => boolean; diff --git a/x-pack/legacy/plugins/reporting/server/usage/reporting_usage_collector.test.ts b/x-pack/plugins/reporting/server/usage/reporting_usage_collector.test.ts similarity index 99% rename from x-pack/legacy/plugins/reporting/server/usage/reporting_usage_collector.test.ts rename to x-pack/plugins/reporting/server/usage/reporting_usage_collector.test.ts index 830c6275cd96a..d5dccaca3042a 100644 --- a/x-pack/legacy/plugins/reporting/server/usage/reporting_usage_collector.test.ts +++ b/x-pack/plugins/reporting/server/usage/reporting_usage_collector.test.ts @@ -8,7 +8,7 @@ import * as Rx from 'rxjs'; import sinon from 'sinon'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { ReportingConfig } from '../'; -import { createMockReportingCore } from '../../test_helpers'; +import { createMockReportingCore } from '../test_helpers'; import { getExportTypesRegistry } from '../lib/export_types_registry'; import { ReportingSetupDeps } from '../types'; import { FeaturesAvailability } from './'; diff --git a/x-pack/legacy/plugins/reporting/server/usage/reporting_usage_collector.ts b/x-pack/plugins/reporting/server/usage/reporting_usage_collector.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/reporting_usage_collector.ts rename to x-pack/plugins/reporting/server/usage/reporting_usage_collector.ts diff --git a/x-pack/legacy/plugins/reporting/server/usage/types.ts b/x-pack/plugins/reporting/server/usage/types.ts similarity index 100% rename from x-pack/legacy/plugins/reporting/server/usage/types.ts rename to x-pack/plugins/reporting/server/usage/types.ts diff --git a/x-pack/tasks/prepare.ts b/x-pack/tasks/prepare.ts index 6d4eb5603ad3a..448905bcf9d91 100644 --- a/x-pack/tasks/prepare.ts +++ b/x-pack/tasks/prepare.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ensureAllBrowsersDownloaded } from '../legacy/plugins/reporting/server/browsers'; +import { ensureAllBrowsersDownloaded } from '../plugins/reporting/server/browsers'; export const prepareTask = async () => { await ensureAllBrowsersDownloaded(); diff --git a/x-pack/test/reporting_api_integration/services.ts b/x-pack/test/reporting_api_integration/services.ts index a0b572787ddfc..dadb466d45982 100644 --- a/x-pack/test/reporting_api_integration/services.ts +++ b/x-pack/test/reporting_api_integration/services.ts @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; import * as Rx from 'rxjs'; import { filter, first, mapTo, switchMap, timeout } from 'rxjs/operators'; // @ts-ignore no module definition -import { indexTimestamp } from '../../legacy/plugins/reporting/server/lib/esqueue/helpers/index_timestamp'; +import { indexTimestamp } from '../../plugins/reporting/server/lib/esqueue/helpers/index_timestamp'; import { services as xpackServices } from '../functional/services'; import { FtrProviderContext } from './ftr_provider_context'; From 36f2bae7b9a78ea825453e57c1b354145f83202b Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Mon, 1 Jun 2020 18:21:43 -0700 Subject: [PATCH 02/16] Elasticsearch is not a plugin dep --- x-pack/plugins/reporting/server/plugin.ts | 7 ++++--- .../server/test_helpers/create_mock_reportingplugin.ts | 1 - x-pack/plugins/reporting/server/types.ts | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/reporting/server/plugin.ts b/x-pack/plugins/reporting/server/plugin.ts index 8e0e3a14ceec8..8706beecdde05 100644 --- a/x-pack/plugins/reporting/server/plugin.ts +++ b/x-pack/plugins/reporting/server/plugin.ts @@ -31,10 +31,11 @@ export class ReportingPlugin } public async setup(core: CoreSetup, plugins: ReportingSetupDeps) { - const { elasticsearch, licensing, security } = plugins; + const { elasticsearch, http } = core; + const { licensing, security } = plugins; const { initializerContext: initContext } = this; - const router = core.http.createRouter(); - const basePath = core.http.basePath.get; + const router = http.createRouter(); + const basePath = http.basePath.get; const coreConfig = await createConfig$(core, this.config$, this.logger) .pipe(first()) diff --git a/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts index e3e6aa812132f..26ba0ff76ecdc 100644 --- a/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts +++ b/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts @@ -21,7 +21,6 @@ import { ReportingSetupDeps, ReportingStartDeps } from '../types'; const createMockSetupDeps = (setupMock?: any): ReportingSetupDeps => { return { - elasticsearch: setupMock.elasticsearch, security: setupMock.security, licensing: { license$: of({ isAvailable: true, isActive: true, type: 'basic' }), diff --git a/x-pack/plugins/reporting/server/types.ts b/x-pack/plugins/reporting/server/types.ts index ad67677f3814d..499a5c0b027f2 100644 --- a/x-pack/plugins/reporting/server/types.ts +++ b/x-pack/plugins/reporting/server/types.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ElasticsearchServiceSetup } from 'kibana/server'; import * as Rx from 'rxjs'; import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths @@ -158,7 +157,6 @@ export type ScreenshotsObservableFn = ({ */ export interface ReportingSetupDeps { - elasticsearch: ElasticsearchServiceSetup; licensing: LicensingPluginSetup; security: SecurityPluginSetup; usageCollection?: UsageCollectionSetup; From 2934c7912cdf177ed8d77e132dc17cc6fbc3d2a7 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Mon, 1 Jun 2020 18:24:08 -0700 Subject: [PATCH 03/16] add data as plugin dependo --- x-pack/plugins/reporting/kibana.json | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/reporting/kibana.json b/x-pack/plugins/reporting/kibana.json index 282419fde4c24..01a668403ffc9 100644 --- a/x-pack/plugins/reporting/kibana.json +++ b/x-pack/plugins/reporting/kibana.json @@ -7,6 +7,7 @@ ], "configPath": ["xpack", "reporting"], "requiredPlugins": [ + "data", "home", "management", "licensing", From 1ba7ddd4f1fac232944f032da10bbcd9f28f673b Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Mon, 1 Jun 2020 18:38:47 -0700 Subject: [PATCH 04/16] diff cleanup 1 --- .../plugins/reporting/server/config/create_config.test.ts | 4 ++-- x-pack/plugins/reporting/server/config/create_config.ts | 2 +- x-pack/plugins/reporting/server/plugin.ts | 2 +- x-pack/plugins/reporting/server/routes/generation.test.ts | 4 +++- .../test_helpers/create_mock_browserdriverfactory.ts | 8 ++++---- .../server/test_helpers/create_mock_layoutinstance.ts | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/reporting/server/config/create_config.test.ts b/x-pack/plugins/reporting/server/config/create_config.test.ts index 7e9fd19b776cc..c7e4f13f696c7 100644 --- a/x-pack/plugins/reporting/server/config/create_config.test.ts +++ b/x-pack/plugins/reporting/server/config/create_config.test.ts @@ -6,9 +6,9 @@ import * as Rx from 'rxjs'; import { CoreSetup, PluginInitializerContext } from 'src/core/server'; -import { ReportingConfigType } from './schema'; -import { createConfig$ } from './create_config'; import { LevelLogger } from '../lib'; +import { createConfig$ } from './create_config'; +import { ReportingConfigType } from './schema'; interface KibanaServer { host?: string; diff --git a/x-pack/plugins/reporting/server/config/create_config.ts b/x-pack/plugins/reporting/server/config/create_config.ts index 2f244a134f014..67df7dacc77ab 100644 --- a/x-pack/plugins/reporting/server/config/create_config.ts +++ b/x-pack/plugins/reporting/server/config/create_config.ts @@ -15,7 +15,7 @@ import { getDefaultChromiumSandboxDisabled } from './default_chromium_sandbox_di import { ReportingConfigType } from './schema'; /* - * Set up computed config defaults + * Set up dynamic config defaults * - xpack.capture.browser.chromium.disableSandbox * - xpack.kibanaServer * - xpack.reporting.encryptionKey diff --git a/x-pack/plugins/reporting/server/plugin.ts b/x-pack/plugins/reporting/server/plugin.ts index 8706beecdde05..3b3f8eaa13721 100644 --- a/x-pack/plugins/reporting/server/plugin.ts +++ b/x-pack/plugins/reporting/server/plugin.ts @@ -21,7 +21,7 @@ export class ReportingPlugin implements Plugin { private readonly initializerContext: PluginInitializerContext; private logger: LevelLogger; - private reportingCore: ReportingCore | null = null; + private reportingCore?: ReportingCore; private config$: Observable; constructor(context: PluginInitializerContext) { diff --git a/x-pack/plugins/reporting/server/routes/generation.test.ts b/x-pack/plugins/reporting/server/routes/generation.test.ts index a96957447dfeb..eb75109c704c7 100644 --- a/x-pack/plugins/reporting/server/routes/generation.test.ts +++ b/x-pack/plugins/reporting/server/routes/generation.test.ts @@ -51,7 +51,9 @@ describe('POST /api/reporting/generate', () => { ({ server, httpSetup } = await setupServer()); const mockDeps = ({ elasticsearch: { - adminClient: { callAsInternalUser: jest.fn() }, + legacy: { + client: { callAsInternalUser: jest.fn() }, + }, }, security: { authc: { diff --git a/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts index 6eaaeddd63500..5b0d740e031ab 100644 --- a/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts +++ b/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts @@ -6,11 +6,11 @@ import { Page } from 'puppeteer'; import * as Rx from 'rxjs'; +import { HeadlessChromiumDriver, HeadlessChromiumDriverFactory } from '../browsers'; +import { createDriverFactory } from '../browsers/chromium'; import * as contexts from '../export_types/common/lib/screenshots/constants'; -import { HeadlessChromiumDriver, HeadlessChromiumDriverFactory } from '../../server/browsers'; -import { createDriverFactory } from '../../server/browsers/chromium'; -import { LevelLogger } from '../../server/lib'; -import { CaptureConfig, ElementsPositionAndAttribute } from '../../server/types'; +import { LevelLogger } from '../lib'; +import { CaptureConfig, ElementsPositionAndAttribute } from '../types'; interface CreateMockBrowserDriverFactoryOpts { evaluate: jest.Mock, any[]>; 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 bac7df1af2d46..22da9eb418e9a 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,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CaptureConfig } from '../../server/types'; import { createLayout, LayoutInstance, LayoutTypes } from '../export_types/common/layouts'; +import { CaptureConfig } from '../types'; export const createMockLayoutInstance = (captureConfig: CaptureConfig) => { const mockLayout = createLayout(captureConfig, { From a8f0837ad6ee39cf7b2ef878c8bb9f50c30a43c7 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 2 Jun 2020 09:45:51 -0700 Subject: [PATCH 05/16] log the browser download --- .../browsers/create_browser_driver_factory.ts | 2 +- .../server/browsers/download/clean.ts | 11 ++++----- .../server/browsers/download/download.ts | 19 ++++++++------- .../browsers/download/ensure_downloaded.ts | 24 ++++++++++++------- .../server/browsers/download/util.ts | 11 --------- x-pack/tasks/prepare.ts | 16 ++++++++++++- 6 files changed, 47 insertions(+), 36 deletions(-) diff --git a/x-pack/plugins/reporting/server/browsers/create_browser_driver_factory.ts b/x-pack/plugins/reporting/server/browsers/create_browser_driver_factory.ts index ff74f4eec45df..f3486a48ba7b1 100644 --- a/x-pack/plugins/reporting/server/browsers/create_browser_driver_factory.ts +++ b/x-pack/plugins/reporting/server/browsers/create_browser_driver_factory.ts @@ -26,7 +26,7 @@ export async function createBrowserDriverFactory( logger.warning(`Enabling the Chromium sandbox provides an additional layer of protection.`); } if (browserAutoDownload) { - await ensureBrowserDownloaded(browserType); + await ensureBrowserDownloaded(browserType, logger); } try { diff --git a/x-pack/plugins/reporting/server/browsers/download/clean.ts b/x-pack/plugins/reporting/server/browsers/download/clean.ts index 8988cbd1c9ec2..8558b001e8174 100644 --- a/x-pack/plugins/reporting/server/browsers/download/clean.ts +++ b/x-pack/plugins/reporting/server/browsers/download/clean.ts @@ -4,17 +4,16 @@ * you may not use this file except in compliance with the Elastic License. */ +import del from 'del'; import { readdirSync } from 'fs'; import { resolve as resolvePath } from 'path'; - -import del from 'del'; - -import { log, asyncMap } from './util'; +import { LevelLogger } from '../../lib'; +import { asyncMap } from './util'; /** * Delete any file in the `dir` that is not in the expectedPaths */ -export async function clean(dir: string, expectedPaths: string[]) { +export async function clean(dir: string, expectedPaths: string[], logger: LevelLogger) { let filenames: string[]; try { filenames = await readdirSync(dir); @@ -30,7 +29,7 @@ export async function clean(dir: string, expectedPaths: string[]) { await asyncMap(filenames, async (filename) => { const path = resolvePath(dir, filename); if (!expectedPaths.includes(path)) { - log(`Deleting unexpected file ${path}`); + logger.warn(`Deleting unexpected file ${path}`); await del(path, { force: true }); } }); diff --git a/x-pack/plugins/reporting/server/browsers/download/download.ts b/x-pack/plugins/reporting/server/browsers/download/download.ts index a5ad69b46e46d..017845d931409 100644 --- a/x-pack/plugins/reporting/server/browsers/download/download.ts +++ b/x-pack/plugins/reporting/server/browsers/download/download.ts @@ -4,13 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { openSync, writeSync, closeSync, mkdirSync } from 'fs'; +import Axios from 'axios'; import { createHash } from 'crypto'; +import { closeSync, mkdirSync, openSync, writeSync } from 'fs'; import { dirname } from 'path'; - -import Axios from 'axios'; - -import { log } from './util'; +import { LevelLogger } from '../../lib'; /** * Download a url and calculate it's checksum @@ -18,8 +16,8 @@ import { log } from './util'; * @param {String} path * @return {Promise} checksum of the downloaded file */ -export async function download(url: string, path: string) { - log(`Downloading ${url}`); +export async function download(url: string, path: string, logger: LevelLogger) { + logger.info(`Downloading ${url} to ${path}`); const hash = createHash('md5'); @@ -39,7 +37,12 @@ export async function download(url: string, path: string) { }); await new Promise((resolve, reject) => { - resp.data.on('error', reject).on('end', resolve); + resp.data + .on('error', (err: Error) => { + logger.error(err); + reject(err); + }) + .on('end', resolve); }); } finally { closeSync(handle); diff --git a/x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.ts b/x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.ts index f1f609ed5607b..b334510d71947 100644 --- a/x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.ts +++ b/x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.ts @@ -8,6 +8,7 @@ import { existsSync } from 'fs'; import { resolve as resolvePath } from 'path'; import { BrowserDownload, chromium } from '../'; import { BROWSER_TYPE } from '../../../common/constants'; +import { LevelLogger } from '../../lib'; import { md5 } from './checksum'; import { clean } from './clean'; import { download } from './download'; @@ -19,16 +20,17 @@ import { asyncMap } from './util'; * @param {String} browserType * @return {Promise} */ -export async function ensureBrowserDownloaded(browserType = BROWSER_TYPE) { - await ensureDownloaded([chromium]); +export async function ensureBrowserDownloaded(browserType = BROWSER_TYPE, logger: LevelLogger) { + await ensureDownloaded([chromium], logger); } /** - * Like ensureBrowserDownloaded(), except it applies to all browsers + * Check for the downloaded archive of each requested browser type and + * download them if they are missing or their checksum is invalid* * @return {Promise} */ -export async function ensureAllBrowsersDownloaded() { - await ensureDownloaded([chromium]); +export async function ensureAllBrowsersDownloaded(logger: LevelLogger) { + await ensureDownloaded([chromium], logger); } /** @@ -38,13 +40,14 @@ export async function ensureAllBrowsersDownloaded() { * @param {BrowserSpec} browsers * @return {Promise} */ -async function ensureDownloaded(browsers: BrowserDownload[]) { +async function ensureDownloaded(browsers: BrowserDownload[], logger: LevelLogger) { await asyncMap(browsers, async (browser) => { const { archivesPath } = browser.paths; await clean( archivesPath, - browser.paths.packages.map((p) => resolvePath(archivesPath, p.archiveFilename)) + browser.paths.packages.map((p) => resolvePath(archivesPath, p.archiveFilename)), + logger ); const invalidChecksums: string[] = []; @@ -53,21 +56,24 @@ async function ensureDownloaded(browsers: BrowserDownload[]) { const path = resolvePath(archivesPath, archiveFilename); if (existsSync(path) && (await md5(path)) === archiveChecksum) { + logger.info(`Browser archive exists in ${path}`); return; } - const downloadedChecksum = await download(url, path); + const downloadedChecksum = await download(url, path, logger); if (downloadedChecksum !== archiveChecksum) { invalidChecksums.push(`${url} => ${path}`); } }); if (invalidChecksums.length) { - throw new Error( + const err = new Error( `Error downloading browsers, checksums incorrect for:\n - ${invalidChecksums.join( '\n - ' )}` ); + logger.error(err); + throw err; } }); } diff --git a/x-pack/plugins/reporting/server/browsers/download/util.ts b/x-pack/plugins/reporting/server/browsers/download/util.ts index 679106742e3d0..99267664be766 100644 --- a/x-pack/plugins/reporting/server/browsers/download/util.ts +++ b/x-pack/plugins/reporting/server/browsers/download/util.ts @@ -6,17 +6,6 @@ import { Readable } from 'stream'; -/** - * Log a message if the DEBUG environment variable is set - */ -export function log(...args: any[]) { - if (process.env.DEBUG) { - // allow console log since this is off by default and only for debugging - // eslint-disable-next-line no-console - console.log(...args); - } -} - /** * Iterate an array asynchronously and in parallel */ diff --git a/x-pack/tasks/prepare.ts b/x-pack/tasks/prepare.ts index 448905bcf9d91..5c71675d44189 100644 --- a/x-pack/tasks/prepare.ts +++ b/x-pack/tasks/prepare.ts @@ -5,7 +5,21 @@ */ import { ensureAllBrowsersDownloaded } from '../plugins/reporting/server/browsers'; +import { LevelLogger } from '../plugins/reporting/server/lib'; export const prepareTask = async () => { - await ensureAllBrowsersDownloaded(); + // eslint-disable-next-line no-console + const consoleLogger = (tag: string) => (message: unknown) => console.log(tag, message); + const innerLogger = { + get: () => innerLogger, + debug: consoleLogger('debug'), + info: consoleLogger('info'), + warn: consoleLogger('warn'), + trace: consoleLogger('trace'), + error: consoleLogger('error'), + fatal: consoleLogger('fatal'), + log: consoleLogger('log'), + }; + const levelLogger = new LevelLogger(innerLogger); + await ensureAllBrowsersDownloaded(levelLogger); }; From 1074dc8bd68f612c33805428b189bf0c50611b98 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 2 Jun 2020 10:20:45 -0700 Subject: [PATCH 06/16] Update paths in outside code for new Reporting home --- .ci/packer_cache.sh | 2 +- src/cli/cluster/cluster_manager.ts | 2 +- src/dev/build/tasks/clean_tasks.js | 2 +- .../ingest_coverage/__tests__/transforms.test.js | 4 ++-- .../jest-combined/coverage-summary-manual-mix.json | 2 +- src/dev/precommit_hook/casing_check_config.js | 12 ++++++------ x-pack/.gitignore | 4 ++-- x-pack/.i18nrc.json | 2 +- x-pack/.kibana-plugin-helpers.json | 4 ++-- x-pack/build_chromium/README.md | 2 +- .../maps/public/connected_components/gis_map/view.js | 2 +- x-pack/plugins/reporting/.gitignore | 1 - .../reporting/server/browsers/download/download.ts | 5 ++++- x-pack/plugins/reporting/server/plugin.ts | 2 +- 14 files changed, 24 insertions(+), 22 deletions(-) delete mode 100644 x-pack/plugins/reporting/.gitignore diff --git a/.ci/packer_cache.sh b/.ci/packer_cache.sh index d47ef93172a9d..11f9ccaeddb1e 100755 --- a/.ci/packer_cache.sh +++ b/.ci/packer_cache.sh @@ -40,7 +40,7 @@ echo "Creating bootstrap_cache archive" # archive cacheable directories mkdir -p "$HOME/.kibana/bootstrap_cache" tar -cf "$HOME/.kibana/bootstrap_cache/$branch.tar" \ - x-pack/legacy/plugins/reporting/.chromium \ + x-pack/plugins/reporting/.chromium \ .es \ .chromedriver \ .geckodriver; diff --git a/src/cli/cluster/cluster_manager.ts b/src/cli/cluster/cluster_manager.ts index fc94f8d585a02..dec16b63d78f0 100644 --- a/src/cli/cluster/cluster_manager.ts +++ b/src/cli/cluster/cluster_manager.ts @@ -261,7 +261,7 @@ export class ClusterManager { /debug\.log$/, ...pluginInternalDirsIgnore, fromRoot('src/legacy/server/sass/__tmp__'), - fromRoot('x-pack/legacy/plugins/reporting/.chromium'), + fromRoot('x-pack/plugins/reporting/.chromium'), fromRoot('x-pack/plugins/siem/cypress'), fromRoot('x-pack/plugins/apm/e2e'), fromRoot('x-pack/plugins/apm/scripts'), diff --git a/src/dev/build/tasks/clean_tasks.js b/src/dev/build/tasks/clean_tasks.js index ec38dd8a1195c..31731e392e5cb 100644 --- a/src/dev/build/tasks/clean_tasks.js +++ b/src/dev/build/tasks/clean_tasks.js @@ -206,7 +206,7 @@ export const CleanExtraBrowsersTask = { async run(config, log, build) { const getBrowserPathsForPlatform = (platform) => { - const reportingDir = 'x-pack/legacy/plugins/reporting'; + const reportingDir = 'x-pack/plugins/reporting'; const chromiumDir = '.chromium'; const chromiumPath = (p) => build.resolvePathForPlatform(platform, reportingDir, chromiumDir, p); diff --git a/src/dev/code_coverage/ingest_coverage/__tests__/transforms.test.js b/src/dev/code_coverage/ingest_coverage/__tests__/transforms.test.js index c62a28a2956e1..8c982b792ed3b 100644 --- a/src/dev/code_coverage/ingest_coverage/__tests__/transforms.test.js +++ b/src/dev/code_coverage/ingest_coverage/__tests__/transforms.test.js @@ -35,13 +35,13 @@ describe(`Transform fn`, () => { it(`should remove the jenkins workspace path`, () => { const obj = { staticSiteUrl: - '/var/lib/jenkins/workspace/elastic+kibana+code-coverage/kibana/x-pack/legacy/plugins/reporting/server/browsers/extract/unzip.js', + '/var/lib/jenkins/workspace/elastic+kibana+code-coverage/kibana/x-pack/plugins/reporting/server/browsers/extract/unzip.js', COVERAGE_INGESTION_KIBANA_ROOT: '/var/lib/jenkins/workspace/elastic+kibana+code-coverage/kibana', }; expect(coveredFilePath(obj)).to.have.property( 'coveredFilePath', - 'x-pack/legacy/plugins/reporting/server/browsers/extract/unzip.js' + 'x-pack/plugins/reporting/server/browsers/extract/unzip.js' ); }); }); diff --git a/src/dev/code_coverage/ingest_coverage/integration_tests/mocks/jest-combined/coverage-summary-manual-mix.json b/src/dev/code_coverage/ingest_coverage/integration_tests/mocks/jest-combined/coverage-summary-manual-mix.json index baf2b6d500679..25cd2fdfb259d 100644 --- a/src/dev/code_coverage/ingest_coverage/integration_tests/mocks/jest-combined/coverage-summary-manual-mix.json +++ b/src/dev/code_coverage/ingest_coverage/integration_tests/mocks/jest-combined/coverage-summary-manual-mix.json @@ -1,5 +1,5 @@ { - "/var/lib/jenkins/workspace/elastic+kibana+code-coverage/kibana/x-pack/legacy/plugins/reporting/server/browsers/extract/unzip.js": { + "/var/lib/jenkins/workspace/elastic+kibana+code-coverage/kibana/x-pack/plugins/reporting/server/browsers/extract/unzip.js": { "lines": { "total": 4, "covered": 4, diff --git a/src/dev/precommit_hook/casing_check_config.js b/src/dev/precommit_hook/casing_check_config.js index d968a365e7bb9..b2b9cefc7c379 100644 --- a/src/dev/precommit_hook/casing_check_config.js +++ b/src/dev/precommit_hook/casing_check_config.js @@ -173,12 +173,12 @@ export const TEMPORARILY_IGNORED_PATHS = [ 'x-pack/plugins/monitoring/public/icons/health-green.svg', 'x-pack/plugins/monitoring/public/icons/health-red.svg', 'x-pack/plugins/monitoring/public/icons/health-yellow.svg', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf', - 'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png', + 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf', + 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf', + 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf', + 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf', + 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf', + 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png', 'x-pack/test/functional/es_archives/monitoring/beats-with-restarted-instance/data.json.gz', 'x-pack/test/functional/es_archives/monitoring/beats-with-restarted-instance/mappings.json', 'x-pack/test/functional/es_archives/monitoring/logstash-pipelines/data.json.gz', diff --git a/x-pack/.gitignore b/x-pack/.gitignore index 6bac5e181861d..5245e8a2e95c4 100644 --- a/x-pack/.gitignore +++ b/x-pack/.gitignore @@ -5,8 +5,8 @@ /test/functional/screenshots /test/functional/apps/reporting/reports/session /test/reporting/configs/failure_debug/ -/legacy/plugins/reporting/.chromium/ -/legacy/plugins/reporting/.phantom/ +/plugins/reporting/.chromium/ +/plugins/reporting/.phantom/ /.aws-config.json /.env /.kibana-plugin-helpers.dev.* diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index a479b08ef9069..48dfa341f6385 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -35,7 +35,7 @@ "xpack.monitoring": ["plugins/monitoring", "legacy/plugins/monitoring"], "xpack.remoteClusters": "plugins/remote_clusters", "xpack.painlessLab": "plugins/painless_lab", - "xpack.reporting": ["plugins/reporting", "legacy/plugins/reporting"], + "xpack.reporting": ["plugins/reporting"], "xpack.rollupJobs": ["legacy/plugins/rollup", "plugins/rollup"], "xpack.searchProfiler": "plugins/searchprofiler", "xpack.security": ["legacy/plugins/security", "plugins/security"], diff --git a/x-pack/.kibana-plugin-helpers.json b/x-pack/.kibana-plugin-helpers.json index ed0b38841c1a8..ca0cae6dd3ca3 100644 --- a/x-pack/.kibana-plugin-helpers.json +++ b/x-pack/.kibana-plugin-helpers.json @@ -13,8 +13,8 @@ "index.js", ".i18nrc.json", "plugins/**/*", - "legacy/plugins/reporting/.phantom/*", - "legacy/plugins/reporting/.chromium/*", + "plugins/reporting/.phantom/*", + "plugins/reporting/.chromium/*", "legacy/common/**/*", "legacy/plugins/**/*", "legacy/server/**/*", diff --git a/x-pack/build_chromium/README.md b/x-pack/build_chromium/README.md index 501136ab0a965..72e41afc80c95 100644 --- a/x-pack/build_chromium/README.md +++ b/x-pack/build_chromium/README.md @@ -110,7 +110,7 @@ To run the build, replace the sha in the following commands with the sha that yo After the build completes, there will be a .zip file and a .md5 file in `~/chromium/chromium/src/out/headless`. These are named like so: `chromium-{first_7_of_SHA}-{platform}`, for example: `chromium-4747cc2-linux`. -The zip files need to be deployed to s3. For testing, I drop them into `headless-shell-dev`, but for production, they need to be in `headless-shell`. And the `x-pack/legacy/plugins/reporting/server/browsers/chromium/paths.js` file needs to be upated to have the correct `archiveChecksum`, `archiveFilename`, `binaryChecksum` and `baseUrl`. Below is a list of what the archive's are: +The zip files need to be deployed to s3. For testing, I drop them into `headless-shell-dev`, but for production, they need to be in `headless-shell`. And the `x-pack/plugins/reporting/server/browsers/chromium/paths.ts` file needs to be upated to have the correct `archiveChecksum`, `archiveFilename`, `binaryChecksum` and `baseUrl`. Below is a list of what the archive's are: - `archiveChecksum`: The contents of the `.md5` file, which is the `md5` checksum of the zip file. - `binaryChecksum`: The `md5` checksum of the `headless_shell` binary itself. diff --git a/x-pack/plugins/maps/public/connected_components/gis_map/view.js b/x-pack/plugins/maps/public/connected_components/gis_map/view.js index f733d08cf0b71..122f5cdd45c1c 100644 --- a/x-pack/plugins/maps/public/connected_components/gis_map/view.js +++ b/x-pack/plugins/maps/public/connected_components/gis_map/view.js @@ -64,7 +64,7 @@ export class GisMap extends Component { // - If it's not, then reporting injects a listener into the browser for a custom "renderComplete" event. // - When that event is fired, we snapshot the viz and move on. // Failure to not have the dom attribute, or custom event, will timeout the job. - // See x-pack/legacy/plugins/reporting/export_types/common/lib/screenshots/wait_for_render.ts for more. + // See x-pack/plugins/reporting/export_types/common/lib/screenshots/wait_for_render.ts for more. _onInitialLoadRenderComplete = () => { const el = document.querySelector(`[data-dom-id="${this.state.domId}"]`); diff --git a/x-pack/plugins/reporting/.gitignore b/x-pack/plugins/reporting/.gitignore deleted file mode 100644 index 41d357b60e1f0..0000000000000 --- a/x-pack/plugins/reporting/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.chromium diff --git a/x-pack/plugins/reporting/server/browsers/download/download.ts b/x-pack/plugins/reporting/server/browsers/download/download.ts index 017845d931409..30b50c32a7402 100644 --- a/x-pack/plugins/reporting/server/browsers/download/download.ts +++ b/x-pack/plugins/reporting/server/browsers/download/download.ts @@ -42,7 +42,10 @@ export async function download(url: string, path: string, logger: LevelLogger) { logger.error(err); reject(err); }) - .on('end', resolve); + .on('end', () => { + logger.info(`Downloaded ${url}`); + resolve(); + }); }); } finally { closeSync(handle); diff --git a/x-pack/plugins/reporting/server/plugin.ts b/x-pack/plugins/reporting/server/plugin.ts index 3b3f8eaa13721..d0d25f6d9e0ae 100644 --- a/x-pack/plugins/reporting/server/plugin.ts +++ b/x-pack/plugins/reporting/server/plugin.ts @@ -25,7 +25,7 @@ export class ReportingPlugin private config$: Observable; constructor(context: PluginInitializerContext) { - this.logger = new LevelLogger(context.logger.get('reporting')); + this.logger = new LevelLogger(context.logger.get()); this.initializerContext = context; this.config$ = context.config.create(); } From 8058f856746ae426ba32d29e957c52daaeb71c6d Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 2 Jun 2020 12:06:17 -0700 Subject: [PATCH 07/16] fix download test --- .../server/browsers/download/download.test.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/reporting/server/browsers/download/download.test.ts b/x-pack/plugins/reporting/server/browsers/download/download.test.ts index 05ee2862f017b..b33dfa721d038 100644 --- a/x-pack/plugins/reporting/server/browsers/download/download.test.ts +++ b/x-pack/plugins/reporting/server/browsers/download/download.test.ts @@ -5,11 +5,11 @@ */ import { createHash } from 'crypto'; -import { resolve as resolvePath } from 'path'; +import del from 'del'; import { readFileSync } from 'fs'; +import { resolve as resolvePath } from 'path'; import { Readable } from 'stream'; - -import del from 'del'; +import { LevelLogger } from '../../lib'; import { download } from './download'; const TEMP_DIR = resolvePath(__dirname, '__tmp__'); @@ -29,6 +29,12 @@ class ReadableOf extends Readable { jest.mock('axios'); const request: jest.Mock = jest.requireMock('axios').request; +const mockLogger = ({ + error: jest.fn(), + warn: jest.fn(), + info: jest.fn(), +} as unknown) as LevelLogger; + test('downloads the url to the path', async () => { const BODY = 'abdcefg'; request.mockImplementationOnce(async () => { @@ -37,7 +43,7 @@ test('downloads the url to the path', async () => { }; }); - await download('url', TEMP_FILE); + await download('url', TEMP_FILE, mockLogger); expect(readFileSync(TEMP_FILE, 'utf8')).toEqual(BODY); }); @@ -50,7 +56,7 @@ test('returns the md5 hex hash of the http body', async () => { }; }); - const returned = await download('url', TEMP_FILE); + const returned = await download('url', TEMP_FILE, mockLogger); expect(returned).toEqual(HASH); }); @@ -59,7 +65,7 @@ test('throws if request emits an error', async () => { throw new Error('foo'); }); - return expect(download('url', TEMP_FILE)).rejects.toThrow('foo'); + return expect(download('url', TEMP_FILE, mockLogger)).rejects.toThrow('foo'); }); afterEach(async () => await del(TEMP_DIR)); From 7cea0e191eb429095ae72c9ab38df41e7b05e1b4 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 2 Jun 2020 13:52:34 -0700 Subject: [PATCH 08/16] add numeral typing for x-pack/test --- x-pack/typings/numeral.d.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 x-pack/typings/numeral.d.ts diff --git a/x-pack/typings/numeral.d.ts b/x-pack/typings/numeral.d.ts new file mode 100644 index 0000000000000..2616639cdeff0 --- /dev/null +++ b/x-pack/typings/numeral.d.ts @@ -0,0 +1,20 @@ +/* + * 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. + */ + +interface Numeral { + (value?: unknown): Numeral; + format: (pattern: string) => string; + unformat: (pattern: string) => number; + language: (key?: any, values?: any) => Numeral; + set: (value?: any) => Numeral; +} + +// eslint-disable-next-line no-var +declare var numeral: Numeral; + +declare module '@elastic/numeral' { + export = numeral; +} From f8269ae171e0c46589e8e706fa0152c6847e7e4f Mon Sep 17 00:00:00 2001 From: Joel Griffith Date: Tue, 2 Jun 2020 14:20:23 -0700 Subject: [PATCH 09/16] Fix jest tests for np migration --- .../server/config/create_config.test.ts | 10 +- .../common/lib/screenshots/observable.test.ts | 2 +- .../csv/server/execute_job.test.ts | 91 ++++++++++--------- .../png/server/execute_job/index.test.ts | 2 + .../server/execute_job/index.test.ts | 2 + .../server/lib/create_worker.test.ts | 2 + .../lib/authorized_user_pre_routing.test.ts | 40 ++++---- .../create_mock_reportingplugin.ts | 18 +++- 8 files changed, 96 insertions(+), 71 deletions(-) diff --git a/x-pack/plugins/reporting/server/config/create_config.test.ts b/x-pack/plugins/reporting/server/config/create_config.test.ts index c7e4f13f696c7..1c4c840cfa312 100644 --- a/x-pack/plugins/reporting/server/config/create_config.test.ts +++ b/x-pack/plugins/reporting/server/config/create_config.test.ts @@ -38,7 +38,6 @@ const makeMockCoreSetup = (serverInfo: KibanaServer): CoreSetup => describe('Reporting server createConfig$', () => { let mockCoreSetup: CoreSetup; let mockInitContext: PluginInitializerContext; - let mockConfig$: any; let mockLogger: LevelLogger; beforeEach(() => { @@ -46,7 +45,6 @@ describe('Reporting server createConfig$', () => { mockInitContext = makeMockInitContext({ kibanaServer: {}, }); - mockConfig$ = mockInitContext.config.create(); mockLogger = ({ warn: jest.fn(), debug: jest.fn() } as unknown) as LevelLogger; }); @@ -55,6 +53,7 @@ describe('Reporting server createConfig$', () => { }); it('creates random encryption key and default config using host, protocol, and port from server info', async () => { + const mockConfig$: any = mockInitContext.config.create(); const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.encryptionKey).toMatch(/\S{32,}/); // random 32 characters @@ -76,8 +75,8 @@ describe('Reporting server createConfig$', () => { encryptionKey: 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', kibanaServer: {}, }); + const mockConfig$: any = mockInitContext.config.create(); const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); - expect(result.encryptionKey).toMatch('iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii'); expect((mockLogger.warn as any).mock.calls.length).toBe(0); }); @@ -91,6 +90,7 @@ describe('Reporting server createConfig$', () => { protocol: 'httpsa', }, }); + const mockConfig$: any = mockInitContext.config.create(); const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result).toMatchInlineSnapshot(` @@ -118,6 +118,7 @@ describe('Reporting server createConfig$', () => { encryptionKey: 'aaaaaaaaaaaaabbbbbbbbbbbbaaaaaaaaa', kibanaServer: { hostname: '0' }, }); + const mockConfig$: any = mockInitContext.config.create(); const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.kibanaServer).toMatchInlineSnapshot(` @@ -139,6 +140,7 @@ describe('Reporting server createConfig$', () => { encryptionKey: '888888888888888888888888888888888', capture: { browser: { chromium: { disableSandbox: false } } }, } as ReportingConfigType); + const mockConfig$: any = mockInitContext.config.create(); const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.capture.browser.chromium).toMatchObject({ disableSandbox: false }); @@ -150,6 +152,7 @@ describe('Reporting server createConfig$', () => { encryptionKey: '888888888888888888888888888888888', capture: { browser: { chromium: { disableSandbox: true } } }, } as ReportingConfigType); + const mockConfig$: any = mockInitContext.config.create(); const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.capture.browser.chromium).toMatchObject({ disableSandbox: true }); @@ -160,6 +163,7 @@ describe('Reporting server createConfig$', () => { mockInitContext = makeMockInitContext({ encryptionKey: '888888888888888888888888888888888', } as ReportingConfigType); + const mockConfig$: any = mockInitContext.config.create(); const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); expect(result.capture.browser.chromium).toMatchObject({ disableSandbox: expect.any(Boolean) }); diff --git a/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts index 4492e7b903394..93b1c78b89e11 100644 --- a/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../../../../server/browsers/chromium/puppeteer', () => ({ +jest.mock('../../../../../server/browsers/chromium/puppeteer', () => ({ puppeteerLaunch: () => ({ // Fixme needs event emitters newPage: () => ({ diff --git a/x-pack/plugins/reporting/server/export_types/csv/server/execute_job.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/execute_job.test.ts index 90b688b19250c..6bbb902370cff 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/server/execute_job.test.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/execute_job.test.ts @@ -45,7 +45,7 @@ describe('CSV Execute Job', function () { let clusterStub: any; let configGetStub: any; let mockReportingConfig: any; - let mockReportingPlugin: any; + let mockReportingCore: any; let callAsCurrentUserStub: any; let cancellationToken: any; @@ -73,9 +73,10 @@ describe('CSV Execute Job', function () { configGetStub.withArgs('csv', 'scroll').returns({}); mockReportingConfig = { get: configGetStub, kbnConfig: { get: configGetStub } }; - mockReportingPlugin = await createMockReportingCore(mockReportingConfig); - mockReportingPlugin.getUiSettingsServiceFactory = () => Promise.resolve(mockUiSettingsClient); - mockReportingPlugin.getElasticsearchService = () => Promise.resolve(mockElasticsearch); + mockReportingCore = await createMockReportingCore(mockReportingConfig); + mockReportingCore.getUiSettingsServiceFactory = () => Promise.resolve(mockUiSettingsClient); + mockReportingCore.getElasticsearchService = () => Promise.resolve(mockElasticsearch); + mockReportingCore.config = mockReportingConfig; cancellationToken = new CancellationToken(); @@ -116,7 +117,7 @@ describe('CSV Execute Job', function () { describe('basic Elasticsearch call behavior', function () { it('should decrypt encrypted headers and pass to callAsCurrentUser', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); await executeJob( 'job456', getJobDocPayload({ @@ -136,7 +137,7 @@ describe('CSV Execute Job', function () { testBody: true, }; - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const job = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -163,7 +164,7 @@ describe('CSV Execute Job', function () { _scroll_id: scrollId, }); callAsCurrentUserStub.onSecondCall().resolves(defaultElasticsearchResponse); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); await executeJob( 'job456', getJobDocPayload({ @@ -181,7 +182,7 @@ describe('CSV Execute Job', function () { }); it('should not execute scroll if there are no hits from the search', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); await executeJob( 'job456', getJobDocPayload({ @@ -215,7 +216,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); await executeJob( 'job456', getJobDocPayload({ @@ -254,7 +255,7 @@ describe('CSV Execute Job', function () { _scroll_id: lastScrollId, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); await executeJob( 'job456', getJobDocPayload({ @@ -286,7 +287,7 @@ describe('CSV Execute Job', function () { _scroll_id: lastScrollId, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -313,7 +314,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -338,7 +339,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['=SUM(A1:A2)', 'two'], @@ -364,7 +365,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -390,7 +391,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['=SUM(A1:A2)', 'two'], @@ -416,7 +417,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -443,7 +444,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -464,7 +465,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -487,7 +488,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -508,7 +509,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -524,7 +525,7 @@ describe('CSV Execute Job', function () { describe('Elasticsearch call errors', function () { it('should reject Promise if search call errors out', async function () { callAsCurrentUserStub.rejects(new Error()); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -543,7 +544,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); callAsCurrentUserStub.onSecondCall().rejects(new Error()); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -564,7 +565,7 @@ describe('CSV Execute Job', function () { _scroll_id: undefined, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -585,7 +586,7 @@ describe('CSV Execute Job', function () { _scroll_id: undefined, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -613,7 +614,7 @@ describe('CSV Execute Job', function () { _scroll_id: undefined, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -641,7 +642,7 @@ describe('CSV Execute Job', function () { _scroll_id: undefined, }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: [], @@ -677,7 +678,7 @@ describe('CSV Execute Job', function () { }); it('should stop calling Elasticsearch when cancellationToken.cancel is called', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); executeJob( 'job345', getJobDocPayload({ @@ -696,7 +697,7 @@ describe('CSV Execute Job', function () { }); it(`shouldn't call clearScroll if it never got a scrollId`, async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); executeJob( 'job345', getJobDocPayload({ @@ -714,7 +715,7 @@ describe('CSV Execute Job', function () { }); it('should call clearScroll if it got a scrollId', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); executeJob( 'job345', getJobDocPayload({ @@ -736,7 +737,7 @@ describe('CSV Execute Job', function () { describe('csv content', function () { it('should write column headers to output, even if there are no results', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -748,7 +749,7 @@ describe('CSV Execute Job', function () { it('should use custom uiSettings csv:separator for header', async function () { mockUiSettingsClient.get.withArgs('csv:separator').returns(';'); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -760,7 +761,7 @@ describe('CSV Execute Job', function () { it('should escape column headers if uiSettings csv:quoteValues is true', async function () { mockUiSettingsClient.get.withArgs('csv:quoteValues').returns(true); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one and a half', 'two', 'three-and-four', 'five & six'], @@ -772,7 +773,7 @@ describe('CSV Execute Job', function () { it(`shouldn't escape column headers if uiSettings csv:quoteValues is false`, async function () { mockUiSettingsClient.get.withArgs('csv:quoteValues').returns(false); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one and a half', 'two', 'three-and-four', 'five & six'], @@ -783,7 +784,7 @@ describe('CSV Execute Job', function () { }); it('should write column headers to output, when there are results', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); callAsCurrentUserStub.onFirstCall().resolves({ hits: { hits: [{ one: '1', two: '2' }], @@ -803,7 +804,7 @@ describe('CSV Execute Job', function () { }); it('should use comma separated values of non-nested fields from _source', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); callAsCurrentUserStub.onFirstCall().resolves({ hits: { hits: [{ _source: { one: 'foo', two: 'bar' } }], @@ -824,7 +825,7 @@ describe('CSV Execute Job', function () { }); it('should concatenate the hits from multiple responses', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); callAsCurrentUserStub.onFirstCall().resolves({ hits: { hits: [{ _source: { one: 'foo', two: 'bar' } }], @@ -852,7 +853,7 @@ describe('CSV Execute Job', function () { }); it('should use field formatters to format fields', async function () { - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); callAsCurrentUserStub.onFirstCall().resolves({ hits: { hits: [{ _source: { one: 'foo', two: 'bar' } }], @@ -894,7 +895,7 @@ describe('CSV Execute Job', function () { beforeEach(async function () { configGetStub.withArgs('csv', 'maxSizeBytes').returns(1); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -924,7 +925,7 @@ describe('CSV Execute Job', function () { beforeEach(async function () { configGetStub.withArgs('csv', 'maxSizeBytes').returns(9); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -961,7 +962,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -990,7 +991,7 @@ describe('CSV Execute Job', function () { let maxSizeReached: boolean; beforeEach(async function () { - mockReportingPlugin.getUiSettingsServiceFactory = () => mockUiSettingsClient; + mockReportingCore.getUiSettingsServiceFactory = () => mockUiSettingsClient; configGetStub.withArgs('csv', 'maxSizeBytes').returns(18); callAsCurrentUserStub.onFirstCall().returns({ @@ -1000,7 +1001,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -1037,7 +1038,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -1063,7 +1064,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], @@ -1089,7 +1090,7 @@ describe('CSV Execute Job', function () { _scroll_id: 'scrollId', }); - const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const executeJob = await executeJobFactory(mockReportingCore, mockLogger); const jobParams = getJobDocPayload({ headers: encryptedHeaders, fields: ['one', 'two'], diff --git a/x-pack/plugins/reporting/server/export_types/png/server/execute_job/index.test.ts b/x-pack/plugins/reporting/server/export_types/png/server/execute_job/index.test.ts index 47be785b2332c..5c331d3246d62 100644 --- a/x-pack/plugins/reporting/server/export_types/png/server/execute_job/index.test.ts +++ b/x-pack/plugins/reporting/server/export_types/png/server/execute_job/index.test.ts @@ -68,6 +68,8 @@ beforeEach(async () => { const mockGetElasticsearch = jest.fn(); mockGetElasticsearch.mockImplementation(() => Promise.resolve(mockElasticsearch)); mockReporting.getElasticsearchService = mockGetElasticsearch; + // @ts-ignore over-riding config method + mockReporting.config = mockReportingConfig; (generatePngObservableFactory as jest.Mock).mockReturnValue(jest.fn()); }); diff --git a/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.test.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.test.ts index cbf8044dd8b92..58fe8218f7e70 100644 --- a/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.test.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.test.ts @@ -66,6 +66,8 @@ beforeEach(async () => { const mockGetElasticsearch = jest.fn(); mockGetElasticsearch.mockImplementation(() => Promise.resolve(mockElasticsearch)); mockReporting.getElasticsearchService = mockGetElasticsearch; + // @ts-ignore over-riding config + mockReporting.config = mockReportingConfig; (generatePdfObservableFactory as jest.Mock).mockReturnValue(jest.fn()); }); diff --git a/x-pack/plugins/reporting/server/lib/create_worker.test.ts b/x-pack/plugins/reporting/server/lib/create_worker.test.ts index 505da9067d6b9..8e1174e01aa7f 100644 --- a/x-pack/plugins/reporting/server/lib/create_worker.test.ts +++ b/x-pack/plugins/reporting/server/lib/create_worker.test.ts @@ -42,6 +42,8 @@ describe('Create Worker', () => { mockConfig = { get: configGetStub, kbnConfig: { get: configGetStub } }; mockReporting = await createMockReportingCore(mockConfig); mockReporting.getExportTypesRegistry = () => getMockExportTypesRegistry(); + // @ts-ignore over-riding config manually + mockReporting.config = mockConfig; client = new ClientMock(); queue = new Esqueue('reporting-queue', { client }); executeJobFactoryStub.reset(); diff --git a/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts b/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts index 76d253418121f..b218f9e4607dd 100644 --- a/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts +++ b/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.test.ts @@ -5,20 +5,23 @@ */ import { KibanaRequest, RequestHandlerContext, KibanaResponseFactory } from 'kibana/server'; -import sinon from 'sinon'; import { coreMock, httpServerMock } from 'src/core/server/mocks'; -import { ReportingConfig, ReportingCore } from '../../'; +import { ReportingCore } from '../../'; import { createMockReportingCore } from '../../test_helpers'; import { authorizedUserPreRoutingFactory } from './authorized_user_pre_routing'; import { ReportingInternalSetup } from '../../core'; -let mockConfig: ReportingConfig; let mockCore: ReportingCore; - -const getMockConfig = (mockConfigGet: sinon.SinonStub) => ({ - get: mockConfigGet, - kbnConfig: { get: mockConfigGet }, -}); +const kbnConfig = { + 'server.basePath': '/sbp', +}; +const reportingConfig = { + 'roles.allow': ['reporting_user'], +}; +const mockReportingConfig = { + get: (...keys: string[]) => (reportingConfig as any)[keys.join('.')] || 'whoah!', + kbnConfig: { get: (...keys: string[]) => (kbnConfig as any)[keys.join('.')] }, +}; const getMockContext = () => (({ @@ -38,13 +41,11 @@ const getMockResponseFactory = () => unauthorized: (obj: unknown) => obj, } as unknown) as KibanaResponseFactory); -beforeEach(async () => { - const mockConfigGet = sinon.stub().withArgs('roles', 'allow').returns(['reporting_user']); - mockConfig = getMockConfig(mockConfigGet); - mockCore = await createMockReportingCore(mockConfig); -}); - describe('authorized_user_pre_routing', function () { + beforeEach(async () => { + mockCore = await createMockReportingCore(mockReportingConfig); + }); + it('should return from handler with null user when security is disabled', async function () { mockCore.getPluginSetupDeps = () => (({ @@ -106,7 +107,7 @@ describe('authorized_user_pre_routing', function () { ).toMatchObject({ body: `Sorry, you don't have access to Reporting` }); }); - it('should return from handler when security is enabled and user has explicitly allowed role', async function () { + it('should return from handler when security is enabled and user has explicitly allowed role', async function (done) { mockCore.getPluginSetupDeps = () => (({ // @ts-ignore @@ -117,17 +118,16 @@ describe('authorized_user_pre_routing', function () { }, }, } as unknown) as ReportingInternalSetup); + // @ts-ignore overloading config getter + mockCore.config = mockReportingConfig; const authorizedUserPreRouting = authorizedUserPreRoutingFactory(mockCore); const mockResponseFactory = getMockResponseFactory(); - let handlerCalled = false; - authorizedUserPreRouting((user: unknown) => { + authorizedUserPreRouting((user) => { expect(user).toMatchObject({ roles: ['reporting_user'], username: 'friendlyuser' }); - handlerCalled = true; + done(); return Promise.resolve({ status: 200, options: {} }); })(getMockContext(), getMockRequest(), mockResponseFactory); - - expect(handlerCalled).toBe(true); }); it('should return from handler when security is enabled and user has superuser role', async function () {}); diff --git a/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts index 26ba0ff76ecdc..b04e697d0a118 100644 --- a/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts +++ b/x-pack/plugins/reporting/server/test_helpers/create_mock_reportingplugin.ts @@ -34,8 +34,22 @@ export const createMockStartDeps = (startMock?: any): ReportingStartDeps => ({ }); const createMockReportingPlugin = async (config: ReportingConfig): Promise => { - config = config || {}; - const plugin = new ReportingPlugin(coreMock.createPluginInitializerContext(config)); + const mockConfig = { + index: '.reporting', + kibanaServer: { + hostname: 'localhost', + port: '80', + }, + capture: { + browser: { + chromium: { + disableSandbox: true, + }, + }, + }, + ...config, + }; + const plugin = new ReportingPlugin(coreMock.createPluginInitializerContext(mockConfig)); const setupMock = coreMock.createSetup(); const coreStartMock = coreMock.createStart(); const startMock = { From d70b48d37f1e1451bc730b8a74ded75ff41d2561 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 2 Jun 2020 15:12:23 -0700 Subject: [PATCH 10/16] Shorten import paths --- .../common/lib/screenshots/observable.test.ts | 8 ++++---- .../server/export_types/csv/server/execute_job.test.ts | 4 ++-- .../export_types/csv/server/lib/hit_iterator.test.ts | 2 +- .../server/export_types/csv/server/lib/hit_iterator.ts | 2 +- .../plugins/reporting/server/export_types/csv/types.d.ts | 2 +- .../server/lib/generate_csv_search.ts | 2 +- .../export_types/png/server/execute_job/index.test.ts | 8 ++++---- .../server/export_types/png/server/lib/generate_png.ts | 6 +++--- .../printable_pdf/server/execute_job/index.test.ts | 8 ++++---- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts index 93b1c78b89e11..2ddb4a5d5b994 100644 --- a/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/lib/screenshots/observable.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../../../../../server/browsers/chromium/puppeteer', () => ({ +jest.mock('../../../../browsers/chromium/puppeteer', () => ({ puppeteerLaunch: () => ({ // Fixme needs event emitters newPage: () => ({ @@ -18,12 +18,12 @@ jest.mock('../../../../../server/browsers/chromium/puppeteer', () => ({ import * as Rx from 'rxjs'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { loggingServiceMock } from '../../../../../../../../src/core/server/mocks'; +import { HeadlessChromiumDriver } from '../../../../browsers'; +import { LevelLogger } from '../../../../lib'; import { createMockBrowserDriverFactory, createMockLayoutInstance } from '../../../../test_helpers'; +import { CaptureConfig, ConditionalHeaders, ElementsPositionAndAttribute } from '../../../../types'; import * as contexts from './constants'; import { screenshotsObservableFactory } from './observable'; -import { LevelLogger } from '../../../../lib'; -import { CaptureConfig, ConditionalHeaders, ElementsPositionAndAttribute } from '../../../../types'; -import { HeadlessChromiumDriver } from '../../../../browsers'; /* * Mocks diff --git a/x-pack/plugins/reporting/server/export_types/csv/server/execute_job.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/execute_job.test.ts index 6bbb902370cff..6f227d00974ca 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/server/execute_job.test.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/execute_job.test.ts @@ -9,10 +9,10 @@ import nodeCrypto from '@elastic/node-crypto'; import Puid from 'puid'; import sinon from 'sinon'; import { fieldFormats } from '../../../../../../../src/plugins/data/server'; -import { CancellationToken } from '../../../../../../plugins/reporting/common'; +import { CancellationToken } from '../../../../common'; +import { CSV_BOM_CHARS } from '../../../../common/constants'; import { LevelLogger } from '../../../lib'; import { setFieldFormats } from '../../../services'; -import { CSV_BOM_CHARS } from '../../../../common/constants'; import { createMockReportingCore } from '../../../test_helpers'; import { JobDocPayloadDiscoverCsv } from '../types'; import { executeJobFactory } from './execute_job'; diff --git a/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.test.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.test.ts index 0c4cd9c4cd193..479879e3c8b01 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.test.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.test.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; import sinon from 'sinon'; -import { CancellationToken } from '../../../../../../../plugins/reporting/common'; +import { CancellationToken } from '../../../../../common'; import { LevelLogger } from '../../../../lib'; import { ScrollConfig } from '../../../../types'; import { createHitIterator } from './hit_iterator'; diff --git a/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.ts b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.ts index 94ec7558d9c7d..38b28573d602d 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/server/lib/hit_iterator.ts @@ -6,7 +6,7 @@ import { i18n } from '@kbn/i18n'; import { SearchParams, SearchResponse } from 'elasticsearch'; -import { CancellationToken } from '../../../../../../../plugins/reporting/common'; +import { CancellationToken } from '../../../../../common'; import { LevelLogger } from '../../../../lib'; import { ScrollConfig } from '../../../../types'; diff --git a/x-pack/plugins/reporting/server/export_types/csv/types.d.ts b/x-pack/plugins/reporting/server/export_types/csv/types.d.ts index 7dcc55117a653..c80cd5fd24fe5 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/types.d.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/types.d.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CancellationToken } from '../../../../../plugins/reporting/common'; +import { CancellationToken } from '../../../common'; import { JobParamPostPayload, JobDocPayload, ScrollConfig } from '../../types'; export type RawValue = string | object | null | undefined; diff --git a/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts index 0df01e8addb03..a9e4366f4eda6 100644 --- a/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts @@ -17,7 +17,7 @@ import { IIndexPattern, Query, } from '../../../../../../../../src/plugins/data/server'; -import { CancellationToken } from '../../../../../../../plugins/reporting/common'; +import { CancellationToken } from '../../../../../common'; import { LevelLogger } from '../../../../lib'; import { createGenerateCsv } from '../../../csv/server/lib/generate_csv'; import { diff --git a/x-pack/plugins/reporting/server/export_types/png/server/execute_job/index.test.ts b/x-pack/plugins/reporting/server/export_types/png/server/execute_job/index.test.ts index 5c331d3246d62..b92f53ff6563f 100644 --- a/x-pack/plugins/reporting/server/export_types/png/server/execute_job/index.test.ts +++ b/x-pack/plugins/reporting/server/export_types/png/server/execute_job/index.test.ts @@ -5,13 +5,13 @@ */ import * as Rx from 'rxjs'; -import { CancellationToken } from '../../../../../../../plugins/reporting/common'; -import { ReportingCore } from '../../../../../server'; -import { cryptoFactory, LevelLogger } from '../../../../../server/lib'; +import { ReportingCore } from '../../../../'; +import { CancellationToken } from '../../../../../common'; +import { cryptoFactory, LevelLogger } from '../../../../lib'; import { createMockReportingCore } from '../../../../test_helpers'; import { JobDocPayloadPNG } from '../../types'; import { generatePngObservableFactory } from '../lib/generate_png'; -import { executeJobFactory } from './index'; +import { executeJobFactory } from './'; jest.mock('../lib/generate_png', () => ({ generatePngObservableFactory: jest.fn() })); diff --git a/x-pack/plugins/reporting/server/export_types/png/server/lib/generate_png.ts b/x-pack/plugins/reporting/server/export_types/png/server/lib/generate_png.ts index 8d46260ac6707..d7e9d0f812b37 100644 --- a/x-pack/plugins/reporting/server/export_types/png/server/lib/generate_png.ts +++ b/x-pack/plugins/reporting/server/export_types/png/server/lib/generate_png.ts @@ -7,9 +7,9 @@ import apm from 'elastic-apm-node'; import * as Rx from 'rxjs'; import { map } from 'rxjs/operators'; -import { ReportingCore } from '../../../../../server'; -import { LevelLogger } from '../../../../../server/lib'; -import { ConditionalHeaders, ScreenshotResults } from '../../../../../server/types'; +import { ReportingCore } from '../../../../'; +import { LevelLogger } from '../../../../lib'; +import { ConditionalHeaders, ScreenshotResults } from '../../../../types'; import { LayoutParams } from '../../../common/layouts'; import { PreserveLayout } from '../../../common/layouts/preserve_layout'; diff --git a/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.test.ts b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.test.ts index 58fe8218f7e70..b8e1e5eebd9e7 100644 --- a/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.test.ts +++ b/x-pack/plugins/reporting/server/export_types/printable_pdf/server/execute_job/index.test.ts @@ -7,13 +7,13 @@ jest.mock('../lib/generate_pdf', () => ({ generatePdfObservableFactory: jest.fn() })); import * as Rx from 'rxjs'; -import { CancellationToken } from '../../../../../../../plugins/reporting/common'; -import { ReportingCore } from '../../../../../server'; -import { cryptoFactory, LevelLogger } from '../../../../../server/lib'; +import { ReportingCore } from '../../../../'; +import { CancellationToken } from '../../../../../common'; +import { cryptoFactory, LevelLogger } from '../../../../lib'; import { createMockReportingCore } from '../../../../test_helpers'; import { JobDocPayloadPDF } from '../../types'; import { generatePdfObservableFactory } from '../lib/generate_pdf'; -import { executeJobFactory } from './index'; +import { executeJobFactory } from './'; let mockReporting: ReportingCore; From cca3ff4712e6201f4149dedd8b6bbe4822955714 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 2 Jun 2020 15:24:41 -0700 Subject: [PATCH 11/16] remove this file, add typings to the node module --- x-pack/typings/numeral.d.ts | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 x-pack/typings/numeral.d.ts diff --git a/x-pack/typings/numeral.d.ts b/x-pack/typings/numeral.d.ts deleted file mode 100644 index 2616639cdeff0..0000000000000 --- a/x-pack/typings/numeral.d.ts +++ /dev/null @@ -1,20 +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. - */ - -interface Numeral { - (value?: unknown): Numeral; - format: (pattern: string) => string; - unformat: (pattern: string) => number; - language: (key?: any, values?: any) => Numeral; - set: (value?: any) => Numeral; -} - -// eslint-disable-next-line no-var -declare var numeral: Numeral; - -declare module '@elastic/numeral' { - export = numeral; -} From 7b320c0048e4af02b57eb5416a0e765bb2a23738 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 2 Jun 2020 15:25:38 -0700 Subject: [PATCH 12/16] remove local typing that has been provided by node module --- x-pack/plugins/apm/typings/numeral.d.ts | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 x-pack/plugins/apm/typings/numeral.d.ts diff --git a/x-pack/plugins/apm/typings/numeral.d.ts b/x-pack/plugins/apm/typings/numeral.d.ts deleted file mode 100644 index 2616639cdeff0..0000000000000 --- a/x-pack/plugins/apm/typings/numeral.d.ts +++ /dev/null @@ -1,20 +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. - */ - -interface Numeral { - (value?: unknown): Numeral; - format: (pattern: string) => string; - unformat: (pattern: string) => number; - language: (key?: any, values?: any) => Numeral; - set: (value?: any) => Numeral; -} - -// eslint-disable-next-line no-var -declare var numeral: Numeral; - -declare module '@elastic/numeral' { - export = numeral; -} From 845c86fb5c0d9d533edca47e86d3db6340a169dc Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 2 Jun 2020 21:46:17 -0700 Subject: [PATCH 13/16] Add optional security plugin dep --- x-pack/plugins/reporting/kibana.json | 1 + x-pack/plugins/reporting/server/core.ts | 2 +- x-pack/plugins/reporting/server/types.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/reporting/kibana.json b/x-pack/plugins/reporting/kibana.json index 01a668403ffc9..bc1a808d500e0 100644 --- a/x-pack/plugins/reporting/kibana.json +++ b/x-pack/plugins/reporting/kibana.json @@ -3,6 +3,7 @@ "version": "8.0.0", "kibanaVersion": "kibana", "optionalPlugins": [ + "security", "usageCollection" ], "configPath": ["xpack", "reporting"], diff --git a/x-pack/plugins/reporting/server/core.ts b/x-pack/plugins/reporting/server/core.ts index edf49d74e184d..e7786b3b753fb 100644 --- a/x-pack/plugins/reporting/server/core.ts +++ b/x-pack/plugins/reporting/server/core.ts @@ -31,7 +31,7 @@ export interface ReportingInternalSetup { licensing: LicensingPluginSetup; basePath: BasePath['get']; router: IRouter; - security: SecurityPluginSetup; + security?: SecurityPluginSetup; } interface ReportingInternalStart { diff --git a/x-pack/plugins/reporting/server/types.ts b/x-pack/plugins/reporting/server/types.ts index 499a5c0b027f2..409a89899bee0 100644 --- a/x-pack/plugins/reporting/server/types.ts +++ b/x-pack/plugins/reporting/server/types.ts @@ -158,7 +158,7 @@ export type ScreenshotsObservableFn = ({ export interface ReportingSetupDeps { licensing: LicensingPluginSetup; - security: SecurityPluginSetup; + security?: SecurityPluginSetup; usageCollection?: UsageCollectionSetup; } From 419cc2b7c8d70c0b9363f7ecd9b62ef5aa16617e Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Wed, 3 Jun 2020 08:31:19 -0700 Subject: [PATCH 14/16] revert conflicting apm typings removal --- x-pack/plugins/apm/typings/numeral.d.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 x-pack/plugins/apm/typings/numeral.d.ts diff --git a/x-pack/plugins/apm/typings/numeral.d.ts b/x-pack/plugins/apm/typings/numeral.d.ts new file mode 100644 index 0000000000000..2616639cdeff0 --- /dev/null +++ b/x-pack/plugins/apm/typings/numeral.d.ts @@ -0,0 +1,20 @@ +/* + * 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. + */ + +interface Numeral { + (value?: unknown): Numeral; + format: (pattern: string) => string; + unformat: (pattern: string) => number; + language: (key?: any, values?: any) => Numeral; + set: (value?: any) => Numeral; +} + +// eslint-disable-next-line no-var +declare var numeral: Numeral; + +declare module '@elastic/numeral' { + export = numeral; +} From a555cb897f9fa30666021ceb743c0018b0daad54 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Wed, 3 Jun 2020 12:16:54 -0700 Subject: [PATCH 15/16] fix i18n --- x-pack/plugins/translations/translations/ja-JP.json | 2 -- x-pack/plugins/translations/translations/zh-CN.json | 2 -- 2 files changed, 4 deletions(-) diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 739aed1c71351..0871d3c151fac 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -12670,8 +12670,6 @@ "xpack.reporting.panelContent.successfullyQueuedReportNotificationTitle": "{objectType} のレポートキュー", "xpack.reporting.panelContent.whatCanBeExportedWarningDescription": "初めに変更内容を保存してください", "xpack.reporting.panelContent.whatCanBeExportedWarningTitle": "保存された {objectType} のみエクスポートできます", - "xpack.reporting.pdfFooterImageDescription": "PDF のフッターに使用するカスタム画像です", - "xpack.reporting.pdfFooterImageLabel": "PDF フッター画像", "xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportMessage": "レポートには、スプレッドシートアプリケーションで式と解釈される可能性のある文字が含まれています。", "xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportTitle": "レポートには式{reportObjectType} '{reportObjectTitle}'が含まれている場合があります", "xpack.reporting.publicNotifier.downloadReportButtonLabel": "レポートをダウンロード", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 7aeb8021b5582..8de30f4173bee 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -12675,8 +12675,6 @@ "xpack.reporting.panelContent.successfullyQueuedReportNotificationTitle": "已为 {objectType} 排队报告", "xpack.reporting.panelContent.whatCanBeExportedWarningDescription": "请先保存您的工作", "xpack.reporting.panelContent.whatCanBeExportedWarningTitle": "只会导出保存的 {objectType}", - "xpack.reporting.pdfFooterImageDescription": "PDF 的页脚中要使用的定制图片", - "xpack.reporting.pdfFooterImageLabel": "PDF 页脚图片", "xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportMessage": "报告包含电子表格应用程序可解释为公式的字符。", "xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportTitle": "报告可能包含公式 {reportObjectType} '{reportObjectTitle}'", "xpack.reporting.publicNotifier.downloadReportButtonLabel": "下载报告", From 755cf11569fced83ecc52b3e857d7b064fc64173 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Wed, 3 Jun 2020 13:26:14 -0700 Subject: [PATCH 16/16] fix snakecase whitelist --- src/dev/precommit_hook/casing_check_config.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dev/precommit_hook/casing_check_config.js b/src/dev/precommit_hook/casing_check_config.js index b2b9cefc7c379..253fc104061a8 100644 --- a/src/dev/precommit_hook/casing_check_config.js +++ b/src/dev/precommit_hook/casing_check_config.js @@ -173,12 +173,12 @@ export const TEMPORARILY_IGNORED_PATHS = [ 'x-pack/plugins/monitoring/public/icons/health-green.svg', 'x-pack/plugins/monitoring/public/icons/health-red.svg', 'x-pack/plugins/monitoring/public/icons/health-yellow.svg', - 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf', - 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf', - 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf', - 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf', - 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf', - 'x-pack/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Medium.ttf', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Regular.ttf', + 'x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/img/logo-grey.png', 'x-pack/test/functional/es_archives/monitoring/beats-with-restarted-instance/data.json.gz', 'x-pack/test/functional/es_archives/monitoring/beats-with-restarted-instance/mappings.json', 'x-pack/test/functional/es_archives/monitoring/logstash-pipelines/data.json.gz',