From 57bf1ccd579710e010099447d72b149c031290c6 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Mon, 1 Jun 2020 13:37:31 -0700 Subject: [PATCH 1/5] [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 9cf63854d40939..8096774d7a4915 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 1ae971b6566b07..00000000000000 --- 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 2388eac48f8ccb..00000000000000 --- 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 14abd53cc83d93..00000000000000 --- 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 6bdd922555fa9f..00000000000000 --- 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 5a407ad3e4c4af..00000000000000 --- 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 00000000000000..41d357b60e1f06 --- /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 36c896fb4f7b8e..cda8934fc8bf62 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 5b9ddfb1bbdea7..2b9e9299852f54 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 e44bd92c42391f..282419fde4c244 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 7495e46de47d92..cd82ef3f19455e 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 6480fb4413f047..898b123e976fd2 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 7b4407890652c5..ff74f4eec45df1 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 3ec5aab4d451b8..4142ab6f0ae433 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 3107866be64967..7e9fd19b776cc8 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 d363494ddb9a6e..2f244a134f0141 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 a0d7618322c653..caa64a7414005e 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 402fddcb5e0146..dfabfa98f8cbf3 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 b89ef9e06b9610..edf49d74e184de 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 fe3ac16b79fe06..4998d936c9b166 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 a13c1fa2a9efb4..e5124c80601d7f 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 5067d5f5e5dd82..5d651ad5f8aea1 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 808d5db5c57d5a..6854f678aa9759 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 2cbde69c81316f..bd6eb4644d87f9 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 777de317af41e1..85d1272fc22ced 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 5f55617724ff68..cacea41477ea4a 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 90f3a3b2c9c242..bcd7f122748cb8 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 0e5974225b932b..5147881a980eac 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 d33760fcb4f89d..216a59d41cec01 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 993b8f6cdc9ab6..23e4c095afe611 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 759f07a33e2b63..30c83771aa3c93 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 d02e852a3c1b65..140d76f8d1cd6c 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 9e446f499ab3a3..42eb91ecba830b 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 578a4dd0b975c2..05c315b8341a33 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 74926918584fe4..ba68a5fec4e4cc 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 8a198880a77685..d72afacc1bef3c 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 cc8b4383104304..4492e7b9033948 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 bb11d1d3b7b63b..028bff4aaa5eee 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 3cf962b8178fdc..bd7e8c508c118f 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 c31c55ea8dec66..b6519e914430a5 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 ff84d06956dbc1..75a7b6516473cb 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 cdb4c36dba3df5..8642a6d5758a80 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 c76b4afe727daa..acf7f0505a735e 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 a8fdd8d1a5bbca..019fa3c9c8e9d2 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 7ef4f502b34a39..0c4cd9c4cd1938 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 803161910443e0..94ec7558d9c7d5 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 0f6223d8553de6..7dcc55117a6539 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 570b91600cbe0d..65802ee5bb7fbb 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 fcef889e52fe42..a0fd8a29fdcc45 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 d23f60d9c24806..c187da5104d3f0 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 19204ef81c5ebb..02abfb90091a1d 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 4ef7b8514b3632..d555100b6320d3 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 2397da9337890f..dd0fb34668e9e6 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 848623ede5b2fa..0df01e8addb03e 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 110ce91ddfd79e..b5d564d93d0d6a 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 4695bbd9225812..26631548cc7972 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 f838268078503a..36ae5b1dac05eb 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 04f56185d49106..a3b51e365e7727 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 ab492c21256eba..3f1556fb297827 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 b0b2d02305b9b3..a4d84b2f9f1e04 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 3b626c8f0da442..366949a033757b 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 0df01fdc16d1c3..087ef5a6ca82c7 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 9d34eba70d0f4c..c78e042d019e8a 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 366a8d94286f11..aa9f86533ef61e 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 1b4eeaa0bae3ef..a764aa1f1eec63 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 1193091075e3ee..505da9067d6b90 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 57bd61aee71956..c9e865668bb301 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 6367c8a1da98a4..3837f593df5b27 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 2d0ac86fd96f1d..9cc62800d439f1 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 ec65c15f53864d..974cb4a5e2a6e1 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 09c94b44a81455..fe8a859ccb4455 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 f852ac9c92404a..b26ed731c68315 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 0d5459a7c106b0..893a2635561ff4 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 164ffc5742d049..49d15a7c551003 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 06c4a7714099ea..8784d8ff35d251 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 905ed2b237c86b..8e0e3a14ceec84 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 4bc143b9115729..b8326406743b78 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 8a6d4553dfa9c0..1221f67855410e 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 87ac71e250d0c2..a96957447dfeb7 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 0911f48f82ca4e..d13b3e72ca8e7e 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 4cb7af3d0d4090..76d253418121fa 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 87582ca3ca239b..2ad974c9dd8e18 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 990af2d0aca80a..1a2e10cf355a2c 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 afa3fd3358fc17..5eceed0a7f2ab4 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 7d15d2e1af1ae9..9f4897a69f4eda 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 260c94c31df1ca..6eaaeddd635004 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 7f4330e7f6bc6b..bac7df1af2d463 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 f6dbccdfe3980b..e3e6aa812132f2 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 2ccc209c3ce502..ad67677f3814dc 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 d00a8570a024f6..a426451db2282b 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 830c6275cd96a0..d5dccaca3042a0 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 6d4eb5603ad3ad..448905bcf9d917 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 a0b572787ddfc5..dadb466d45982a 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 2/5] 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 8e0e3a14ceec84..8706beecdde054 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 e3e6aa812132f2..26ba0ff76ecdc0 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 ad67677f3814dc..499a5c0b027f28 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 3/5] 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 282419fde4c244..01a668403ffc90 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 4/5] 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 7e9fd19b776cc8..c7e4f13f696c75 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 2f244a134f0141..67df7dacc77ab8 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 8706beecdde054..3b3f8eaa13721a 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 a96957447dfeb7..eb75109c704c7e 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 6eaaeddd635004..5b0d740e031ab3 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 bac7df1af2d463..22da9eb418e9ac 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 f8269ae171e0c46589e8e706fa0152c6847e7e4f Mon Sep 17 00:00:00 2001 From: Joel Griffith Date: Tue, 2 Jun 2020 14:20:23 -0700 Subject: [PATCH 5/5] 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 c7e4f13f696c75..1c4c840cfa3126 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 4492e7b9033948..93b1c78b89e11a 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 90b688b19250ce..6bbb902370cff1 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 47be785b2332c5..5c331d3246d62d 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 cbf8044dd8b924..58fe8218f7e701 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 505da9067d6b90..8e1174e01aa7fe 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 76d253418121fa..b218f9e4607dde 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 26ba0ff76ecdc0..b04e697d0a118c 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 = {