From b5522ed30c1445a9ad07c8f7d95771e1f6b95609 Mon Sep 17 00:00:00 2001 From: John Schulz Date: Wed, 3 Mar 2021 13:58:20 -0500 Subject: [PATCH] [Fleet] Add lint rule/fix for `import` order groups (#93300) ## Problem Blocks of 10-15 `import`s are common in the plugin and there a few places which have ~50 lines of `import`s. It makes it more difficult to understand the where/why of what's being imported. We've had instances while files import from the same module in different lines. i.e. ```ts import { a } from './file'; ... 5-10 lines later import { b } from './file'; ``` ## Proposed solution Add a lint rule to enforce a convention on the module `import` order. This can help in the same way Prettier & ESLint help to format type signatures or other code. It makes it easier to understand or notice any changes in the code. It's also able to be fixed automatically (`node scripts/eslint.js --fix` or any existing "format on save" in an editor). ## This PR replaces #92980 (based on https://github.com/elastic/kibana/pull/92980#pullrequestreview-601070556) ### Lint rule f9be98d Add eslint rule to enforce/autofix import group order. Use the same rule as a few other plugins. Groups `import` statements by type as shown in the [lint rule docs](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md#importorder-enforce-a-convention-in-module-import-order ). The order is: 1. node "builtin" modules 2. "external" modules 3. "internal" modules 4. modules from a "parent" directory 5. "sibling" modules from the same or a sibling's directory, "index" of the current directory, everything else e.g. ```typescript import fs from 'fs'; import path from 'path'; import _ from 'lodash'; import chalk from 'chalk'; import foo from 'src/foo'; import foo from '../foo'; import qux from '../../foo/qux'; import bar from './bar'; import baz from './bar/baz'; import main from './'; ``` The [lint rule](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md#importorder-enforce-a-convention-in-module-import-order) is relatively light handed. It only ensures the `imports` are groups together in the given order. It doesn't alphabetize or otherwise sort the order of the files. e.g. imports aren't rewritten to be in alphabetical order. This is fine ```ts import from './c'; import from './a'; import from './b'; ``` The [docs show other options](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md#options) and https://github.com/jfsiii/kibana/blob/2831f02bc7d7d4d6792e980b7733ddcdfc340cea/.eslintrc.js#L1138-L1168 uses many of them ### Newlines option The newlines settings means a change from something like ```typescript import fs from 'fs'; import path from 'path'; import _ from 'lodash'; import chalk from 'chalk'; import foo from 'src/foo'; import foo from '../foo'; import qux from '../../foo/qux'; import bar from './bar'; import baz from './bar/baz'; import main from './'; ``` to ```typescript import fs from 'fs'; import path from 'path'; import _ from 'lodash'; import chalk from 'chalk'; import foo from 'src/foo'; import foo from '../foo'; import qux from '../../foo/qux'; import bar from './bar'; import baz from './bar/baz'; import main from './'; ``` Added it as a separate commit 2831f02 in case we want to avoid it, but I believe it's an improvement overall. Especially on the files with 25+ lines of imports. Even the "worst case" of something like this isn't bad (IMO). Especially since it's an automatic reformat like anything else in prettier ```typescript import fs from 'fs'; import _ from 'lodash'; import foo from '../foo'; import main from './'; ``` --- .eslintrc.js | 16 ++++++++++ .../fleet/common/constants/agent_policy.ts | 3 +- .../services/full_agent_policy_to_yaml.ts | 1 + .../services/is_agent_upgradeable.test.ts | 3 +- .../common/services/is_agent_upgradeable.ts | 1 + .../plugins/fleet/common/services/license.ts | 1 + .../package_policies_to_agent_inputs.test.ts | 1 + .../package_to_package_policy.test.ts | 1 + .../fleet/common/types/models/agent.ts | 3 +- .../fleet/common/types/models/agent_policy.ts | 1 + .../plugins/fleet/common/types/models/epm.ts | 2 ++ .../common/types/rest_spec/agent_policy.ts | 1 + .../fleet/public/applications/fleet/app.tsx | 8 +++-- .../fleet/components/alpha_messaging.tsx | 1 + .../enrollment_instructions/manual/index.tsx | 1 + .../fleet/components/extension_wrapper.tsx | 1 + .../tutorial_directory_header_link.tsx | 2 ++ .../tutorial_directory_notice.tsx | 1 + .../tutorial_module_notice.tsx | 1 + .../fleet/components/linked_agent_count.tsx | 1 + .../fleet/components/package_icon.tsx | 1 + .../fleet/components/search_bar.tsx | 1 + .../fleet/components/settings_flyout.tsx | 1 + .../fleet/hooks/use_breadcrumbs.tsx | 2 ++ .../applications/fleet/hooks/use_config.ts | 1 + .../fleet/hooks/use_fleet_status.tsx | 4 ++- .../fleet/hooks/use_intra_app_state.tsx | 1 + .../applications/fleet/hooks/use_link.ts | 1 + .../fleet/hooks/use_package_icon_type.ts | 2 ++ .../fleet/hooks/use_request/agent_policy.ts | 6 ++-- .../fleet/hooks/use_request/agents.ts | 6 ++-- .../fleet/hooks/use_request/app.ts | 3 +- .../fleet/hooks/use_request/data_stream.ts | 3 +- .../hooks/use_request/enrollment_api_keys.ts | 6 ++-- .../fleet/hooks/use_request/epm.ts | 3 +- .../fleet/hooks/use_request/outputs.ts | 3 +- .../fleet/hooks/use_request/package_policy.ts | 3 +- .../fleet/hooks/use_request/settings.ts | 3 +- .../fleet/hooks/use_request/setup.ts | 3 +- .../fleet/hooks/use_request/use_request.ts | 1 + .../fleet/hooks/use_ui_extension.ts | 1 + .../fleet/hooks/use_url_pagination.ts | 1 + .../fleet/public/applications/fleet/index.tsx | 2 ++ .../applications/fleet/layouts/default.tsx | 1 + .../fleet/layouts/with_header.tsx | 2 ++ .../fleet/mock/create_test_renderer.tsx | 4 ++- .../fleet/mock/fleet_start_services.tsx | 4 ++- .../fleet/mock/plugin_dependencies.ts | 1 + .../fleet/mock/plugin_interfaces.ts | 1 + .../public/applications/fleet/mock/types.ts | 1 + .../agent_policy/components/actions_menu.tsx | 2 ++ .../components/agent_policy_copy_provider.tsx | 1 + .../agent_policy_delete_provider.tsx | 1 + .../components/agent_policy_form.tsx | 2 ++ .../components/agent_policy_yaml_flyout.tsx | 1 + .../components/confirm_deploy_modal.tsx | 1 + .../package_policy_delete_provider.tsx | 1 + .../components/layout.tsx | 1 + .../package_policy_input_config.tsx | 2 ++ .../components/package_policy_input_panel.tsx | 2 ++ .../package_policy_input_stream.tsx | 2 ++ .../package_policy_input_var_field.tsx | 1 + .../create_package_policy_page/index.test.tsx | 10 ++++--- .../create_package_policy_page/index.tsx | 14 +++++---- .../services/has_invalid_but_required_var.ts | 1 + .../services/validate_package_policy.test.ts | 1 + .../services/validate_package_policy.ts | 1 + .../step_configure_package.tsx | 2 ++ .../step_define_package_policy.tsx | 4 ++- .../step_select_agent_policy.tsx | 1 + .../step_select_package.tsx | 1 + .../components/package_policies/index.tsx | 2 ++ .../package_policies/no_package_policies.tsx | 1 + .../package_policies_table.tsx | 1 + .../components/settings/index.tsx | 1 + .../details_page/hooks/use_agent_status.tsx | 1 + .../agent_policy/details_page/index.tsx | 6 ++-- .../edit_package_policy_page/index.tsx | 1 + .../fleet/sections/agent_policy/index.tsx | 2 ++ .../components/create_agent_policy.tsx | 1 + .../sections/agent_policy/list_page/index.tsx | 2 ++ .../components/actions_menu.tsx | 1 + .../agent_details_integrations.tsx | 2 ++ .../agent_details/agent_details_overview.tsx | 1 + .../components/agent_details/index.tsx | 2 ++ .../agent_details/input_type_utils.ts | 1 + .../components/agent_logs/agent_logs.tsx | 5 +++- .../components/agent_logs/filter_dataset.tsx | 2 ++ .../agent_logs/filter_log_level.tsx | 4 ++- .../components/agent_logs/index.tsx | 2 ++ .../components/agent_logs/query_bar.tsx | 2 ++ .../agent_logs/select_log_level.tsx | 2 ++ .../agents/agent_details_page/index.tsx | 6 ++-- .../components/bulk_actions.tsx | 1 + .../components/search_and_filter_bar.tsx | 1 + .../components/status_badges.tsx | 1 + .../agent_list_page/components/status_bar.tsx | 1 + .../components/table_header.tsx | 1 + .../sections/agents/agent_list_page/index.tsx | 2 ++ .../agent_policy_selection.tsx | 1 + .../agent_enrollment_flyout/index.tsx | 2 ++ .../managed_instructions.tsx | 2 ++ .../standalone_instructions.tsx | 4 ++- .../agent_enrollment_flyout/steps.tsx | 4 ++- .../agents/components/agent_health.tsx | 1 + .../agent_policy_package_badges.tsx | 1 + .../agent_reassign_policy_flyout/index.tsx | 1 + .../components/agent_unenroll_modal/index.tsx | 1 + .../components/agent_upgrade_modal/index.tsx | 1 + .../agents/components/list_layout.tsx | 1 + .../components/confirm_delete_modal.tsx | 1 + .../components/new_enrollment_key_flyout.tsx | 1 + .../enrollment_token_list_page/index.tsx | 2 ++ .../fleet/sections/agents/index.tsx | 4 ++- .../sections/agents/services/agent_status.tsx | 1 + .../sections/agents/setup_page/index.tsx | 1 + .../fleet/sections/data_stream/index.tsx | 2 ++ .../components/data_stream_row_actions.tsx | 1 + .../sections/data_stream/list_page/index.tsx | 2 ++ .../epm/components/assets_facet_group.tsx | 1 + .../sections/epm/components/icon_panel.tsx | 1 + .../sections/epm/components/package_card.tsx | 2 ++ .../epm/components/package_list_grid.tsx | 4 ++- .../sections/epm/components/release_badge.ts | 1 + .../sections/epm/components/requirements.tsx | 2 ++ .../fleet/sections/epm/components/version.tsx | 1 + .../fleet/sections/epm/constants.tsx | 1 + .../sections/epm/hooks/use_local_search.tsx | 1 + .../epm/hooks/use_package_install.tsx | 1 + .../applications/fleet/sections/epm/index.tsx | 2 ++ .../screens/detail/components/icon_panel.tsx | 1 + .../integration_agent_policy_count.tsx | 1 + .../epm/screens/detail/custom/custom.tsx | 1 + .../epm/screens/detail/index.test.tsx | 10 ++++--- .../sections/epm/screens/detail/index.tsx | 2 ++ .../epm/screens/detail/overview/details.tsx | 1 + .../epm/screens/detail/overview/overview.tsx | 2 ++ .../epm/screens/detail/overview/readme.tsx | 2 ++ .../screens/detail/overview/screenshots.tsx | 1 + .../detail/policies/package_policies.tsx | 2 ++ .../use_package_policies_with_agent_policy.ts | 1 + .../detail/settings/installation_button.tsx | 2 ++ .../epm/screens/detail/settings/settings.tsx | 2 ++ .../epm/screens/home/category_facets.tsx | 1 + .../sections/epm/screens/home/header.tsx | 1 + .../fleet/sections/epm/screens/home/index.tsx | 2 ++ .../sections/epm/screens/policy/index.tsx | 1 + .../components/agent_policy_section.tsx | 6 ++-- .../overview/components/agent_section.tsx | 6 ++-- .../components/datastream_section.tsx | 6 ++-- .../components/integration_section.tsx | 6 ++-- .../fleet/sections/overview/index.tsx | 2 ++ .../fleet/services/ui_extensions.test.ts | 2 ++ .../fleet/types/intra_app_route_state.ts | 1 + .../applications/fleet/types/ui_extensions.ts | 1 + x-pack/plugins/fleet/public/index.ts | 1 + x-pack/plugins/fleet/public/plugin.ts | 5 +++- .../plugins/fleet/scripts/dev_agent/script.ts | 4 ++- .../server/collectors/agent_collectors.ts | 1 + .../fleet/server/collectors/helpers.ts | 1 + .../server/collectors/package_collectors.ts | 1 + .../fleet/server/collectors/register.ts | 4 ++- .../fleet/server/errors/handlers.test.ts | 2 ++ .../plugins/fleet/server/errors/handlers.ts | 2 ++ x-pack/plugins/fleet/server/index.ts | 4 ++- x-pack/plugins/fleet/server/mocks.ts | 5 +++- x-pack/plugins/fleet/server/plugin.ts | 16 +++++----- .../server/routes/agent/acks_handlers.test.ts | 4 ++- .../server/routes/agent/acks_handlers.ts | 1 + .../routes/agent/actions_handlers.test.ts | 7 +++-- .../server/routes/agent/actions_handlers.ts | 1 + .../fleet/server/routes/agent/handlers.ts | 1 + .../fleet/server/routes/agent/index.ts | 8 +++-- .../server/routes/agent/unenroll_handler.ts | 1 + .../server/routes/agent/upgrade_handler.ts | 1 + .../server/routes/agent_policy/handlers.ts | 1 + .../fleet/server/routes/agent_policy/index.ts | 2 ++ .../plugins/fleet/server/routes/app/index.ts | 1 + .../server/routes/data_streams/handlers.ts | 1 + .../fleet/server/routes/data_streams/index.ts | 2 ++ .../routes/enrollment_api_key/handler.ts | 1 + .../server/routes/enrollment_api_key/index.ts | 2 ++ .../fleet/server/routes/epm/handlers.ts | 4 ++- .../plugins/fleet/server/routes/epm/index.ts | 24 ++++++++------- .../server/routes/install_script/index.ts | 2 ++ .../server/routes/limited_concurrency.test.ts | 4 ++- .../server/routes/limited_concurrency.ts | 1 + .../fleet/server/routes/output/handler.ts | 1 + .../fleet/server/routes/output/index.ts | 4 ++- .../routes/package_policy/handlers.test.ts | 4 ++- .../server/routes/package_policy/handlers.ts | 1 + .../server/routes/package_policy/index.ts | 2 ++ .../plugins/fleet/server/routes/security.ts | 1 + .../fleet/server/routes/settings/index.ts | 1 + .../server/routes/setup/handlers.test.ts | 4 ++- .../fleet/server/routes/setup/handlers.ts | 1 + .../fleet/server/routes/setup/index.ts | 4 ++- .../fleet/server/saved_objects/index.ts | 12 ++++---- .../saved_objects/migrations/to_v7_10_0.ts | 1 + .../saved_objects/migrations/to_v7_12_0.ts | 1 + .../server/services/agent_policy.test.ts | 4 ++- .../fleet/server/services/agent_policy.ts | 4 ++- .../server/services/agent_policy_update.ts | 1 + .../fleet/server/services/agents/acks.test.ts | 2 ++ .../fleet/server/services/agents/acks.ts | 2 ++ .../server/services/agents/actions.test.ts | 7 +++-- .../fleet/server/services/agents/actions.ts | 6 ++-- .../server/services/agents/authenticate.ts | 2 ++ .../server/services/agents/checkin/index.ts | 4 ++- .../agents/checkin/rxjs_utils.test.ts | 1 + .../server/services/agents/checkin/state.ts | 4 ++- .../agents/checkin/state_connected_agents.ts | 1 + .../agents/checkin/state_new_actions.test.ts | 8 +++-- .../agents/checkin/state_new_actions.ts | 5 ++-- .../fleet/server/services/agents/crud.ts | 2 ++ .../services/agents/crud_fleet_server.ts | 4 ++- .../fleet/server/services/agents/crud_so.ts | 4 ++- .../fleet/server/services/agents/enroll.ts | 5 ++-- .../fleet/server/services/agents/events.ts | 1 + .../server/services/agents/reassign.test.ts | 2 ++ .../fleet/server/services/agents/reassign.ts | 5 ++-- .../server/services/agents/saved_objects.ts | 1 + .../fleet/server/services/agents/setup.ts | 2 ++ .../server/services/agents/status.test.ts | 6 ++-- .../fleet/server/services/agents/status.ts | 4 ++- .../server/services/agents/unenroll.test.ts | 2 ++ .../fleet/server/services/agents/unenroll.ts | 4 ++- .../fleet/server/services/agents/update.ts | 4 ++- .../fleet/server/services/agents/upgrade.ts | 6 ++-- .../services/api_keys/enrollment_api_key.ts | 2 ++ .../enrollment_api_key_fleet_server.ts | 4 ++- .../api_keys/enrollment_api_key_so.ts | 4 ++- .../fleet/server/services/api_keys/index.ts | 1 + .../server/services/api_keys/security.ts | 1 + .../fleet/server/services/app_context.ts | 1 + .../plugins/fleet/server/services/config.ts | 1 + .../fleet/server/services/epm/agent/agent.ts | 1 + .../server/services/epm/archive/cache.ts | 3 +- .../server/services/epm/archive/extract.ts | 2 ++ .../server/services/epm/archive/index.ts | 1 + .../server/services/epm/archive/storage.ts | 5 +++- .../server/services/epm/archive/validation.ts | 4 ++- .../elasticsearch/datastream_ilm/install.ts | 4 ++- .../elasticsearch/datastream_ilm/remove.ts | 1 + .../services/epm/elasticsearch/index.test.ts | 1 + .../ingest_pipeline/ingest_pipelines.test.ts | 4 ++- .../elasticsearch/ingest_pipeline/install.ts | 2 ++ .../elasticsearch/ingest_pipeline/remove.ts | 1 + .../elasticsearch/template/install.test.ts | 4 ++- .../epm/elasticsearch/template/install.ts | 6 ++-- .../elasticsearch/template/template.test.ts | 5 +++- .../epm/elasticsearch/transform/install.ts | 6 ++-- .../elasticsearch/transform/remove.test.ts | 5 +++- .../epm/elasticsearch/transform/remove.ts | 1 + .../elasticsearch/transform/transform.test.ts | 8 +++-- .../server/services/epm/fields/field.test.ts | 4 ++- .../fleet/server/services/epm/fields/field.ts | 1 + .../services/epm/kibana/assets/install.ts | 1 + .../epm/kibana/index_pattern/install.test.ts | 5 +++- .../epm/kibana/index_pattern/install.ts | 1 + .../epm/packages/_install_package.test.ts | 2 ++ .../services/epm/packages/_install_package.ts | 6 ++-- .../services/epm/packages/assets.test.ts | 4 ++- .../epm/packages/bulk_install_packages.ts | 2 ++ .../ensure_installed_default_packages.test.ts | 10 +++++-- .../server/services/epm/packages/get.test.ts | 2 ++ .../fleet/server/services/epm/packages/get.ts | 4 ++- .../epm/packages/get_install_type.test.ts | 4 ++- .../server/services/epm/packages/index.ts | 1 + .../server/services/epm/packages/install.ts | 29 ++++++++++--------- .../server/services/epm/packages/remove.ts | 4 ++- .../services/epm/registry/index.test.ts | 1 + .../server/services/epm/registry/index.ts | 9 ++++-- .../services/epm/registry/proxy.test.ts | 1 + .../server/services/epm/registry/proxy.ts | 1 + .../services/epm/registry/requests.test.ts | 3 +- .../server/services/epm/registry/requests.ts | 2 ++ .../fleet/server/services/es_index_pattern.ts | 4 ++- .../fleet_server/elastic_index.test.ts | 4 ++- .../services/fleet_server/elastic_index.ts | 1 + .../server/services/fleet_server/index.ts | 2 ++ .../fleet_server/saved_object_migrations.ts | 1 + x-pack/plugins/fleet/server/services/index.ts | 2 ++ .../server/services/install_script/index.ts | 1 + .../plugins/fleet/server/services/output.ts | 4 ++- .../server/services/package_policy.test.ts | 12 +++++--- .../fleet/server/services/package_policy.ts | 4 ++- .../fleet/server/services/saved_object.ts | 1 + .../plugins/fleet/server/services/settings.ts | 5 +++- .../fleet/server/services/setup.test.ts | 1 + x-pack/plugins/fleet/server/services/setup.ts | 19 +++++++----- .../fleet/server/types/models/agent_policy.ts | 4 ++- .../fleet/server/types/models/output.ts | 1 + .../server/types/models/package_policy.ts | 1 + .../fleet/server/types/rest_spec/agent.ts | 1 + .../server/types/rest_spec/agent_policy.ts | 2 ++ .../server/types/rest_spec/package_policy.ts | 2 ++ .../fleet/server/types/rest_spec/settings.ts | 1 + 298 files changed, 664 insertions(+), 182 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9cc7985b8bce2..0540bb213101a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -789,6 +789,22 @@ module.exports = { }, }, + /** + * Fleet overrides + */ + { + files: ['x-pack/plugins/fleet/**/*.{js,mjs,ts,tsx}'], + rules: { + 'import/order': [ + 'warn', + { + groups: ['builtin', 'external', 'internal', 'parent'], + 'newlines-between': 'always-and-inside-groups', + }, + ], + }, + }, + /** * Security Solution overrides */ diff --git a/x-pack/plugins/fleet/common/constants/agent_policy.ts b/x-pack/plugins/fleet/common/constants/agent_policy.ts index 51cf0382e2dbc..859a96801595a 100644 --- a/x-pack/plugins/fleet/common/constants/agent_policy.ts +++ b/x-pack/plugins/fleet/common/constants/agent_policy.ts @@ -5,9 +5,10 @@ * 2.0. */ -import { defaultPackages } from './epm'; import type { AgentPolicy } from '../types'; +import { defaultPackages } from './epm'; + export const AGENT_POLICY_SAVED_OBJECT_TYPE = 'ingest-agent-policies'; export const AGENT_POLICY_INDEX = '.fleet-policies'; export const agentPolicyStatuses = { diff --git a/x-pack/plugins/fleet/common/services/full_agent_policy_to_yaml.ts b/x-pack/plugins/fleet/common/services/full_agent_policy_to_yaml.ts index 64d297922f570..e532a90f8839f 100644 --- a/x-pack/plugins/fleet/common/services/full_agent_policy_to_yaml.ts +++ b/x-pack/plugins/fleet/common/services/full_agent_policy_to_yaml.ts @@ -6,6 +6,7 @@ */ import { safeDump } from 'js-yaml'; + import type { FullAgentPolicy } from '../types'; const POLICY_KEYS_ORDER = [ diff --git a/x-pack/plugins/fleet/common/services/is_agent_upgradeable.test.ts b/x-pack/plugins/fleet/common/services/is_agent_upgradeable.test.ts index 38ae63933a076..f6656b881c598 100644 --- a/x-pack/plugins/fleet/common/services/is_agent_upgradeable.test.ts +++ b/x-pack/plugins/fleet/common/services/is_agent_upgradeable.test.ts @@ -5,9 +5,10 @@ * 2.0. */ -import { isAgentUpgradeable } from './is_agent_upgradeable'; import type { Agent } from '../types/models/agent'; +import { isAgentUpgradeable } from './is_agent_upgradeable'; + const getAgent = ({ version, upgradeable = false, diff --git a/x-pack/plugins/fleet/common/services/is_agent_upgradeable.ts b/x-pack/plugins/fleet/common/services/is_agent_upgradeable.ts index 7de4e7c11d09e..0350c47816f6d 100644 --- a/x-pack/plugins/fleet/common/services/is_agent_upgradeable.ts +++ b/x-pack/plugins/fleet/common/services/is_agent_upgradeable.ts @@ -7,6 +7,7 @@ import semverCoerce from 'semver/functions/coerce'; import semverLt from 'semver/functions/lt'; + import type { Agent } from '../types'; export function isAgentUpgradeable(agent: Agent, kibanaVersion: string) { diff --git a/x-pack/plugins/fleet/common/services/license.ts b/x-pack/plugins/fleet/common/services/license.ts index 68cbee5786d3b..767c94436effb 100644 --- a/x-pack/plugins/fleet/common/services/license.ts +++ b/x-pack/plugins/fleet/common/services/license.ts @@ -6,6 +6,7 @@ */ import { Observable, Subscription } from 'rxjs'; + import type { ILicense } from '../../../licensing/common/types'; // Generic license service class that works with the license observable diff --git a/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.test.ts b/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.test.ts index 930a111f66d6b..31c47bf9dc69d 100644 --- a/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.test.ts +++ b/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.test.ts @@ -6,6 +6,7 @@ */ import type { PackagePolicy, PackagePolicyInput } from '../types'; + import { storedPackagePoliciesToAgentInputs } from './package_policies_to_agent_inputs'; describe('Fleet - storedPackagePoliciesToAgentInputs', () => { diff --git a/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts b/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts index e8ede61098dc2..ab15212431401 100644 --- a/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts +++ b/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts @@ -6,6 +6,7 @@ */ import type { PackageInfo } from '../types'; + import { packageToPackagePolicy, packageToPackagePolicyInputs } from './package_to_package_policy'; describe('Fleet - packageToPackagePolicy', () => { diff --git a/x-pack/plugins/fleet/common/types/models/agent.ts b/x-pack/plugins/fleet/common/types/models/agent.ts index 60eb47a6ecc43..0e558f8ebdcdb 100644 --- a/x-pack/plugins/fleet/common/types/models/agent.ts +++ b/x-pack/plugins/fleet/common/types/models/agent.ts @@ -5,9 +5,10 @@ * 2.0. */ -import type { FullAgentPolicy } from './agent_policy'; import { AGENT_TYPE_EPHEMERAL, AGENT_TYPE_PERMANENT, AGENT_TYPE_TEMPORARY } from '../../constants'; +import type { FullAgentPolicy } from './agent_policy'; + export type AgentType = | typeof AGENT_TYPE_EPHEMERAL | typeof AGENT_TYPE_PERMANENT diff --git a/x-pack/plugins/fleet/common/types/models/agent_policy.ts b/x-pack/plugins/fleet/common/types/models/agent_policy.ts index 1aaca4fc5d932..3325a8db713aa 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -7,6 +7,7 @@ import { agentPolicyStatuses } from '../../constants'; import type { DataType, ValueOf } from '../../types'; + import type { PackagePolicy, PackagePolicyPackage } from './package_policy'; import type { Output } from './output'; diff --git a/x-pack/plugins/fleet/common/types/models/epm.ts b/x-pack/plugins/fleet/common/types/models/epm.ts index e42ef7515b4c1..ca397f73ee770 100644 --- a/x-pack/plugins/fleet/common/types/models/epm.ts +++ b/x-pack/plugins/fleet/common/types/models/epm.ts @@ -8,6 +8,7 @@ // Follow pattern from https://github.com/elastic/kibana/pull/52447 // TODO: Update when https://github.com/elastic/kibana/issues/53021 is closed import type { SavedObject, SavedObjectAttributes, SavedObjectReference } from 'src/core/public'; + import { ASSETS_SAVED_OBJECT_TYPE, agentAssetTypes, @@ -17,6 +18,7 @@ import { requiredPackages, } from '../../constants'; import type { ValueOf } from '../../types'; + import type { PackageSpecManifest, PackageSpecScreenshot } from './package_spec'; export type InstallationStatus = typeof installationStatuses; diff --git a/x-pack/plugins/fleet/common/types/rest_spec/agent_policy.ts b/x-pack/plugins/fleet/common/types/rest_spec/agent_policy.ts index 4b64044e1f2de..927368694693a 100644 --- a/x-pack/plugins/fleet/common/types/rest_spec/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/rest_spec/agent_policy.ts @@ -6,6 +6,7 @@ */ import type { AgentPolicy, NewAgentPolicy, FullAgentPolicy } from '../models'; + import type { ListWithKuery } from './common'; export interface GetAgentPoliciesRequest { diff --git a/x-pack/plugins/fleet/public/applications/fleet/app.tsx b/x-pack/plugins/fleet/public/applications/fleet/app.tsx index b441a2181af35..57758d616d908 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/app.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/app.tsx @@ -14,6 +14,11 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import styled from 'styled-components'; import useObservable from 'react-use/lib/useObservable'; + +import { FleetConfigType, FleetStartServices } from '../../plugin'; +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; +import { EuiThemeProvider } from '../../../../../../src/plugins/kibana_react/common'; + import { ConfigContext, FleetStatusProvider, @@ -34,10 +39,7 @@ import { DataStreamApp } from './sections/data_stream'; import { FleetApp } from './sections/agents'; import { IngestManagerOverview } from './sections/overview'; import { ProtectedRoute } from './index'; -import { FleetConfigType, FleetStartServices } from '../../plugin'; import { UIExtensionsStorage } from './types'; -import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; -import { EuiThemeProvider } from '../../../../../../src/plugins/kibana_react/common'; import { UIExtensionsContext } from './hooks/use_ui_extension'; const ErrorLayout = ({ children }: { children: JSX.Element }) => ( diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/alpha_messaging.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/alpha_messaging.tsx index a3b6401741fb2..af550868c126b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/alpha_messaging.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/alpha_messaging.tsx @@ -9,6 +9,7 @@ import React, { useState } from 'react'; import styled from 'styled-components'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiText, EuiLink } from '@elastic/eui'; + import { AlphaFlyout } from './alpha_flyout'; const Message = styled(EuiText).attrs((props) => ({ diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/enrollment_instructions/manual/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/enrollment_instructions/manual/index.tsx index b77bf21945e30..6243597cf003c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/enrollment_instructions/manual/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/enrollment_instructions/manual/index.tsx @@ -9,6 +9,7 @@ import React from 'react'; import styled from 'styled-components'; import { EuiText, EuiSpacer, EuiLink, EuiTitle, EuiCodeBlock } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; + import { EnrollmentAPIKey } from '../../../types'; interface Props { diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/extension_wrapper.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/extension_wrapper.tsx index d8188740c1cab..bb22586122295 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/extension_wrapper.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/extension_wrapper.tsx @@ -7,6 +7,7 @@ import React, { memo, ReactNode, Suspense } from 'react'; import { EuiErrorBoundary } from '@elastic/eui'; + import { Loading } from './loading'; export const ExtensionWrapper = memo<{ children: ReactNode }>(({ children }) => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_header_link.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_header_link.tsx index cd378ec842679..106df8a9afb1d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_header_link.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_header_link.tsx @@ -9,8 +9,10 @@ import React, { memo, useState, useEffect } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButtonEmpty } from '@elastic/eui'; import type { TutorialDirectoryHeaderLinkComponent } from 'src/plugins/home/public'; + import { RedirectAppLinks } from '../../../../../../../../src/plugins/kibana_react/public'; import { useLink, useCapabilities, useStartServices } from '../../hooks'; + import { tutorialDirectoryNoticeState$ } from './tutorial_directory_notice'; const TutorialDirectoryHeaderLink: TutorialDirectoryHeaderLinkComponent = memo(() => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_notice.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_notice.tsx index 8ea0c8730fdb5..4e8123a4fadec 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_notice.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_notice.tsx @@ -19,6 +19,7 @@ import { EuiSpacer, } from '@elastic/eui'; import type { TutorialDirectoryNoticeComponent } from 'src/plugins/home/public'; + import { RedirectAppLinks } from '../../../../../../../../src/plugins/kibana_react/public'; import { sendPutSettings, diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_module_notice.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_module_notice.tsx index 88b6933fe4774..526b6513173ef 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_module_notice.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_module_notice.tsx @@ -9,6 +9,7 @@ import React, { memo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiText, EuiLink, EuiSpacer } from '@elastic/eui'; import { TutorialModuleNoticeComponent } from 'src/plugins/home/public'; + import { useGetPackages, useLink, useCapabilities } from '../../hooks'; import { pkgKeyFromPackageInfo } from '../../services/pkg_key_from_package_info'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/linked_agent_count.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/linked_agent_count.tsx index 325229a298ec5..3b788126a570f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/linked_agent_count.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/linked_agent_count.tsx @@ -7,6 +7,7 @@ import React, { memo } from 'react'; import { EuiLink, EuiLinkAnchorProps } from '@elastic/eui'; + import { useLink } from '../hooks'; import { AGENT_SAVED_OBJECT_TYPE } from '../constants'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/package_icon.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/package_icon.tsx index 0b35d6cf9fa2d..5b8fddd2d5e05 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/package_icon.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/package_icon.tsx @@ -7,6 +7,7 @@ import React from 'react'; import { EuiIcon, EuiIconProps } from '@elastic/eui'; + import { usePackageIconType, UsePackageIconType } from '../hooks'; export const PackageIcon: React.FunctionComponent< diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/search_bar.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/search_bar.tsx index 9897d89881450..cac475fc7a98a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/search_bar.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/search_bar.tsx @@ -6,6 +6,7 @@ */ import React, { useState, useEffect, useMemo } from 'react'; + import { QueryStringInput, IFieldType, diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/settings_flyout.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/settings_flyout.tsx index ea48e483a7fed..c668097cdb47e 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/settings_flyout.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/settings_flyout.tsx @@ -27,6 +27,7 @@ import { import { FormattedMessage } from '@kbn/i18n/react'; import { EuiText } from '@elastic/eui'; import { safeLoad } from 'js-yaml'; + import { useComboInput, useStartServices, diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx index 22dfe2e8be517..000c664548cb8 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx @@ -7,7 +7,9 @@ import { i18n } from '@kbn/i18n'; import { ChromeBreadcrumb } from 'src/core/public'; + import { BASE_PATH, Page, DynamicPagePathValues, pagePathGetters } from '../constants'; + import { useStartServices } from './use_core'; const BASE_BREADCRUMB: ChromeBreadcrumb = { diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_config.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_config.ts index cee563280e7bf..b72860efcc9ec 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_config.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_config.ts @@ -6,6 +6,7 @@ */ import React, { useContext } from 'react'; + import type { FleetConfigType } from '../../../plugin'; export const ConfigContext = React.createContext(null); diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_fleet_status.tsx b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_fleet_status.tsx index 71161c17a7b49..c506ccda37de8 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_fleet_status.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_fleet_status.tsx @@ -6,9 +6,11 @@ */ import React, { useState, useContext, useEffect } from 'react'; + +import { GetFleetStatusResponse } from '../types'; + import { useConfig } from './use_config'; import { sendGetFleetStatus } from './use_request'; -import { GetFleetStatusResponse } from '../types'; interface FleetStatusState { enabled: boolean; diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_intra_app_state.tsx b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_intra_app_state.tsx index e5acdff405994..e6f91093aafad 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_intra_app_state.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_intra_app_state.tsx @@ -8,6 +8,7 @@ import React, { memo, useContext, useMemo } from 'react'; import { AppMountParameters } from 'kibana/public'; import { useLocation } from 'react-router-dom'; + import { AnyIntraAppRouteState } from '../types'; interface IntraAppState { diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_link.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_link.ts index bcb8c4c749211..440cd693d7af2 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_link.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_link.ts @@ -7,6 +7,7 @@ import { BASE_PATH, pagePathGetters } from '../constants'; import type { StaticPage, DynamicPage, DynamicPagePathValues } from '../constants'; + import { useStartServices } from './'; const getPath = (page: StaticPage | DynamicPage, values: DynamicPagePathValues = {}): string => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_package_icon_type.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_package_icon_type.ts index 679c44f2c0ea9..654cfc70ab418 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_package_icon_type.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_package_icon_type.ts @@ -7,8 +7,10 @@ import { useEffect, useState } from 'react'; import { ICON_TYPES } from '@elastic/eui'; + import type { PackageInfo, PackageListItem } from '../types'; import { useLinks } from '../sections/epm/hooks'; + import { sendGetPackageInfoByKey } from './index'; type Package = PackageInfo | PackageListItem; diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agent_policy.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agent_policy.ts index d60383c15d2f4..7b3007a61d248 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agent_policy.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agent_policy.ts @@ -5,9 +5,8 @@ * 2.0. */ -import { useRequest, sendRequest, useConditionalRequest } from './use_request'; -import type { SendConditionalRequestConfig } from './use_request'; import { agentPolicyRouteService } from '../../services'; + import type { GetAgentPoliciesRequest, GetAgentPoliciesResponse, @@ -23,6 +22,9 @@ import type { DeleteAgentPolicyResponse, } from '../../types'; +import { useRequest, sendRequest, useConditionalRequest } from './use_request'; +import type { SendConditionalRequestConfig } from './use_request'; + export const useGetAgentPolicies = (query?: GetAgentPoliciesRequest['query']) => { return useRequest({ path: agentPolicyRouteService.getListPath(), diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agents.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agents.ts index a40ebbf78e0f2..90ca762173a80 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agents.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agents.ts @@ -5,9 +5,8 @@ * 2.0. */ -import { useRequest, sendRequest } from './use_request'; -import type { UseRequestConfig } from './use_request'; import { agentRouteService } from '../../services'; + import type { GetOneAgentResponse, GetOneAgentEventsResponse, @@ -32,6 +31,9 @@ import type { PostNewAgentActionResponse, } from '../../types'; +import { useRequest, sendRequest } from './use_request'; +import type { UseRequestConfig } from './use_request'; + type RequestOptions = Pick, 'pollIntervalMs'>; export function useGetOneAgent(agentId: string, options?: RequestOptions) { diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/app.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/app.ts index 2e93a1700d08c..bd690a4b53e07 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/app.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/app.ts @@ -5,10 +5,11 @@ * 2.0. */ -import { sendRequest } from './use_request'; import { appRoutesService } from '../../services'; import type { CheckPermissionsResponse } from '../../types'; +import { sendRequest } from './use_request'; + export const sendGetPermissionsCheck = () => { return sendRequest({ path: appRoutesService.getCheckPermissionsPath(), diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/data_stream.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/data_stream.ts index 16e27596e7090..e2bd8eca1c89d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/data_stream.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/data_stream.ts @@ -5,10 +5,11 @@ * 2.0. */ -import { useRequest } from './use_request'; import { dataStreamRouteService } from '../../services'; import type { GetDataStreamsResponse } from '../../types'; +import { useRequest } from './use_request'; + export const useGetDataStreams = () => { return useRequest({ path: dataStreamRouteService.getListPath(), diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/enrollment_api_keys.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/enrollment_api_keys.ts index 4aad8b7314482..601d54ec56c46 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/enrollment_api_keys.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/enrollment_api_keys.ts @@ -5,15 +5,17 @@ * 2.0. */ -import { useRequest, sendRequest, useConditionalRequest } from './use_request'; -import type { UseRequestConfig, SendConditionalRequestConfig } from './use_request'; import { enrollmentAPIKeyRouteService } from '../../services'; + import type { GetOneEnrollmentAPIKeyResponse, GetEnrollmentAPIKeysResponse, GetEnrollmentAPIKeysRequest, } from '../../types'; +import { useRequest, sendRequest, useConditionalRequest } from './use_request'; +import type { UseRequestConfig, SendConditionalRequestConfig } from './use_request'; + type RequestOptions = Pick, 'pollIntervalMs'>; export function useGetOneEnrollmentAPIKey(keyId: string | undefined) { diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/epm.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/epm.ts index 45e754849b5bc..3f3d2299fdebf 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/epm.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/epm.ts @@ -5,7 +5,6 @@ * 2.0. */ -import { useRequest, sendRequest } from './use_request'; import { epmRouteService } from '../../services'; import type { GetCategoriesRequest, @@ -19,6 +18,8 @@ import type { } from '../../types'; import type { GetStatsResponse } from '../../../../../common'; +import { useRequest, sendRequest } from './use_request'; + export const useGetCategories = (query: GetCategoriesRequest['query'] = {}) => { return useRequest({ path: epmRouteService.getCategoriesPath(), diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/outputs.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/outputs.ts index 64c82d2a04790..0fcaa262cf321 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/outputs.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/outputs.ts @@ -5,10 +5,11 @@ * 2.0. */ -import { sendRequest, useRequest } from './use_request'; import { outputRoutesService } from '../../services'; import type { PutOutputRequest, GetOutputsResponse } from '../../types'; +import { sendRequest, useRequest } from './use_request'; + export function useGetOutputs() { return useRequest({ method: 'get', diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/package_policy.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/package_policy.ts index 1266f47a80e21..89eab44a14461 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/package_policy.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/package_policy.ts @@ -5,7 +5,6 @@ * 2.0. */ -import { sendRequest, useRequest } from './use_request'; import { packagePolicyRouteService } from '../../services'; import type { CreatePackagePolicyRequest, @@ -21,6 +20,8 @@ import type { GetOnePackagePolicyResponse, } from '../../../../../common/types/rest_spec'; +import { sendRequest, useRequest } from './use_request'; + export const sendCreatePackagePolicy = (body: CreatePackagePolicyRequest['body']) => { return sendRequest({ path: packagePolicyRouteService.getCreatePath(), diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/settings.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/settings.ts index bf4ea6eacb3c1..83b2612822f60 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/settings.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/settings.ts @@ -5,10 +5,11 @@ * 2.0. */ -import { sendRequest, useRequest } from './use_request'; import { settingsRoutesService } from '../../services'; import type { PutSettingsResponse, PutSettingsRequest, GetSettingsResponse } from '../../types'; +import { sendRequest, useRequest } from './use_request'; + export function useGetSettings() { return useRequest({ method: 'get', diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/setup.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/setup.ts index 001b8af99aec5..67d631d5d55bc 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/setup.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/setup.ts @@ -5,10 +5,11 @@ * 2.0. */ -import { sendRequest } from './use_request'; import { setupRouteService, fleetSetupRouteService } from '../../services'; import type { GetFleetStatusResponse } from '../../types'; +import { sendRequest } from './use_request'; + export const sendSetup = () => { return sendRequest({ path: setupRouteService.getSetupPath(), diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/use_request.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/use_request.ts index 985f4d71d6a75..91c45e3019cf5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/use_request.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/use_request.ts @@ -7,6 +7,7 @@ import { useState, useEffect } from 'react'; import type { HttpSetup } from 'src/core/public'; + import { UseRequestConfig as _UseRequestConfig, sendRequest as _sendRequest, diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_ui_extension.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_ui_extension.ts index f6b3cfd2b3642..3880a08a7ec03 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_ui_extension.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_ui_extension.ts @@ -6,6 +6,7 @@ */ import React, { useContext } from 'react'; + import type { UIExtensionPoint, UIExtensionsStorage } from '../types'; export const UIExtensionsContext = React.createContext({}); diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_url_pagination.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_url_pagination.ts index 090ce34ae244a..b73a298a704ff 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_url_pagination.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_url_pagination.ts @@ -7,6 +7,7 @@ import { useCallback, useEffect, useMemo } from 'react'; import { useHistory, useLocation } from 'react-router-dom'; + import { useUrlParams } from './use_url_params'; import { PAGE_SIZE_OPTIONS, usePagination } from './use_pagination'; import type { Pagination } from './use_pagination'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/index.tsx index 440a613e3653e..a66b28e5f05c9 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/index.tsx @@ -9,7 +9,9 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Redirect, Route, RouteProps } from 'react-router-dom'; import { CoreStart, AppMountParameters } from 'src/core/public'; + import { FleetConfigType, FleetStartServices } from '../../plugin'; + import { licenseService } from './hooks'; import { UIExtensionsStorage } from './types'; import { AppRoutes, FleetAppContext, WithPermissionsAndSetup } from './app'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/layouts/default.tsx b/x-pack/plugins/fleet/public/applications/fleet/layouts/default.tsx index bc71f8bd10414..001ad069f1b6f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/layouts/default.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/layouts/default.tsx @@ -9,6 +9,7 @@ import React from 'react'; import styled from 'styled-components'; import { EuiTabs, EuiTab, EuiFlexGroup, EuiFlexItem, EuiButtonEmpty } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; + import { Section } from '../sections'; import { AlphaMessaging, SettingFlyout } from '../components'; import { useLink, useConfig } from '../hooks'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/layouts/with_header.tsx b/x-pack/plugins/fleet/public/applications/fleet/layouts/with_header.tsx index 461a0bb84d181..c8a8d47e6d802 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/layouts/with_header.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/layouts/with_header.tsx @@ -7,7 +7,9 @@ import React, { Fragment } from 'react'; import { EuiPageBody, EuiSpacer } from '@elastic/eui'; + import { Header, HeaderProps } from '../components'; + import { Page, ContentWrapper } from './without_header'; export interface WithHeaderLayoutProps extends HeaderProps { diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/create_test_renderer.tsx b/x-pack/plugins/fleet/public/applications/fleet/mock/create_test_renderer.tsx index 04c4923d6f8a8..0a1346c888acc 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/mock/create_test_renderer.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/mock/create_test_renderer.tsx @@ -8,11 +8,13 @@ import { createMemoryHistory, History, createHashHistory } from 'history'; import React, { memo } from 'react'; import { render as reactRender, RenderOptions, RenderResult, act } from '@testing-library/react'; + import { ScopedHistory } from '../../../../../../../src/core/public'; import { FleetAppContext } from '../app'; import { FleetConfigType } from '../../../plugin'; -import { createConfigurationMock } from './plugin_configuration'; import { UIExtensionsStorage } from '../types'; + +import { createConfigurationMock } from './plugin_configuration'; import { createStartMock } from './plugin_interfaces'; import { createStartServices } from './fleet_start_services'; import { MockedFleetStart, MockedFleetStartServices } from './types'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/fleet_start_services.tsx b/x-pack/plugins/fleet/public/applications/fleet/mock/fleet_start_services.tsx index d219384f66cef..4dfa0805bdbc5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/mock/fleet_start_services.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/mock/fleet_start_services.tsx @@ -8,10 +8,12 @@ import React from 'react'; import { I18nProvider } from '@kbn/i18n/react'; import { MockedKeys } from '@kbn/utility-types/jest'; + import { coreMock } from '../../../../../../../src/core/public/mocks'; -import { createStartDepsMock } from './plugin_dependencies'; import { IStorage, Storage } from '../../../../../../../src/plugins/kibana_utils/public'; import { setHttpClient } from '../hooks/use_request'; + +import { createStartDepsMock } from './plugin_dependencies'; import { MockedFleetStartServices } from './types'; // Taken from core. See: src/plugins/kibana_utils/public/storage/storage.test.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_dependencies.ts b/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_dependencies.ts index 8207e3d89fc56..d7725830afb41 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_dependencies.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_dependencies.ts @@ -8,6 +8,7 @@ import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks'; import { licensingMock } from '../../../../../licensing/public/mocks'; import { homePluginMock } from '../../../../../../../src/plugins/home/public/mocks'; + import type { MockedFleetSetupDeps, MockedFleetStartDeps } from './types'; export const createSetupDepsMock = (): MockedFleetSetupDeps => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_interfaces.ts b/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_interfaces.ts index 3c76452f17ce7..134bd408d8c3c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_interfaces.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_interfaces.ts @@ -7,6 +7,7 @@ import type { UIExtensionsStorage } from '../types'; import { createExtensionRegistrationCallback } from '../services/ui_extensions'; + import type { MockedFleetStart } from './types'; export const createStartMock = (extensionsStorage: UIExtensionsStorage = {}): MockedFleetStart => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/types.ts b/x-pack/plugins/fleet/public/applications/fleet/mock/types.ts index 660fe6af29fb1..b1a1ddc4a582f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/mock/types.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/mock/types.ts @@ -6,6 +6,7 @@ */ import type { MockedKeys } from '@kbn/utility-types/jest'; + import type { FleetSetupDeps, FleetStart, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx index 78e43f4c04b99..0db0f1f8cab72 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx @@ -8,10 +8,12 @@ import React, { memo, useState, useMemo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiContextMenuItem, EuiPortal } from '@elastic/eui'; + import { AgentPolicy } from '../../../types'; import { useCapabilities } from '../../../hooks'; import { ContextMenuActions } from '../../../components'; import { AgentEnrollmentFlyout } from '../../agents/components'; + import { AgentPolicyYamlFlyout } from './agent_policy_yaml_flyout'; import { AgentPolicyCopyProvider } from './agent_policy_copy_provider'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_copy_provider.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_copy_provider.tsx index 2b7ecc75195b0..d16a0351f1bbd 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_copy_provider.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_copy_provider.tsx @@ -9,6 +9,7 @@ import React, { Fragment, useRef, useState } from 'react'; import { EuiConfirmModal, EuiFormRow, EuiFieldText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; + import { AgentPolicy } from '../../../types'; import { sendCopyAgentPolicy, useStartServices } from '../../../hooks'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_delete_provider.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_delete_provider.tsx index 014af7f54d020..c5d0e5279220e 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_delete_provider.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_delete_provider.tsx @@ -9,6 +9,7 @@ import React, { Fragment, useRef, useState } from 'react'; import { EuiConfirmModal, EuiCallOut } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; + import { AGENT_SAVED_OBJECT_TYPE } from '../../../constants'; import { sendDeleteAgentPolicy, useStartServices, useConfig, sendRequest } from '../../../hooks'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx index 37f3e5bc398b8..c0da3a72dce62 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx @@ -24,9 +24,11 @@ import { import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import styled from 'styled-components'; + import { dataTypes } from '../../../../../../common'; import { NewAgentPolicy, AgentPolicy } from '../../../types'; import { isValidNamespace } from '../../../services'; + import { AgentPolicyDeleteProvider } from './agent_policy_delete_provider'; interface ValidationResults { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_yaml_flyout.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_yaml_flyout.tsx index 9ed4bb6ff6ff4..e434347c2c367 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_yaml_flyout.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_yaml_flyout.tsx @@ -21,6 +21,7 @@ import { EuiButton, EuiCallOut, } from '@elastic/eui'; + import { useGetOneAgentPolicyFull, useGetOneAgentPolicy, useStartServices } from '../../../hooks'; import { Loading } from '../../../components'; import { fullAgentPolicyToYaml, agentPolicyRouteService } from '../../../services'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/confirm_deploy_modal.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/confirm_deploy_modal.tsx index f3d01e6b528ca..f75aea703fd19 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/confirm_deploy_modal.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/confirm_deploy_modal.tsx @@ -9,6 +9,7 @@ import React from 'react'; import { EuiCallOut, EuiConfirmModal, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; + import { AgentPolicy } from '../../../types'; export const ConfirmDeployAgentPolicyModal: React.FunctionComponent<{ diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/package_policy_delete_provider.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/package_policy_delete_provider.tsx index 80952fee05bb4..05b2bbf46b9e9 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/package_policy_delete_provider.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/package_policy_delete_provider.tsx @@ -9,6 +9,7 @@ import React, { Fragment, useMemo, useRef, useState } from 'react'; import { EuiCallOut, EuiConfirmModal, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; + import { useStartServices, sendRequest, sendDeletePackagePolicy, useConfig } from '../../../hooks'; import { AGENT_API_ROUTES, AGENT_SAVED_OBJECT_TYPE } from '../../../constants'; import { AgentPolicy } from '../../../types'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/layout.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/layout.tsx index 8b63f280a3aa7..0f51b603a49aa 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/layout.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/layout.tsx @@ -17,6 +17,7 @@ import { EuiButtonEmpty, EuiSpacer, } from '@elastic/eui'; + import { WithHeaderLayout } from '../../../../layouts'; import { AgentPolicy, PackageInfo } from '../../../../types'; import { PackageIcon } from '../../../../components/package_icon'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_config.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_config.tsx index cd76e5b1a2a25..c5c1033f1b800 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_config.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_config.tsx @@ -16,12 +16,14 @@ import { EuiSpacer, EuiButtonEmpty, } from '@elastic/eui'; + import { NewPackagePolicyInput, RegistryVarsEntry } from '../../../../types'; import { isAdvancedVar, PackagePolicyConfigValidationResults, validationHasErrors, } from '../services'; + import { PackagePolicyInputVarField } from './package_policy_input_var_field'; const FlexItemWithMaxWidth = styled(EuiFlexItem)` diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_panel.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_panel.tsx index 197ba78c3e0fe..92098d6971d35 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_panel.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_panel.tsx @@ -18,6 +18,7 @@ import { EuiHorizontalRule, EuiSpacer, } from '@elastic/eui'; + import { NewPackagePolicyInput, PackagePolicyInputStream, @@ -29,6 +30,7 @@ import { hasInvalidButRequiredVar, countValidationErrors, } from '../services'; + import { PackagePolicyInputConfig } from './package_policy_input_config'; import { PackagePolicyInputStreamConfig } from './package_policy_input_stream'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_stream.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_stream.tsx index 519f7acbbc64e..b21e8ca2e2243 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_stream.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_stream.tsx @@ -18,12 +18,14 @@ import { EuiSpacer, EuiButtonEmpty, } from '@elastic/eui'; + import { NewPackagePolicyInputStream, RegistryStream, RegistryVarsEntry } from '../../../../types'; import { isAdvancedVar, PackagePolicyConfigValidationResults, validationHasErrors, } from '../services'; + import { PackagePolicyInputVarField } from './package_policy_input_var_field'; const FlexItemWithMaxWidth = styled(EuiFlexItem)` diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_var_field.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_var_field.tsx index 6f5c9e79fa5f1..8de60739fe6ae 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_var_field.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_var_field.tsx @@ -16,6 +16,7 @@ import { EuiText, EuiCodeEditor, } from '@elastic/eui'; + import { RegistryVarsEntry } from '../../../../types'; import 'brace/mode/yaml'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.test.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.test.tsx index c3b76a51ff2f1..d9d43dc6ef975 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.test.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.test.tsx @@ -5,14 +5,16 @@ * 2.0. */ -import { createTestRendererMock, MockedFleetStartServices, TestRenderer } from '../../../mock'; -import { PAGE_ROUTING_PATHS, pagePathGetters, PLUGIN_ID } from '../../../constants'; import { Route } from 'react-router-dom'; -import { CreatePackagePolicyPage } from './index'; import React from 'react'; -import { CreatePackagePolicyRouteState } from '../../../types'; import { act } from 'react-test-renderer'; +import { createTestRendererMock, MockedFleetStartServices, TestRenderer } from '../../../mock'; +import { PAGE_ROUTING_PATHS, pagePathGetters, PLUGIN_ID } from '../../../constants'; +import { CreatePackagePolicyRouteState } from '../../../types'; + +import { CreatePackagePolicyPage } from './index'; + describe('when on the package policy create page', () => { const createPageUrlPath = pagePathGetters.add_integration_to_policy({ pkgkey: 'nginx-0.3.7' }); let testRenderer: TestRenderer; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx index a076012100421..bf6540db7dee7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx @@ -21,6 +21,7 @@ import { } from '@elastic/eui'; import { EuiStepProps } from '@elastic/eui/src/components/steps/step'; import { ApplicationStart } from 'kibana/public'; + import { AgentPolicy, PackageInfo, @@ -37,6 +38,13 @@ import { } from '../../../hooks'; import { Loading } from '../../../components'; import { ConfirmDeployAgentPolicyModal } from '../components'; +import { useIntraAppState } from '../../../hooks/use_intra_app_state'; +import { useUIExtension } from '../../../hooks/use_ui_extension'; +import { ExtensionWrapper } from '../../../components/extension_wrapper'; +import { PackagePolicyEditExtensionComponentProps } from '../../../types'; +import { PLUGIN_ID } from '../../../../../../common/constants'; +import { pkgKeyFromPackageInfo } from '../../../services/pkg_key_from_package_info'; + import { CreatePackagePolicyPageLayout } from './components'; import { CreatePackagePolicyFrom, PackagePolicyFormState } from './types'; import { @@ -48,12 +56,6 @@ import { StepSelectPackage } from './step_select_package'; import { StepSelectAgentPolicy } from './step_select_agent_policy'; import { StepConfigurePackagePolicy } from './step_configure_package'; import { StepDefinePackagePolicy } from './step_define_package_policy'; -import { useIntraAppState } from '../../../hooks/use_intra_app_state'; -import { useUIExtension } from '../../../hooks/use_ui_extension'; -import { ExtensionWrapper } from '../../../components/extension_wrapper'; -import { PackagePolicyEditExtensionComponentProps } from '../../../types'; -import { PLUGIN_ID } from '../../../../../../common/constants'; -import { pkgKeyFromPackageInfo } from '../../../services/pkg_key_from_package_info'; const StepsWithLessPadding = styled(EuiSteps)` .euiStep__content { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/has_invalid_but_required_var.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/has_invalid_but_required_var.ts index a9a0480098323..e204d86b51511 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/has_invalid_but_required_var.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/has_invalid_but_required_var.ts @@ -6,6 +6,7 @@ */ import type { PackagePolicyConfigRecord, RegistryVarsEntry } from '../../../../types'; + import { validatePackagePolicyConfig } from './'; export const hasInvalidButRequiredVar = ( diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.test.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.test.ts index e1e0d026966c3..180a585a4305a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.test.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.test.ts @@ -7,6 +7,7 @@ import { installationStatuses } from '../../../../../../../common/constants'; import type { PackageInfo, NewPackagePolicy, RegistryPolicyTemplate } from '../../../../types'; + import { validatePackagePolicy, validationHasErrors } from './validate_package_policy'; describe('Fleet - validatePackagePolicy()', () => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.ts index c727be683c130..3773f071ffb4c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.ts @@ -7,6 +7,7 @@ import { i18n } from '@kbn/i18n'; import { safeLoad } from 'js-yaml'; + import { getFlattenedObject, isValidNamespace } from '../../../../services'; import type { NewPackagePolicy, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_configure_package.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_configure_package.tsx index 54875bbfeb0b2..35619f528f907 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_configure_package.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_configure_package.tsx @@ -14,6 +14,7 @@ import { EuiText, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; + import { PackageInfo, RegistryStream, @@ -21,6 +22,7 @@ import { NewPackagePolicyInput, } from '../../../types'; import { Loading } from '../../../components'; + import { PackagePolicyValidationResults } from './services'; import { PackagePolicyInputPanel } from './components'; import { CreatePackagePolicyFrom } from './types'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx index 64837b208ae45..fdcb4e15112a6 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx @@ -18,12 +18,14 @@ import { EuiFlexGroup, EuiFlexItem, } from '@elastic/eui'; + import { AgentPolicy, PackageInfo, PackagePolicy, NewPackagePolicy } from '../../../types'; import { packageToPackagePolicyInputs } from '../../../services'; import { Loading } from '../../../components'; -import { PackagePolicyValidationResults } from './services'; import { pkgKeyFromPackageInfo } from '../../../services/pkg_key_from_package_info'; +import { PackagePolicyValidationResults } from './services'; + export const StepDefinePackagePolicy: React.FunctionComponent<{ agentPolicy: AgentPolicy; packageInfo: PackageInfo; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_agent_policy.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_agent_policy.tsx index 4e386ba9789ce..5359075ed19c3 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_agent_policy.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_agent_policy.tsx @@ -19,6 +19,7 @@ import { EuiFormRow, EuiLink, } from '@elastic/eui'; + import { Error } from '../../../components'; import { AgentPolicy, PackageInfo, GetAgentPoliciesResponseItem } from '../../../types'; import { isPackageLimited, doesAgentPolicyAlreadyIncludePackage } from '../../../services'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_package.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_package.tsx index e1062c84e4314..346dba971a2b4 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_package.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_package.tsx @@ -9,6 +9,7 @@ import React, { useEffect, useState, Fragment } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem, EuiSelectable, EuiSpacer } from '@elastic/eui'; + import { Error } from '../../../components'; import { AgentPolicy, PackageInfo, PackagePolicy, GetPackagesResponse } from '../../../types'; import { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/index.tsx index 804ce89005f42..c131183f20bdc 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/index.tsx @@ -6,7 +6,9 @@ */ import React, { memo } from 'react'; + import { AgentPolicy, PackagePolicy } from '../../../../../types'; + import { NoPackagePolicies } from './no_package_policies'; import { PackagePoliciesTable } from './package_policies_table'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/no_package_policies.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/no_package_policies.tsx index 6c8e9c9536da5..54adbd78ab75a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/no_package_policies.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/no_package_policies.tsx @@ -8,6 +8,7 @@ import React, { memo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButton, EuiEmptyPrompt } from '@elastic/eui'; + import { useCapabilities, useLink } from '../../../../../hooks'; export const NoPackagePolicies = memo<{ policyId: string }>(({ policyId }) => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx index 550a0275f1895..423ea052be41b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx @@ -17,6 +17,7 @@ import { EuiFlexGroup, EuiFlexItem, } from '@elastic/eui'; + import { AgentPolicy, PackagePolicy } from '../../../../../types'; import { PackageIcon, ContextMenuActions } from '../../../../../components'; import { PackagePolicyDeleteProvider, DangerEuiContextMenuItem } from '../../../components'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx index bad504333b9d7..c10c197691390 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx @@ -11,6 +11,7 @@ import styled from 'styled-components'; import { EuiBottomBar, EuiFlexGroup, EuiFlexItem, EuiButtonEmpty, EuiButton } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; + import { AgentPolicy } from '../../../../../types'; import { useLink, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/hooks/use_agent_status.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/hooks/use_agent_status.tsx index 05af605fc3509..8171dc12483a8 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/hooks/use_agent_status.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/hooks/use_agent_status.tsx @@ -6,6 +6,7 @@ */ import React from 'react'; + import { useRequest } from '../../../../hooks'; import { GetAgentStatusResponse } from '../../../../types'; import { agentRouteService } from '../../../../services'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx index ec05aaf0acc28..d365d9407ffc0 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx @@ -22,6 +22,7 @@ import { } from '@elastic/eui'; import { Props as EuiTabProps } from '@elastic/eui/src/components/tabs/tab'; import styled from 'styled-components'; + import { AgentPolicy, AgentPolicyDetailsDeployAgentAction } from '../../../types'; import { PAGE_ROUTING_PATHS } from '../../../constants'; import { @@ -33,11 +34,12 @@ import { } from '../../../hooks'; import { Loading, Error } from '../../../components'; import { WithHeaderLayout } from '../../../layouts'; -import { AgentPolicyRefreshContext, useGetAgentStatus, AgentStatusRefreshContext } from './hooks'; import { LinkedAgentCount, AgentPolicyActionMenu } from '../components'; -import { PackagePoliciesView, SettingsView } from './components'; import { useIntraAppState } from '../../../hooks/use_intra_app_state'; +import { AgentPolicyRefreshContext, useGetAgentStatus, AgentStatusRefreshContext } from './hooks'; +import { PackagePoliciesView, SettingsView } from './components'; + const Divider = styled.div` width: 0; height: 100%; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx index b0f2232cf5067..05ad1848a0bf5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx @@ -17,6 +17,7 @@ import { EuiFlexItem, EuiSpacer, } from '@elastic/eui'; + import { AgentPolicy, PackageInfo, UpdatePackagePolicy } from '../../../types'; import { useLink, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/index.tsx index 4b3a873e9b5fd..345a4b4afa935 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/index.tsx @@ -7,8 +7,10 @@ import React from 'react'; import { HashRouter as Router, Switch, Route } from 'react-router-dom'; + import { PAGE_ROUTING_PATHS } from '../../constants'; import { useBreadcrumbs } from '../../hooks'; + import { AgentPolicyListPage } from './list_page'; import { AgentPolicyDetailsPage } from './details_page'; import { CreatePackagePolicyPage } from './create_package_policy_page'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/list_page/components/create_agent_policy.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/list_page/components/create_agent_policy.tsx index 35c75796633cf..3e103775ae494 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/list_page/components/create_agent_policy.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/list_page/components/create_agent_policy.tsx @@ -23,6 +23,7 @@ import { EuiFlyoutProps, EuiSpacer, } from '@elastic/eui'; + import { dataTypes } from '../../../../../../../common'; import { NewAgentPolicy, AgentPolicy } from '../../../../types'; import { useCapabilities, useStartServices, sendCreateAgentPolicy } from '../../../../hooks'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/list_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/list_page/index.tsx index dd1375ea3b30f..795c1934c3361 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/list_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/list_page/index.tsx @@ -23,6 +23,7 @@ import { CriteriaWithPagination } from '@elastic/eui/src/components/basic_table/ import { i18n } from '@kbn/i18n'; import { FormattedMessage, FormattedDate } from '@kbn/i18n/react'; import { useHistory } from 'react-router-dom'; + import { AgentPolicy } from '../../../types'; import { AGENT_POLICY_SAVED_OBJECT_TYPE } from '../../../constants'; import { WithHeaderLayout } from '../../../layouts'; @@ -38,6 +39,7 @@ import { } from '../../../hooks'; import { LinkAndRevision, SearchBar } from '../../../components'; import { LinkedAgentCount, AgentPolicyActionMenu } from '../components'; + import { CreateAgentPolicyFlyout } from './components'; const AgentPolicyListPageLayout: React.FunctionComponent = ({ children }) => ( diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/actions_menu.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/actions_menu.tsx index 93646e79589aa..887e91e1c375d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/actions_menu.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/actions_menu.tsx @@ -8,6 +8,7 @@ import React, { memo, useState, useMemo } from 'react'; import { EuiPortal, EuiContextMenuItem } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; + import { Agent } from '../../../../types'; import { useCapabilities, useKibanaVersion } from '../../../../hooks'; import { ContextMenuActions } from '../../../../components'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_integrations.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_integrations.tsx index d71fb8be5f9cf..bbd47b9afb8c9 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_integrations.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_integrations.tsx @@ -20,9 +20,11 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import styled from 'styled-components'; + import { Agent, AgentPolicy, PackagePolicy, PackagePolicyInput } from '../../../../../types'; import { useLink } from '../../../../../hooks'; import { PackageIcon } from '../../../../../components'; + import { displayInputType, getLogsQueryByInputType } from './input_type_utils'; const StyledEuiAccordion = styled(EuiAccordion)` diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx index a992c1a274063..28d7b026eb737 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx @@ -19,6 +19,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; + import { Agent, AgentPolicy } from '../../../../../types'; import { useKibanaVersion, useLink } from '../../../../../hooks'; import { isAgentUpgradeable } from '../../../../../services'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/index.tsx index 059e4ef405daa..656bb8509aa30 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/index.tsx @@ -9,7 +9,9 @@ import React, { memo } from 'react'; import styled from 'styled-components'; import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; + import { Agent, AgentPolicy } from '../../../../../types'; + import { AgentDetailsOverviewSection } from './agent_details_overview'; import { AgentDetailsIntegrationsSection } from './agent_details_integrations'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/input_type_utils.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/input_type_utils.ts index 012fc863e4607..dd1197a8ee2d7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/input_type_utils.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/input_type_utils.ts @@ -6,6 +6,7 @@ */ import { i18n } from '@kbn/i18n'; + import { STATE_DATASET_FIELD, AGENT_DATASET_FILEBEAT, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/agent_logs.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/agent_logs.tsx index fafe389d07b82..ed2ae773bbb7e 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/agent_logs.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/agent_logs.tsx @@ -5,9 +5,10 @@ * 2.0. */ +import url from 'url'; + import React, { memo, useMemo, useState, useCallback, useEffect } from 'react'; import styled from 'styled-components'; -import url from 'url'; import { encode } from 'rison-node'; import { stringify } from 'query-string'; import { @@ -24,12 +25,14 @@ import useMeasure from 'react-use/lib/useMeasure'; import { FormattedMessage } from '@kbn/i18n/react'; import semverGte from 'semver/functions/gte'; import semverCoerce from 'semver/functions/coerce'; + import { createStateContainerReactHelpers } from '../../../../../../../../../../../src/plugins/kibana_utils/public'; import { RedirectAppLinks } from '../../../../../../../../../../../src/plugins/kibana_react/public'; import { TimeRange, esKuery } from '../../../../../../../../../../../src/plugins/data/public'; import { LogStream } from '../../../../../../../../../infra/public'; import { Agent } from '../../../../../types'; import { useStartServices } from '../../../../../hooks'; + import { DEFAULT_DATE_RANGE } from './constants'; import { DatasetFilter } from './filter_dataset'; import { LogLevelFilter } from './filter_log_level'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_dataset.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_dataset.tsx index ba1475cfe1cd9..47174561230ba 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_dataset.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_dataset.tsx @@ -8,7 +8,9 @@ import React, { memo, useState, useEffect } from 'react'; import { EuiPopover, EuiFilterButton, EuiFilterSelectItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; + import { useStartServices } from '../../../../../hooks'; + import { AGENT_LOG_INDEX_PATTERN, DATASET_FIELD, AGENT_DATASET } from './constants'; export const DatasetFilter: React.FunctionComponent<{ diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx index a88b7dd2b2a15..120f21fe68207 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/filter_log_level.tsx @@ -8,9 +8,11 @@ import React, { memo, useState, useEffect } from 'react'; import { EuiPopover, EuiFilterButton, EuiFilterSelectItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { ORDERED_FILTER_LOG_LEVELS, AGENT_LOG_INDEX_PATTERN, LOG_LEVEL_FIELD } from './constants'; + import { useStartServices } from '../../../../../hooks'; +import { ORDERED_FILTER_LOG_LEVELS, AGENT_LOG_INDEX_PATTERN, LOG_LEVEL_FIELD } from './constants'; + function sortLogLevels(levels: string[]): string[] { return [ ...new Set([ diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/index.tsx index 2c327c8c7c6df..7e37e5fb49cb3 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/index.tsx @@ -6,6 +6,7 @@ */ import React, { memo, useEffect, useState, useMemo } from 'react'; + import { createStateContainer, syncState, @@ -14,6 +15,7 @@ import { PureTransition, getStateFromKbnUrl, } from '../../../../../../../../../../../src/plugins/kibana_utils/public'; + import { DEFAULT_LOGS_STATE, STATE_STORAGE_KEY } from './constants'; import { AgentLogsUI, AgentLogsProps, AgentLogsState, AgentLogsUrlStateHelper } from './agent_logs'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/query_bar.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/query_bar.tsx index 17b77d0935b31..776c866e22f4b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/query_bar.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/query_bar.tsx @@ -7,11 +7,13 @@ import React, { memo, useState, useEffect } from 'react'; import { i18n } from '@kbn/i18n'; + import { QueryStringInput, IFieldType, } from '../../../../../../../../../../../src/plugins/data/public'; import { useStartServices } from '../../../../../hooks'; + import { AGENT_LOG_INDEX_PATTERN, AGENT_ID_FIELD, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx index 123fe2cf1df29..d4ea76605b777 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/select_log_level.tsx @@ -9,8 +9,10 @@ import React, { memo, useState, useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiSelect, EuiFormLabel, EuiButtonEmpty, EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; + import { Agent } from '../../../../../types'; import { sendPostAgentAction, useStartServices } from '../../../../../hooks'; + import { AGENT_LOG_LEVELS, DEFAULT_LOG_LEVEL } from './constants'; const LEVEL_VALUES = Object.values(AGENT_LOG_LEVELS); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx index e8f6ca92db272..dc1e25401bf18 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx @@ -21,6 +21,7 @@ import { Props as EuiTabProps } from '@elastic/eui/src/components/tabs/tab'; import { FormattedMessage, FormattedRelative } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { EuiIconTip } from '@elastic/eui'; + import { Agent, AgentPolicy, AgentDetailsReassignPolicyAction } from '../../../types'; import { PAGE_ROUTING_PATHS } from '../../../constants'; import { Loading, Error } from '../../../components'; @@ -34,11 +35,12 @@ import { } from '../../../hooks'; import { WithHeaderLayout } from '../../../layouts'; import { AgentHealth } from '../components'; -import { AgentRefreshContext } from './hooks'; -import { AgentLogs, AgentDetailsActionMenu, AgentDetailsContent } from './components'; import { useIntraAppState } from '../../../hooks/use_intra_app_state'; import { isAgentUpgradeable } from '../../../services'; +import { AgentRefreshContext } from './hooks'; +import { AgentLogs, AgentDetailsActionMenu, AgentDetailsContent } from './components'; + export const AgentDetailsPage: React.FunctionComponent = () => { const { params: { agentId, tabId = '' }, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/bulk_actions.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/bulk_actions.tsx index fecbe7d00368a..1fe611dd97fcf 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/bulk_actions.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/bulk_actions.tsx @@ -18,6 +18,7 @@ import { EuiPortal, } from '@elastic/eui'; import { FormattedMessage, FormattedNumber } from '@kbn/i18n/react'; + import { SO_SEARCH_LIMIT } from '../../../../constants'; import { Agent } from '../../../../types'; import { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/search_and_filter_bar.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/search_and_filter_bar.tsx index af990a36a7415..982194f52ddac 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/search_and_filter_bar.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/search_and_filter_bar.tsx @@ -16,6 +16,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; + import { AgentPolicy } from '../../../../types'; import { SearchBar } from '../../../../components'; import { AGENTS_INDEX, AGENT_SAVED_OBJECT_TYPE } from '../../../../constants'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/status_badges.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/status_badges.tsx index 66911b61c713c..755d895d3b768 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/status_badges.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/status_badges.tsx @@ -7,6 +7,7 @@ import { EuiFlexGroup, EuiHealth, EuiNotificationBadge, EuiFlexItem } from '@elastic/eui'; import React, { memo, useMemo } from 'react'; + import { AGENT_STATUSES, getColorForAgentStatus, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/status_bar.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/status_bar.tsx index f28a59093ab00..64bf580f15b5a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/status_bar.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/status_bar.tsx @@ -8,6 +8,7 @@ import styled from 'styled-components'; import { EuiColorPaletteDisplay } from '@elastic/eui'; import React, { useMemo } from 'react'; + import { AGENT_STATUSES, getColorForAgentStatus } from '../../services/agent_status'; import { SimplifiedAgentStatus } from '../../../../types'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/table_header.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/table_header.tsx index 6d20486e145c3..9d3fb45ff2ff8 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/table_header.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/table_header.tsx @@ -7,6 +7,7 @@ import React from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; + import { Agent, SimplifiedAgentStatus } from '../../../../types'; import { AgentStatusBar } from './status_bar'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx index 80191fbb0a370..a66105a15f17c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx @@ -21,6 +21,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage, FormattedRelative } from '@kbn/i18n/react'; + import { AgentEnrollmentFlyout } from '../components'; import { Agent, AgentPolicy, SimplifiedAgentStatus } from '../../../types'; import { @@ -45,6 +46,7 @@ import { AgentUnenrollAgentModal, AgentUpgradeAgentModal, } from '../components'; + import { AgentTableHeader } from './components/table_header'; import { SelectionMode } from './components/bulk_actions'; import { SearchAndFilterBar } from './components/search_and_filter_bar'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/agent_policy_selection.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/agent_policy_selection.tsx index 3c2c2940a2233..09d66b9b7cfad 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/agent_policy_selection.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/agent_policy_selection.tsx @@ -9,6 +9,7 @@ import React, { useState, useEffect } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiSelect, EuiSpacer, EuiText, EuiButtonEmpty } from '@elastic/eui'; + import { SO_SEARCH_LIMIT } from '../../../../constants'; import { AgentPolicy, GetEnrollmentAPIKeysResponse } from '../../../../types'; import { sendGetEnrollmentAPIKeys, useStartServices } from '../../../../hooks'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/index.tsx index ce8e3b1e514c6..e013e35488161 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/index.tsx @@ -22,7 +22,9 @@ import { EuiTabs, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; + import { AgentPolicy } from '../../../../types'; + import { ManagedInstructions } from './managed_instructions'; import { StandaloneInstructions } from './standalone_instructions'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/managed_instructions.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/managed_instructions.tsx index 73e82461c04a6..5a22a47c2593c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/managed_instructions.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/managed_instructions.tsx @@ -10,6 +10,7 @@ import { EuiSteps, EuiLink, EuiText, EuiSpacer } from '@elastic/eui'; import { EuiContainedStepProps } from '@elastic/eui/src/components/steps/steps'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; + import { AgentPolicy } from '../../../../types'; import { useGetOneEnrollmentAPIKey, @@ -19,6 +20,7 @@ import { useFleetStatus, } from '../../../../hooks'; import { ManualInstructions } from '../../../../components/enrollment_instructions'; + import { DownloadStep, AgentPolicySelectionStep } from './steps'; interface Props { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/standalone_instructions.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/standalone_instructions.tsx index f70dc491f2000..6e4f4168a64c5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/standalone_instructions.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/standalone_instructions.tsx @@ -21,11 +21,13 @@ import { import { EuiContainedStepProps } from '@elastic/eui/src/components/steps/steps'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; + import { AgentPolicy } from '../../../../types'; import { useStartServices, useLink, sendGetOneAgentPolicyFull } from '../../../../hooks'; -import { DownloadStep, AgentPolicySelectionStep } from './steps'; import { fullAgentPolicyToYaml, agentPolicyRouteService } from '../../../../services'; +import { DownloadStep, AgentPolicySelectionStep } from './steps'; + interface Props { agentPolicies?: AgentPolicy[]; } diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/steps.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/steps.tsx index ad444bf18c496..8ea2259ca80c3 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/steps.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/steps.tsx @@ -9,9 +9,11 @@ import React from 'react'; import { EuiText, EuiButton, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -import { EnrollmentStepAgentPolicy } from './agent_policy_selection'; + import { AgentPolicy } from '../../../../types'; +import { EnrollmentStepAgentPolicy } from './agent_policy_selection'; + export const DownloadStep = () => { return { title: i18n.translate('xpack.fleet.agentEnrollment.stepDownloadAgentTitle', { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_health.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_health.tsx index 6fc801a6419ac..26ad0550ae71f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_health.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_health.tsx @@ -8,6 +8,7 @@ import React from 'react'; import { FormattedMessage, FormattedRelative } from '@kbn/i18n/react'; import { EuiBadge, EuiToolTip } from '@elastic/eui'; + import { Agent } from '../../../types'; interface Props { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx index ec770305c1f03..e7868e4b6fe10 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx @@ -8,6 +8,7 @@ import React, { useMemo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiSpacer, EuiText, EuiFlexGroup, EuiFlexItem, EuiBadge } from '@elastic/eui'; + import { PackagePolicy, PackagePolicyPackage } from '../../../types'; import { useGetOneAgentPolicy } from '../../../hooks'; import { PackageIcon } from '../../../components/package_icon'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_reassign_policy_flyout/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_reassign_policy_flyout/index.tsx index e97298f7063b3..265adc29164c5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_reassign_policy_flyout/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_reassign_policy_flyout/index.tsx @@ -23,6 +23,7 @@ import { EuiText, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; + import { Agent } from '../../../../types'; import { sendPutAgentReassign, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_unenroll_modal/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_unenroll_modal/index.tsx index a50cc18d46f55..fe550123fec2a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_unenroll_modal/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_unenroll_modal/index.tsx @@ -9,6 +9,7 @@ import React, { useState } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiConfirmModal, EuiFormFieldset, EuiCheckbox } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; + import { Agent } from '../../../../types'; import { sendPostAgentUnenroll, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_upgrade_modal/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_upgrade_modal/index.tsx index 57f4007a00274..90c291f249ef5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_upgrade_modal/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_upgrade_modal/index.tsx @@ -9,6 +9,7 @@ import React, { useState } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiConfirmModal, EuiBetaBadge, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; + import { Agent } from '../../../../types'; import { sendPostAgentUpgrade, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/list_layout.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/list_layout.tsx index b82dcb9bbf1c4..6c79ab6657fa7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/list_layout.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/list_layout.tsx @@ -10,6 +10,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { EuiText, EuiFlexGroup, EuiFlexItem, EuiButton, EuiPortal } from '@elastic/eui'; import { Props as EuiTabProps } from '@elastic/eui/src/components/tabs/tab'; import { useRouteMatch } from 'react-router-dom'; + import { PAGE_ROUTING_PATHS } from '../../../constants'; import { WithHeaderLayout } from '../../../layouts'; import { useCapabilities, useLink, useGetAgentPolicies } from '../../../hooks'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/components/confirm_delete_modal.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/components/confirm_delete_modal.tsx index 565657c70e17f..41dab3d6479e0 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/components/confirm_delete_modal.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/components/confirm_delete_modal.tsx @@ -8,6 +8,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiConfirmModal, EuiCallOut } from '@elastic/eui'; + import { EnrollmentAPIKey } from '../../../../types'; interface Props { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/components/new_enrollment_key_flyout.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/components/new_enrollment_key_flyout.tsx index c5e31187bac02..9644845ca4ff5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/components/new_enrollment_key_flyout.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/components/new_enrollment_key_flyout.tsx @@ -23,6 +23,7 @@ import { EuiSelect, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; + import { AgentPolicy } from '../../../../types'; import { useInput, useStartServices, sendRequest } from '../../../../hooks'; import { enrollmentAPIKeyRouteService } from '../../../../services'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/index.tsx index bab3763ea4f6a..ce4c76141fad0 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/index.tsx @@ -20,6 +20,7 @@ import { HorizontalAlignment, } from '@elastic/eui'; import { FormattedMessage, FormattedDate } from '@kbn/i18n/react'; + import { ENROLLMENT_API_KEYS_INDEX, ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, @@ -36,6 +37,7 @@ import { } from '../../../hooks'; import { EnrollmentAPIKey } from '../../../types'; import { SearchBar } from '../../../components/search_bar'; + import { NewEnrollmentTokenFlyout } from './components/new_enrollment_key_flyout'; import { ConfirmEnrollmentTokenDelete } from './components/confirm_delete_modal'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/index.tsx index 95f1136880a1c..7888b29223d50 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/index.tsx @@ -8,16 +8,18 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom'; + import { PAGE_ROUTING_PATHS } from '../../constants'; import { Loading, Error } from '../../components'; import { useConfig, useFleetStatus, useBreadcrumbs, useCapabilities } from '../../hooks'; +import { WithoutHeaderLayout } from '../../layouts'; + import { AgentListPage } from './agent_list_page'; import { SetupPage } from './setup_page'; import { AgentDetailsPage } from './agent_details_page'; import { NoAccessPage } from './error_pages/no_access'; import { EnrollmentTokenListPage } from './enrollment_token_list_page'; import { ListLayout } from './components/list_layout'; -import { WithoutHeaderLayout } from '../../layouts'; export const FleetApp: React.FunctionComponent = () => { useBreadcrumbs('fleet'); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/services/agent_status.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/services/agent_status.tsx index 1cd63f74bdc40..301dd565f94c3 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/services/agent_status.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/services/agent_status.tsx @@ -7,6 +7,7 @@ import { euiPaletteColorBlindBehindText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; + import { SimplifiedAgentStatus } from '../../../types'; const visColors = euiPaletteColorBlindBehindText(); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/setup_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/setup_page/index.tsx index e5dbaaef66f89..860e081748f56 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/setup_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/setup_page/index.tsx @@ -24,6 +24,7 @@ import { EuiCodeBlock, EuiLink, } from '@elastic/eui'; + import { useStartServices, sendPostFleetSetup } from '../../../hooks'; import { WithoutHeaderLayout } from '../../../layouts'; import { GetFleetStatusResponse } from '../../../types'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/index.tsx index 25e92159ae182..fb6078ce73b70 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/index.tsx @@ -7,7 +7,9 @@ import React from 'react'; import { HashRouter as Router, Route, Switch } from 'react-router-dom'; + import { PAGE_ROUTING_PATHS } from '../../constants'; + import { DataStreamListPage } from './list_page'; export const DataStreamApp: React.FunctionComponent = () => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/components/data_stream_row_actions.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/components/data_stream_row_actions.tsx index 5ce46904bfb02..0516a0a8829af 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/components/data_stream_row_actions.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/components/data_stream_row_actions.tsx @@ -8,6 +8,7 @@ import React, { memo } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; + import { DataStream } from '../../../../types'; import { useKibanaLink } from '../../../../hooks'; import { ContextMenuActions } from '../../../../components'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/index.tsx index c5278494bc547..dd525dcaf795b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/index.tsx @@ -19,10 +19,12 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage, FormattedDate } from '@kbn/i18n/react'; + import { DataStream } from '../../../types'; import { WithHeaderLayout } from '../../../layouts'; import { useGetDataStreams, useStartServices, usePagination, useBreadcrumbs } from '../../../hooks'; import { PackageIcon } from '../../../components/package_icon'; + import { DataStreamRowActions } from './components/data_stream_row_actions'; const DataStreamListPageLayout: React.FunctionComponent = ({ children }) => ( diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/assets_facet_group.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/assets_facet_group.tsx index e1c86a8990313..a88c6ceaea0c4 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/assets_facet_group.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/assets_facet_group.tsx @@ -18,6 +18,7 @@ import { } from '@elastic/eui'; import styled from 'styled-components'; import { FormattedMessage } from '@kbn/i18n/react'; + import { AssetsGroupedByServiceByType, AssetTypeToParts, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/icon_panel.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/icon_panel.tsx index 7700c8ed5fdc2..9574ecbcf4e0c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/icon_panel.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/icon_panel.tsx @@ -8,6 +8,7 @@ import React from 'react'; import styled from 'styled-components'; import { EuiIcon, EuiPanel } from '@elastic/eui'; + import { usePackageIconType, UsePackageIconType } from '../../../hooks'; import { Loading } from '../../../components'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_card.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_card.tsx index cac8ff7d5e7a2..43985a9d8efa4 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_card.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_card.tsx @@ -8,9 +8,11 @@ import React from 'react'; import styled from 'styled-components'; import { EuiCard } from '@elastic/eui'; + import { PackageInfo, PackageListItem } from '../../../types'; import { useLink } from '../../../hooks'; import { PackageIcon } from '../../../components/package_icon'; + import { RELEASE_BADGE_LABEL, RELEASE_BADGE_DESCRIPTION } from './release_badge'; type PackageCardProps = PackageListItem | PackageInfo; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_list_grid.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_list_grid.tsx index 7f089430d547c..da8f2c690a010 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_list_grid.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_list_grid.tsx @@ -19,12 +19,14 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; + import { Loading } from '../../../components'; import { PackageList } from '../../../types'; import { useLocalSearch, searchIdField } from '../hooks'; -import { PackageCard } from './package_card'; import { pkgKeyFromPackageInfo } from '../../../services/pkg_key_from_package_info'; +import { PackageCard } from './package_card'; + interface ListProps { isLoading?: boolean; controls?: ReactNode; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/release_badge.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/release_badge.ts index 9e4e51e410e7e..547d920045b90 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/release_badge.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/release_badge.ts @@ -6,6 +6,7 @@ */ import { i18n } from '@kbn/i18n'; + import type { RegistryRelease } from '../../../types'; export const RELEASE_BADGE_LABEL: { [key in Exclude]: string } = { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/requirements.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/requirements.tsx index 244d7d3f97153..3cb0f1e061fa3 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/requirements.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/requirements.tsx @@ -8,8 +8,10 @@ import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiText, EuiTextColor, EuiTitle } from '@elastic/eui'; import React, { Fragment } from 'react'; import styled from 'styled-components'; + import { RequirementsByServiceName, ServiceName, entries } from '../../../types'; import { ServiceTitleMap } from '../constants'; + import { Version } from './version'; export interface RequirementsProps { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/version.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/version.tsx index 332d8345c6251..cde8f1ebebfb5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/version.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/version.tsx @@ -7,6 +7,7 @@ import React from 'react'; import styled from 'styled-components'; + import { RequirementVersion } from '../../../types'; const CodeText = styled.span` diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/constants.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/constants.tsx index 84bca0d2f342a..a50c35765e661 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/constants.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/constants.tsx @@ -6,6 +6,7 @@ */ import { IconType } from '@elastic/eui'; + import { AssetType, ElasticsearchAssetType, KibanaAssetType, ServiceName } from '../../types'; // only allow Kibana assets for the kibana key, ES asssets for elasticsearch, etc diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_local_search.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_local_search.tsx index 5508f94dc730a..9c4839ff859f0 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_local_search.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_local_search.tsx @@ -7,6 +7,7 @@ import { Search as LocalSearch } from 'js-search'; import { useEffect, useRef } from 'react'; + import { PackageList, PackageListItem } from '../../../types'; export type SearchField = keyof PackageListItem; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_package_install.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_package_install.tsx index d3fccb6001733..b5412ce5b57ea 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_package_install.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_package_install.tsx @@ -10,6 +10,7 @@ import React, { useCallback, useState } from 'react'; import { useHistory } from 'react-router-dom'; import { FormattedMessage } from '@kbn/i18n/react'; import { NotificationsStart } from 'src/core/public'; + import { toMountPoint } from '../../../../../../../../../src/plugins/kibana_react/public'; import { PackageInfo } from '../../../types'; import { sendInstallPackage, sendRemovePackage, useLink } from '../../../hooks'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/index.tsx index a02cc852a1d13..cb94ddf3ddf2a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/index.tsx @@ -7,9 +7,11 @@ import React from 'react'; import { Switch, Route } from 'react-router-dom'; + import { PAGE_ROUTING_PATHS } from '../../constants'; import { useBreadcrumbs } from '../../hooks'; import { CreatePackagePolicyPage } from '../agent_policy/create_package_policy_page'; + import { EPMHomePage } from './screens/home'; import { Detail } from './screens/detail'; import { Policy } from './screens/policy'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/icon_panel.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/icon_panel.tsx index b2495b607af59..74d2b2fbc680f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/icon_panel.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/icon_panel.tsx @@ -8,6 +8,7 @@ import React from 'react'; import styled from 'styled-components'; import { EuiIcon, EuiPanel } from '@elastic/eui'; + import { usePackageIconType, UsePackageIconType } from '../../../../../hooks'; import { Loading } from '../../../../../components'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/integration_agent_policy_count.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/integration_agent_policy_count.tsx index eeb74526046e2..26e61d536333b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/integration_agent_policy_count.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/integration_agent_policy_count.tsx @@ -6,6 +6,7 @@ */ import React, { memo } from 'react'; + import { useGetPackageStats } from '../../../../../hooks'; /** diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/custom/custom.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/custom/custom.tsx index f005c1e24dee7..3ea41436c22d8 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/custom/custom.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/custom/custom.tsx @@ -7,6 +7,7 @@ import React, { memo, useMemo } from 'react'; import { Redirect } from 'react-router-dom'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; + import { useUIExtension } from '../../../../../hooks/use_ui_extension'; import { useLink } from '../../../../../hooks'; import { PackageInfo } from '../../../../../types'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.test.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.test.tsx index 32e39d7c4d6ee..e17e9bdfe2ef2 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.test.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.test.tsx @@ -5,11 +5,11 @@ * 2.0. */ -import { createTestRendererMock, MockedFleetStartServices, TestRenderer } from '../../../../mock'; -import { Detail } from './index'; import React, { lazy, memo } from 'react'; -import { PAGE_ROUTING_PATHS, pagePathGetters } from '../../../../constants'; import { Route } from 'react-router-dom'; +import { act, cleanup } from '@testing-library/react'; + +import { PAGE_ROUTING_PATHS, pagePathGetters } from '../../../../constants'; import { GetAgentPoliciesResponse, GetFleetStatusResponse, @@ -24,7 +24,9 @@ import { fleetSetupRouteService, packagePolicyRouteService, } from '../../../../../../../common/services'; -import { act, cleanup } from '@testing-library/react'; +import { createTestRendererMock, MockedFleetStartServices, TestRenderer } from '../../../../mock'; + +import { Detail } from './index'; describe('when on integration detail', () => { const pkgkey = 'nginx-0.3.7'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx index 3cb57b63e707d..2d442744bb138 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx @@ -21,6 +21,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; + import { useUIExtension } from '../../../../hooks/use_ui_extension'; import { PAGE_ROUTING_PATHS, PLUGIN_ID } from '../../../../constants'; import { useCapabilities, useGetPackageInfoByKey, useLink } from '../../../../hooks'; @@ -36,6 +37,7 @@ import { useBreadcrumbs } from '../../../../hooks'; import { WithHeaderLayout, WithHeaderLayoutProps } from '../../../../layouts'; import { RELEASE_BADGE_DESCRIPTION, RELEASE_BADGE_LABEL } from '../../components/release_badge'; import { useSetPackageInstallStatus } from '../../hooks'; + import { IntegrationAgentPolicyCount, UpdateIcon, IconPanel, LoadingIconPanel } from './components'; import { OverviewPage } from './overview'; import { PackagePoliciesPage } from './policies'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/details.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/details.tsx index 3b9daaeb0216e..3d6573feab459 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/details.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/details.tsx @@ -15,6 +15,7 @@ import { EuiNotificationBadge, } from '@elastic/eui'; import { EuiDescriptionListProps } from '@elastic/eui/src/components/description_list/description_list'; + import { PackageInfo, PackageSpecCategory, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/overview.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/overview.tsx index 4e45ecd2f70cb..da8a5133d77e6 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/overview.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/overview.tsx @@ -7,7 +7,9 @@ import React, { memo } from 'react'; import styled from 'styled-components'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; + import { PackageInfo } from '../../../../../types'; + import { Screenshots } from './screenshots'; import { Readme } from './readme'; import { Details } from './details'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/readme.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/readme.tsx index 92022f5e97a60..d92b4ce598fd2 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/readme.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/readme.tsx @@ -8,8 +8,10 @@ import { EuiLoadingContent, EuiText } from '@elastic/eui'; import React, { Fragment, useEffect, useState } from 'react'; import ReactMarkdown from 'react-markdown'; + import { useLinks } from '../../../hooks'; import { sendGetFileByPath } from '../../../../../hooks'; + import { markdownRenderers } from './markdown_renderers'; export function Readme({ diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/screenshots.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/screenshots.tsx index 33b2c3efe2fba..4a278967229ad 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/screenshots.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/screenshots.tsx @@ -8,6 +8,7 @@ import React, { useState, useMemo, memo } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem, EuiImage, EuiText, EuiPagination } from '@elastic/eui'; + import { ScreenshotItem } from '../../../../../types'; import { useLinks } from '../../../hooks'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/package_policies.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/package_policies.tsx index 53cd642a1ef78..1349a48b315ff 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/package_policies.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/package_policies.tsx @@ -17,12 +17,14 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedRelative, FormattedMessage } from '@kbn/i18n/react'; + import { InstallStatus } from '../../../../../types'; import { useLink, useUrlPagination } from '../../../../../hooks'; import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '../../../../../constants'; import { LinkAndRevision, LinkAndRevisionProps } from '../../../../../components'; import { LinkedAgentCount } from '../../../../../components/linked_agent_count'; import { useGetPackageInstallStatus } from '../../../hooks'; + import { PackagePolicyAndAgentPolicy, usePackagePoliciesWithAgentPolicy, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts index 77811a92093ee..f32047860717c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts @@ -6,6 +6,7 @@ */ import { useEffect, useMemo, useState } from 'react'; + import type { PackagePolicy, GetAgentPoliciesResponse, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/installation_button.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/installation_button.tsx index ca37095f5db19..dd71d4090c86b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/installation_button.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/installation_button.tsx @@ -8,9 +8,11 @@ import { EuiButton } from '@elastic/eui'; import React, { Fragment, useCallback, useMemo, useState } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; + import { PackageInfo, InstallStatus } from '../../../../../types'; import { useCapabilities } from '../../../../../hooks'; import { useUninstallPackage, useGetPackageInstallStatus, useInstallPackage } from '../../../hooks'; + import { ConfirmPackageUninstall } from './confirm_package_uninstall'; import { ConfirmPackageInstall } from './confirm_package_install'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx index 2c3559a651307..e69d148f89e0a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx @@ -9,11 +9,13 @@ import React, { memo } from 'react'; import styled from 'styled-components'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiTitle, EuiFlexGroup, EuiFlexItem, EuiText, EuiSpacer } from '@elastic/eui'; + import { InstallStatus, PackageInfo } from '../../../../../types'; import { useGetPackagePolicies } from '../../../../../hooks'; import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '../../../../../constants'; import { useGetPackageInstallStatus } from '../../../hooks'; import { UpdateIcon } from '../components'; + import { InstallationButton } from './installation_button'; const SettingsTitleCell = styled.td` diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/category_facets.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/category_facets.tsx index 6c1333ef1fc17..6a754ca86d7aa 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/category_facets.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/category_facets.tsx @@ -7,6 +7,7 @@ import { EuiFacetButton, EuiFacetGroup } from '@elastic/eui'; import React from 'react'; + import { Loading } from '../../../../components'; import { CategorySummaryItem, CategorySummaryList } from '../../../../types'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/header.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/header.tsx index d2b9a97b5f443..54ee34e9021a5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/header.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/header.tsx @@ -10,6 +10,7 @@ import { i18n } from '@kbn/i18n'; import styled from 'styled-components'; import { EuiFlexGroup, EuiFlexItem, EuiImage, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; + import { useLinks } from '../../hooks'; import { useStartServices } from '../../../../hooks'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/index.tsx index 7f43aaf128d9e..8f43adef71b10 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/index.tsx @@ -9,12 +9,14 @@ import React, { useState } from 'react'; import { useRouteMatch, Switch, Route, useLocation, useHistory } from 'react-router-dom'; import { Props as EuiTabProps } from '@elastic/eui/src/components/tabs/tab'; import { i18n } from '@kbn/i18n'; + import { installationStatuses } from '../../../../../../../common/constants'; import { PAGE_ROUTING_PATHS } from '../../../../constants'; import { useLink, useGetCategories, useGetPackages, useBreadcrumbs } from '../../../../hooks'; import { WithHeaderLayout } from '../../../../layouts'; import { CategorySummaryItem } from '../../../../types'; import { PackageListGrid } from '../../components/package_list_grid'; + import { CategoryFacets } from './category_facets'; import { HeroCopy, HeroImage } from './header'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/policy/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/policy/index.tsx index 0f23ccd82d825..b8963b8e39514 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/policy/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/policy/index.tsx @@ -7,6 +7,7 @@ import React, { memo } from 'react'; import { useRouteMatch } from 'react-router-dom'; + import { EditPackagePolicyForm } from '../../../agent_policy/edit_package_policy_page'; export const Policy = memo(() => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/agent_policy_section.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/agent_policy_section.tsx index c3b59458abf0a..9c3c76efddc1a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/agent_policy_section.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/agent_policy_section.tsx @@ -14,13 +14,15 @@ import { EuiDescriptionListTitle, EuiDescriptionListDescription, } from '@elastic/eui'; -import { OverviewPanel } from './overview_panel'; -import { OverviewStats } from './overview_stats'; + import { SO_SEARCH_LIMIT } from '../../../constants'; import { useLink, useGetPackagePolicies } from '../../../hooks'; import { AgentPolicy } from '../../../types'; import { Loading } from '../../agents/components'; +import { OverviewStats } from './overview_stats'; +import { OverviewPanel } from './overview_panel'; + export const OverviewPolicySection: React.FC<{ agentPolicies: AgentPolicy[] }> = ({ agentPolicies, }) => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/agent_section.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/agent_section.tsx index 487e963c70c2c..d69306969c78c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/agent_section.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/agent_section.tsx @@ -14,11 +14,13 @@ import { EuiDescriptionListDescription, EuiFlexItem, } from '@elastic/eui'; -import { OverviewPanel } from './overview_panel'; -import { OverviewStats } from './overview_stats'; + import { useLink, useGetAgentStatus } from '../../../hooks'; import { Loading } from '../../agents/components'; +import { OverviewPanel } from './overview_panel'; +import { OverviewStats } from './overview_stats'; + export const OverviewAgentSection = () => { const { getHref } = useLink(); const agentStatusRequest = useGetAgentStatus({}); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/datastream_section.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/datastream_section.tsx index ce3a73eb0ccff..b51be3fdd20e5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/datastream_section.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/datastream_section.tsx @@ -14,11 +14,13 @@ import { EuiDescriptionListTitle, EuiDescriptionListDescription, } from '@elastic/eui'; -import { OverviewPanel } from './overview_panel'; -import { OverviewStats } from './overview_stats'; + import { useLink, useGetDataStreams, useStartServices } from '../../../hooks'; import { Loading } from '../../agents/components'; +import { OverviewPanel } from './overview_panel'; +import { OverviewStats } from './overview_stats'; + export const OverviewDatastreamSection: React.FC = () => { const { getHref } = useLink(); const datastreamRequest = useGetDataStreams(); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/integration_section.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/integration_section.tsx index 795b3b374596a..5ada8e298507c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/integration_section.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/integration_section.tsx @@ -14,12 +14,14 @@ import { EuiDescriptionListTitle, EuiDescriptionListDescription, } from '@elastic/eui'; -import { OverviewPanel } from './overview_panel'; -import { OverviewStats } from './overview_stats'; + import { useLink, useGetPackages } from '../../../hooks'; import { Loading } from '../../agents/components'; import { installationStatuses } from '../../../../../../common/constants'; +import { OverviewStats } from './overview_stats'; +import { OverviewPanel } from './overview_panel'; + export const OverviewIntegrationSection: React.FC = () => { const { getHref } = useLink(); const packagesRequest = useGetPackages(); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/index.tsx index 467680e47dda9..9da10c1de2be0 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/index.tsx @@ -17,9 +17,11 @@ import { } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; + import { WithHeaderLayout } from '../../layouts'; import { useGetAgentPolicies, useBreadcrumbs } from '../../hooks'; import { AgentEnrollmentFlyout } from '../agents/components'; + import { OverviewAgentSection } from './components/agent_section'; import { OverviewPolicySection } from './components/agent_policy_section'; import { OverviewIntegrationSection } from './components/integration_section'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/services/ui_extensions.test.ts b/x-pack/plugins/fleet/public/applications/fleet/services/ui_extensions.test.ts index bcddcb4afdbb3..1ca135538d2d2 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/services/ui_extensions.test.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/services/ui_extensions.test.ts @@ -6,11 +6,13 @@ */ import { lazy } from 'react'; + import type { PackagePolicyEditExtensionComponent, UIExtensionRegistrationCallback, UIExtensionsStorage, } from '../types'; + import { createExtensionRegistrationCallback } from './ui_extensions'; describe('UI Extension services', () => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/types/intra_app_route_state.ts b/x-pack/plugins/fleet/public/applications/fleet/types/intra_app_route_state.ts index b118797d7d38e..74921daa0d2a1 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/types/intra_app_route_state.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/types/intra_app_route_state.ts @@ -6,6 +6,7 @@ */ import type { ApplicationStart } from 'kibana/public'; + import type { PackagePolicy } from './'; /** diff --git a/x-pack/plugins/fleet/public/applications/fleet/types/ui_extensions.ts b/x-pack/plugins/fleet/public/applications/fleet/types/ui_extensions.ts index a9cea79ee7d8b..c79b676a26b33 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/types/ui_extensions.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/types/ui_extensions.ts @@ -6,6 +6,7 @@ */ import type { ComponentType, LazyExoticComponent } from 'react'; + import type { NewPackagePolicy, PackageInfo, PackagePolicy } from './index'; /** Register a Fleet UI extension */ diff --git a/x-pack/plugins/fleet/public/index.ts b/x-pack/plugins/fleet/public/index.ts index 3b1136747f343..0304b7b56181c 100644 --- a/x-pack/plugins/fleet/public/index.ts +++ b/x-pack/plugins/fleet/public/index.ts @@ -6,6 +6,7 @@ */ import type { PluginInitializerContext } from 'src/core/public'; + import { FleetPlugin } from './plugin'; export { FleetSetup, FleetStart } from './plugin'; diff --git a/x-pack/plugins/fleet/public/plugin.ts b/x-pack/plugins/fleet/public/plugin.ts index 7f2fd4ee24d4f..071c9eee46617 100644 --- a/x-pack/plugins/fleet/public/plugin.ts +++ b/x-pack/plugins/fleet/public/plugin.ts @@ -13,6 +13,7 @@ import type { CoreStart, } from 'src/core/public'; import { i18n } from '@kbn/i18n'; + import { DEFAULT_APP_CATEGORIES, AppNavLinkStatus } from '../../../../src/core/public'; import type { DataPublicPluginSetup, @@ -24,8 +25,10 @@ import { Storage } from '../../../../src/plugins/kibana_utils/public'; import type { LicensingPluginSetup } from '../../licensing/public'; import { PLUGIN_ID, setupRouteService, appRoutesService } from '../common'; import type { CheckPermissionsResponse, PostIngestSetupResponse } from '../common'; -import { BASE_PATH } from './applications/fleet/constants'; + import type { FleetConfigType } from '../common/types'; + +import { BASE_PATH } from './applications/fleet/constants'; import { licenseService } from './applications/fleet/hooks/use_license'; import { setHttpClient } from './applications/fleet/hooks/use_request/use_request'; import { diff --git a/x-pack/plugins/fleet/scripts/dev_agent/script.ts b/x-pack/plugins/fleet/scripts/dev_agent/script.ts index 87727ef657e5f..e937706080218 100644 --- a/x-pack/plugins/fleet/scripts/dev_agent/script.ts +++ b/x-pack/plugins/fleet/scripts/dev_agent/script.ts @@ -5,9 +5,11 @@ * 2.0. */ +import os from 'os'; + import { createFlagError, run, ToolingLog } from '@kbn/dev-utils'; import fetch from 'node-fetch'; -import os from 'os'; + import type { Agent as _Agent, PostAgentCheckinRequest, diff --git a/x-pack/plugins/fleet/server/collectors/agent_collectors.ts b/x-pack/plugins/fleet/server/collectors/agent_collectors.ts index 9aeae1dba0ea5..b88249fb71d8d 100644 --- a/x-pack/plugins/fleet/server/collectors/agent_collectors.ts +++ b/x-pack/plugins/fleet/server/collectors/agent_collectors.ts @@ -7,6 +7,7 @@ import { SavedObjectsClient } from 'kibana/server'; import type { ElasticsearchClient } from 'kibana/server'; + import { FleetConfigType } from '../../common/types'; import * as AgentService from '../services/agents'; import { isFleetServerSetup } from '../services/fleet_server'; diff --git a/x-pack/plugins/fleet/server/collectors/helpers.ts b/x-pack/plugins/fleet/server/collectors/helpers.ts index 4de2330e70a2c..83970b0aa0d54 100644 --- a/x-pack/plugins/fleet/server/collectors/helpers.ts +++ b/x-pack/plugins/fleet/server/collectors/helpers.ts @@ -6,6 +6,7 @@ */ import type { CoreSetup } from 'kibana/server'; + import { SavedObjectsClient } from '../../../../../src/core/server'; import type { ElasticsearchClient } from '../../../../../src/core/server'; diff --git a/x-pack/plugins/fleet/server/collectors/package_collectors.ts b/x-pack/plugins/fleet/server/collectors/package_collectors.ts index e0f5667fbe458..20370231c7919 100644 --- a/x-pack/plugins/fleet/server/collectors/package_collectors.ts +++ b/x-pack/plugins/fleet/server/collectors/package_collectors.ts @@ -7,6 +7,7 @@ import { SavedObjectsClient } from 'kibana/server'; import _ from 'lodash'; + import { getPackageSavedObjects } from '../services/epm/packages/get'; import { agentPolicyService } from '../services'; import type { NewPackagePolicy } from '../types'; diff --git a/x-pack/plugins/fleet/server/collectors/register.ts b/x-pack/plugins/fleet/server/collectors/register.ts index 30b3ced260172..7992d54d1dfad 100644 --- a/x-pack/plugins/fleet/server/collectors/register.ts +++ b/x-pack/plugins/fleet/server/collectors/register.ts @@ -7,13 +7,15 @@ import type { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import type { CoreSetup } from 'kibana/server'; + +import type { FleetConfigType } from '..'; + import { getIsAgentsEnabled } from './config_collectors'; import { getAgentUsage } from './agent_collectors'; import type { AgentUsage } from './agent_collectors'; import { getInternalClients } from './helpers'; import { getPackageUsage } from './package_collectors'; import type { PackageUsage } from './package_collectors'; -import type { FleetConfigType } from '..'; interface Usage { agents_enabled: boolean; diff --git a/x-pack/plugins/fleet/server/errors/handlers.test.ts b/x-pack/plugins/fleet/server/errors/handlers.test.ts index 2b12d031ba533..dc6f90d64180d 100644 --- a/x-pack/plugins/fleet/server/errors/handlers.test.ts +++ b/x-pack/plugins/fleet/server/errors/handlers.test.ts @@ -8,8 +8,10 @@ import Boom from '@hapi/boom'; import { errors } from 'elasticsearch'; import { httpServerMock } from 'src/core/server/mocks'; + import { createAppContextStartContractMock } from '../mocks'; import { appContextService } from '../services'; + import { IngestManagerError, RegistryError, diff --git a/x-pack/plugins/fleet/server/errors/handlers.ts b/x-pack/plugins/fleet/server/errors/handlers.ts index 2d5339b158d9b..cbb1d9c9ca7f7 100644 --- a/x-pack/plugins/fleet/server/errors/handlers.ts +++ b/x-pack/plugins/fleet/server/errors/handlers.ts @@ -14,7 +14,9 @@ import type { } from 'src/core/server'; import { errors as LegacyESErrors } from 'elasticsearch'; import { ResponseError } from '@elastic/elasticsearch/lib/errors'; + import { appContextService } from '../services'; + import { IngestManagerError, RegistryError, diff --git a/x-pack/plugins/fleet/server/index.ts b/x-pack/plugins/fleet/server/index.ts index cb5eb6413fdf8..6a7d437e05543 100644 --- a/x-pack/plugins/fleet/server/index.ts +++ b/x-pack/plugins/fleet/server/index.ts @@ -8,13 +8,15 @@ import { schema } from '@kbn/config-schema'; import type { TypeOf } from '@kbn/config-schema'; import type { PluginConfigDescriptor, PluginInitializerContext } from 'src/core/server'; -import { FleetPlugin } from './plugin'; + import { AGENT_POLICY_ROLLOUT_RATE_LIMIT_INTERVAL_MS, AGENT_POLICY_ROLLOUT_RATE_LIMIT_REQUEST_PER_INTERVAL, AGENT_POLLING_REQUEST_TIMEOUT_MS, } from '../common'; +import { FleetPlugin } from './plugin'; + export { default as apm } from 'elastic-apm-node'; export { AgentService, diff --git a/x-pack/plugins/fleet/server/mocks.ts b/x-pack/plugins/fleet/server/mocks.ts index 3a7f9ebcc9e53..ea3ba20c59e9c 100644 --- a/x-pack/plugins/fleet/server/mocks.ts +++ b/x-pack/plugins/fleet/server/mocks.ts @@ -10,11 +10,14 @@ import { loggingSystemMock, savedObjectsServiceMock, } from 'src/core/server/mocks'; + import { coreMock } from '../../../../src/core/server/mocks'; import { licensingMock } from '../../../plugins/licensing/server/mocks'; -import type { FleetAppContext } from './plugin'; + import { encryptedSavedObjectsMock } from '../../encrypted_saved_objects/server/mocks'; import { securityMock } from '../../security/server/mocks'; + +import type { FleetAppContext } from './plugin'; import type { PackagePolicyServiceInterface } from './services/package_policy'; import type { AgentPolicyServiceInterface, AgentService } from './services'; diff --git a/x-pack/plugins/fleet/server/plugin.ts b/x-pack/plugins/fleet/server/plugin.ts index d4cd39b274f05..581478ee5190a 100644 --- a/x-pack/plugins/fleet/server/plugin.ts +++ b/x-pack/plugins/fleet/server/plugin.ts @@ -21,6 +21,7 @@ import { KibanaRequest, } from 'kibana/server'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; + import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/server'; import { LicensingPluginSetup, ILicense } from '../../licensing/server'; import { @@ -29,6 +30,14 @@ import { } from '../../encrypted_saved_objects/server'; import { SecurityPluginSetup, SecurityPluginStart } from '../../security/server'; import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server'; +import { + EsAssetReference, + FleetConfigType, + NewPackagePolicy, + UpdatePackagePolicy, +} from '../common'; +import { CloudSetup } from '../../cloud/server'; + import { PLUGIN_ID, OUTPUT_SAVED_OBJECT_TYPE, @@ -55,12 +64,6 @@ import { registerSettingsRoutes, registerAppRoutes, } from './routes'; -import { - EsAssetReference, - FleetConfigType, - NewPackagePolicy, - UpdatePackagePolicy, -} from '../common'; import { appContextService, licenseService, @@ -78,7 +81,6 @@ import { listAgents, getAgent, } from './services/agents'; -import { CloudSetup } from '../../cloud/server'; import { agentCheckinState } from './services/agents/checkin/state'; import { registerFleetUsageCollector } from './collectors/register'; import { getInstallation } from './services/epm/packages'; diff --git a/x-pack/plugins/fleet/server/routes/agent/acks_handlers.test.ts b/x-pack/plugins/fleet/server/routes/agent/acks_handlers.test.ts index b1bd10e8a4a77..c4cd58226697c 100644 --- a/x-pack/plugins/fleet/server/routes/agent/acks_handlers.test.ts +++ b/x-pack/plugins/fleet/server/routes/agent/acks_handlers.test.ts @@ -5,13 +5,13 @@ * 2.0. */ -import { postAgentAcksHandlerBuilder } from './acks_handlers'; import type { ElasticsearchClient, KibanaResponseFactory, RequestHandlerContext, SavedObjectsClientContract, } from 'kibana/server'; + import { elasticsearchServiceMock, httpServerMock, @@ -21,6 +21,8 @@ import type { PostAgentAcksResponse } from '../../../common/types/rest_spec'; import { AckEventSchema } from '../../types/models'; import type { AcksService } from '../../services/agents'; +import { postAgentAcksHandlerBuilder } from './acks_handlers'; + describe('test acks schema', () => { it('validate that ack event schema expect action id', async () => { expect(() => diff --git a/x-pack/plugins/fleet/server/routes/agent/acks_handlers.ts b/x-pack/plugins/fleet/server/routes/agent/acks_handlers.ts index e05638b9e6d8e..44c15ecbfa313 100644 --- a/x-pack/plugins/fleet/server/routes/agent/acks_handlers.ts +++ b/x-pack/plugins/fleet/server/routes/agent/acks_handlers.ts @@ -8,6 +8,7 @@ // handlers that handle events from agents in response to actions received import type { RequestHandler } from 'kibana/server'; + import type { AcksService } from '../../services/agents'; import type { AgentEvent } from '../../../common/types/models'; import type { PostAgentAcksRequest, PostAgentAcksResponse } from '../../../common/types/rest_spec'; diff --git a/x-pack/plugins/fleet/server/routes/agent/actions_handlers.test.ts b/x-pack/plugins/fleet/server/routes/agent/actions_handlers.test.ts index 6c12a826a11df..3f300aef692ff 100644 --- a/x-pack/plugins/fleet/server/routes/agent/actions_handlers.test.ts +++ b/x-pack/plugins/fleet/server/routes/agent/actions_handlers.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import { NewAgentActionSchema } from '../../types/models'; import type { ElasticsearchClient, KibanaResponseFactory, @@ -17,14 +16,18 @@ import { savedObjectsClientMock, httpServerMock, } from 'src/core/server/mocks'; + +import { NewAgentActionSchema } from '../../types/models'; import type { ActionsService } from '../../services/agents'; import type { AgentAction } from '../../../common/types/models'; -import { postNewAgentActionHandlerBuilder } from './actions_handlers'; + import type { PostNewAgentActionRequest, PostNewAgentActionResponse, } from '../../../common/types/rest_spec'; +import { postNewAgentActionHandlerBuilder } from './actions_handlers'; + describe('test actions handlers schema', () => { it('validate that new agent actions schema is valid', async () => { expect( diff --git a/x-pack/plugins/fleet/server/routes/agent/actions_handlers.ts b/x-pack/plugins/fleet/server/routes/agent/actions_handlers.ts index 2d5cfa4fd5b4f..c0c9df1d86ede 100644 --- a/x-pack/plugins/fleet/server/routes/agent/actions_handlers.ts +++ b/x-pack/plugins/fleet/server/routes/agent/actions_handlers.ts @@ -9,6 +9,7 @@ import type { RequestHandler } from 'kibana/server'; import type { TypeOf } from '@kbn/config-schema'; + import { PostNewAgentActionRequestSchema } from '../../types/rest_spec'; import type { ActionsService } from '../../services/agents'; import type { PostNewAgentActionResponse } from '../../../common/types/rest_spec'; diff --git a/x-pack/plugins/fleet/server/routes/agent/handlers.ts b/x-pack/plugins/fleet/server/routes/agent/handlers.ts index d5e2df56da601..64d562fa5f7ab 100644 --- a/x-pack/plugins/fleet/server/routes/agent/handlers.ts +++ b/x-pack/plugins/fleet/server/routes/agent/handlers.ts @@ -8,6 +8,7 @@ import type { RequestHandler } from 'src/core/server'; import type { TypeOf } from '@kbn/config-schema'; import { AbortController } from 'abort-controller'; + import type { GetAgentsResponse, GetOneAgentResponse, diff --git a/x-pack/plugins/fleet/server/routes/agent/index.ts b/x-pack/plugins/fleet/server/routes/agent/index.ts index 0b9e180a1cfd8..58bbde95b918b 100644 --- a/x-pack/plugins/fleet/server/routes/agent/index.ts +++ b/x-pack/plugins/fleet/server/routes/agent/index.ts @@ -7,6 +7,7 @@ import type { IRouter, RouteValidationResultFactory } from 'src/core/server'; import Ajv from 'ajv'; + import { PLUGIN_ID, AGENT_API_ROUTES, @@ -34,6 +35,10 @@ import { PostAgentUpgradeRequestSchema, PostBulkAgentUpgradeRequestSchema, } from '../../types'; +import * as AgentService from '../../services/agents'; +import { appContextService } from '../../services'; +import { FleetConfigType } from '../..'; + import { getAgentsHandler, getAgentHandler, @@ -47,11 +52,8 @@ import { postBulkAgentsReassignHandler, } from './handlers'; import { postAgentAcksHandlerBuilder } from './acks_handlers'; -import * as AgentService from '../../services/agents'; import { postNewAgentActionHandlerBuilder } from './actions_handlers'; -import { appContextService } from '../../services'; import { postAgentUnenrollHandler, postBulkAgentsUnenrollHandler } from './unenroll_handler'; -import type { FleetConfigType } from '../..'; import { postAgentUpgradeHandler, postBulkAgentsUpgradeHandler } from './upgrade_handler'; const ajv = new Ajv({ diff --git a/x-pack/plugins/fleet/server/routes/agent/unenroll_handler.ts b/x-pack/plugins/fleet/server/routes/agent/unenroll_handler.ts index 07ca776ef104b..079783cef6d8b 100644 --- a/x-pack/plugins/fleet/server/routes/agent/unenroll_handler.ts +++ b/x-pack/plugins/fleet/server/routes/agent/unenroll_handler.ts @@ -7,6 +7,7 @@ import type { RequestHandler } from 'src/core/server'; import type { TypeOf } from '@kbn/config-schema'; + import type { PostAgentUnenrollResponse, PostBulkAgentUnenrollResponse, diff --git a/x-pack/plugins/fleet/server/routes/agent/upgrade_handler.ts b/x-pack/plugins/fleet/server/routes/agent/upgrade_handler.ts index 4999801c4122a..dda63533d2f4c 100644 --- a/x-pack/plugins/fleet/server/routes/agent/upgrade_handler.ts +++ b/x-pack/plugins/fleet/server/routes/agent/upgrade_handler.ts @@ -8,6 +8,7 @@ import type { RequestHandler } from 'src/core/server'; import type { TypeOf } from '@kbn/config-schema'; import semverCoerce from 'semver/functions/coerce'; + import type { PostAgentUpgradeResponse, PostBulkAgentUpgradeResponse } from '../../../common/types'; import { PostAgentUpgradeRequestSchema, PostBulkAgentUpgradeRequestSchema } from '../../types'; import * as AgentService from '../../services/agents'; diff --git a/x-pack/plugins/fleet/server/routes/agent_policy/handlers.ts b/x-pack/plugins/fleet/server/routes/agent_policy/handlers.ts index a0a30b1c1190b..4a28263bc4fec 100644 --- a/x-pack/plugins/fleet/server/routes/agent_policy/handlers.ts +++ b/x-pack/plugins/fleet/server/routes/agent_policy/handlers.ts @@ -8,6 +8,7 @@ import type { TypeOf } from '@kbn/config-schema'; import type { RequestHandler, ResponseHeaders } from 'src/core/server'; import bluebird from 'bluebird'; + import { fullAgentPolicyToYaml } from '../../../common/services'; import { appContextService, agentPolicyService, packagePolicyService } from '../../services'; import { listAgents } from '../../services/agents'; diff --git a/x-pack/plugins/fleet/server/routes/agent_policy/index.ts b/x-pack/plugins/fleet/server/routes/agent_policy/index.ts index 5cf58414f7992..a66a9ab9cadc7 100644 --- a/x-pack/plugins/fleet/server/routes/agent_policy/index.ts +++ b/x-pack/plugins/fleet/server/routes/agent_policy/index.ts @@ -6,6 +6,7 @@ */ import type { IRouter } from 'src/core/server'; + import { PLUGIN_ID, AGENT_POLICY_API_ROUTES } from '../../constants'; import { GetAgentPoliciesRequestSchema, @@ -16,6 +17,7 @@ import { DeleteAgentPolicyRequestSchema, GetFullAgentPolicyRequestSchema, } from '../../types'; + import { getAgentPoliciesHandler, getOneAgentPolicyHandler, diff --git a/x-pack/plugins/fleet/server/routes/app/index.ts b/x-pack/plugins/fleet/server/routes/app/index.ts index 04c5bf2df47be..ba7c649c4fa54 100644 --- a/x-pack/plugins/fleet/server/routes/app/index.ts +++ b/x-pack/plugins/fleet/server/routes/app/index.ts @@ -6,6 +6,7 @@ */ import type { IRouter, RequestHandler } from 'src/core/server'; + import { APP_API_ROUTES } from '../../constants'; import { appContextService } from '../../services'; import type { CheckPermissionsResponse } from '../../../common'; diff --git a/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts b/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts index 2826840d773e0..3d05cea261f70 100644 --- a/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts +++ b/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts @@ -7,6 +7,7 @@ import { keyBy, keys, merge } from 'lodash'; import type { RequestHandler, SavedObjectsClientContract } from 'src/core/server'; + import type { DataStream } from '../../types'; import { KibanaAssetType, KibanaSavedObjectType } from '../../../common'; import type { GetDataStreamsResponse } from '../../../common'; diff --git a/x-pack/plugins/fleet/server/routes/data_streams/index.ts b/x-pack/plugins/fleet/server/routes/data_streams/index.ts index 05efff12d01da..2c1fa7b2f3b15 100644 --- a/x-pack/plugins/fleet/server/routes/data_streams/index.ts +++ b/x-pack/plugins/fleet/server/routes/data_streams/index.ts @@ -6,7 +6,9 @@ */ import type { IRouter } from 'src/core/server'; + import { PLUGIN_ID, DATA_STREAM_API_ROUTES } from '../../constants'; + import { getListHandler } from './handlers'; export const registerRoutes = (router: IRouter) => { diff --git a/x-pack/plugins/fleet/server/routes/enrollment_api_key/handler.ts b/x-pack/plugins/fleet/server/routes/enrollment_api_key/handler.ts index b41af3b0c770c..bf00676f99dad 100644 --- a/x-pack/plugins/fleet/server/routes/enrollment_api_key/handler.ts +++ b/x-pack/plugins/fleet/server/routes/enrollment_api_key/handler.ts @@ -7,6 +7,7 @@ import type { RequestHandler } from 'src/core/server'; import type { TypeOf } from '@kbn/config-schema'; + import { GetEnrollmentAPIKeysRequestSchema, PostEnrollmentAPIKeyRequestSchema, diff --git a/x-pack/plugins/fleet/server/routes/enrollment_api_key/index.ts b/x-pack/plugins/fleet/server/routes/enrollment_api_key/index.ts index cf736edd4633e..b37a88e70e085 100644 --- a/x-pack/plugins/fleet/server/routes/enrollment_api_key/index.ts +++ b/x-pack/plugins/fleet/server/routes/enrollment_api_key/index.ts @@ -6,6 +6,7 @@ */ import type { IRouter } from 'src/core/server'; + import { PLUGIN_ID, ENROLLMENT_API_KEY_ROUTES } from '../../constants'; import { GetEnrollmentAPIKeysRequestSchema, @@ -13,6 +14,7 @@ import { DeleteEnrollmentAPIKeyRequestSchema, PostEnrollmentAPIKeyRequestSchema, } from '../../types'; + import { getEnrollmentApiKeysHandler, getOneEnrollmentApiKeyHandler, diff --git a/x-pack/plugins/fleet/server/routes/epm/handlers.ts b/x-pack/plugins/fleet/server/routes/epm/handlers.ts index 09a53f2c0d8ff..9d2edb4f0f155 100644 --- a/x-pack/plugins/fleet/server/routes/epm/handlers.ts +++ b/x-pack/plugins/fleet/server/routes/epm/handlers.ts @@ -5,10 +5,12 @@ * 2.0. */ +import path from 'path'; + import type { TypeOf } from '@kbn/config-schema'; import mime from 'mime-types'; -import path from 'path'; import type { RequestHandler, ResponseHeaders, KnownHeaders } from 'src/core/server'; + import type { GetInfoResponse, InstallPackageResponse, diff --git a/x-pack/plugins/fleet/server/routes/epm/index.ts b/x-pack/plugins/fleet/server/routes/epm/index.ts index 9ed4d7e11ad29..40316bd102e5f 100644 --- a/x-pack/plugins/fleet/server/routes/epm/index.ts +++ b/x-pack/plugins/fleet/server/routes/epm/index.ts @@ -6,7 +6,20 @@ */ import type { IRouter } from 'src/core/server'; + import { PLUGIN_ID, EPM_API_ROUTES } from '../../constants'; +import { + GetCategoriesRequestSchema, + GetPackagesRequestSchema, + GetFileRequestSchema, + GetInfoRequestSchema, + InstallPackageFromRegistryRequestSchema, + InstallPackageByUploadRequestSchema, + DeletePackageRequestSchema, + BulkUpgradePackagesFromRegistryRequestSchema, + GetStatsRequestSchema, +} from '../../types'; + import { getCategoriesHandler, getListHandler, @@ -19,17 +32,6 @@ import { bulkInstallPackagesFromRegistryHandler, getStatsHandler, } from './handlers'; -import { - GetCategoriesRequestSchema, - GetPackagesRequestSchema, - GetFileRequestSchema, - GetInfoRequestSchema, - InstallPackageFromRegistryRequestSchema, - InstallPackageByUploadRequestSchema, - DeletePackageRequestSchema, - BulkUpgradePackagesFromRegistryRequestSchema, - GetStatsRequestSchema, -} from '../../types'; const MAX_FILE_SIZE_BYTES = 104857600; // 100MB diff --git a/x-pack/plugins/fleet/server/routes/install_script/index.ts b/x-pack/plugins/fleet/server/routes/install_script/index.ts index 5fb2ea726c62b..c3b3541871d03 100644 --- a/x-pack/plugins/fleet/server/routes/install_script/index.ts +++ b/x-pack/plugins/fleet/server/routes/install_script/index.ts @@ -6,8 +6,10 @@ */ import url from 'url'; + import { BasePath, KibanaRequest } from 'src/core/server'; import type { IRouter } from 'src/core/server'; + import { INSTALL_SCRIPT_API_ROUTES } from '../../constants'; import { getScript } from '../../services/install_script'; import { InstallScriptRequestSchema } from '../../types'; diff --git a/x-pack/plugins/fleet/server/routes/limited_concurrency.test.ts b/x-pack/plugins/fleet/server/routes/limited_concurrency.test.ts index 626df529c1236..c645d8fceaab8 100644 --- a/x-pack/plugins/fleet/server/routes/limited_concurrency.test.ts +++ b/x-pack/plugins/fleet/server/routes/limited_concurrency.test.ts @@ -6,12 +6,14 @@ */ import { coreMock, httpServerMock, httpServiceMock } from 'src/core/server/mocks'; + +import type { FleetConfigType } from '../index'; + import { createLimitedPreAuthHandler, isLimitedRoute, registerLimitedConcurrencyRoutes, } from './limited_concurrency'; -import type { FleetConfigType } from '../index'; describe('registerLimitedConcurrencyRoutes', () => { test(`doesn't call registerOnPreAuth if maxConcurrentConnections is 0`, async () => { diff --git a/x-pack/plugins/fleet/server/routes/limited_concurrency.ts b/x-pack/plugins/fleet/server/routes/limited_concurrency.ts index ae4cab2839c79..78bdc4bb7554c 100644 --- a/x-pack/plugins/fleet/server/routes/limited_concurrency.ts +++ b/x-pack/plugins/fleet/server/routes/limited_concurrency.ts @@ -12,6 +12,7 @@ import type { OnPreAuthToolkit, OnPreAuthHandler, } from 'kibana/server'; + import { LIMITED_CONCURRENCY_ROUTE_TAG } from '../../common'; import type { FleetConfigType } from '../index'; diff --git a/x-pack/plugins/fleet/server/routes/output/handler.ts b/x-pack/plugins/fleet/server/routes/output/handler.ts index a1bbe1112d04b..fe2ee8e9bee18 100644 --- a/x-pack/plugins/fleet/server/routes/output/handler.ts +++ b/x-pack/plugins/fleet/server/routes/output/handler.ts @@ -7,6 +7,7 @@ import type { RequestHandler } from 'src/core/server'; import type { TypeOf } from '@kbn/config-schema'; + import { GetOneOutputRequestSchema, PutOutputRequestSchema } from '../../types'; import type { GetOneOutputResponse, GetOutputsResponse } from '../../../common'; import { outputService } from '../../services/output'; diff --git a/x-pack/plugins/fleet/server/routes/output/index.ts b/x-pack/plugins/fleet/server/routes/output/index.ts index ce4610cf7f85b..5bdbfc7387414 100644 --- a/x-pack/plugins/fleet/server/routes/output/index.ts +++ b/x-pack/plugins/fleet/server/routes/output/index.ts @@ -6,14 +6,16 @@ */ import type { IRouter } from 'src/core/server'; + import { PLUGIN_ID, OUTPUT_API_ROUTES } from '../../constants'; -import { getOneOuputHandler, getOutputsHandler, putOuputHandler } from './handler'; import { GetOneOutputRequestSchema, GetOutputsRequestSchema, PutOutputRequestSchema, } from '../../types'; +import { getOneOuputHandler, getOutputsHandler, putOuputHandler } from './handler'; + export const registerRoutes = (router: IRouter) => { router.get( { diff --git a/x-pack/plugins/fleet/server/routes/package_policy/handlers.test.ts b/x-pack/plugins/fleet/server/routes/package_policy/handlers.test.ts index a94313282a360..865f07c0f9271 100644 --- a/x-pack/plugins/fleet/server/routes/package_policy/handlers.test.ts +++ b/x-pack/plugins/fleet/server/routes/package_policy/handlers.test.ts @@ -8,13 +8,15 @@ import { httpServerMock, httpServiceMock } from 'src/core/server/mocks'; import { KibanaRequest } from 'kibana/server'; import type { IRouter, RequestHandler, RouteConfig } from 'kibana/server'; -import { registerRoutes } from './index'; + import { PACKAGE_POLICY_API_ROUTES } from '../../../common/constants'; import { appContextService, packagePolicyService } from '../../services'; import { createAppContextStartContractMock, xpackMocks } from '../../mocks'; import type { PackagePolicyServiceInterface, ExternalCallback } from '../..'; import { CreatePackagePolicyRequestSchema } from '../../types/rest_spec'; +import { registerRoutes } from './index'; + const packagePolicyServiceMock = packagePolicyService as jest.Mocked; jest.mock('../../services/package_policy', (): { diff --git a/x-pack/plugins/fleet/server/routes/package_policy/handlers.ts b/x-pack/plugins/fleet/server/routes/package_policy/handlers.ts index fb2c853f506c9..d456ef6b525b7 100644 --- a/x-pack/plugins/fleet/server/routes/package_policy/handlers.ts +++ b/x-pack/plugins/fleet/server/routes/package_policy/handlers.ts @@ -7,6 +7,7 @@ import type { TypeOf } from '@kbn/config-schema'; import Boom from '@hapi/boom'; + import { SavedObjectsErrorHelpers } from '../../../../../../src/core/server'; import type { RequestHandler } from '../../../../../../src/core/server'; import { appContextService, packagePolicyService } from '../../services'; diff --git a/x-pack/plugins/fleet/server/routes/package_policy/index.ts b/x-pack/plugins/fleet/server/routes/package_policy/index.ts index 19fc261685ff7..b78771a1f62f7 100644 --- a/x-pack/plugins/fleet/server/routes/package_policy/index.ts +++ b/x-pack/plugins/fleet/server/routes/package_policy/index.ts @@ -6,6 +6,7 @@ */ import type { IRouter } from 'src/core/server'; + import { PLUGIN_ID, PACKAGE_POLICY_API_ROUTES } from '../../constants'; import { GetPackagePoliciesRequestSchema, @@ -14,6 +15,7 @@ import { UpdatePackagePolicyRequestSchema, DeletePackagePoliciesRequestSchema, } from '../../types'; + import { getPackagePoliciesHandler, getOnePackagePolicyHandler, diff --git a/x-pack/plugins/fleet/server/routes/security.ts b/x-pack/plugins/fleet/server/routes/security.ts index 001dbf4b9b2f4..60011dcf3d33f 100644 --- a/x-pack/plugins/fleet/server/routes/security.ts +++ b/x-pack/plugins/fleet/server/routes/security.ts @@ -6,6 +6,7 @@ */ import type { IRouter, RequestHandler } from 'src/core/server'; + import { appContextService } from '../services'; export function enforceSuperUser( diff --git a/x-pack/plugins/fleet/server/routes/settings/index.ts b/x-pack/plugins/fleet/server/routes/settings/index.ts index 2f71e3967c38c..2313f0ee170a0 100644 --- a/x-pack/plugins/fleet/server/routes/settings/index.ts +++ b/x-pack/plugins/fleet/server/routes/settings/index.ts @@ -7,6 +7,7 @@ import type { IRouter, RequestHandler } from 'src/core/server'; import type { TypeOf } from '@kbn/config-schema'; + import { PLUGIN_ID, SETTINGS_API_ROUTES } from '../../constants'; import { PutSettingsRequestSchema, GetSettingsRequestSchema } from '../../types'; import { defaultIngestErrorHandler } from '../../errors'; diff --git a/x-pack/plugins/fleet/server/routes/setup/handlers.test.ts b/x-pack/plugins/fleet/server/routes/setup/handlers.test.ts index 4016e90ea19b3..469b2409f140a 100644 --- a/x-pack/plugins/fleet/server/routes/setup/handlers.test.ts +++ b/x-pack/plugins/fleet/server/routes/setup/handlers.test.ts @@ -6,13 +6,15 @@ */ import { httpServerMock } from 'src/core/server/mocks'; + import type { PostIngestSetupResponse } from '../../../common'; import { RegistryError } from '../../errors'; import { createAppContextStartContractMock, xpackMocks } from '../../mocks'; -import { FleetSetupHandler } from './handlers'; import { appContextService } from '../../services/app_context'; import { setupIngestManager } from '../../services/setup'; +import { FleetSetupHandler } from './handlers'; + jest.mock('../../services/setup', () => { return { setupIngestManager: jest.fn(), diff --git a/x-pack/plugins/fleet/server/routes/setup/handlers.ts b/x-pack/plugins/fleet/server/routes/setup/handlers.ts index 8d4d44276dfc1..0dc3a0109d682 100644 --- a/x-pack/plugins/fleet/server/routes/setup/handlers.ts +++ b/x-pack/plugins/fleet/server/routes/setup/handlers.ts @@ -7,6 +7,7 @@ import type { RequestHandler } from 'src/core/server'; import type { TypeOf } from '@kbn/config-schema'; + import { outputService, appContextService } from '../../services'; import type { GetFleetStatusResponse, PostIngestSetupResponse } from '../../../common'; import { setupIngestManager, setupFleet } from '../../services/setup'; diff --git a/x-pack/plugins/fleet/server/routes/setup/index.ts b/x-pack/plugins/fleet/server/routes/setup/index.ts index 7e07723b4acd8..d8ba6e16e31bb 100644 --- a/x-pack/plugins/fleet/server/routes/setup/index.ts +++ b/x-pack/plugins/fleet/server/routes/setup/index.ts @@ -6,11 +6,13 @@ */ import type { IRouter } from 'src/core/server'; + import { PLUGIN_ID, AGENTS_SETUP_API_ROUTES, SETUP_API_ROUTE } from '../../constants'; import type { FleetConfigType } from '../../../common'; -import { getFleetStatusHandler, createFleetSetupHandler, FleetSetupHandler } from './handlers'; import { PostFleetSetupRequestSchema } from '../../types'; +import { getFleetStatusHandler, createFleetSetupHandler, FleetSetupHandler } from './handlers'; + export const registerFleetSetupRoute = (router: IRouter) => { router.post( { diff --git a/x-pack/plugins/fleet/server/saved_objects/index.ts b/x-pack/plugins/fleet/server/saved_objects/index.ts index e41881c6f8b09..05e8fecdcaad1 100644 --- a/x-pack/plugins/fleet/server/saved_objects/index.ts +++ b/x-pack/plugins/fleet/server/saved_objects/index.ts @@ -6,12 +6,8 @@ */ import type { SavedObjectsServiceSetup, SavedObjectsType } from 'kibana/server'; + import type { EncryptedSavedObjectsPluginSetup } from '../../../encrypted_saved_objects/server'; -import { - migratePackagePolicyToV7110, - migratePackagePolicyToV7120, - // @ts-expect-error -} from './security_solution'; import { OUTPUT_SAVED_OBJECT_TYPE, AGENT_POLICY_SAVED_OBJECT_TYPE, @@ -24,6 +20,12 @@ import { ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, GLOBAL_SETTINGS_SAVED_OBJECT_TYPE, } from '../constants'; + +import { + migratePackagePolicyToV7110, + migratePackagePolicyToV7120, + // @ts-expect-error +} from './security_solution'; import { migrateAgentToV7100, migrateAgentEventToV7100, diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_10_0.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_10_0.ts index 976f02e1f242c..97a5dd6e13eda 100644 --- a/x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_10_0.ts +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_10_0.ts @@ -6,6 +6,7 @@ */ import type { SavedObjectMigrationFn, SavedObjectUnsanitizedDoc } from 'kibana/server'; + import type { EncryptedSavedObjectsPluginSetup } from '../../../../encrypted_saved_objects/server'; import type { Agent, diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_12_0.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_12_0.ts index 15e68ace987b9..94851cc11c72f 100644 --- a/x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_12_0.ts +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_12_0.ts @@ -6,6 +6,7 @@ */ import type { SavedObjectMigrationFn } from 'kibana/server'; + import type { Agent, AgentPolicy } from '../../types'; export const migrateAgentToV7120: SavedObjectMigrationFn = ( diff --git a/x-pack/plugins/fleet/server/services/agent_policy.test.ts b/x-pack/plugins/fleet/server/services/agent_policy.test.ts index 800d4f479bfde..515d2b1195638 100644 --- a/x-pack/plugins/fleet/server/services/agent_policy.test.ts +++ b/x-pack/plugins/fleet/server/services/agent_policy.test.ts @@ -6,9 +6,11 @@ */ import { elasticsearchServiceMock, savedObjectsClientMock } from 'src/core/server/mocks'; + +import type { AgentPolicy, NewAgentPolicy, Output } from '../types'; + import { agentPolicyService } from './agent_policy'; import { agentPolicyUpdateEventHandler } from './agent_policy_update'; -import type { AgentPolicy, NewAgentPolicy, Output } from '../types'; function getSavedObjectMock(agentPolicyAttributes: any) { const mock = savedObjectsClientMock.create(); diff --git a/x-pack/plugins/fleet/server/services/agent_policy.ts b/x-pack/plugins/fleet/server/services/agent_policy.ts index bda754a1800b8..091adda0ed981 100644 --- a/x-pack/plugins/fleet/server/services/agent_policy.ts +++ b/x-pack/plugins/fleet/server/services/agent_policy.ts @@ -13,6 +13,7 @@ import type { SavedObjectsClientContract, SavedObjectsBulkUpdateResponse, } from 'src/core/server'; + import type { AuthenticatedUser } from '../../../security/server'; import { DEFAULT_AGENT_POLICY, @@ -40,13 +41,14 @@ import { AgentPolicyDeletionError, IngestManagerError, } from '../errors'; +import { getFullAgentPolicyKibanaConfig } from '../../common/services/full_agent_policy_kibana_config'; + import { createAgentPolicyAction, listAgents } from './agents'; import { packagePolicyService } from './package_policy'; import { outputService } from './output'; import { agentPolicyUpdateEventHandler } from './agent_policy_update'; import { getSettings } from './settings'; import { normalizeKuery, escapeSearchQueryPhrase } from './saved_object'; -import { getFullAgentPolicyKibanaConfig } from '../../common/services/full_agent_policy_kibana_config'; import { isAgentsSetup } from './agents/setup'; import { appContextService } from './app_context'; diff --git a/x-pack/plugins/fleet/server/services/agent_policy_update.ts b/x-pack/plugins/fleet/server/services/agent_policy_update.ts index b6acafc667c9b..a7ac7ce0ab659 100644 --- a/x-pack/plugins/fleet/server/services/agent_policy_update.ts +++ b/x-pack/plugins/fleet/server/services/agent_policy_update.ts @@ -7,6 +7,7 @@ import { KibanaRequest } from 'src/core/server'; import type { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; + import { generateEnrollmentAPIKey, deleteEnrollmentApiKeyForAgentPolicyId } from './api_keys'; import { isAgentsSetup, unenrollForAgentPolicyId } from './agents'; import { agentPolicyService } from './agent_policy'; diff --git a/x-pack/plugins/fleet/server/services/agents/acks.test.ts b/x-pack/plugins/fleet/server/services/agents/acks.test.ts index 1a4b89a9b2a94..139ba8ffc4329 100644 --- a/x-pack/plugins/fleet/server/services/agents/acks.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/acks.test.ts @@ -8,6 +8,7 @@ import Boom from '@hapi/boom'; import type { SavedObjectsBulkResponse } from 'kibana/server'; import { elasticsearchServiceMock, savedObjectsClientMock } from 'src/core/server/mocks'; + import type { Agent, AgentActionSOAttributes, @@ -15,6 +16,7 @@ import type { AgentEvent, } from '../../../common/types/models'; import { AGENT_TYPE_PERMANENT, AGENT_ACTION_SAVED_OBJECT_TYPE } from '../../../common/constants'; + import { acknowledgeAgentActions } from './acks'; describe('test agent acks services', () => { diff --git a/x-pack/plugins/fleet/server/services/agents/acks.ts b/x-pack/plugins/fleet/server/services/agents/acks.ts index 0fecc18f7a622..6683ba44b77c0 100644 --- a/x-pack/plugins/fleet/server/services/agents/acks.ts +++ b/x-pack/plugins/fleet/server/services/agents/acks.ts @@ -14,6 +14,7 @@ import type { } from 'src/core/server'; import Boom from '@hapi/boom'; import LRU from 'lru-cache'; + import type { Agent, AgentAction, @@ -25,6 +26,7 @@ import type { AgentActionSOAttributes, } from '../../types'; import { AGENT_EVENT_SAVED_OBJECT_TYPE, AGENT_ACTION_SAVED_OBJECT_TYPE } from '../../constants'; + import { getAgentActionByIds } from './actions'; import { forceUnenrollAgent } from './unenroll'; import { ackAgentUpgraded } from './upgrade'; diff --git a/x-pack/plugins/fleet/server/services/agents/actions.test.ts b/x-pack/plugins/fleet/server/services/agents/actions.test.ts index 18e954d4aa9bd..1af6173f938d6 100644 --- a/x-pack/plugins/fleet/server/services/agents/actions.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/actions.test.ts @@ -5,11 +5,14 @@ * 2.0. */ -import { createAgentAction } from './actions'; import type { SavedObject } from 'kibana/server'; -import type { AgentAction } from '../../../common/types/models'; + import { savedObjectsClientMock, elasticsearchServiceMock } from 'src/core/server/mocks'; +import type { AgentAction } from '../../../common/types/models'; + +import { createAgentAction } from './actions'; + describe('test agent actions services', () => { it('should create a new action', async () => { const mockSavedObjectsClient = savedObjectsClientMock.create(); diff --git a/x-pack/plugins/fleet/server/services/agents/actions.ts b/x-pack/plugins/fleet/server/services/agents/actions.ts index 58d52f408f1fb..299bc70d86995 100644 --- a/x-pack/plugins/fleet/server/services/agents/actions.ts +++ b/x-pack/plugins/fleet/server/services/agents/actions.ts @@ -6,6 +6,7 @@ */ import type { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; + import type { Agent, AgentAction, @@ -16,13 +17,14 @@ import type { FleetServerAgentAction, } from '../../../common/types/models'; import { AGENT_ACTION_SAVED_OBJECT_TYPE, AGENT_ACTIONS_INDEX } from '../../../common/constants'; +import { appContextService } from '../app_context'; +import { nodeTypes } from '../../../../../../src/plugins/data/common'; + import { isAgentActionSavedObject, isPolicyActionSavedObject, savedObjectToAgentAction, } from './saved_objects'; -import { appContextService } from '../app_context'; -import { nodeTypes } from '../../../../../../src/plugins/data/common'; const ONE_MONTH_IN_MS = 2592000000; diff --git a/x-pack/plugins/fleet/server/services/agents/authenticate.ts b/x-pack/plugins/fleet/server/services/agents/authenticate.ts index 10469fcb3a013..54ee6f35b2e1b 100644 --- a/x-pack/plugins/fleet/server/services/agents/authenticate.ts +++ b/x-pack/plugins/fleet/server/services/agents/authenticate.ts @@ -8,8 +8,10 @@ import Boom from '@hapi/boom'; import { KibanaRequest } from 'src/core/server'; import type { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server'; + import type { Agent } from '../../types'; import * as APIKeyService from '../api_keys'; + import { getAgentByAccessAPIKeyId } from './crud'; export async function authenticateAgentWithAccessToken( diff --git a/x-pack/plugins/fleet/server/services/agents/checkin/index.ts b/x-pack/plugins/fleet/server/services/agents/checkin/index.ts index 925006f9e67b3..c8bf79e08ab07 100644 --- a/x-pack/plugins/fleet/server/services/agents/checkin/index.ts +++ b/x-pack/plugins/fleet/server/services/agents/checkin/index.ts @@ -11,6 +11,7 @@ import type { SavedObjectsClientContract, SavedObjectsBulkCreateObject, } from 'src/core/server'; + import type { Agent, NewAgentEvent, @@ -19,10 +20,11 @@ import type { AgentEventSOAttributes, } from '../../../types'; import { AGENT_EVENT_SAVED_OBJECT_TYPE } from '../../../constants'; -import { agentCheckinState } from './state'; import { getAgentActionsForCheckin } from '../actions'; import { updateAgent } from '../crud'; +import { agentCheckinState } from './state'; + export async function agentCheckin( soClient: SavedObjectsClientContract, esClient: ElasticsearchClient, diff --git a/x-pack/plugins/fleet/server/services/agents/checkin/rxjs_utils.test.ts b/x-pack/plugins/fleet/server/services/agents/checkin/rxjs_utils.test.ts index 5386277dc0d1f..18f788b087250 100644 --- a/x-pack/plugins/fleet/server/services/agents/checkin/rxjs_utils.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/checkin/rxjs_utils.test.ts @@ -6,6 +6,7 @@ */ import { TestScheduler } from 'rxjs/testing'; + import { createRateLimiter } from './rxjs_utils'; describe('createRateLimiter', () => { diff --git a/x-pack/plugins/fleet/server/services/agents/checkin/state.ts b/x-pack/plugins/fleet/server/services/agents/checkin/state.ts index de965646a59c3..c48e0380da2c4 100644 --- a/x-pack/plugins/fleet/server/services/agents/checkin/state.ts +++ b/x-pack/plugins/fleet/server/services/agents/checkin/state.ts @@ -6,11 +6,13 @@ */ import type { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; + import type { Agent } from '../../../types'; import { appContextService } from '../../app_context'; +import { AGENT_UPDATE_LAST_CHECKIN_INTERVAL_MS } from '../../../constants'; + import { agentCheckinStateConnectedAgentsFactory } from './state_connected_agents'; import { agentCheckinStateNewActionsFactory } from './state_new_actions'; -import { AGENT_UPDATE_LAST_CHECKIN_INTERVAL_MS } from '../../../constants'; function agentCheckinStateFactory() { const agentConnected = agentCheckinStateConnectedAgentsFactory(); diff --git a/x-pack/plugins/fleet/server/services/agents/checkin/state_connected_agents.ts b/x-pack/plugins/fleet/server/services/agents/checkin/state_connected_agents.ts index 6156212a63203..24769de2c717f 100644 --- a/x-pack/plugins/fleet/server/services/agents/checkin/state_connected_agents.ts +++ b/x-pack/plugins/fleet/server/services/agents/checkin/state_connected_agents.ts @@ -6,6 +6,7 @@ */ import { KibanaRequest } from 'src/core/server'; + import { appContextService } from '../../app_context'; import { bulkUpdateAgents } from '../crud'; diff --git a/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.test.ts b/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.test.ts index 1433eccab038b..5fbf080e5ac99 100644 --- a/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.test.ts @@ -8,13 +8,15 @@ import type { ElasticsearchClient } from 'kibana/server'; import { savedObjectsClientMock } from 'src/core/server/mocks'; import { take } from 'rxjs/operators'; + +import { getNewActionsSince } from '../actions'; +import type { Agent, AgentAction, AgentPolicyAction } from '../../../types'; +import { outputType } from '../../../../common/constants'; + import { createAgentActionFromPolicyAction, createNewActionsSharedObservable, } from './state_new_actions'; -import { getNewActionsSince } from '../actions'; -import type { Agent, AgentAction, AgentPolicyAction } from '../../../types'; -import { outputType } from '../../../../common/constants'; jest.mock('../../app_context', () => ({ appContextService: { diff --git a/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.ts b/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.ts index c66bff30a2e57..4557f93e72ac3 100644 --- a/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.ts +++ b/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.ts @@ -7,7 +7,6 @@ import semverParse from 'semver/functions/parse'; import semverLt from 'semver/functions/lt'; - import { timer, from, Observable, TimeoutError, of, EMPTY } from 'rxjs'; import { omit } from 'lodash'; import { @@ -24,6 +23,7 @@ import { } from 'rxjs/operators'; import { KibanaRequest } from 'src/core/server'; import type { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; + import type { Agent, AgentAction, @@ -45,9 +45,10 @@ import { getAgentPolicyActionByIds, } from '../actions'; import { appContextService } from '../../app_context'; -import { toPromiseAbortable, AbortError, createRateLimiter } from './rxjs_utils'; import { getAgent, updateAgent } from '../crud'; +import { toPromiseAbortable, AbortError, createRateLimiter } from './rxjs_utils'; + function getInternalUserSOClient() { const fakeRequest = ({ headers: {}, diff --git a/x-pack/plugins/fleet/server/services/agents/crud.ts b/x-pack/plugins/fleet/server/services/agents/crud.ts index 60a2ed8f67cee..207e00c001595 100644 --- a/x-pack/plugins/fleet/server/services/agents/crud.ts +++ b/x-pack/plugins/fleet/server/services/agents/crud.ts @@ -6,8 +6,10 @@ */ import type { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server'; + import type { AgentSOAttributes, Agent, ListWithKuery } from '../../types'; import { appContextService, agentPolicyService } from '../../services'; + import * as crudServiceSO from './crud_so'; import * as crudServiceFleetServer from './crud_fleet_server'; diff --git a/x-pack/plugins/fleet/server/services/agents/crud_fleet_server.ts b/x-pack/plugins/fleet/server/services/agents/crud_fleet_server.ts index 53a22e842a544..8002e8fd121a1 100644 --- a/x-pack/plugins/fleet/server/services/agents/crud_fleet_server.ts +++ b/x-pack/plugins/fleet/server/services/agents/crud_fleet_server.ts @@ -8,17 +8,19 @@ import Boom from '@hapi/boom'; import type { SearchResponse } from 'elasticsearch'; import type { ElasticsearchClient } from 'src/core/server'; + import { isAgentUpgradeable, SO_SEARCH_LIMIT } from '../../../common'; import type { FleetServerAgent } from '../../../common'; import { AGENT_SAVED_OBJECT_TYPE, AGENTS_INDEX } from '../../constants'; import type { ESSearchHit } from '../../../../../typings/elasticsearch'; import type { AgentSOAttributes, Agent, ListWithKuery } from '../../types'; import { escapeSearchQueryPhrase, normalizeKuery } from '../saved_object'; -import { searchHitToAgent, agentSOAttributesToFleetServerAgentDoc } from './helpers'; import { appContextService } from '../../services'; import { esKuery } from '../../../../../../src/plugins/data/server'; import type { KueryNode } from '../../../../../../src/plugins/data/server'; +import { searchHitToAgent, agentSOAttributesToFleetServerAgentDoc } from './helpers'; + const ACTIVE_AGENT_CONDITION = 'active:true'; const INACTIVE_AGENT_CONDITION = `NOT (${ACTIVE_AGENT_CONDITION})`; diff --git a/x-pack/plugins/fleet/server/services/agents/crud_so.ts b/x-pack/plugins/fleet/server/services/agents/crud_so.ts index 2daeff9b7344d..028210b620a13 100644 --- a/x-pack/plugins/fleet/server/services/agents/crud_so.ts +++ b/x-pack/plugins/fleet/server/services/agents/crud_so.ts @@ -7,15 +7,17 @@ import Boom from '@hapi/boom'; import type { SavedObjectsBulkUpdateObject, SavedObjectsClientContract } from 'src/core/server'; + import { isAgentUpgradeable } from '../../../common'; import { AGENT_SAVED_OBJECT_TYPE } from '../../constants'; import type { AgentSOAttributes, Agent, ListWithKuery } from '../../types'; import { escapeSearchQueryPhrase, normalizeKuery, findAllSOs } from '../saved_object'; -import { savedObjectToAgent } from './saved_objects'; import { appContextService } from '../../services'; import { esKuery } from '../../../../../../src/plugins/data/server'; import type { KueryNode } from '../../../../../../src/plugins/data/server'; +import { savedObjectToAgent } from './saved_objects'; + const ACTIVE_AGENT_CONDITION = `${AGENT_SAVED_OBJECT_TYPE}.attributes.active:true`; const INACTIVE_AGENT_CONDITION = `NOT (${ACTIVE_AGENT_CONDITION})`; diff --git a/x-pack/plugins/fleet/server/services/agents/enroll.ts b/x-pack/plugins/fleet/server/services/agents/enroll.ts index 6ca19bf884cca..afa0c03a393f9 100644 --- a/x-pack/plugins/fleet/server/services/agents/enroll.ts +++ b/x-pack/plugins/fleet/server/services/agents/enroll.ts @@ -10,16 +10,17 @@ import uuid from 'uuid/v4'; import semverParse from 'semver/functions/parse'; import semverDiff from 'semver/functions/diff'; import semverLte from 'semver/functions/lte'; - import type { SavedObjectsClientContract } from 'src/core/server'; + import type { AgentType, Agent, AgentSOAttributes, FleetServerAgent } from '../../types'; -import { savedObjectToAgent } from './saved_objects'; import { AGENT_SAVED_OBJECT_TYPE, AGENTS_INDEX } from '../../constants'; import { IngestManagerError } from '../../errors'; import * as APIKeyService from '../api_keys'; import { agentPolicyService } from '../../services'; import { appContextService } from '../app_context'; +import { savedObjectToAgent } from './saved_objects'; + export async function enroll( soClient: SavedObjectsClientContract, type: AgentType, diff --git a/x-pack/plugins/fleet/server/services/agents/events.ts b/x-pack/plugins/fleet/server/services/agents/events.ts index 29b42a5de8282..e61ce04f1b640 100644 --- a/x-pack/plugins/fleet/server/services/agents/events.ts +++ b/x-pack/plugins/fleet/server/services/agents/events.ts @@ -6,6 +6,7 @@ */ import type { SavedObjectsClientContract } from 'src/core/server'; + import { AGENT_EVENT_SAVED_OBJECT_TYPE } from '../../constants'; import type { AgentEventSOAttributes, AgentEvent } from '../../types'; import { normalizeKuery } from '../saved_object'; diff --git a/x-pack/plugins/fleet/server/services/agents/reassign.test.ts b/x-pack/plugins/fleet/server/services/agents/reassign.test.ts index 466870bead71c..94c4c1ad57009 100644 --- a/x-pack/plugins/fleet/server/services/agents/reassign.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/reassign.test.ts @@ -7,8 +7,10 @@ import { elasticsearchServiceMock, savedObjectsClientMock } from 'src/core/server/mocks'; import type { SavedObject } from 'kibana/server'; + import type { Agent, AgentPolicy } from '../../types'; import { AgentReassignmentError } from '../../errors'; + import { reassignAgent, reassignAgents } from './reassign'; const agentInManagedSO = { diff --git a/x-pack/plugins/fleet/server/services/agents/reassign.ts b/x-pack/plugins/fleet/server/services/agents/reassign.ts index 62d59aada3b7b..7c6a646cfded2 100644 --- a/x-pack/plugins/fleet/server/services/agents/reassign.ts +++ b/x-pack/plugins/fleet/server/services/agents/reassign.ts @@ -7,7 +7,10 @@ import type { SavedObjectsClientContract, ElasticsearchClient } from 'kibana/server'; import Boom from '@hapi/boom'; + import { agentPolicyService } from '../agent_policy'; +import { AgentReassignmentError } from '../../errors'; + import { getAgents, getAgentPolicyForAgent, @@ -15,8 +18,6 @@ import { updateAgent, bulkUpdateAgents, } from './crud'; -import { AgentReassignmentError } from '../../errors'; - import { createAgentAction, bulkCreateAgentActions } from './actions'; export async function reassignAgent( diff --git a/x-pack/plugins/fleet/server/services/agents/saved_objects.ts b/x-pack/plugins/fleet/server/services/agents/saved_objects.ts index 45d5a0de040ea..8438048f12a87 100644 --- a/x-pack/plugins/fleet/server/services/agents/saved_objects.ts +++ b/x-pack/plugins/fleet/server/services/agents/saved_objects.ts @@ -7,6 +7,7 @@ import Boom from '@hapi/boom'; import type { SavedObject } from 'src/core/server'; + import type { Agent, AgentSOAttributes, diff --git a/x-pack/plugins/fleet/server/services/agents/setup.ts b/x-pack/plugins/fleet/server/services/agents/setup.ts index b55eb8efb1370..c6c7b50c5d3ae 100644 --- a/x-pack/plugins/fleet/server/services/agents/setup.ts +++ b/x-pack/plugins/fleet/server/services/agents/setup.ts @@ -6,9 +6,11 @@ */ import type { SavedObjectsClientContract } from 'src/core/server'; + import { SO_SEARCH_LIMIT } from '../../constants'; import { agentPolicyService } from '../agent_policy'; import { outputService } from '../output'; + import { getLatestConfigChangeAction } from './actions'; export async function isAgentsSetup(soClient: SavedObjectsClientContract): Promise { diff --git a/x-pack/plugins/fleet/server/services/agents/status.test.ts b/x-pack/plugins/fleet/server/services/agents/status.test.ts index c6a021195f8f8..93ec138dc9fa1 100644 --- a/x-pack/plugins/fleet/server/services/agents/status.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/status.test.ts @@ -6,10 +6,12 @@ */ import { elasticsearchServiceMock, savedObjectsClientMock } from 'src/core/server/mocks'; -import { getAgentStatusById } from './status'; +import type { SavedObject } from 'kibana/server'; + import { AGENT_TYPE_PERMANENT } from '../../../common/constants'; import type { AgentSOAttributes } from '../../../common/types/models'; -import type { SavedObject } from 'kibana/server'; + +import { getAgentStatusById } from './status'; describe('Agent status service', () => { it('should return inactive when agent is not active', async () => { diff --git a/x-pack/plugins/fleet/server/services/agents/status.ts b/x-pack/plugins/fleet/server/services/agents/status.ts index 29171adf92bb9..3d6067ae2a826 100644 --- a/x-pack/plugins/fleet/server/services/agents/status.ts +++ b/x-pack/plugins/fleet/server/services/agents/status.ts @@ -7,7 +7,7 @@ import type { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; import pMap from 'p-map'; -import { getAgent, listAgents } from './crud'; + import { AGENT_EVENT_SAVED_OBJECT_TYPE, AGENT_SAVED_OBJECT_TYPE } from '../../constants'; import type { AgentStatus } from '../../types'; import { AgentStatusKueryHelper } from '../../../common/services'; @@ -15,6 +15,8 @@ import { esKuery } from '../../../../../../src/plugins/data/server'; import type { KueryNode } from '../../../../../../src/plugins/data/server'; import { normalizeKuery } from '../saved_object'; import { appContextService } from '../app_context'; + +import { getAgent, listAgents } from './crud'; import { removeSOAttributes } from './crud_fleet_server'; export async function getAgentStatusById( diff --git a/x-pack/plugins/fleet/server/services/agents/unenroll.test.ts b/x-pack/plugins/fleet/server/services/agents/unenroll.test.ts index cd46cff0f8a17..b74df90cc86d9 100644 --- a/x-pack/plugins/fleet/server/services/agents/unenroll.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/unenroll.test.ts @@ -7,8 +7,10 @@ import { elasticsearchServiceMock, savedObjectsClientMock } from 'src/core/server/mocks'; import type { SavedObject } from 'kibana/server'; + import type { Agent, AgentPolicy } from '../../types'; import { AgentUnenrollmentError } from '../../errors'; + import { unenrollAgent, unenrollAgents } from './unenroll'; const agentInManagedSO = { diff --git a/x-pack/plugins/fleet/server/services/agents/unenroll.ts b/x-pack/plugins/fleet/server/services/agents/unenroll.ts index 97dc7ea87706e..e7c5a30836aa8 100644 --- a/x-pack/plugins/fleet/server/services/agents/unenroll.ts +++ b/x-pack/plugins/fleet/server/services/agents/unenroll.ts @@ -6,7 +6,10 @@ */ import type { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; + import * as APIKeyService from '../api_keys'; +import { AgentUnenrollmentError } from '../../errors'; + import { createAgentAction, bulkCreateAgentActions } from './actions'; import { getAgent, @@ -16,7 +19,6 @@ import { listAllAgents, bulkUpdateAgents, } from './crud'; -import { AgentUnenrollmentError } from '../../errors'; async function unenrollAgentIsAllowed( soClient: SavedObjectsClientContract, diff --git a/x-pack/plugins/fleet/server/services/agents/update.ts b/x-pack/plugins/fleet/server/services/agents/update.ts index 81214b6fd0eb5..7e40b2baf02e5 100644 --- a/x-pack/plugins/fleet/server/services/agents/update.ts +++ b/x-pack/plugins/fleet/server/services/agents/update.ts @@ -6,8 +6,10 @@ */ import type { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; -import { listAgents } from './crud'; + import { AGENT_SAVED_OBJECT_TYPE } from '../../constants'; + +import { listAgents } from './crud'; import { unenrollAgent } from './unenroll'; export async function unenrollForAgentPolicyId( diff --git a/x-pack/plugins/fleet/server/services/agents/upgrade.ts b/x-pack/plugins/fleet/server/services/agents/upgrade.ts index 9986edd3d805f..6742e6ab84f73 100644 --- a/x-pack/plugins/fleet/server/services/agents/upgrade.ts +++ b/x-pack/plugins/fleet/server/services/agents/upgrade.ts @@ -6,10 +6,14 @@ */ import type { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; + import type { AgentAction, AgentActionSOAttributes } from '../../types'; import { AGENT_ACTION_SAVED_OBJECT_TYPE } from '../../constants'; import { agentPolicyService } from '../../services'; import { IngestManagerError } from '../../errors'; +import { isAgentUpgradeable } from '../../../common/services'; +import { appContextService } from '../app_context'; + import { bulkCreateAgentActions, createAgentAction } from './actions'; import { getAgents, @@ -18,8 +22,6 @@ import { bulkUpdateAgents, getAgentPolicyForAgent, } from './crud'; -import { isAgentUpgradeable } from '../../../common/services'; -import { appContextService } from '../app_context'; export async function sendUpgradeAgentAction({ soClient, diff --git a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts index 5d86393f0905e..f8352b1d698a4 100644 --- a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts +++ b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts @@ -6,8 +6,10 @@ */ import type { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server'; + import type { EnrollmentAPIKey } from '../../types'; import { appContextService } from '../app_context'; + import * as enrollmentApiKeyServiceSO from './enrollment_api_key_so'; import * as enrollmentApiKeyServiceFleetServer from './enrollment_api_key_fleet_server'; diff --git a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key_fleet_server.ts b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key_fleet_server.ts index 5cde87da95cdf..b6d2e942207b5 100644 --- a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key_fleet_server.ts +++ b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key_fleet_server.ts @@ -10,13 +10,15 @@ import Boom from '@hapi/boom'; import type { GetResponse } from 'elasticsearch'; import { ResponseError } from '@elastic/elasticsearch/lib/errors'; import type { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server'; + import type { ESSearchResponse as SearchResponse } from '../../../../../typings/elasticsearch'; import type { EnrollmentAPIKey, FleetServerEnrollmentAPIKey } from '../../types'; import { ENROLLMENT_API_KEYS_INDEX } from '../../constants'; -import { createAPIKey, invalidateAPIKeys } from './security'; import { agentPolicyService } from '../agent_policy'; import { escapeSearchQueryPhrase } from '../saved_object'; +import { createAPIKey, invalidateAPIKeys } from './security'; + export async function listEnrollmentApiKeys( esClient: ElasticsearchClient, options: { diff --git a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key_so.ts b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key_so.ts index 4001cabe76aa3..9b2937f4d3224 100644 --- a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key_so.ts +++ b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key_so.ts @@ -8,13 +8,15 @@ import uuid from 'uuid'; import Boom from '@hapi/boom'; import type { SavedObjectsClientContract, SavedObject } from 'src/core/server'; + import type { EnrollmentAPIKey, EnrollmentAPIKeySOAttributes } from '../../types'; import { ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE } from '../../constants'; -import { createAPIKey, invalidateAPIKeys } from './security'; import { agentPolicyService } from '../agent_policy'; import { appContextService } from '../app_context'; import { normalizeKuery, escapeSearchQueryPhrase } from '../saved_object'; +import { createAPIKey, invalidateAPIKeys } from './security'; + export async function listEnrollmentApiKeys( soClient: SavedObjectsClientContract, options: { diff --git a/x-pack/plugins/fleet/server/services/api_keys/index.ts b/x-pack/plugins/fleet/server/services/api_keys/index.ts index 724583e42efe0..849867bdd5879 100644 --- a/x-pack/plugins/fleet/server/services/api_keys/index.ts +++ b/x-pack/plugins/fleet/server/services/api_keys/index.ts @@ -7,6 +7,7 @@ import { KibanaRequest } from 'src/core/server'; import type { SavedObjectsClientContract } from 'src/core/server'; + import { createAPIKey } from './security'; export { invalidateAPIKeys } from './security'; diff --git a/x-pack/plugins/fleet/server/services/api_keys/security.ts b/x-pack/plugins/fleet/server/services/api_keys/security.ts index 356f9012791eb..836e7b2343f6c 100644 --- a/x-pack/plugins/fleet/server/services/api_keys/security.ts +++ b/x-pack/plugins/fleet/server/services/api_keys/security.ts @@ -6,6 +6,7 @@ */ import type { Request } from '@hapi/hapi'; + import { KibanaRequest } from '../../../../../../src/core/server'; import type { SavedObjectsClientContract } from '../../../../../../src/core/server'; import { FleetAdminUserInvalidError, isESClientError } from '../../errors'; diff --git a/x-pack/plugins/fleet/server/services/app_context.ts b/x-pack/plugins/fleet/server/services/app_context.ts index f63d3b2d7ccab..cad730b81f98b 100644 --- a/x-pack/plugins/fleet/server/services/app_context.ts +++ b/x-pack/plugins/fleet/server/services/app_context.ts @@ -15,6 +15,7 @@ import type { HttpServiceSetup, Logger, } from 'src/core/server'; + import type { EncryptedSavedObjectsClient, EncryptedSavedObjectsPluginSetup, diff --git a/x-pack/plugins/fleet/server/services/config.ts b/x-pack/plugins/fleet/server/services/config.ts index d14e31e5b510f..128cb6b136c23 100644 --- a/x-pack/plugins/fleet/server/services/config.ts +++ b/x-pack/plugins/fleet/server/services/config.ts @@ -6,6 +6,7 @@ */ import { Observable, Subscription } from 'rxjs'; + import type { FleetConfigType } from '../'; /** diff --git a/x-pack/plugins/fleet/server/services/epm/agent/agent.ts b/x-pack/plugins/fleet/server/services/epm/agent/agent.ts index 38631ad784ea9..bbdc99b880e8c 100644 --- a/x-pack/plugins/fleet/server/services/epm/agent/agent.ts +++ b/x-pack/plugins/fleet/server/services/epm/agent/agent.ts @@ -7,6 +7,7 @@ import Handlebars from 'handlebars'; import { safeLoad, safeDump } from 'js-yaml'; + import type { PackagePolicyConfigRecord } from '../../../../common'; const handlebars = Handlebars.create(); diff --git a/x-pack/plugins/fleet/server/services/epm/archive/cache.ts b/x-pack/plugins/fleet/server/services/epm/archive/cache.ts index 8d4234e3cf538..a0c817b497e0d 100644 --- a/x-pack/plugins/fleet/server/services/epm/archive/cache.ts +++ b/x-pack/plugins/fleet/server/services/epm/archive/cache.ts @@ -5,9 +5,10 @@ * 2.0. */ -import type { ArchiveEntry } from './index'; import type { ArchivePackage, RegistryPackage } from '../../../../common'; +import type { ArchiveEntry } from './index'; + const archiveEntryCache: Map = new Map(); export const getArchiveEntry = (key: string) => archiveEntryCache.get(key); export const setArchiveEntry = (key: string, value: Buffer) => archiveEntryCache.set(key, value); diff --git a/x-pack/plugins/fleet/server/services/epm/archive/extract.ts b/x-pack/plugins/fleet/server/services/epm/archive/extract.ts index 8d576310813c0..0bdb07df26814 100644 --- a/x-pack/plugins/fleet/server/services/epm/archive/extract.ts +++ b/x-pack/plugins/fleet/server/services/epm/archive/extract.ts @@ -7,7 +7,9 @@ import tar from 'tar'; import yauzl from 'yauzl'; + import { bufferToStream, streamToBuffer } from '../streams'; + import type { ArchiveEntry } from './index'; export async function untarBuffer( diff --git a/x-pack/plugins/fleet/server/services/epm/archive/index.ts b/x-pack/plugins/fleet/server/services/epm/archive/index.ts index 44046ac749f6c..809684df0592c 100644 --- a/x-pack/plugins/fleet/server/services/epm/archive/index.ts +++ b/x-pack/plugins/fleet/server/services/epm/archive/index.ts @@ -7,6 +7,7 @@ import type { AssetParts, InstallSource } from '../../../../common/types'; import { PackageInvalidArchiveError, PackageUnsupportedMediaTypeError } from '../../../errors'; + import { getArchiveEntry, setArchiveEntry, diff --git a/x-pack/plugins/fleet/server/services/epm/archive/storage.ts b/x-pack/plugins/fleet/server/services/epm/archive/storage.ts index 671d428918caf..8843171c4c6f4 100644 --- a/x-pack/plugins/fleet/server/services/epm/archive/storage.ts +++ b/x-pack/plugins/fleet/server/services/epm/archive/storage.ts @@ -6,12 +6,14 @@ */ import { extname } from 'path'; + import { uniq } from 'lodash'; import { safeLoad } from 'js-yaml'; import { isBinaryFile } from 'isbinaryfile'; import mime from 'mime-types'; import uuidv5 from 'uuid/v5'; import type { SavedObjectsClientContract, SavedObjectsBulkCreateObject } from 'src/core/server'; + import { ASSETS_SAVED_OBJECT_TYPE } from '../../../../common'; import type { InstallablePackage, @@ -19,10 +21,11 @@ import type { PackageAssetReference, RegistryDataStream, } from '../../../../common'; +import { pkgToPkgKey } from '../registry'; + import { getArchiveEntry, setArchiveEntry, setArchiveFilelist } from './index'; import type { ArchiveEntry } from './index'; import { parseAndVerifyPolicyTemplates, parseAndVerifyStreams } from './validation'; -import { pkgToPkgKey } from '../registry'; // could be anything, picked this from https://github.com/elastic/elastic-agent-client/issues/17 const MAX_ES_ASSET_BYTES = 4 * 1024 * 1024; diff --git a/x-pack/plugins/fleet/server/services/epm/archive/validation.ts b/x-pack/plugins/fleet/server/services/epm/archive/validation.ts index 03f30cab45734..769b9930d26fb 100644 --- a/x-pack/plugins/fleet/server/services/epm/archive/validation.ts +++ b/x-pack/plugins/fleet/server/services/epm/archive/validation.ts @@ -7,6 +7,7 @@ import yaml from 'js-yaml'; import { pick, uniq } from 'lodash'; + import type { ArchivePackage, RegistryPolicyTemplate, @@ -17,9 +18,10 @@ import type { PackageSpecManifest, } from '../../../../common/types'; import { PackageInvalidArchiveError } from '../../../errors'; -import { unpackBufferEntries } from './index'; import { pkgToPkgKey } from '../registry'; +import { unpackBufferEntries } from './index'; + const MANIFESTS: Record = {}; const MANIFEST_NAME = 'manifest.yml'; diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/datastream_ilm/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/datastream_ilm/install.ts index e18cf2eb52bcd..7d821e1416c9f 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/datastream_ilm/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/datastream_ilm/install.ts @@ -6,6 +6,7 @@ */ import type { SavedObjectsClientContract } from 'kibana/server'; + import { ElasticsearchAssetType } from '../../../../../common/types/models'; import type { EsAssetReference, @@ -14,10 +15,11 @@ import type { } from '../../../../../common/types/models'; import type { CallESAsCurrentUser } from '../../../../types'; import { getInstallation } from '../../packages'; -import { deleteIlmRefs, deleteIlms } from './remove'; import { saveInstalledEsRefs } from '../../packages/install'; import { getAsset } from '../transform/common'; +import { deleteIlmRefs, deleteIlms } from './remove'; + interface IlmInstallation { installationName: string; content: string; diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/datastream_ilm/remove.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/datastream_ilm/remove.ts index 7da980e61f0ec..651710c02fc38 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/datastream_ilm/remove.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/datastream_ilm/remove.ts @@ -6,6 +6,7 @@ */ import type { SavedObjectsClientContract } from 'kibana/server'; + import { ElasticsearchAssetType } from '../../../../types'; import type { CallESAsCurrentUser, EsAssetReference } from '../../../../types'; import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../../../common/constants'; diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/index.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/index.test.ts index aa64cd7a6ed02..e4fae7ca0ca41 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/index.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/index.test.ts @@ -6,6 +6,7 @@ */ import type { RegistryDataStream } from '../../../types'; + import { getRegistryDataStreamAssetBaseName } from './index'; test('getBaseName', () => { diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/ingest_pipelines.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/ingest_pipelines.test.ts index 0a96186339bc0..097f9ce28c7d1 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/ingest_pipelines.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/ingest_pipelines.test.ts @@ -7,9 +7,11 @@ import { readFileSync } from 'fs'; import path from 'path'; -import { rewriteIngestPipeline, getPipelineNameForInstallation } from './install'; + import type { RegistryDataStream } from '../../../../types'; +import { rewriteIngestPipeline, getPipelineNameForInstallation } from './install'; + test('a json-format pipeline with pipeline references is correctly rewritten', () => { const inputStandard = readFileSync( path.join(__dirname, '/tests/ingest_pipelines/real_input_standard.json'), diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts index ff3262cb65418..735242c1e6984 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts @@ -6,6 +6,7 @@ */ import type { SavedObjectsClientContract } from 'src/core/server'; + import { ElasticsearchAssetType } from '../../../../types'; import type { EsAssetReference, @@ -17,6 +18,7 @@ import { getAsset, getPathParts } from '../../archive'; import type { ArchiveEntry } from '../../archive'; import { saveInstalledEsRefs } from '../../packages/install'; import { getInstallationObject } from '../../packages'; + import { deletePipelineRefs } from './remove'; interface RewriteSubstitution { diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/remove.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/remove.ts index d78c9d989bd4d..46f9be53f8864 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/remove.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/remove.ts @@ -6,6 +6,7 @@ */ import type { SavedObjectsClientContract } from 'src/core/server'; + import { appContextService } from '../../../'; import { ElasticsearchAssetType } from '../../../../types'; import type { CallESAsCurrentUser } from '../../../../types'; diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts index 42e724794b791..a580f58d4fed1 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts @@ -5,9 +5,11 @@ * 2.0. */ +import { elasticsearchServiceMock } from 'src/core/server/mocks'; + import type { RegistryDataStream } from '../../../../types'; import type { Field } from '../../fields/field'; -import { elasticsearchServiceMock } from 'src/core/server/mocks'; + import { installTemplate } from './install'; test('tests installPackage to use correct priority and index_patterns for data stream with dataset_is_prefix not set', async () => { diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts index 353331528ca3c..28cfda3fd4189 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts @@ -7,6 +7,7 @@ import Boom from '@hapi/boom'; import type { SavedObjectsClientContract } from 'src/core/server'; + import { ElasticsearchAssetType } from '../../../../types'; import type { RegistryDataStream, @@ -18,6 +19,9 @@ import type { import { loadFieldsFromYaml, processFields } from '../../fields/field'; import type { Field } from '../../fields/field'; import { getPipelineNameForInstallation } from '../ingest_pipeline/install'; +import { getAsset, getPathParts } from '../../archive'; +import { removeAssetsFromInstalledEsByType, saveInstalledEsRefs } from '../../packages/install'; + import { generateMappings, generateTemplateName, @@ -25,8 +29,6 @@ import { getTemplate, getTemplatePriority, } from './template'; -import { getAsset, getPathParts } from '../../archive'; -import { removeAssetsFromInstalledEsByType, saveInstalledEsRefs } from '../../packages/install'; export const installTemplates = async ( installablePackage: InstallablePackage, diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.test.ts index 95e9e8e6d5c71..0f53d260592e7 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.test.ts @@ -6,11 +6,14 @@ */ import { readFileSync } from 'fs'; -import { safeLoad } from 'js-yaml'; import path from 'path'; + +import { safeLoad } from 'js-yaml'; + import type { RegistryDataStream } from '../../../../types'; import { processFields } from '../../fields/field'; import type { Field } from '../../fields/field'; + import { generateMappings, getTemplate, diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts index e68c5070affd3..16b543846baee 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts @@ -6,17 +6,19 @@ */ import type { SavedObjectsClientContract } from 'kibana/server'; + import { saveInstalledEsRefs } from '../../packages/install'; import { getPathParts } from '../../archive'; import { ElasticsearchAssetType } from '../../../../../common/types/models'; import type { EsAssetReference, InstallablePackage } from '../../../../../common/types/models'; import type { CallESAsCurrentUser } from '../../../../types'; import { getInstallation } from '../../packages'; -import { deleteTransforms, deleteTransformRefs } from './remove'; -import { getAsset } from './common'; import { appContextService } from '../../../app_context'; import { isLegacyESClientError } from '../../../../errors'; +import { deleteTransforms, deleteTransformRefs } from './remove'; +import { getAsset } from './common'; + interface TransformInstallation { installationName: string; content: string; diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/remove.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/remove.test.ts index 6df9f34489aeb..5f1d8db121a41 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/remove.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/remove.test.ts @@ -6,11 +6,14 @@ */ import type { SavedObjectsClientContract } from 'kibana/server'; + // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { savedObjectsClientMock } from '../../../../../../../../src/core/server/saved_objects/service/saved_objects_client.mock'; -import { deleteTransformRefs } from './remove'; + import type { EsAssetReference } from '../../../../../common/types/models'; +import { deleteTransformRefs } from './remove'; + describe('test transform install', () => { let savedObjectsClient: jest.Mocked; beforeEach(() => { diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/remove.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/remove.ts index 510071f119910..2611978be20a2 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/remove.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/remove.ts @@ -6,6 +6,7 @@ */ import type { SavedObjectsClientContract } from 'kibana/server'; + import { ElasticsearchAssetType } from '../../../../types'; import type { CallESAsCurrentUser, EsAssetReference } from '../../../../types'; import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../../../common/constants'; diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts index 602908c5908e5..254196b4af053 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts @@ -5,6 +5,7 @@ * 2.0. */ +// eslint-disable-next-line import/order import { createAppContextStartContractMock } from '../../../../mocks'; jest.mock('../../packages/get', () => { @@ -18,20 +19,23 @@ jest.mock('./common', () => { }); import { errors as LegacyESErrors } from 'elasticsearch'; -import { installTransform } from './install'; + import type { ILegacyScopedClusterClient, SavedObject, SavedObjectsClientContract, } from 'kibana/server'; + import { ElasticsearchAssetType } from '../../../../types'; import type { Installation, RegistryPackage } from '../../../../types'; import { getInstallation, getInstallationObject } from '../../packages'; -import { getAsset } from './common'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { savedObjectsClientMock } from '../../../../../../../../src/core/server/saved_objects/service/saved_objects_client.mock'; import { appContextService } from '../../../app_context'; +import { getAsset } from './common'; +import { installTransform } from './install'; + describe('test transform install', () => { let legacyScopedClusterClient: jest.Mocked; let savedObjectsClient: jest.Mocked; diff --git a/x-pack/plugins/fleet/server/services/epm/fields/field.test.ts b/x-pack/plugins/fleet/server/services/epm/fields/field.test.ts index 21c0fc52f6b3f..8be5f4655b480 100644 --- a/x-pack/plugins/fleet/server/services/epm/fields/field.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/fields/field.test.ts @@ -6,9 +6,11 @@ */ import { readFileSync } from 'fs'; +import path from 'path'; + import glob from 'glob'; import { safeLoad } from 'js-yaml'; -import path from 'path'; + import { getField, processFields } from './field'; import type { Field, Fields } from './field'; diff --git a/x-pack/plugins/fleet/server/services/epm/fields/field.ts b/x-pack/plugins/fleet/server/services/epm/fields/field.ts index 7144a4ca4e7f0..addcaf20cd146 100644 --- a/x-pack/plugins/fleet/server/services/epm/fields/field.ts +++ b/x-pack/plugins/fleet/server/services/epm/fields/field.ts @@ -6,6 +6,7 @@ */ import { safeLoad } from 'js-yaml'; + import type { InstallablePackage } from '../../../types'; import { getAssetsData } from '../packages/assets'; diff --git a/x-pack/plugins/fleet/server/services/epm/kibana/assets/install.ts b/x-pack/plugins/fleet/server/services/epm/kibana/assets/install.ts index a004bf0f21f62..4196138a2534f 100644 --- a/x-pack/plugins/fleet/server/services/epm/kibana/assets/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/kibana/assets/install.ts @@ -10,6 +10,7 @@ import type { SavedObjectsBulkCreateObject, SavedObjectsClientContract, } from 'src/core/server'; + import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../../../common'; import { getAsset, getPathParts } from '../../archive'; import { KibanaAssetType, KibanaSavedObjectType } from '../../../../types'; diff --git a/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.test.ts b/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.test.ts index e6d36235f0384..a0eaed04d649e 100644 --- a/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.test.ts @@ -7,8 +7,12 @@ import path from 'path'; import { readFileSync } from 'fs'; + import glob from 'glob'; import { safeLoad } from 'js-yaml'; + +import type { Fields, Field } from '../../fields/field'; + import { flattenFields, dedupeFields, @@ -19,7 +23,6 @@ import { createIndexPattern, } from './install'; import type { IndexPatternField } from './install'; -import type { Fields, Field } from '../../fields/field'; import { dupeFields } from './tests/test_data'; // Add our own serialiser to just do JSON.stringify diff --git a/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.ts b/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.ts index f45eeab8bc2ba..3ec9d2c65a6da 100644 --- a/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.ts @@ -6,6 +6,7 @@ */ import type { SavedObjectsClientContract } from 'src/core/server'; + import { INDEX_PATTERN_SAVED_OBJECT_TYPE } from '../../../../constants'; import { loadFieldsFromYaml } from '../../fields/field'; import type { Fields, Field } from '../../fields/field'; diff --git a/x-pack/plugins/fleet/server/services/epm/packages/_install_package.test.ts b/x-pack/plugins/fleet/server/services/epm/packages/_install_package.test.ts index cf928d5b80d63..97c29ebff145a 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/_install_package.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/_install_package.test.ts @@ -8,6 +8,7 @@ import { LegacyScopedClusterClient } from 'src/core/server'; import type { SavedObjectsClientContract } from 'src/core/server'; import { savedObjectsClientMock, elasticsearchServiceMock } from 'src/core/server/mocks'; + import { appContextService } from '../../app_context'; import { createAppContextStartContractMock } from '../../../mocks'; @@ -20,6 +21,7 @@ jest.mock('./get'); import { updateCurrentWriteIndices } from '../elasticsearch/template/template'; import { installKibanaAssets } from '../kibana/assets/install'; import { installIndexPatterns } from '../kibana/index_pattern/install'; + import { _installPackage } from './_install_package'; const mockedUpdateCurrentWriteIndices = updateCurrentWriteIndices as jest.MockedFunction< diff --git a/x-pack/plugins/fleet/server/services/epm/packages/_install_package.ts b/x-pack/plugins/fleet/server/services/epm/packages/_install_package.ts index 206bef75df14b..2774149f252e3 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/_install_package.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/_install_package.ts @@ -6,6 +6,7 @@ */ import type { SavedObject, SavedObjectsClientContract } from 'src/core/server'; + import { MAX_TIME_COMPLETE_INSTALL, ASSETS_SAVED_OBJECT_TYPE } from '../../../../common'; import type { InstallablePackage, InstallSource, PackageAssetReference } from '../../../../common'; import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../constants'; @@ -22,13 +23,14 @@ import { installPipelines, deletePreviousPipelines } from '../elasticsearch/inge import { installILMPolicy } from '../elasticsearch/ilm/install'; import { installKibanaAssets, getKibanaAssets } from '../kibana/assets/install'; import { updateCurrentWriteIndices } from '../elasticsearch/template/template'; -import { deleteKibanaSavedObjectsAssets } from './remove'; import { installTransform } from '../elasticsearch/transform/install'; -import { createInstallation, saveKibanaAssetsRefs, updateVersion } from './install'; import { installIlmForDataStream } from '../elasticsearch/datastream_ilm/install'; import { saveArchiveEntries } from '../archive/storage'; import { ConcurrentInstallOperationError } from '../../../errors'; +import { createInstallation, saveKibanaAssetsRefs, updateVersion } from './install'; +import { deleteKibanaSavedObjectsAssets } from './remove'; + // this is only exported for testing // use a leading underscore to indicate it's not the supported path // only the more explicit `installPackage*` functions should be used diff --git a/x-pack/plugins/fleet/server/services/epm/packages/assets.test.ts b/x-pack/plugins/fleet/server/services/epm/packages/assets.test.ts index 6e5c257badef7..999cf878d07b7 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/assets.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/assets.test.ts @@ -6,9 +6,11 @@ */ import type { InstallablePackage } from '../../../types'; -import { getAssets } from './assets'; + import { getArchiveFilelist } from '../archive/cache'; +import { getAssets } from './assets'; + jest.mock('../archive/cache', () => { return { getArchiveFilelist: jest.fn(), diff --git a/x-pack/plugins/fleet/server/services/epm/packages/bulk_install_packages.ts b/x-pack/plugins/fleet/server/services/epm/packages/bulk_install_packages.ts index 64fd132145ffc..e6df3d5e7a83d 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/bulk_install_packages.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/bulk_install_packages.ts @@ -6,8 +6,10 @@ */ import type { SavedObjectsClientContract } from 'src/core/server'; + import type { CallESAsCurrentUser } from '../../../types'; import * as Registry from '../registry'; + import { getInstallationObject } from './index'; import { upgradePackage } from './install'; import type { BulkInstallResponse, IBulkInstallPackageError } from './install'; diff --git a/x-pack/plugins/fleet/server/services/epm/packages/ensure_installed_default_packages.test.ts b/x-pack/plugins/fleet/server/services/epm/packages/ensure_installed_default_packages.test.ts index 6c2a98450c1a7..e01af7b64c0e3 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/ensure_installed_default_packages.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/ensure_installed_default_packages.test.ts @@ -5,24 +5,28 @@ * 2.0. */ +import type { SavedObject, SavedObjectsClientContract } from 'src/core/server'; + import { ElasticsearchAssetType, KibanaSavedObjectType } from '../../../types'; import type { Installation } from '../../../types'; -import type { SavedObject, SavedObjectsClientContract } from 'src/core/server'; jest.mock('./install'); jest.mock('./bulk_install_packages'); jest.mock('./get'); -import { bulkInstallPackages, isBulkInstallError } from './bulk_install_packages'; const { ensureInstalledDefaultPackages } = jest.requireActual('./install'); const { isBulkInstallError: actualIsBulkInstallError } = jest.requireActual( './bulk_install_packages' ); -import { getInstallation } from './get'; +// eslint-disable-next-line import/order import { savedObjectsClientMock } from 'src/core/server/mocks'; + import { appContextService } from '../../app_context'; import { createAppContextStartContractMock } from '../../../mocks'; +import { getInstallation } from './get'; +import { bulkInstallPackages, isBulkInstallError } from './bulk_install_packages'; + // if we add this assertion, TS will type check the return value // and the editor will also know about .mockImplementation, .mock.calls, etc const mockedBulkInstallPackages = bulkInstallPackages as jest.MockedFunction< diff --git a/x-pack/plugins/fleet/server/services/epm/packages/get.test.ts b/x-pack/plugins/fleet/server/services/epm/packages/get.test.ts index 354bcf88685cb..9be22e7618466 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/get.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/get.test.ts @@ -6,9 +6,11 @@ */ import type { SavedObjectsClientContract, SavedObjectsFindResult } from 'kibana/server'; + import { savedObjectsClientMock } from '../../../../../../../src/core/server/mocks'; import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '../../../../common'; import type { PackagePolicySOAttributes } from '../../../../common'; + import { getPackageUsageStats } from './get'; describe('When using EPM `get` services', () => { diff --git a/x-pack/plugins/fleet/server/services/epm/packages/get.ts b/x-pack/plugins/fleet/server/services/epm/packages/get.ts index a32ac2ad4d88f..05c46fe409ad4 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/get.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/get.ts @@ -6,6 +6,7 @@ */ import type { SavedObjectsClientContract, SavedObjectsFindOptions } from 'src/core/server'; + import { isPackageLimited, installationStatuses, @@ -22,11 +23,12 @@ import { KibanaAssetType } from '../../../types'; import type { Installation, PackageInfo } from '../../../types'; import { IngestManagerError } from '../../../errors'; import * as Registry from '../registry'; -import { createInstallableFrom, isRequiredPackage } from './index'; import { getEsPackage } from '../archive/storage'; import { getArchivePackage } from '../archive'; import { normalizeKuery } from '../../saved_object'; +import { createInstallableFrom, isRequiredPackage } from './index'; + export { getFile, SearchParams } from '../registry'; function nameAsTitle(name: string) { diff --git a/x-pack/plugins/fleet/server/services/epm/packages/get_install_type.test.ts b/x-pack/plugins/fleet/server/services/epm/packages/get_install_type.test.ts index ae29a1c7956cf..155cd67e60287 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/get_install_type.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/get_install_type.test.ts @@ -5,11 +5,13 @@ * 2.0. */ -import { getInstallType } from './install'; import type { SavedObject } from 'src/core/server'; + import { ElasticsearchAssetType, KibanaSavedObjectType } from '../../../types'; import type { Installation } from '../../../types'; +import { getInstallType } from './install'; + const mockInstallation: SavedObject = { id: 'test-pkg', references: [], diff --git a/x-pack/plugins/fleet/server/services/epm/packages/index.ts b/x-pack/plugins/fleet/server/services/epm/packages/index.ts index 2dc845f94991e..c85376ef177b3 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/index.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/index.ts @@ -6,6 +6,7 @@ */ import type { SavedObject } from 'src/core/server'; + import { requiredPackages, installationStatuses } from '../../../../common'; import type { RequiredPackage, ValueOf } from '../../../../common'; import { KibanaAssetType } from '../../../types'; diff --git a/x-pack/plugins/fleet/server/services/epm/packages/install.ts b/x-pack/plugins/fleet/server/services/epm/packages/install.ts index 96b4b63312edd..5350d67b313c1 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/install.ts @@ -10,16 +10,16 @@ import semverLt from 'semver/functions/lt'; import Boom from '@hapi/boom'; import type { UnwrapPromise } from '@kbn/utility-types'; import type { SavedObject, SavedObjectsClientContract } from 'src/core/server'; + import { generateESIndexPatterns } from '../elasticsearch/template/template'; -import { - isRequiredPackage, - getInstallation, - getInstallationObject, - bulkInstallPackages, - isBulkInstallError, -} from './index'; + import { defaultPackages } from '../../../../common'; import type { BulkInstallPackageInfo, InstallablePackage, InstallSource } from '../../../../common'; +import { + IngestManagerError, + PackageOperationNotSupportedError, + PackageOutdatedError, +} from '../../../errors'; import { PACKAGES_SAVED_OBJECT_TYPE, MAX_TIME_COMPLETE_INSTALL } from '../../../constants'; import { KibanaAssetType } from '../../../types'; import type { @@ -30,18 +30,21 @@ import type { EsAssetReference, InstallType, } from '../../../types'; +import { appContextService } from '../../app_context'; import * as Registry from '../registry'; import { setPackageInfo, parseAndVerifyArchiveEntries, unpackBufferToCache } from '../archive'; import { toAssetReference } from '../kibana/assets/install'; import type { ArchiveAsset } from '../kibana/assets/install'; -import { removeInstallation } from './remove'; + import { - IngestManagerError, - PackageOperationNotSupportedError, - PackageOutdatedError, -} from '../../../errors'; + isRequiredPackage, + getInstallation, + getInstallationObject, + bulkInstallPackages, + isBulkInstallError, +} from './index'; +import { removeInstallation } from './remove'; import { getPackageSavedObjects } from './get'; -import { appContextService } from '../../app_context'; import { _installPackage } from './_install_package'; export async function installLatestPackage(options: { diff --git a/x-pack/plugins/fleet/server/services/epm/packages/remove.ts b/x-pack/plugins/fleet/server/services/epm/packages/remove.ts index 4d05daaf82500..0648404312ad7 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/remove.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/remove.ts @@ -7,6 +7,7 @@ import type { SavedObjectsClientContract } from 'src/core/server'; import Boom from '@hapi/boom'; + import { PACKAGE_POLICY_SAVED_OBJECT_TYPE, PACKAGES_SAVED_OBJECT_TYPE } from '../../../constants'; import { ElasticsearchAssetType } from '../../../types'; import type { @@ -17,7 +18,6 @@ import type { KibanaAssetReference, Installation, } from '../../../types'; -import { getInstallation, savedObjectTypes } from './index'; import { deletePipeline } from '../elasticsearch/ingest_pipeline/'; import { installIndexPatterns } from '../kibana/index_pattern/install'; import { deleteTransforms } from '../elasticsearch/transform/remove'; @@ -27,6 +27,8 @@ import { deletePackageCache } from '../archive'; import { deleteIlms } from '../elasticsearch/datastream_ilm/remove'; import { removeArchiveEntries } from '../archive/storage'; +import { getInstallation, savedObjectTypes } from './index'; + export async function removeInstallation(options: { savedObjectsClient: SavedObjectsClientContract; pkgkey: string; diff --git a/x-pack/plugins/fleet/server/services/epm/registry/index.test.ts b/x-pack/plugins/fleet/server/services/epm/registry/index.test.ts index e7ac5a0ce912e..16b57e1a9d011 100644 --- a/x-pack/plugins/fleet/server/services/epm/registry/index.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/registry/index.test.ts @@ -7,6 +7,7 @@ import type { AssetParts } from '../../../types'; import { getBufferExtractor, getPathParts, untarBuffer, unzipBuffer } from '../archive'; + import { splitPkgKey } from './index'; const testPaths = [ diff --git a/x-pack/plugins/fleet/server/services/epm/registry/index.ts b/x-pack/plugins/fleet/server/services/epm/registry/index.ts index 8c5e2c9530b61..eb0725bf8ac42 100644 --- a/x-pack/plugins/fleet/server/services/epm/registry/index.ts +++ b/x-pack/plugins/fleet/server/services/epm/registry/index.ts @@ -5,10 +5,12 @@ * 2.0. */ +import { URL } from 'url'; + import mime from 'mime-types'; import semverValid from 'semver/functions/valid'; import { Response } from 'node-fetch'; -import { URL } from 'url'; + import { KibanaAssetType } from '../../../types'; import type { AssetsGroupedByServiceByType, @@ -26,12 +28,13 @@ import { getPackageInfo, setPackageInfo, } from '../archive'; -import { fetchUrl, getResponse, getResponseStream } from './requests'; import { streamToBuffer } from '../streams'; -import { getRegistryUrl } from './registry_url'; import { appContextService } from '../..'; import { PackageNotFoundError, PackageCacheError } from '../../../errors'; +import { fetchUrl, getResponse, getResponseStream } from './requests'; +import { getRegistryUrl } from './registry_url'; + export interface SearchParams { category?: CategoryId; experimental?: boolean; diff --git a/x-pack/plugins/fleet/server/services/epm/registry/proxy.test.ts b/x-pack/plugins/fleet/server/services/epm/registry/proxy.test.ts index ebaf17a610dae..7ce8f14c04dba 100644 --- a/x-pack/plugins/fleet/server/services/epm/registry/proxy.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/registry/proxy.test.ts @@ -7,6 +7,7 @@ import HttpProxyAgent from 'http-proxy-agent'; import { HttpsProxyAgent } from 'https-proxy-agent'; + import { getProxyAgent, getProxyAgentOptions } from './proxy'; describe('getProxyAgent', () => { diff --git a/x-pack/plugins/fleet/server/services/epm/registry/proxy.ts b/x-pack/plugins/fleet/server/services/epm/registry/proxy.ts index 0be25da2bca23..3c71fa0859fdb 100644 --- a/x-pack/plugins/fleet/server/services/epm/registry/proxy.ts +++ b/x-pack/plugins/fleet/server/services/epm/registry/proxy.ts @@ -8,6 +8,7 @@ import HttpProxyAgent from 'http-proxy-agent'; import HttpsProxyAgent, { HttpsProxyAgent as IHttpsProxyAgent } from 'https-proxy-agent'; import type { HttpsProxyAgentOptions } from 'https-proxy-agent'; + import { appContextService } from '../../index'; export interface RegistryProxySettings { diff --git a/x-pack/plugins/fleet/server/services/epm/registry/requests.test.ts b/x-pack/plugins/fleet/server/services/epm/registry/requests.test.ts index cd9ba20776b07..e1fac27e52042 100644 --- a/x-pack/plugins/fleet/server/services/epm/registry/requests.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/registry/requests.test.ts @@ -5,8 +5,9 @@ * 2.0. */ -import { fetchUrl } from './requests'; import { RegistryError, RegistryConnectionError, RegistryResponseError } from '../../../errors'; + +import { fetchUrl } from './requests'; jest.mock('node-fetch'); const { Response, FetchError } = jest.requireActual('node-fetch'); diff --git a/x-pack/plugins/fleet/server/services/epm/registry/requests.ts b/x-pack/plugins/fleet/server/services/epm/registry/requests.ts index 1b4abbc7e9b71..eff6927732573 100644 --- a/x-pack/plugins/fleet/server/services/epm/registry/requests.ts +++ b/x-pack/plugins/fleet/server/services/epm/registry/requests.ts @@ -8,9 +8,11 @@ import fetch, { FetchError, Response } from 'node-fetch'; import type { RequestInit } from 'node-fetch'; import pRetry from 'p-retry'; + import { streamToString } from '../streams'; import { appContextService } from '../../app_context'; import { RegistryError, RegistryConnectionError, RegistryResponseError } from '../../../errors'; + import { getProxyAgent, getRegistryProxyUrl } from './proxy'; type FailedAttemptErrors = pRetry.FailedAttemptError | FetchError | Error; diff --git a/x-pack/plugins/fleet/server/services/es_index_pattern.ts b/x-pack/plugins/fleet/server/services/es_index_pattern.ts index 015fb91a9660e..993a8bebe42c7 100644 --- a/x-pack/plugins/fleet/server/services/es_index_pattern.ts +++ b/x-pack/plugins/fleet/server/services/es_index_pattern.ts @@ -6,9 +6,11 @@ */ import type { SavedObjectsClientContract } from 'kibana/server'; -import { getInstallation } from './epm/packages'; + import type { ESIndexPatternService } from '../../server'; +import { getInstallation } from './epm/packages'; + export class ESIndexPatternSavedObjectService implements ESIndexPatternService { public async getESIndexPattern( savedObjectsClient: SavedObjectsClientContract, diff --git a/x-pack/plugins/fleet/server/services/fleet_server/elastic_index.test.ts b/x-pack/plugins/fleet/server/services/fleet_server/elastic_index.test.ts index 310db24b8184d..275ea421a508f 100644 --- a/x-pack/plugins/fleet/server/services/fleet_server/elastic_index.test.ts +++ b/x-pack/plugins/fleet/server/services/fleet_server/elastic_index.test.ts @@ -7,6 +7,9 @@ import { elasticsearchServiceMock } from 'src/core/server/mocks'; import hash from 'object-hash'; + +import { FLEET_SERVER_INDICES } from '../../../common'; + import { setupFleetServerIndexes } from './elastic_index'; import ESFleetAgentIndex from './elasticsearch/fleet_agents.json'; import ESFleetPoliciesIndex from './elasticsearch/fleet_policies.json'; @@ -15,7 +18,6 @@ import ESFleetServersIndex from './elasticsearch/fleet_servers.json'; import ESFleetEnrollmentApiKeysIndex from './elasticsearch/fleet_enrollment_api_keys.json'; import EsFleetActionsIndex from './elasticsearch/fleet_actions.json'; import EsFleetArtifactsIndex from './elasticsearch/fleet_artifacts.json'; -import { FLEET_SERVER_INDICES } from '../../../common'; const FLEET_INDEXES_MIGRATION_HASH: Record = { '.fleet-actions': hash(EsFleetActionsIndex), diff --git a/x-pack/plugins/fleet/server/services/fleet_server/elastic_index.ts b/x-pack/plugins/fleet/server/services/fleet_server/elastic_index.ts index 9722c28d96d23..d58228f57a1b2 100644 --- a/x-pack/plugins/fleet/server/services/fleet_server/elastic_index.ts +++ b/x-pack/plugins/fleet/server/services/fleet_server/elastic_index.ts @@ -10,6 +10,7 @@ import hash from 'object-hash'; import { FLEET_SERVER_INDICES, FLEET_SERVER_INDICES_VERSION } from '../../../common'; import { appContextService } from '../app_context'; + import ESFleetAgentIndex from './elasticsearch/fleet_agents.json'; import ESFleetPoliciesIndex from './elasticsearch/fleet_policies.json'; import ESFleetPoliciesLeaderIndex from './elasticsearch/fleet_policies_leader.json'; diff --git a/x-pack/plugins/fleet/server/services/fleet_server/index.ts b/x-pack/plugins/fleet/server/services/fleet_server/index.ts index 0b54dc0d168b4..d43cbaff26476 100644 --- a/x-pack/plugins/fleet/server/services/fleet_server/index.ts +++ b/x-pack/plugins/fleet/server/services/fleet_server/index.ts @@ -6,8 +6,10 @@ */ import { first } from 'rxjs/operators'; + import { appContextService } from '../app_context'; import { licenseService } from '../license'; + import { setupFleetServerIndexes } from './elastic_index'; import { runFleetServerMigration } from './saved_object_migrations'; diff --git a/x-pack/plugins/fleet/server/services/fleet_server/saved_object_migrations.ts b/x-pack/plugins/fleet/server/services/fleet_server/saved_object_migrations.ts index d160925544adf..fab3ac4a72813 100644 --- a/x-pack/plugins/fleet/server/services/fleet_server/saved_object_migrations.ts +++ b/x-pack/plugins/fleet/server/services/fleet_server/saved_object_migrations.ts @@ -7,6 +7,7 @@ import { isBoom } from '@hapi/boom'; import { KibanaRequest } from 'src/core/server'; + import { ENROLLMENT_API_KEYS_INDEX, ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, diff --git a/x-pack/plugins/fleet/server/services/index.ts b/x-pack/plugins/fleet/server/services/index.ts index 3f28a3f987a8e..a3aace9b496f4 100644 --- a/x-pack/plugins/fleet/server/services/index.ts +++ b/x-pack/plugins/fleet/server/services/index.ts @@ -7,7 +7,9 @@ import { KibanaRequest } from 'kibana/server'; import type { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; + import type { AgentStatus, Agent, EsAssetReference } from '../types'; + import { getAgent, listAgents } from './agents'; import { agentPolicyService } from './agent_policy'; import * as settingsService from './settings'; diff --git a/x-pack/plugins/fleet/server/services/install_script/index.ts b/x-pack/plugins/fleet/server/services/install_script/index.ts index d6e36f43e792b..b978eddbfc673 100644 --- a/x-pack/plugins/fleet/server/services/install_script/index.ts +++ b/x-pack/plugins/fleet/server/services/install_script/index.ts @@ -6,6 +6,7 @@ */ import { appContextService } from '../app_context'; + import { macosInstallTemplate } from './install_templates/macos'; import { linuxInstallTemplate } from './install_templates/linux'; diff --git a/x-pack/plugins/fleet/server/services/output.ts b/x-pack/plugins/fleet/server/services/output.ts index 2301570c54cd2..c3850dd1b25b4 100644 --- a/x-pack/plugins/fleet/server/services/output.ts +++ b/x-pack/plugins/fleet/server/services/output.ts @@ -6,11 +6,13 @@ */ import type { SavedObjectsClientContract } from 'src/core/server'; + import type { NewOutput, Output, OutputSOAttributes } from '../types'; import { DEFAULT_OUTPUT, OUTPUT_SAVED_OBJECT_TYPE } from '../constants'; -import { appContextService } from './app_context'; import { decodeCloudId } from '../../common'; +import { appContextService } from './app_context'; + const SAVED_OBJECT_TYPE = OUTPUT_SAVED_OBJECT_TYPE; let cachedAdminUser: null | { username: string; password: string } = null; diff --git a/x-pack/plugins/fleet/server/services/package_policy.test.ts b/x-pack/plugins/fleet/server/services/package_policy.test.ts index e8991f2d66647..b5c465e443ea0 100644 --- a/x-pack/plugins/fleet/server/services/package_policy.test.ts +++ b/x-pack/plugins/fleet/server/services/package_policy.test.ts @@ -10,15 +10,19 @@ import { savedObjectsClientMock, httpServerMock, } from 'src/core/server/mocks'; -import { createPackagePolicyMock } from '../../common/mocks'; -import { packagePolicyService } from './package_policy'; -import type { PackageInfo, PackagePolicySOAttributes } from '../types'; + import type { SavedObjectsUpdateResponse } from 'src/core/server'; import { KibanaRequest } from 'kibana/server'; + +import type { PackageInfo, PackagePolicySOAttributes } from '../types'; +import { createPackagePolicyMock } from '../../common/mocks'; import type { ExternalCallback } from '..'; -import { appContextService } from './app_context'; + import { createAppContextStartContractMock, xpackMocks } from '../mocks'; +import { packagePolicyService } from './package_policy'; +import { appContextService } from './app_context'; + async function mockedGetAssetsData(_a: any, _b: any, dataset: string) { if (dataset === 'dataset1') { return [ diff --git a/x-pack/plugins/fleet/server/services/package_policy.ts b/x-pack/plugins/fleet/server/services/package_policy.ts index 3a350ded2d7ed..54772096fa88f 100644 --- a/x-pack/plugins/fleet/server/services/package_policy.ts +++ b/x-pack/plugins/fleet/server/services/package_policy.ts @@ -12,6 +12,7 @@ import type { SavedObjectsClientContract, } from 'src/core/server'; import uuid from 'uuid'; + import type { AuthenticatedUser } from '../../../security/server'; import { packageToPackagePolicy, @@ -38,6 +39,8 @@ import type { RegistryPackage, CallESAsCurrentUser, } from '../types'; +import { ExternalCallback } from '..'; + import { agentPolicyService } from './agent_policy'; import { outputService } from './output'; import * as Registry from './epm/registry'; @@ -46,7 +49,6 @@ import { getAssetsData } from './epm/packages/assets'; import { compileTemplate } from './epm/agent/agent'; import { normalizeKuery } from './saved_object'; import { appContextService } from '.'; -import type { ExternalCallback } from '..'; const SAVED_OBJECT_TYPE = PACKAGE_POLICY_SAVED_OBJECT_TYPE; diff --git a/x-pack/plugins/fleet/server/services/saved_object.ts b/x-pack/plugins/fleet/server/services/saved_object.ts index da416fa812cc4..bdecffb843e8e 100644 --- a/x-pack/plugins/fleet/server/services/saved_object.ts +++ b/x-pack/plugins/fleet/server/services/saved_object.ts @@ -6,6 +6,7 @@ */ import type { SavedObjectsClientContract, SavedObjectsFindResponse } from 'src/core/server'; + import { SO_SEARCH_LIMIT } from '../constants'; import type { ListWithKuery } from '../types'; diff --git a/x-pack/plugins/fleet/server/services/settings.ts b/x-pack/plugins/fleet/server/services/settings.ts index 01454c6217c05..3a322ebb7dd9d 100644 --- a/x-pack/plugins/fleet/server/services/settings.ts +++ b/x-pack/plugins/fleet/server/services/settings.ts @@ -5,11 +5,14 @@ * 2.0. */ +import url from 'url'; + import Boom from '@hapi/boom'; import type { SavedObjectsClientContract } from 'kibana/server'; -import url from 'url'; + import { GLOBAL_SETTINGS_SAVED_OBJECT_TYPE, decodeCloudId } from '../../common'; import type { SettingsSOAttributes, Settings, BaseSettings } from '../../common'; + import { appContextService } from './app_context'; export async function getSettings(soClient: SavedObjectsClientContract): Promise { diff --git a/x-pack/plugins/fleet/server/services/setup.test.ts b/x-pack/plugins/fleet/server/services/setup.test.ts index 479f28fa0a1ed..8120e41ade606 100644 --- a/x-pack/plugins/fleet/server/services/setup.test.ts +++ b/x-pack/plugins/fleet/server/services/setup.test.ts @@ -6,6 +6,7 @@ */ import { createAppContextStartContractMock, xpackMocks } from '../mocks'; + import { appContextService } from './app_context'; import { setupIngestManager } from './setup'; diff --git a/x-pack/plugins/fleet/server/services/setup.ts b/x-pack/plugins/fleet/server/services/setup.ts index b90f223629b60..0dd30b80869e1 100644 --- a/x-pack/plugins/fleet/server/services/setup.ts +++ b/x-pack/plugins/fleet/server/services/setup.ts @@ -7,21 +7,26 @@ import uuid from 'uuid'; import type { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; + import type { CallESAsCurrentUser } from '../types'; -import { agentPolicyService } from './agent_policy'; -import { outputService } from './output'; -import { - ensureInstalledDefaultPackages, - ensureInstalledPackage, - ensurePackagesCompletedInstall, -} from './epm/packages/install'; + import { packageToPackagePolicy, DEFAULT_AGENT_POLICIES_PACKAGES, FLEET_SERVER_PACKAGE, } from '../../common'; + import type { PackagePolicy, AgentPolicy, Installation, Output } from '../../common'; + import { SO_SEARCH_LIMIT } from '../constants'; + +import { agentPolicyService } from './agent_policy'; +import { outputService } from './output'; +import { + ensureInstalledDefaultPackages, + ensureInstalledPackage, + ensurePackagesCompletedInstall, +} from './epm/packages/install'; import { getPackageInfo } from './epm/packages'; import { packagePolicyService } from './package_policy'; import { generateEnrollmentAPIKey } from './api_keys'; diff --git a/x-pack/plugins/fleet/server/types/models/agent_policy.ts b/x-pack/plugins/fleet/server/types/models/agent_policy.ts index 5891320c2544b..90615c2df7bf6 100644 --- a/x-pack/plugins/fleet/server/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/agent_policy.ts @@ -6,9 +6,11 @@ */ import { schema } from '@kbn/config-schema'; -import { PackagePolicySchema, NamespaceSchema } from './package_policy'; + import { agentPolicyStatuses, dataTypes } from '../../../common'; +import { PackagePolicySchema, NamespaceSchema } from './package_policy'; + const AgentPolicyBaseSchema = { name: schema.string({ minLength: 1 }), namespace: NamespaceSchema, diff --git a/x-pack/plugins/fleet/server/types/models/output.ts b/x-pack/plugins/fleet/server/types/models/output.ts index bb9ce26de7f22..679500a6490e7 100644 --- a/x-pack/plugins/fleet/server/types/models/output.ts +++ b/x-pack/plugins/fleet/server/types/models/output.ts @@ -6,6 +6,7 @@ */ import { schema } from '@kbn/config-schema'; + import { outputType } from '../../../common/constants'; const OutputBaseSchema = { diff --git a/x-pack/plugins/fleet/server/types/models/package_policy.ts b/x-pack/plugins/fleet/server/types/models/package_policy.ts index 1d47ac9d3ea40..6248b375f8edb 100644 --- a/x-pack/plugins/fleet/server/types/models/package_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/package_policy.ts @@ -6,6 +6,7 @@ */ import { schema } from '@kbn/config-schema'; + import { isValidNamespace } from '../../../common'; export const NamespaceSchema = schema.string({ diff --git a/x-pack/plugins/fleet/server/types/rest_spec/agent.ts b/x-pack/plugins/fleet/server/types/rest_spec/agent.ts index 847dd75c4fe65..e74a4e6ed55bd 100644 --- a/x-pack/plugins/fleet/server/types/rest_spec/agent.ts +++ b/x-pack/plugins/fleet/server/types/rest_spec/agent.ts @@ -6,6 +6,7 @@ */ import { schema } from '@kbn/config-schema'; + import { NewAgentActionSchema } from '../models'; export const GetAgentsRequestSchema = { diff --git a/x-pack/plugins/fleet/server/types/rest_spec/agent_policy.ts b/x-pack/plugins/fleet/server/types/rest_spec/agent_policy.ts index 48017522f0ba2..714ffab922dd9 100644 --- a/x-pack/plugins/fleet/server/types/rest_spec/agent_policy.ts +++ b/x-pack/plugins/fleet/server/types/rest_spec/agent_policy.ts @@ -6,7 +6,9 @@ */ import { schema } from '@kbn/config-schema'; + import { NewAgentPolicySchema } from '../models'; + import { ListWithKuerySchema } from './index'; export const GetAgentPoliciesRequestSchema = { diff --git a/x-pack/plugins/fleet/server/types/rest_spec/package_policy.ts b/x-pack/plugins/fleet/server/types/rest_spec/package_policy.ts index 86776a9a31e6a..3c6f54177096e 100644 --- a/x-pack/plugins/fleet/server/types/rest_spec/package_policy.ts +++ b/x-pack/plugins/fleet/server/types/rest_spec/package_policy.ts @@ -6,7 +6,9 @@ */ import { schema } from '@kbn/config-schema'; + import { NewPackagePolicySchema, UpdatePackagePolicySchema } from '../models'; + import { ListWithKuerySchema } from './index'; export const GetPackagePoliciesRequestSchema = { diff --git a/x-pack/plugins/fleet/server/types/rest_spec/settings.ts b/x-pack/plugins/fleet/server/types/rest_spec/settings.ts index 13077a560a1be..fa885d45c1115 100644 --- a/x-pack/plugins/fleet/server/types/rest_spec/settings.ts +++ b/x-pack/plugins/fleet/server/types/rest_spec/settings.ts @@ -6,6 +6,7 @@ */ import { schema } from '@kbn/config-schema'; + import { isDiffPathProtocol } from '../../../common'; export const GetSettingsRequestSchema = {};