From f9be98d8485dbc73afe9bf918ee1d5111988a572 Mon Sep 17 00:00:00 2001 From: John Schulz <john.schulz@elastic.co> Date: Tue, 2 Mar 2021 13:40:47 -0500 Subject: [PATCH] Add eslint rule to enforce/autofix import group order --- .eslintrc.js | 15 +++++++++++++ .../fleet/common/constants/agent_policy.ts | 2 +- .../services/is_agent_upgradeable.test.ts | 2 +- .../fleet/common/types/models/agent.ts | 2 +- .../fleet/public/applications/fleet/app.tsx | 6 ++--- .../fleet/hooks/use_fleet_status.tsx | 2 +- .../fleet/hooks/use_request/agent_policy.ts | 12 +++++----- .../fleet/hooks/use_request/agents.ts | 2 +- .../fleet/hooks/use_request/app.ts | 2 +- .../fleet/hooks/use_request/data_stream.ts | 2 +- .../hooks/use_request/enrollment_api_keys.ts | 12 +++++----- .../fleet/hooks/use_request/epm.ts | 2 +- .../fleet/hooks/use_request/outputs.ts | 2 +- .../fleet/hooks/use_request/package_policy.ts | 2 +- .../fleet/hooks/use_request/settings.ts | 2 +- .../fleet/hooks/use_request/setup.ts | 2 +- .../fleet/mock/create_test_renderer.tsx | 2 +- .../fleet/mock/fleet_start_services.tsx | 2 +- .../create_package_policy_page/index.test.tsx | 8 +++---- .../create_package_policy_page/index.tsx | 12 +++++----- .../step_define_package_policy.tsx | 2 +- .../agent_policy/details_page/index.tsx | 4 ++-- .../components/agent_logs/agent_logs.tsx | 2 +- .../agent_logs/filter_log_level.tsx | 2 +- .../agents/agent_details_page/index.tsx | 4 ++-- .../standalone_instructions.tsx | 2 +- .../agent_enrollment_flyout/steps.tsx | 2 +- .../fleet/sections/agents/index.tsx | 2 +- .../epm/components/package_list_grid.tsx | 2 +- .../epm/screens/detail/index.test.tsx | 8 +++---- .../components/agent_policy_section.tsx | 4 ++-- .../overview/components/agent_section.tsx | 4 ++-- .../components/datastream_section.tsx | 4 ++-- .../components/integration_section.tsx | 4 ++-- x-pack/plugins/fleet/public/plugin.ts | 2 +- .../plugins/fleet/scripts/dev_agent/script.ts | 2 +- .../fleet/server/collectors/register.ts | 2 +- x-pack/plugins/fleet/server/index.ts | 2 +- x-pack/plugins/fleet/server/mocks.ts | 2 +- x-pack/plugins/fleet/server/plugin.ts | 14 ++++++------ .../server/routes/agent/acks_handlers.test.ts | 2 +- .../routes/agent/actions_handlers.test.ts | 4 ++-- .../fleet/server/routes/agent/index.ts | 6 ++--- .../fleet/server/routes/epm/handlers.ts | 2 +- .../plugins/fleet/server/routes/epm/index.ts | 22 +++++++++---------- .../server/routes/limited_concurrency.test.ts | 2 +- .../fleet/server/routes/output/index.ts | 2 +- .../routes/package_policy/handlers.test.ts | 2 +- .../server/routes/setup/handlers.test.ts | 2 +- .../fleet/server/routes/setup/index.ts | 2 +- .../fleet/server/saved_objects/index.ts | 10 ++++----- .../server/services/agent_policy.test.ts | 2 +- .../fleet/server/services/agent_policy.ts | 2 +- .../server/services/agents/actions.test.ts | 4 ++-- .../fleet/server/services/agents/actions.ts | 4 ++-- .../server/services/agents/checkin/index.ts | 2 +- .../server/services/agents/checkin/state.ts | 2 +- .../agents/checkin/state_new_actions.test.ts | 6 ++--- .../agents/checkin/state_new_actions.ts | 2 +- .../services/agents/crud_fleet_server.ts | 2 +- .../fleet/server/services/agents/crud_so.ts | 2 +- .../fleet/server/services/agents/enroll.ts | 2 +- .../fleet/server/services/agents/reassign.ts | 2 +- .../server/services/agents/status.test.ts | 4 ++-- .../fleet/server/services/agents/status.ts | 2 +- .../fleet/server/services/agents/unenroll.ts | 2 +- .../fleet/server/services/agents/update.ts | 2 +- .../fleet/server/services/agents/upgrade.ts | 4 ++-- .../enrollment_api_key_fleet_server.ts | 2 +- .../api_keys/enrollment_api_key_so.ts | 2 +- .../server/services/epm/archive/cache.ts | 2 +- .../server/services/epm/archive/storage.ts | 2 +- .../server/services/epm/archive/validation.ts | 2 +- .../elasticsearch/datastream_ilm/install.ts | 2 +- .../ingest_pipeline/ingest_pipelines.test.ts | 2 +- .../elasticsearch/template/install.test.ts | 2 +- .../epm/elasticsearch/template/install.ts | 4 ++-- .../elasticsearch/template/template.test.ts | 2 +- .../epm/elasticsearch/transform/install.ts | 4 ++-- .../elasticsearch/transform/remove.test.ts | 2 +- .../elasticsearch/transform/transform.test.ts | 5 +++-- .../server/services/epm/fields/field.test.ts | 2 +- .../epm/kibana/index_pattern/install.test.ts | 2 +- .../services/epm/packages/_install_package.ts | 4 ++-- .../services/epm/packages/assets.test.ts | 2 +- .../ensure_installed_default_packages.test.ts | 5 +++-- .../fleet/server/services/epm/packages/get.ts | 2 +- .../server/services/epm/packages/install.ts | 16 +++++++------- .../server/services/epm/packages/remove.ts | 2 +- .../server/services/epm/registry/index.ts | 6 ++--- .../services/epm/registry/requests.test.ts | 2 +- .../fleet/server/services/es_index_pattern.ts | 2 +- .../fleet_server/elastic_index.test.ts | 2 +- .../plugins/fleet/server/services/output.ts | 2 +- .../server/services/package_policy.test.ts | 8 +++---- .../fleet/server/services/package_policy.ts | 2 +- .../plugins/fleet/server/services/settings.ts | 2 +- x-pack/plugins/fleet/server/services/setup.ts | 14 ++++++------ .../fleet/server/types/models/agent_policy.ts | 2 +- 99 files changed, 196 insertions(+), 179 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9cc7985b8bce2..44bd2201fec4d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -789,6 +789,21 @@ module.exports = { }, }, + /** + * Fleet overrides + */ + { + files: ['x-pack/plugins/fleet/**/*.{js,mjs,ts,tsx}'], + rules: { + 'import/order': [ + 'warn', + { + groups: ['builtin', 'external', 'internal', 'parent'], + }, + ], + }, + }, + /** * 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 bed9b6e8390b8..885a7b59026da 100644 --- a/x-pack/plugins/fleet/common/constants/agent_policy.ts +++ b/x-pack/plugins/fleet/common/constants/agent_policy.ts @@ -5,8 +5,8 @@ * 2.0. */ -import { defaultPackages } from './epm'; import { 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/is_agent_upgradeable.test.ts b/x-pack/plugins/fleet/common/services/is_agent_upgradeable.test.ts index ed5e2a22709c4..fe3371ceda74c 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,8 +5,8 @@ * 2.0. */ -import { isAgentUpgradeable } from './is_agent_upgradeable'; import { Agent } from '../types/models/agent'; +import { isAgentUpgradeable } from './is_agent_upgradeable'; const getAgent = ({ version, diff --git a/x-pack/plugins/fleet/common/types/models/agent.ts b/x-pack/plugins/fleet/common/types/models/agent.ts index 2e18d427272ce..3781d1292ef7c 100644 --- a/x-pack/plugins/fleet/common/types/models/agent.ts +++ b/x-pack/plugins/fleet/common/types/models/agent.ts @@ -5,8 +5,8 @@ * 2.0. */ -import { FullAgentPolicy } from './agent_policy'; import { AGENT_TYPE_EPHEMERAL, AGENT_TYPE_PERMANENT, AGENT_TYPE_TEMPORARY } from '../../constants'; +import { FullAgentPolicy } from './agent_policy'; export type AgentType = | typeof AGENT_TYPE_EPHEMERAL diff --git a/x-pack/plugins/fleet/public/applications/fleet/app.tsx b/x-pack/plugins/fleet/public/applications/fleet/app.tsx index b441a2181af35..960db7fb38a73 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/app.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/app.tsx @@ -14,6 +14,9 @@ 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 +37,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/hooks/use_fleet_status.tsx b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_fleet_status.tsx index 71161c17a7b49..64ce21266350c 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,9 @@ */ 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_request/agent_policy.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agent_policy.ts index 2cba3b48a9564..26e781773ea88 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,12 +5,6 @@ * 2.0. */ -import { - useRequest, - sendRequest, - useConditionalRequest, - SendConditionalRequestConfig, -} from './use_request'; import { agentPolicyRouteService } from '../../services'; import { GetAgentPoliciesRequest, @@ -26,6 +20,12 @@ import { DeleteAgentPolicyRequest, DeleteAgentPolicyResponse, } from '../../types'; +import { + useRequest, + sendRequest, + useConditionalRequest, + SendConditionalRequestConfig, +} from './use_request'; export const useGetAgentPolicies = (query?: GetAgentPoliciesRequest['query']) => { return useRequest<GetAgentPoliciesResponse>({ 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 7f774a85ff9d6..8d40d7befa189 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,7 +5,6 @@ * 2.0. */ -import { useRequest, UseRequestConfig, sendRequest } from './use_request'; import { agentRouteService } from '../../services'; import { GetOneAgentResponse, @@ -30,6 +29,7 @@ import { PostNewAgentActionRequest, PostNewAgentActionResponse, } from '../../types'; +import { useRequest, UseRequestConfig, sendRequest } from './use_request'; type RequestOptions = Pick<Partial<UseRequestConfig>, 'pollIntervalMs'>; 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 00f093474695f..813628182e15c 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,9 +5,9 @@ * 2.0. */ -import { sendRequest } from './use_request'; import { appRoutesService } from '../../services'; import { CheckPermissionsResponse } from '../../types'; +import { sendRequest } from './use_request'; export const sendGetPermissionsCheck = () => { return sendRequest<CheckPermissionsResponse>({ 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 9e275e606f667..2437bdbdcad6d 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,9 +5,9 @@ * 2.0. */ -import { useRequest } from './use_request'; import { dataStreamRouteService } from '../../services'; import { GetDataStreamsResponse } from '../../types'; +import { useRequest } from './use_request'; export const useGetDataStreams = () => { return useRequest<GetDataStreamsResponse>({ 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 cd0397d611df1..98ce844c7bd43 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,6 +5,12 @@ * 2.0. */ +import { enrollmentAPIKeyRouteService } from '../../services'; +import { + GetOneEnrollmentAPIKeyResponse, + GetEnrollmentAPIKeysResponse, + GetEnrollmentAPIKeysRequest, +} from '../../types'; import { useRequest, UseRequestConfig, @@ -12,12 +18,6 @@ import { useConditionalRequest, SendConditionalRequestConfig, } from './use_request'; -import { enrollmentAPIKeyRouteService } from '../../services'; -import { - GetOneEnrollmentAPIKeyResponse, - GetEnrollmentAPIKeysResponse, - GetEnrollmentAPIKeysRequest, -} from '../../types'; type RequestOptions = Pick<Partial<UseRequestConfig>, 'pollIntervalMs'>; 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 f518ee2ea44ff..c645bf0ddf9ff 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 { GetCategoriesRequest, @@ -18,6 +17,7 @@ import { DeletePackageResponse, } from '../../types'; import { GetStatsResponse } from '../../../../../common'; +import { useRequest, sendRequest } from './use_request'; export const useGetCategories = (query: GetCategoriesRequest['query'] = {}) => { return useRequest<GetCategoriesResponse>({ 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 1c43b84b2bc02..26130a9021ce8 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,9 +5,9 @@ * 2.0. */ -import { sendRequest, useRequest } from './use_request'; import { outputRoutesService } from '../../services'; import { PutOutputRequest, GetOutputsResponse } from '../../types'; +import { sendRequest, useRequest } from './use_request'; export function useGetOutputs() { return useRequest<GetOutputsResponse>({ 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 ee4a4e4c24e28..9b234c512ddbf 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 { CreatePackagePolicyRequest, @@ -20,6 +19,7 @@ import { GetPackagePoliciesResponse, GetOnePackagePolicyResponse, } from '../../../../../common/types/rest_spec'; +import { sendRequest, useRequest } from './use_request'; export const sendCreatePackagePolicy = (body: CreatePackagePolicyRequest['body']) => { return sendRequest<CreatePackagePolicyResponse>({ 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 9cc54a5c4223b..ed3a079d46502 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,9 +5,9 @@ * 2.0. */ -import { sendRequest, useRequest } from './use_request'; import { settingsRoutesService } from '../../services'; import { PutSettingsResponse, PutSettingsRequest, GetSettingsResponse } from '../../types'; +import { sendRequest, useRequest } from './use_request'; export function useGetSettings() { return useRequest<GetSettingsResponse>({ 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 0f52712e8ded9..9154662757efb 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,9 +5,9 @@ * 2.0. */ -import { sendRequest } from './use_request'; import { setupRouteService, fleetSetupRouteService } from '../../services'; import { GetFleetStatusResponse } from '../../types'; +import { sendRequest } from './use_request'; export const sendSetup = () => { return sendRequest({ 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..2f92a952db23c 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 @@ -11,8 +11,8 @@ import { render as reactRender, RenderOptions, RenderResult, act } from '@testin 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..826166df07ee8 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 @@ -9,9 +9,9 @@ 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/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..1ecf68a9fdbd0 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,13 +5,13 @@ * 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' }); 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..54f598a8ced17 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 @@ -37,6 +37,12 @@ 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 +54,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/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 c66a28944ea71..acc2a1e55fcbe 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 @@ -21,8 +21,8 @@ import { 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; 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..d4bf80d5e33a3 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 @@ -33,10 +33,10 @@ 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; 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..48414a0139d66 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,9 @@ * 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 { 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..edacdc7d1e959 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,8 +8,8 @@ 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 [ 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..0d17c9d2afc90 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 @@ -34,10 +34,10 @@ 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 { 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..e7d313d4edfe7 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 @@ -23,8 +23,8 @@ 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..995955bb44b67 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,8 +9,8 @@ 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 { 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..2057896e72278 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 @@ -11,13 +11,13 @@ 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/epm/components/package_list_grid.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_list_grid.tsx index 7f089430d547c..2029d054fa075 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 @@ -22,8 +22,8 @@ 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; 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..eb504f901f78b 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,10 @@ * 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 +23,8 @@ 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/overview/components/agent_policy_section.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/components/agent_policy_section.tsx index c3b59458abf0a..39bfb8c800e38 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,12 +14,12 @@ 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..03fbcb5072286 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,10 +14,10 @@ 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(); 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..a81d4e5843d64 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,10 +14,10 @@ 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(); 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..4d7da7c97fdcb 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,11 +14,11 @@ 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(); diff --git a/x-pack/plugins/fleet/public/plugin.ts b/x-pack/plugins/fleet/public/plugin.ts index 50e647e271ecc..5b1750476aee4 100644 --- a/x-pack/plugins/fleet/public/plugin.ts +++ b/x-pack/plugins/fleet/public/plugin.ts @@ -22,10 +22,10 @@ import { import { Storage } from '../../../../src/plugins/kibana_utils/public'; import { LicensingPluginSetup } from '../../licensing/public'; import { PLUGIN_ID, CheckPermissionsResponse, PostIngestSetupResponse } from '../common'; -import { BASE_PATH } from './applications/fleet/constants'; import { FleetConfigType } from '../common/types'; import { setupRouteService, appRoutesService } from '../common'; +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 fc4a10f4f655f..26acff8c6fb47 100644 --- a/x-pack/plugins/fleet/scripts/dev_agent/script.ts +++ b/x-pack/plugins/fleet/scripts/dev_agent/script.ts @@ -5,9 +5,9 @@ * 2.0. */ +import os from 'os'; import { createFlagError, run, ToolingLog } from '@kbn/dev-utils'; import fetch from 'node-fetch'; -import os from 'os'; import { Agent as _Agent, PostAgentCheckinRequest, diff --git a/x-pack/plugins/fleet/server/collectors/register.ts b/x-pack/plugins/fleet/server/collectors/register.ts index c2e043145cd97..ecc9395452fdc 100644 --- a/x-pack/plugins/fleet/server/collectors/register.ts +++ b/x-pack/plugins/fleet/server/collectors/register.ts @@ -7,11 +7,11 @@ import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { CoreSetup } from 'kibana/server'; +import { FleetConfigType } from '..'; import { getIsAgentsEnabled } from './config_collectors'; import { AgentUsage, getAgentUsage } from './agent_collectors'; import { getInternalClients } from './helpers'; import { PackageUsage, getPackageUsage } from './package_collectors'; -import { FleetConfigType } from '..'; interface Usage { agents_enabled: boolean; diff --git a/x-pack/plugins/fleet/server/index.ts b/x-pack/plugins/fleet/server/index.ts index 2d189d5f940ae..4b98f59458aec 100644 --- a/x-pack/plugins/fleet/server/index.ts +++ b/x-pack/plugins/fleet/server/index.ts @@ -7,12 +7,12 @@ import { schema, TypeOf } from '@kbn/config-schema'; import { 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 { diff --git a/x-pack/plugins/fleet/server/mocks.ts b/x-pack/plugins/fleet/server/mocks.ts index 430e38bd1bc3e..84c1004720276 100644 --- a/x-pack/plugins/fleet/server/mocks.ts +++ b/x-pack/plugins/fleet/server/mocks.ts @@ -13,9 +13,9 @@ import { import { coreMock } from '../../../../src/core/server/mocks'; import { licensingMock } from '../../../plugins/licensing/server/mocks'; -import { FleetAppContext } from './plugin'; import { encryptedSavedObjectsMock } from '../../encrypted_saved_objects/server/mocks'; import { securityMock } from '../../security/server/mocks'; +import { FleetAppContext } from './plugin'; import { PackagePolicyServiceInterface } from './services/package_policy'; import { AgentPolicyServiceInterface, AgentService } from './services'; diff --git a/x-pack/plugins/fleet/server/plugin.ts b/x-pack/plugins/fleet/server/plugin.ts index d4cd39b274f05..5f89c1f73e81f 100644 --- a/x-pack/plugins/fleet/server/plugin.ts +++ b/x-pack/plugins/fleet/server/plugin.ts @@ -29,6 +29,13 @@ 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 +62,6 @@ import { registerSettingsRoutes, registerAppRoutes, } from './routes'; -import { - EsAssetReference, - FleetConfigType, - NewPackagePolicy, - UpdatePackagePolicy, -} from '../common'; import { appContextService, licenseService, @@ -78,7 +79,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 e1ed453a572f6..90c2206cbc24c 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,7 +5,6 @@ * 2.0. */ -import { postAgentAcksHandlerBuilder } from './acks_handlers'; import { ElasticsearchClient, KibanaResponseFactory, @@ -20,6 +19,7 @@ import { import { PostAgentAcksResponse } from '../../../common/types/rest_spec'; import { AckEventSchema } from '../../types/models'; import { AcksService } from '../../services/agents'; +import { postAgentAcksHandlerBuilder } from './acks_handlers'; describe('test acks schema', () => { it('validate that ack event schema expect action id', async () => { 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 6affe332b8f87..c847ef0b55260 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 { ElasticsearchClient, KibanaResponseFactory, @@ -17,13 +16,14 @@ import { savedObjectsClientMock, httpServerMock, } from 'src/core/server/mocks'; +import { NewAgentActionSchema } from '../../types/models'; import { ActionsService } from '../../services/agents'; import { AgentAction } from '../../../common/types/models'; -import { postNewAgentActionHandlerBuilder } from './actions_handlers'; import { 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 () => { diff --git a/x-pack/plugins/fleet/server/routes/agent/index.ts b/x-pack/plugins/fleet/server/routes/agent/index.ts index 86c88aeaf46ac..ed0c302b8a7c0 100644 --- a/x-pack/plugins/fleet/server/routes/agent/index.ts +++ b/x-pack/plugins/fleet/server/routes/agent/index.ts @@ -34,6 +34,9 @@ import { PostAgentUpgradeRequestSchema, PostBulkAgentUpgradeRequestSchema, } from '../../types'; +import * as AgentService from '../../services/agents'; +import { appContextService } from '../../services'; +import { FleetConfigType } from '../..'; import { getAgentsHandler, getAgentHandler, @@ -47,11 +50,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 { FleetConfigType } from '../..'; import { postAgentUpgradeHandler, postBulkAgentsUpgradeHandler } from './upgrade_handler'; const ajv = new Ajv({ diff --git a/x-pack/plugins/fleet/server/routes/epm/handlers.ts b/x-pack/plugins/fleet/server/routes/epm/handlers.ts index 47e53b27a600f..585910f74dcbe 100644 --- a/x-pack/plugins/fleet/server/routes/epm/handlers.ts +++ b/x-pack/plugins/fleet/server/routes/epm/handlers.ts @@ -5,9 +5,9 @@ * 2.0. */ +import path from 'path'; import { TypeOf } from '@kbn/config-schema'; import mime from 'mime-types'; -import path from 'path'; import { RequestHandler, ResponseHeaders, KnownHeaders } from 'src/core/server'; import { GetInfoResponse, diff --git a/x-pack/plugins/fleet/server/routes/epm/index.ts b/x-pack/plugins/fleet/server/routes/epm/index.ts index f5788fe252beb..f250b6a460c05 100644 --- a/x-pack/plugins/fleet/server/routes/epm/index.ts +++ b/x-pack/plugins/fleet/server/routes/epm/index.ts @@ -7,6 +7,17 @@ import { 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 +30,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/limited_concurrency.test.ts b/x-pack/plugins/fleet/server/routes/limited_concurrency.test.ts index f71aeb80a6d3e..0c0fd7f8fa3a0 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,12 @@ */ import { coreMock, httpServerMock, httpServiceMock } from 'src/core/server/mocks'; +import { FleetConfigType } from '../index'; import { createLimitedPreAuthHandler, isLimitedRoute, registerLimitedConcurrencyRoutes, } from './limited_concurrency'; -import { FleetConfigType } from '../index'; describe('registerLimitedConcurrencyRoutes', () => { test(`doesn't call registerOnPreAuth if maxConcurrentConnections is 0`, async () => { diff --git a/x-pack/plugins/fleet/server/routes/output/index.ts b/x-pack/plugins/fleet/server/routes/output/index.ts index 7114a7c673d6b..301961b8fa7b4 100644 --- a/x-pack/plugins/fleet/server/routes/output/index.ts +++ b/x-pack/plugins/fleet/server/routes/output/index.ts @@ -7,12 +7,12 @@ import { 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 813279f2a800f..4110429dd02cc 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 @@ -7,13 +7,13 @@ import { httpServerMock, httpServiceMock } from 'src/core/server/mocks'; import { IRouter, KibanaRequest, RequestHandler, RouteConfig } from 'kibana/server'; -import { registerRoutes } from './index'; import { PACKAGE_POLICY_API_ROUTES } from '../../../common/constants'; import { appContextService } from '../../services'; import { createAppContextStartContractMock, xpackMocks } from '../../mocks'; import { PackagePolicyServiceInterface, ExternalCallback } from '../..'; import { CreatePackagePolicyRequestSchema } from '../../types/rest_spec'; import { packagePolicyService } from '../../services'; +import { registerRoutes } from './index'; const packagePolicyServiceMock = packagePolicyService as jest.Mocked<PackagePolicyServiceInterface>; 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 946f17ad8129d..743fea1562c12 100644 --- a/x-pack/plugins/fleet/server/routes/setup/handlers.test.ts +++ b/x-pack/plugins/fleet/server/routes/setup/handlers.test.ts @@ -9,9 +9,9 @@ import { httpServerMock } from 'src/core/server/mocks'; import { 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 { diff --git a/x-pack/plugins/fleet/server/routes/setup/index.ts b/x-pack/plugins/fleet/server/routes/setup/index.ts index 3698b74c8c02b..5b288ee8fe2f5 100644 --- a/x-pack/plugins/fleet/server/routes/setup/index.ts +++ b/x-pack/plugins/fleet/server/routes/setup/index.ts @@ -9,8 +9,8 @@ import { IRouter } from 'src/core/server'; import { PLUGIN_ID, AGENTS_SETUP_API_ROUTES, SETUP_API_ROUTE } from '../../constants'; import { 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 d6e3cba998907..2dfe6206aad1e 100644 --- a/x-pack/plugins/fleet/server/saved_objects/index.ts +++ b/x-pack/plugins/fleet/server/saved_objects/index.ts @@ -7,11 +7,6 @@ import { SavedObjectsServiceSetup, SavedObjectsType } from 'kibana/server'; import { 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 +19,11 @@ 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/services/agent_policy.test.ts b/x-pack/plugins/fleet/server/services/agent_policy.test.ts index 800d4f479bfde..3524ced67aae6 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,9 @@ */ 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 44962ea31c56c..de398bff96a84 100644 --- a/x-pack/plugins/fleet/server/services/agent_policy.ts +++ b/x-pack/plugins/fleet/server/services/agent_policy.ts @@ -42,13 +42,13 @@ 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/agents/actions.test.ts b/x-pack/plugins/fleet/server/services/agents/actions.test.ts index 3d391cc89a7e3..4daa31e008497 100644 --- a/x-pack/plugins/fleet/server/services/agents/actions.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/actions.test.ts @@ -5,10 +5,10 @@ * 2.0. */ -import { createAgentAction } from './actions'; import { SavedObject } from 'kibana/server'; -import { AgentAction } from '../../../common/types/models'; import { savedObjectsClientMock, elasticsearchServiceMock } from 'src/core/server/mocks'; +import { AgentAction } from '../../../common/types/models'; +import { createAgentAction } from './actions'; describe('test agent actions services', () => { it('should create a new action', async () => { diff --git a/x-pack/plugins/fleet/server/services/agents/actions.ts b/x-pack/plugins/fleet/server/services/agents/actions.ts index 8dfeac11dacf3..cf8b76f5ad691 100644 --- a/x-pack/plugins/fleet/server/services/agents/actions.ts +++ b/x-pack/plugins/fleet/server/services/agents/actions.ts @@ -16,13 +16,13 @@ import { 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/checkin/index.ts b/x-pack/plugins/fleet/server/services/agents/checkin/index.ts index bcebedae2e07a..a6a4b5f2f30a6 100644 --- a/x-pack/plugins/fleet/server/services/agents/checkin/index.ts +++ b/x-pack/plugins/fleet/server/services/agents/checkin/index.ts @@ -20,9 +20,9 @@ import { } 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, 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 e1cec6292a355..479d58cc3d180 100644 --- a/x-pack/plugins/fleet/server/services/agents/checkin/state.ts +++ b/x-pack/plugins/fleet/server/services/agents/checkin/state.ts @@ -8,9 +8,9 @@ import { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; import { 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_new_actions.test.ts b/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.test.ts index cd6e0ef61e3f0..128689d7ebae3 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,13 @@ import { ElasticsearchClient } from 'kibana/server'; import { savedObjectsClientMock } from 'src/core/server/mocks'; import { take } from 'rxjs/operators'; +import { getNewActionsSince } from '../actions'; +import { Agent, AgentAction, AgentPolicyAction } from '../../../types'; +import { outputType } from '../../../../common/constants'; import { createAgentActionFromPolicyAction, createNewActionsSharedObservable, } from './state_new_actions'; -import { getNewActionsSince } from '../actions'; -import { 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 01759c2015cdf..477aebfdcea9f 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 @@ -44,8 +44,8 @@ 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 = ({ 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 caff15efff68c..a5c4b31837424 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 @@ -14,9 +14,9 @@ import { AGENT_SAVED_OBJECT_TYPE, AGENTS_INDEX } from '../../constants'; import { ESSearchHit } from '../../../../../typings/elasticsearch'; import { AgentSOAttributes, Agent, ListWithKuery } from '../../types'; import { escapeSearchQueryPhrase, normalizeKuery } from '../saved_object'; -import { searchHitToAgent, agentSOAttributesToFleetServerAgentDoc } from './helpers'; import { appContextService } from '../../services'; import { esKuery, 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 c3ceb4b7502e2..2bd50047bbaa5 100644 --- a/x-pack/plugins/fleet/server/services/agents/crud_so.ts +++ b/x-pack/plugins/fleet/server/services/agents/crud_so.ts @@ -12,9 +12,9 @@ import { isAgentUpgradeable } from '../../../common'; import { AGENT_SAVED_OBJECT_TYPE } from '../../constants'; import { AgentSOAttributes, Agent, ListWithKuery } from '../../types'; import { escapeSearchQueryPhrase, normalizeKuery, findAllSOs } from '../saved_object'; -import { savedObjectToAgent } from './saved_objects'; import { appContextService } from '../../services'; import { esKuery, 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..a925d62efb70b 100644 --- a/x-pack/plugins/fleet/server/services/agents/enroll.ts +++ b/x-pack/plugins/fleet/server/services/agents/enroll.ts @@ -13,12 +13,12 @@ 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, diff --git a/x-pack/plugins/fleet/server/services/agents/reassign.ts b/x-pack/plugins/fleet/server/services/agents/reassign.ts index 62d59aada3b7b..d944ef59a87ad 100644 --- a/x-pack/plugins/fleet/server/services/agents/reassign.ts +++ b/x-pack/plugins/fleet/server/services/agents/reassign.ts @@ -8,6 +8,7 @@ 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,7 +16,6 @@ import { updateAgent, bulkUpdateAgents, } from './crud'; -import { AgentReassignmentError } from '../../errors'; import { createAgentAction, bulkCreateAgentActions } from './actions'; 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 a6b8bf41b6cb4..6407ceb069377 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,10 @@ */ import { elasticsearchServiceMock, savedObjectsClientMock } from 'src/core/server/mocks'; -import { getAgentStatusById } from './status'; +import { SavedObject } from 'kibana/server'; import { AGENT_TYPE_PERMANENT } from '../../../common/constants'; import { AgentSOAttributes } from '../../../common/types/models'; -import { 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 42d3aff2b0d70..275776457f84a 100644 --- a/x-pack/plugins/fleet/server/services/agents/status.ts +++ b/x-pack/plugins/fleet/server/services/agents/status.ts @@ -7,7 +7,6 @@ import { 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 { AgentStatus } from '../../types'; @@ -15,6 +14,7 @@ import { AgentStatusKueryHelper } from '../../../common/services'; import { esKuery, 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.ts b/x-pack/plugins/fleet/server/services/agents/unenroll.ts index 72d551a122980..8544d46af143c 100644 --- a/x-pack/plugins/fleet/server/services/agents/unenroll.ts +++ b/x-pack/plugins/fleet/server/services/agents/unenroll.ts @@ -7,6 +7,7 @@ import { 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 +17,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 21087be392bcd..f70bf92c3a650 100644 --- a/x-pack/plugins/fleet/server/services/agents/update.ts +++ b/x-pack/plugins/fleet/server/services/agents/update.ts @@ -6,8 +6,8 @@ */ import { 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 d73cc38e32c39..d41e2b83333da 100644 --- a/x-pack/plugins/fleet/server/services/agents/upgrade.ts +++ b/x-pack/plugins/fleet/server/services/agents/upgrade.ts @@ -10,6 +10,8 @@ import { 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 +20,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_fleet_server.ts b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key_fleet_server.ts index f5d0015297daa..75ed997364dfc 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 @@ -13,9 +13,9 @@ import { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server import { ESSearchResponse as SearchResponse } from '../../../../../typings/elasticsearch'; import { 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, 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 014bc58e747ea..25e9bc99fbc26 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 @@ -10,10 +10,10 @@ import Boom from '@hapi/boom'; import { SavedObjectsClientContract, SavedObject } from 'src/core/server'; import { 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, 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 97e0303e9f50f..3fbafd0d7ccf3 100644 --- a/x-pack/plugins/fleet/server/services/epm/archive/cache.ts +++ b/x-pack/plugins/fleet/server/services/epm/archive/cache.ts @@ -5,8 +5,8 @@ * 2.0. */ -import { ArchiveEntry } from './index'; import { ArchivePackage, RegistryPackage } from '../../../../common'; +import { ArchiveEntry } from './index'; const archiveEntryCache: Map<ArchiveEntry['path'], ArchiveEntry['buffer']> = new Map(); export const getArchiveEntry = (key: string) => archiveEntryCache.get(key); 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 20e1e8825fbd8..b8e4465a74b55 100644 --- a/x-pack/plugins/fleet/server/services/epm/archive/storage.ts +++ b/x-pack/plugins/fleet/server/services/epm/archive/storage.ts @@ -19,9 +19,9 @@ import { PackageAssetReference, RegistryDataStream, } from '../../../../common'; +import { pkgToPkgKey } from '../registry'; import { ArchiveEntry, getArchiveEntry, setArchiveEntry, setArchiveFilelist } 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 05daa98579079..3c8cc7c0ff330 100644 --- a/x-pack/plugins/fleet/server/services/epm/archive/validation.ts +++ b/x-pack/plugins/fleet/server/services/epm/archive/validation.ts @@ -17,8 +17,8 @@ import { PackageSpecManifest, } from '../../../../common/types'; import { PackageInvalidArchiveError } from '../../../errors'; -import { unpackBufferEntries } from './index'; import { pkgToPkgKey } from '../registry'; +import { unpackBufferEntries } from './index'; const MANIFESTS: Record<string, Buffer> = {}; 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 a18c2710ce776..8b830038a943b 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 @@ -14,9 +14,9 @@ import { } from '../../../../../common/types/models'; import { 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; 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 001add36ea95d..e93045b464bc0 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,8 +7,8 @@ import { readFileSync } from 'fs'; import path from 'path'; -import { rewriteIngestPipeline, getPipelineNameForInstallation } from './install'; import { RegistryDataStream } from '../../../../types'; +import { rewriteIngestPipeline, getPipelineNameForInstallation } from './install'; test('a json-format pipeline with pipeline references is correctly rewritten', () => { const inputStandard = readFileSync( 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 cdcd3972fd189..db973c30d9230 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,10 +5,10 @@ * 2.0. */ +import { elasticsearchServiceMock } from 'src/core/server/mocks'; import { RegistryDataStream } from '../../../../types'; import { 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 70afa78e723bc..b241bea7318a1 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 @@ -17,6 +17,8 @@ import { import { CallESAsCurrentUser } from '../../../../types'; import { Field, loadFieldsFromYaml, processFields } from '../../fields/field'; import { getPipelineNameForInstallation } from '../ingest_pipeline/install'; +import { getAsset, getPathParts } from '../../archive'; +import { removeAssetsFromInstalledEsByType, saveInstalledEsRefs } from '../../packages/install'; import { generateMappings, generateTemplateName, @@ -24,8 +26,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 a176805307845..443d8e8999cb9 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,8 +6,8 @@ */ import { readFileSync } from 'fs'; -import { safeLoad } from 'js-yaml'; import path from 'path'; +import { safeLoad } from 'js-yaml'; import { RegistryDataStream } from '../../../../types'; import { Field, processFields } from '../../fields/field'; import { 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 948a9c56746f3..9054408a9fc20 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 @@ -16,10 +16,10 @@ import { } from '../../../../../common/types/models'; import { 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; 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 658a130d70c61..2e76f54771cb6 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 @@ -8,8 +8,8 @@ import { 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 { EsAssetReference } from '../../../../../common/types/models'; +import { deleteTransformRefs } from './remove'; describe('test transform install', () => { let savedObjectsClient: jest.Mocked<SavedObjectsClientContract>; 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 bd944391b5f23..181841ea3fc2c 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,14 +19,14 @@ jest.mock('./common', () => { }); import { errors as LegacyESErrors } from 'elasticsearch'; -import { installTransform } from './install'; import { ILegacyScopedClusterClient, SavedObject, SavedObjectsClientContract } from 'kibana/server'; import { ElasticsearchAssetType, 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<ILegacyScopedClusterClient>; 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 b10c417210656..46ad7810f479f 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,9 @@ */ import { readFileSync } from 'fs'; +import path from 'path'; import glob from 'glob'; import { safeLoad } from 'js-yaml'; -import path from 'path'; import { Field, Fields, getField, processFields } from './field'; // Add our own serialiser to just do JSON.stringify 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 afac05f6ecaec..215ac397b98aa 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 @@ -9,6 +9,7 @@ import path from 'path'; import { readFileSync } from 'fs'; import glob from 'glob'; import { safeLoad } from 'js-yaml'; +import { Fields, Field } from '../../fields/field'; import { flattenFields, dedupeFields, @@ -19,7 +20,6 @@ import { createIndexPatternFields, createIndexPattern, } from './install'; -import { 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/packages/_install_package.ts b/x-pack/plugins/fleet/server/services/epm/packages/_install_package.ts index 2a6a4c93cb8e0..5778871ae8bc0 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 @@ -27,12 +27,12 @@ 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 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 aa35ddd2c294b..38310d641489a 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,8 +6,8 @@ */ import { InstallablePackage } from '../../../types'; -import { getAssets } from './assets'; import { getArchiveFilelist } from '../archive/cache'; +import { getAssets } from './assets'; jest.mock('../archive/cache', () => { return { 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 aeb08bad06184..71c7aaed33bfa 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,6 +5,7 @@ * 2.0. */ +// eslint-disable-next-line import/order import { ElasticsearchAssetType, Installation, KibanaSavedObjectType } from '../../../types'; import { SavedObject, SavedObjectsClientContract } from 'src/core/server'; @@ -12,15 +13,15 @@ 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'; 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 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 c07b88a45e6dc..f0c5f7f64c056 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/get.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/get.ts @@ -18,10 +18,10 @@ import { ArchivePackage, RegistryPackage, EpmPackageAdditions } from '../../../. import { Installation, PackageInfo, KibanaAssetType } 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'; 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 ac3c0f3952127..ba9f5a2629576 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/install.ts @@ -11,7 +11,6 @@ import Boom from '@hapi/boom'; import { UnwrapPromise } from '@kbn/utility-types'; import { SavedObject, SavedObjectsClientContract } from 'src/core/server'; import { generateESIndexPatterns } from '../elasticsearch/template/template'; -import { isRequiredPackage } from './index'; import { BulkInstallPackageInfo, InstallablePackage, @@ -30,21 +29,22 @@ import { } from '../../../types'; import * as Registry from '../registry'; import { setPackageInfo, parseAndVerifyArchiveEntries, unpackBufferToCache } from '../archive'; +import { toAssetReference, ArchiveAsset } from '../kibana/assets/install'; +import { + IngestManagerError, + PackageOperationNotSupportedError, + PackageOutdatedError, +} from '../../../errors'; +import { appContextService } from '../../app_context'; import { getInstallation, getInstallationObject, bulkInstallPackages, isBulkInstallError, } from './index'; -import { toAssetReference, ArchiveAsset } from '../kibana/assets/install'; import { removeInstallation } from './remove'; -import { - IngestManagerError, - PackageOperationNotSupportedError, - PackageOutdatedError, -} from '../../../errors'; import { getPackageSavedObjects } from './get'; -import { appContextService } from '../../app_context'; +import { isRequiredPackage } from './index'; 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 78471f70adc3c..6a0e408ad8741 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/remove.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/remove.ts @@ -17,7 +17,6 @@ import { 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'; @@ -26,6 +25,7 @@ import { splitPkgKey } from '../registry'; 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; 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 bee979a58076b..7216a7b5d5ebe 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,10 @@ * 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 { AssetsGroupedByServiceByType, CategoryId, @@ -26,11 +26,11 @@ 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; 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..8916fd6129d8b 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,8 @@ * 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/es_index_pattern.ts b/x-pack/plugins/fleet/server/services/es_index_pattern.ts index 0d5a4c888e93f..66c9e8cfcf341 100644 --- a/x-pack/plugins/fleet/server/services/es_index_pattern.ts +++ b/x-pack/plugins/fleet/server/services/es_index_pattern.ts @@ -6,8 +6,8 @@ */ import { SavedObjectsClientContract } from 'kibana/server'; -import { getInstallation } from './epm/packages'; import { ESIndexPatternService } from '../../server'; +import { getInstallation } from './epm/packages'; export class ESIndexPatternSavedObjectService implements ESIndexPatternService { public async getESIndexPattern( 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..c98fcf10ee16b 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,7 @@ 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 +16,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<typeof FLEET_SERVER_INDICES[number], string> = { '.fleet-actions': hash(EsFleetActionsIndex), diff --git a/x-pack/plugins/fleet/server/services/output.ts b/x-pack/plugins/fleet/server/services/output.ts index c3e453bc0e24f..74dcfa81bd06e 100644 --- a/x-pack/plugins/fleet/server/services/output.ts +++ b/x-pack/plugins/fleet/server/services/output.ts @@ -8,8 +8,8 @@ import { SavedObjectsClientContract } from 'src/core/server'; import { 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; 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 604592a0a8d87..5ef65b1dbb11c 100644 --- a/x-pack/plugins/fleet/server/services/package_policy.test.ts +++ b/x-pack/plugins/fleet/server/services/package_policy.test.ts @@ -6,15 +6,15 @@ */ import { elasticsearchServiceMock, savedObjectsClientMock } from 'src/core/server/mocks'; -import { createPackagePolicyMock } from '../../common/mocks'; -import { packagePolicyService } from './package_policy'; -import { PackageInfo, PackagePolicySOAttributes } from '../types'; import { SavedObjectsUpdateResponse } from 'src/core/server'; import { httpServerMock } from 'src/core/server/mocks'; import { KibanaRequest } from 'kibana/server'; +import { PackageInfo, PackagePolicySOAttributes } from '../types'; +import { createPackagePolicyMock } from '../../common/mocks'; import { 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') { diff --git a/x-pack/plugins/fleet/server/services/package_policy.ts b/x-pack/plugins/fleet/server/services/package_policy.ts index 335cd7c956faf..1684489662311 100644 --- a/x-pack/plugins/fleet/server/services/package_policy.ts +++ b/x-pack/plugins/fleet/server/services/package_policy.ts @@ -37,6 +37,7 @@ import { NewPackagePolicySchema, UpdatePackagePolicySchema, } from '../types'; +import { ExternalCallback } from '..'; import { agentPolicyService } from './agent_policy'; import { outputService } from './output'; import * as Registry from './epm/registry'; @@ -45,7 +46,6 @@ import { getAssetsData } from './epm/packages/assets'; import { compileTemplate } from './epm/agent/agent'; import { normalizeKuery } from './saved_object'; import { appContextService } from '.'; -import { ExternalCallback } from '..'; const SAVED_OBJECT_TYPE = PACKAGE_POLICY_SAVED_OBJECT_TYPE; diff --git a/x-pack/plugins/fleet/server/services/settings.ts b/x-pack/plugins/fleet/server/services/settings.ts index c58d3de9db1a7..6fb857da78cee 100644 --- a/x-pack/plugins/fleet/server/services/settings.ts +++ b/x-pack/plugins/fleet/server/services/settings.ts @@ -5,9 +5,9 @@ * 2.0. */ +import url from 'url'; import Boom from '@hapi/boom'; import { SavedObjectsClientContract } from 'kibana/server'; -import url from 'url'; import { GLOBAL_SETTINGS_SAVED_OBJECT_TYPE, SettingsSOAttributes, diff --git a/x-pack/plugins/fleet/server/services/setup.ts b/x-pack/plugins/fleet/server/services/setup.ts index 2a3166e9dc729..c16b3e9db1e90 100644 --- a/x-pack/plugins/fleet/server/services/setup.ts +++ b/x-pack/plugins/fleet/server/services/setup.ts @@ -8,13 +8,6 @@ import uuid from 'uuid'; import { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; import { CallESAsCurrentUser } from '../types'; -import { agentPolicyService } from './agent_policy'; -import { outputService } from './output'; -import { - ensureInstalledDefaultPackages, - ensureInstalledPackage, - ensurePackagesCompletedInstall, -} from './epm/packages/install'; import { packageToPackagePolicy, PackagePolicy, @@ -25,6 +18,13 @@ import { FLEET_SERVER_PACKAGE, } 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..ae05e6cb86cca 100644 --- a/x-pack/plugins/fleet/server/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/agent_policy.ts @@ -6,8 +6,8 @@ */ 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 }),