From 086ba324d898e1da83c4faf7fd420a7f55c27047 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Wed, 20 May 2020 17:04:53 -0700 Subject: [PATCH 1/8] Prevents importing of public code into server We should not be allowing importing of public into server. Any shared code should reside in a common directory. After #66506, this will not even be possible as we will no longer be transpiling public code into commonjs. Blocks #66506 Signed-off-by: Tyler Smalley --- .eslintrc.js | 5 +++++ src/plugins/apm_oss/server/index.ts | 2 ++ .../server/lib/index_pattern/create_static_index_pattern.ts | 6 ++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 6b3378d44cb81b..e4f1506b831e13 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -197,6 +197,11 @@ module.exports = { from: ['src/core/utils/**/*'], errorMessage: `Plugins may only import from src/core/server and src/core/public.`, }, + { + target: ['(src|x-pack)/plugins/*/server/**/*'], + from: ['(src|x-pack)/plugins/*/public/**/*'], + errorMessage: `Server code can not import from public, use a common directory.`, + }, { target: [ '(src|x-pack)/legacy/**/*', diff --git a/src/plugins/apm_oss/server/index.ts b/src/plugins/apm_oss/server/index.ts index d2e7321f39e7b7..8a7e97e4ebc5c5 100644 --- a/src/plugins/apm_oss/server/index.ts +++ b/src/plugins/apm_oss/server/index.ts @@ -44,6 +44,8 @@ export { APMOSSPluginSetup } from './plugin'; export { apmIndexPattern }; +export { APM_STATIC_INDEX_PATTERN_ID } from '../common/index_pattern_constants'; + export { createNodeAgentInstructions, createDjangoAgentInstructions, diff --git a/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts b/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts index 2e9087b2384067..7ff5e29449ad94 100644 --- a/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts +++ b/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts @@ -4,8 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ import { SavedObjectsErrorHelpers } from '../../../../../../src/core/server'; -import { apmIndexPattern } from '../../../../../../src/plugins/apm_oss/server'; -import { APM_STATIC_INDEX_PATTERN_ID } from '../../../../../../src/plugins/apm_oss/public'; +import { + apmIndexPattern, + APM_STATIC_INDEX_PATTERN_ID +} from '../../../../../../src/plugins/apm_oss/server'; import { hasHistoricalAgentData } from '../services/get_services/has_historical_agent_data'; import { Setup } from '../helpers/setup_request'; import { APMRequestHandlerContext } from '../../routes/typings'; From 969436209d2238494560428892370744db474451 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Wed, 20 May 2020 22:14:43 -0700 Subject: [PATCH 2/8] Additional updates Signed-off-by: Tyler Smalley --- .eslintrc.js | 2 +- .../components/authorization_provider.tsx | 0 .../authorization/components/index.ts | 0 .../components/not_authorized_section.tsx | 0 .../components/section_error.tsx | 0 .../components/with_privileges.tsx | 0 .../authorization/index.ts | 0 .../authorization/types.ts | 0 .../{public/authorization => common}/index.ts | 12 ++++++++++- src/plugins/es_ui_shared/public/index.ts | 12 ----------- .../server/report/store_report.test.ts | 2 +- .../server/alerts_client_factory.test.ts | 2 +- .../ingest_pipelines/public/shared_imports.ts | 5 +++-- .../server/routes/api/privileges.ts | 2 +- .../endpoint/alerts/handlers/lib/index.ts | 2 +- .../endpoint/routes/resolver/queries/base.ts | 2 +- .../routes/resolver/queries/events.ts | 2 +- .../routes/resolver/queries/lifecycle.ts | 2 +- .../endpoint/routes/resolver/queries/stats.ts | 2 +- .../routes/resolver/utils/pagination.ts | 2 +- x-pack/plugins/siem/server/lib/types.ts | 2 +- .../siem/server/utils/serialized_query.ts | 2 +- .../snapshot_restore/public/shared_imports.ts | 21 +++++++++++-------- .../snapshot_restore/server/routes/api/app.ts | 2 +- 24 files changed, 39 insertions(+), 37 deletions(-) rename src/plugins/es_ui_shared/{__packages_do_not_import__ => common}/authorization/components/authorization_provider.tsx (100%) rename src/plugins/es_ui_shared/{__packages_do_not_import__ => common}/authorization/components/index.ts (100%) rename src/plugins/es_ui_shared/{__packages_do_not_import__ => common}/authorization/components/not_authorized_section.tsx (100%) rename src/plugins/es_ui_shared/{__packages_do_not_import__ => common}/authorization/components/section_error.tsx (100%) rename src/plugins/es_ui_shared/{__packages_do_not_import__ => common}/authorization/components/with_privileges.tsx (100%) rename src/plugins/es_ui_shared/{__packages_do_not_import__ => common}/authorization/index.ts (100%) rename src/plugins/es_ui_shared/{__packages_do_not_import__ => common}/authorization/types.ts (100%) rename src/plugins/es_ui_shared/{public/authorization => common}/index.ts (78%) diff --git a/.eslintrc.js b/.eslintrc.js index e4f1506b831e13..6aa5cee3e68816 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -198,7 +198,7 @@ module.exports = { errorMessage: `Plugins may only import from src/core/server and src/core/public.`, }, { - target: ['(src|x-pack)/plugins/*/server/**/*'], + target: ['(src|x-pack)/plugins/*/server/**/*', '!x-pack/plugins/apm/**/*'], from: ['(src|x-pack)/plugins/*/public/**/*'], errorMessage: `Server code can not import from public, use a common directory.`, }, diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/authorization_provider.tsx b/src/plugins/es_ui_shared/common/authorization/components/authorization_provider.tsx similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/authorization_provider.tsx rename to src/plugins/es_ui_shared/common/authorization/components/authorization_provider.tsx diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/index.ts b/src/plugins/es_ui_shared/common/authorization/components/index.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/index.ts rename to src/plugins/es_ui_shared/common/authorization/components/index.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/not_authorized_section.tsx b/src/plugins/es_ui_shared/common/authorization/components/not_authorized_section.tsx similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/not_authorized_section.tsx rename to src/plugins/es_ui_shared/common/authorization/components/not_authorized_section.tsx diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/section_error.tsx b/src/plugins/es_ui_shared/common/authorization/components/section_error.tsx similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/section_error.tsx rename to src/plugins/es_ui_shared/common/authorization/components/section_error.tsx diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/with_privileges.tsx b/src/plugins/es_ui_shared/common/authorization/components/with_privileges.tsx similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/with_privileges.tsx rename to src/plugins/es_ui_shared/common/authorization/components/with_privileges.tsx diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/index.ts b/src/plugins/es_ui_shared/common/authorization/index.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/authorization/index.ts rename to src/plugins/es_ui_shared/common/authorization/index.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/types.ts b/src/plugins/es_ui_shared/common/authorization/types.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/authorization/types.ts rename to src/plugins/es_ui_shared/common/authorization/types.ts diff --git a/src/plugins/es_ui_shared/public/authorization/index.ts b/src/plugins/es_ui_shared/common/index.ts similarity index 78% rename from src/plugins/es_ui_shared/public/authorization/index.ts rename to src/plugins/es_ui_shared/common/index.ts index 3a02c0d2694f3d..5381cbf0587728 100644 --- a/src/plugins/es_ui_shared/public/authorization/index.ts +++ b/src/plugins/es_ui_shared/common/index.ts @@ -17,4 +17,14 @@ * under the License. */ -export * from '../../__packages_do_not_import__/authorization'; +export { + AuthorizationContext, + AuthorizationProvider, + NotAuthorizedSection, + WithPrivileges, + Privileges, + MissingPrivileges, + SectionError, + Error, + useAuthorizationContext, +} from './authorization'; diff --git a/src/plugins/es_ui_shared/public/index.ts b/src/plugins/es_ui_shared/public/index.ts index 7e5510d7c9c651..a0371bf351193c 100644 --- a/src/plugins/es_ui_shared/public/index.ts +++ b/src/plugins/es_ui_shared/public/index.ts @@ -47,18 +47,6 @@ export { expandLiteralStrings, } from './console_lang'; -export { - AuthorizationContext, - AuthorizationProvider, - NotAuthorizedSection, - WithPrivileges, - Privileges, - MissingPrivileges, - SectionError, - Error, - useAuthorizationContext, -} from './authorization'; - /** dummy plugin, we just want esUiShared to have its own bundle */ export function plugin() { return new (class EsUiSharedPlugin { diff --git a/src/plugins/usage_collection/server/report/store_report.test.ts b/src/plugins/usage_collection/server/report/store_report.test.ts index 29b6d79cc139a8..d8327eb834e12c 100644 --- a/src/plugins/usage_collection/server/report/store_report.test.ts +++ b/src/plugins/usage_collection/server/report/store_report.test.ts @@ -20,7 +20,7 @@ import { savedObjectsRepositoryMock } from '../../../../core/server/mocks'; import { storeReport } from './store_report'; import { ReportSchemaType } from './schema'; -import { METRIC_TYPE } from '../../public'; +import { METRIC_TYPE } from '@kbn/analytics'; describe('store_report', () => { test('stores report for all types of data', async () => { diff --git a/x-pack/plugins/alerting/server/alerts_client_factory.test.ts b/x-pack/plugins/alerting/server/alerts_client_factory.test.ts index cc792d11c890dd..426dde27c9e45e 100644 --- a/x-pack/plugins/alerting/server/alerts_client_factory.test.ts +++ b/x-pack/plugins/alerting/server/alerts_client_factory.test.ts @@ -11,7 +11,7 @@ import { taskManagerMock } from '../../../plugins/task_manager/server/task_manag import { KibanaRequest } from '../../../../src/core/server'; import { loggingServiceMock, savedObjectsClientMock } from '../../../../src/core/server/mocks'; import { encryptedSavedObjectsMock } from '../../../plugins/encrypted_saved_objects/server/mocks'; -import { AuthenticatedUser } from '../../../plugins/security/public'; +import { AuthenticatedUser } from '../../../plugins/security/common/model'; import { securityMock } from '../../../plugins/security/server/mocks'; jest.mock('./alerts_client'); diff --git a/x-pack/plugins/ingest_pipelines/public/shared_imports.ts b/x-pack/plugins/ingest_pipelines/public/shared_imports.ts index a2ee3215260520..f15c23cfde53fe 100644 --- a/x-pack/plugins/ingest_pipelines/public/shared_imports.ts +++ b/x-pack/plugins/ingest_pipelines/public/shared_imports.ts @@ -42,13 +42,14 @@ export { } from '../../../../src/plugins/es_ui_shared/static/validators/string'; export { - SectionLoading, WithPrivileges, AuthorizationProvider, SectionError, Error, useAuthorizationContext, NotAuthorizedSection, -} from '../../../../src/plugins/es_ui_shared/public'; +} from '../../../../src/plugins/es_ui_shared/common'; + +export { SectionLoading } from '../../../../src/plugins/es_ui_shared/public'; export const useKibana = () => _useKibana(); diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/privileges.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/privileges.ts index 2e1c11928959f0..d240d98e838d2b 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/api/privileges.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/privileges.ts @@ -5,7 +5,7 @@ */ import { RouteDependencies } from '../../types'; import { API_BASE_PATH, APP_CLUSTER_REQUIRED_PRIVILEGES } from '../../../common/constants'; -import { Privileges } from '../../../../../../src/plugins/es_ui_shared/public'; +import { Privileges } from '../../../../../../src/plugins/es_ui_shared/common'; const extractMissingPrivileges = (privilegesObject: { [key: string]: boolean } = {}): string[] => Object.keys(privilegesObject).reduce((privileges: string[], privilegeName: string): string[] => { diff --git a/x-pack/plugins/siem/server/endpoint/alerts/handlers/lib/index.ts b/x-pack/plugins/siem/server/endpoint/alerts/handlers/lib/index.ts index 4f0a7ba2450dce..e398e70f1d7b7b 100644 --- a/x-pack/plugins/siem/server/endpoint/alerts/handlers/lib/index.ts +++ b/x-pack/plugins/siem/server/endpoint/alerts/handlers/lib/index.ts @@ -6,7 +6,7 @@ import { SearchResponse } from 'elasticsearch'; import { IScopedClusterClient } from 'kibana/server'; import { AlertEvent } from '../../../../../common/endpoint/types'; -import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public'; +import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common'; import { esQuery } from '../../../../../../../../src/plugins/data/server'; import { AlertAPIOrdering, diff --git a/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/base.ts b/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/base.ts index 4f6003492fd3ad..7b1f774eda1579 100644 --- a/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/base.ts +++ b/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/base.ts @@ -13,7 +13,7 @@ import { PaginationParams, PaginatedResults, } from '../utils/pagination'; -import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public'; +import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common'; import { legacyEventIndexPattern } from './legacy_event_index_pattern'; export abstract class ResolverQuery { diff --git a/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/events.ts b/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/events.ts index 80c3a0e9accccd..7d2d6ae48b8e4d 100644 --- a/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/events.ts +++ b/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/events.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import { ResolverQuery } from './base'; -import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public'; +import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common'; export class EventsQuery extends ResolverQuery { protected legacyQuery(endpointID: string, uniquePIDs: string[], index: string): JsonObject { diff --git a/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/lifecycle.ts b/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/lifecycle.ts index 7dbbdec2fdfcdb..b8955e5de815b2 100644 --- a/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/lifecycle.ts +++ b/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/lifecycle.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import { ResolverQuery } from './base'; -import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public'; +import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common'; export class LifecycleQuery extends ResolverQuery { protected legacyQuery(endpointID: string, uniquePIDs: string[], index: string): JsonObject { diff --git a/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/stats.ts b/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/stats.ts index 5fddf86ea4a7cd..5ec5205863e8fe 100644 --- a/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/stats.ts +++ b/x-pack/plugins/siem/server/endpoint/routes/resolver/queries/stats.ts @@ -6,7 +6,7 @@ import { SearchResponse } from 'elasticsearch'; import { ResolverQuery } from './base'; import { ResolverEvent } from '../../../../../common/endpoint/types'; -import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public'; +import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common'; import { PaginatedResults } from '../utils/pagination'; export class StatsQuery extends ResolverQuery { diff --git a/x-pack/plugins/siem/server/endpoint/routes/resolver/utils/pagination.ts b/x-pack/plugins/siem/server/endpoint/routes/resolver/utils/pagination.ts index a47c4442b6cf4f..27d5b19a9d1079 100644 --- a/x-pack/plugins/siem/server/endpoint/routes/resolver/utils/pagination.ts +++ b/x-pack/plugins/siem/server/endpoint/routes/resolver/utils/pagination.ts @@ -7,7 +7,7 @@ import { SearchResponse } from 'elasticsearch'; import { ResolverEvent } from '../../../../../common/endpoint/types'; import { entityId } from '../../../../../common/endpoint/models/event'; -import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public'; +import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common'; export interface PaginationParams { size: number; diff --git a/x-pack/plugins/siem/server/lib/types.ts b/x-pack/plugins/siem/server/lib/types.ts index 2a897806dc6287..ff89512124b66a 100644 --- a/x-pack/plugins/siem/server/lib/types.ts +++ b/x-pack/plugins/siem/server/lib/types.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AuthenticatedUser } from '../../../security/public'; +import { AuthenticatedUser } from '../../../security/common/model'; import { RequestHandlerContext } from '../../../../../src/core/server'; export { ConfigType as Configuration } from '../config'; diff --git a/x-pack/plugins/siem/server/utils/serialized_query.ts b/x-pack/plugins/siem/server/utils/serialized_query.ts index 09b227d8c5a325..357aec1db480b1 100644 --- a/x-pack/plugins/siem/server/utils/serialized_query.ts +++ b/x-pack/plugins/siem/server/utils/serialized_query.ts @@ -7,7 +7,7 @@ import { UserInputError } from 'apollo-server-errors'; import { isEmpty, isPlainObject, isString } from 'lodash/fp'; -import { JsonObject } from '../../../../../src/plugins/kibana_utils/public'; +import { JsonObject } from '../../../../../src/plugins/kibana_utils/common'; export const parseFilterQuery = (filterQuery: string): JsonObject => { try { diff --git a/x-pack/plugins/snapshot_restore/public/shared_imports.ts b/x-pack/plugins/snapshot_restore/public/shared_imports.ts index e0024ea8e0c126..8836220533c88f 100644 --- a/x-pack/plugins/snapshot_restore/public/shared_imports.ts +++ b/x-pack/plugins/snapshot_restore/public/shared_imports.ts @@ -5,17 +5,20 @@ */ export { + CronEditor, + DAY, + sendRequest, SendRequestConfig, SendRequestResponse, - UseRequestConfig, - sendRequest, useRequest, - CronEditor, - DAY, - SectionError, + UseRequestConfig, +} from '../../../../src/plugins/es_ui_shared/public'; + +export { + AuthorizationProvider, Error, - WithPrivileges, - useAuthorizationContext, NotAuthorizedSection, - AuthorizationProvider, -} from '../../../../src/plugins/es_ui_shared/public'; + SectionError, + useAuthorizationContext, + WithPrivileges, +} from '../../../../src/plugins/es_ui_shared/common'; diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/app.ts b/x-pack/plugins/snapshot_restore/server/routes/api/app.ts index bda64fdb665714..b9f0c67e9fac01 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/app.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/app.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { Privileges } from '../../../../../../src/plugins/es_ui_shared/public'; +import { Privileges } from '../../../../../../src/plugins/es_ui_shared/common'; import { APP_REQUIRED_CLUSTER_PRIVILEGES, From b348579d12e48e13bde00b258319deb2408102d1 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Thu, 21 May 2020 13:18:21 -0700 Subject: [PATCH 3/8] es_ui_shared feedback Signed-off-by: Tyler Smalley --- .../components/authorization_provider.tsx | 0 .../authorization/components/index.ts | 0 .../components/not_authorized_section.tsx | 0 .../components/section_error.tsx | 0 .../components/with_privileges.tsx | 0 .../authorization/index.ts | 0 .../authorization/types.ts | 0 src/plugins/es_ui_shared/common/index.ts | 12 +------- .../public/authorization/index.ts | 28 +++++++++++++++++++ src/plugins/es_ui_shared/public/index.ts | 10 +++++++ .../ingest_pipelines/public/shared_imports.ts | 2 +- .../snapshot_restore/public/shared_imports.ts | 15 ++++------ 12 files changed, 46 insertions(+), 21 deletions(-) rename src/plugins/es_ui_shared/{common => __packages_do_not_import__}/authorization/components/authorization_provider.tsx (100%) rename src/plugins/es_ui_shared/{common => __packages_do_not_import__}/authorization/components/index.ts (100%) rename src/plugins/es_ui_shared/{common => __packages_do_not_import__}/authorization/components/not_authorized_section.tsx (100%) rename src/plugins/es_ui_shared/{common => __packages_do_not_import__}/authorization/components/section_error.tsx (100%) rename src/plugins/es_ui_shared/{common => __packages_do_not_import__}/authorization/components/with_privileges.tsx (100%) rename src/plugins/es_ui_shared/{common => __packages_do_not_import__}/authorization/index.ts (100%) rename src/plugins/es_ui_shared/{common => __packages_do_not_import__}/authorization/types.ts (100%) create mode 100644 src/plugins/es_ui_shared/public/authorization/index.ts diff --git a/src/plugins/es_ui_shared/common/authorization/components/authorization_provider.tsx b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/authorization_provider.tsx similarity index 100% rename from src/plugins/es_ui_shared/common/authorization/components/authorization_provider.tsx rename to src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/authorization_provider.tsx diff --git a/src/plugins/es_ui_shared/common/authorization/components/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/index.ts similarity index 100% rename from src/plugins/es_ui_shared/common/authorization/components/index.ts rename to src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/index.ts diff --git a/src/plugins/es_ui_shared/common/authorization/components/not_authorized_section.tsx b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/not_authorized_section.tsx similarity index 100% rename from src/plugins/es_ui_shared/common/authorization/components/not_authorized_section.tsx rename to src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/not_authorized_section.tsx diff --git a/src/plugins/es_ui_shared/common/authorization/components/section_error.tsx b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/section_error.tsx similarity index 100% rename from src/plugins/es_ui_shared/common/authorization/components/section_error.tsx rename to src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/section_error.tsx diff --git a/src/plugins/es_ui_shared/common/authorization/components/with_privileges.tsx b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/with_privileges.tsx similarity index 100% rename from src/plugins/es_ui_shared/common/authorization/components/with_privileges.tsx rename to src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/with_privileges.tsx diff --git a/src/plugins/es_ui_shared/common/authorization/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/index.ts similarity index 100% rename from src/plugins/es_ui_shared/common/authorization/index.ts rename to src/plugins/es_ui_shared/__packages_do_not_import__/authorization/index.ts diff --git a/src/plugins/es_ui_shared/common/authorization/types.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/types.ts similarity index 100% rename from src/plugins/es_ui_shared/common/authorization/types.ts rename to src/plugins/es_ui_shared/__packages_do_not_import__/authorization/types.ts diff --git a/src/plugins/es_ui_shared/common/index.ts b/src/plugins/es_ui_shared/common/index.ts index 5381cbf0587728..c13dff5cf1fa19 100644 --- a/src/plugins/es_ui_shared/common/index.ts +++ b/src/plugins/es_ui_shared/common/index.ts @@ -17,14 +17,4 @@ * under the License. */ -export { - AuthorizationContext, - AuthorizationProvider, - NotAuthorizedSection, - WithPrivileges, - Privileges, - MissingPrivileges, - SectionError, - Error, - useAuthorizationContext, -} from './authorization'; +export { Privileges, MissingPrivileges } from '../__packages_do_not_import__/authorization'; diff --git a/src/plugins/es_ui_shared/public/authorization/index.ts b/src/plugins/es_ui_shared/public/authorization/index.ts new file mode 100644 index 00000000000000..510f84b6643f29 --- /dev/null +++ b/src/plugins/es_ui_shared/public/authorization/index.ts @@ -0,0 +1,28 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { + WithPrivileges, + NotAuthorizedSection, + AuthorizationProvider, + AuthorizationContext, + SectionError, + Error, + useAuthorizationContext, +} from '../../__packages_do_not_import__/authorization'; diff --git a/src/plugins/es_ui_shared/public/index.ts b/src/plugins/es_ui_shared/public/index.ts index a0371bf351193c..63df344e6c043d 100644 --- a/src/plugins/es_ui_shared/public/index.ts +++ b/src/plugins/es_ui_shared/public/index.ts @@ -47,6 +47,16 @@ export { expandLiteralStrings, } from './console_lang'; +export { + WithPrivileges, + NotAuthorizedSection, + AuthorizationProvider, + AuthorizationContext, + SectionError, + Error, + useAuthorizationContext, +} from '../__packages_do_not_import__/authorization'; + /** dummy plugin, we just want esUiShared to have its own bundle */ export function plugin() { return new (class EsUiSharedPlugin { diff --git a/x-pack/plugins/ingest_pipelines/public/shared_imports.ts b/x-pack/plugins/ingest_pipelines/public/shared_imports.ts index f15c23cfde53fe..05f8f575a4380a 100644 --- a/x-pack/plugins/ingest_pipelines/public/shared_imports.ts +++ b/x-pack/plugins/ingest_pipelines/public/shared_imports.ts @@ -48,7 +48,7 @@ export { Error, useAuthorizationContext, NotAuthorizedSection, -} from '../../../../src/plugins/es_ui_shared/common'; +} from '../../../../src/plugins/es_ui_shared/public'; export { SectionLoading } from '../../../../src/plugins/es_ui_shared/public'; diff --git a/x-pack/plugins/snapshot_restore/public/shared_imports.ts b/x-pack/plugins/snapshot_restore/public/shared_imports.ts index 8836220533c88f..cad8ce147bd252 100644 --- a/x-pack/plugins/snapshot_restore/public/shared_imports.ts +++ b/x-pack/plugins/snapshot_restore/public/shared_imports.ts @@ -5,20 +5,17 @@ */ export { + AuthorizationProvider, CronEditor, DAY, + Error, + NotAuthorizedSection, + SectionError, sendRequest, SendRequestConfig, SendRequestResponse, + useAuthorizationContext, useRequest, UseRequestConfig, -} from '../../../../src/plugins/es_ui_shared/public'; - -export { - AuthorizationProvider, - Error, - NotAuthorizedSection, - SectionError, - useAuthorizationContext, WithPrivileges, -} from '../../../../src/plugins/es_ui_shared/common'; +} from '../../../../src/plugins/es_ui_shared/public'; From 3826004c838bd612331d78f96117290e1dc1911c Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Thu, 21 May 2020 13:24:36 -0700 Subject: [PATCH 4/8] es_ui_shared feedback Signed-off-by: Tyler Smalley --- src/plugins/es_ui_shared/public/index.ts | 10 +-------- .../ingest_pipelines/public/shared_imports.ts | 22 ++++++++----------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/plugins/es_ui_shared/public/index.ts b/src/plugins/es_ui_shared/public/index.ts index 63df344e6c043d..bd00adb753e589 100644 --- a/src/plugins/es_ui_shared/public/index.ts +++ b/src/plugins/es_ui_shared/public/index.ts @@ -47,15 +47,7 @@ export { expandLiteralStrings, } from './console_lang'; -export { - WithPrivileges, - NotAuthorizedSection, - AuthorizationProvider, - AuthorizationContext, - SectionError, - Error, - useAuthorizationContext, -} from '../__packages_do_not_import__/authorization'; +export * from './authorization'; /** dummy plugin, we just want esUiShared to have its own bundle */ export function plugin() { diff --git a/x-pack/plugins/ingest_pipelines/public/shared_imports.ts b/x-pack/plugins/ingest_pipelines/public/shared_imports.ts index 05f8f575a4380a..ab56ae427120bc 100644 --- a/x-pack/plugins/ingest_pipelines/public/shared_imports.ts +++ b/x-pack/plugins/ingest_pipelines/public/shared_imports.ts @@ -7,11 +7,18 @@ import { useKibana as _useKibana } from '../../../../src/plugins/kibana_react/pu import { AppServices } from './application'; export { + AuthorizationProvider, + Error, + NotAuthorizedSection, + SectionError, + SectionLoading, + sendRequest, SendRequestConfig, SendRequestResponse, - UseRequestConfig, - sendRequest, + useAuthorizationContext, useRequest, + UseRequestConfig, + WithPrivileges, } from '../../../../src/plugins/es_ui_shared/public/'; export { @@ -41,15 +48,4 @@ export { isEmptyString, } from '../../../../src/plugins/es_ui_shared/static/validators/string'; -export { - WithPrivileges, - AuthorizationProvider, - SectionError, - Error, - useAuthorizationContext, - NotAuthorizedSection, -} from '../../../../src/plugins/es_ui_shared/public'; - -export { SectionLoading } from '../../../../src/plugins/es_ui_shared/public'; - export const useKibana = () => _useKibana(); From fafa902aaa65f5c65e54ac31494c3f6cfaf41442 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Thu, 21 May 2020 16:08:59 -0700 Subject: [PATCH 5/8] Import license type from server Signed-off-by: Tyler Smalley --- x-pack/plugins/maps/server/plugin.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/maps/server/plugin.ts b/x-pack/plugins/maps/server/plugin.ts index dfaf65ce38c4fa..f2331b9a1a9600 100644 --- a/x-pack/plugins/maps/server/plugin.ts +++ b/x-pack/plugins/maps/server/plugin.ts @@ -23,7 +23,8 @@ import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/s import { emsBoundariesSpecProvider } from './tutorials/ems'; // @ts-ignore import { initRoutes } from './routes'; -import { ILicense, LicensingPluginSetup } from '../../licensing/common/types'; +import { ILicense } from '../../licensing/common/types'; +import { LicensingPluginSetup } from '../../licensing/server'; import { HomeServerPluginSetup } from '../../../../src/plugins/home/server'; interface SetupDeps { From 11054f714df03fc5b3b28afd8d81843c269f9ae0 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Mon, 25 May 2020 10:06:07 -0700 Subject: [PATCH 6/8] Resolves eslint error Signed-off-by: Tyler Smalley --- .../apm/server/lib/index_pattern/create_static_index_pattern.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts b/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts index bed1a70173ce93..7ff5e29449ad94 100644 --- a/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts +++ b/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts @@ -38,7 +38,7 @@ export async function createStaticIndexPattern( 'index-pattern', { ...apmIndexPattern.attributes, - title: apmIndexPatternTitle, + title: apmIndexPatternTitle }, { id: APM_STATIC_INDEX_PATTERN_ID, overwrite: false } ); From 6675b800964dbf6e7cc424c1673bc07f3474e14e Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Mon, 25 May 2020 13:44:16 -0700 Subject: [PATCH 7/8] Prettier updates Signed-off-by: Tyler Smalley --- .../public/lib/autocomplete/autocomplete.ts | 2 +- .../public/custom_time_range_action.test.ts | 4 +--- .../index_pattern/create_static_index_pattern.ts | 4 ++-- .../plugins/embeddable_enhanced/public/plugin.ts | 14 ++++++++------ .../application/store/actions/start_basic.js | 3 ++- .../timelines/components/open_timeline/helpers.ts | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/plugins/console/public/lib/autocomplete/autocomplete.ts b/src/plugins/console/public/lib/autocomplete/autocomplete.ts index b05c7ddbb020d0..3959f2ed8cf46f 100644 --- a/src/plugins/console/public/lib/autocomplete/autocomplete.ts +++ b/src/plugins/console/public/lib/autocomplete/autocomplete.ts @@ -308,7 +308,7 @@ export function getCurrentMethodAndTokenPaths( } // eslint-disable-next-line -export default function({ coreEditor: editor, parser }: { coreEditor: CoreEditor; parser: any }) { +export default function ({ coreEditor: editor, parser }: { coreEditor: CoreEditor; parser: any }) { function isUrlPathToken(token: Token | null) { switch ((token || ({} as any)).type) { case 'url.slash': diff --git a/x-pack/plugins/advanced_ui_actions/public/custom_time_range_action.test.ts b/x-pack/plugins/advanced_ui_actions/public/custom_time_range_action.test.ts index e82ebd9a5a4ad5..0d6e9743f0f4b0 100644 --- a/x-pack/plugins/advanced_ui_actions/public/custom_time_range_action.test.ts +++ b/x-pack/plugins/advanced_ui_actions/public/custom_time_range_action.test.ts @@ -13,9 +13,7 @@ import { mount } from 'enzyme'; import { TimeRangeEmbeddable, TimeRangeContainer, TIME_RANGE_EMBEDDABLE } from './test_helpers'; import { CustomTimeRangeAction } from './custom_time_range_action'; /* eslint-disable */ -import { - HelloWorldContainer, -} from '../../../../src/plugins/embeddable/public/lib/test_samples'; +import { HelloWorldContainer } from '../../../../src/plugins/embeddable/public/lib/test_samples'; /* eslint-enable */ import { diff --git a/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts b/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts index 7ff5e29449ad94..ea7cc9b1456965 100644 --- a/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts +++ b/x-pack/plugins/apm/server/lib/index_pattern/create_static_index_pattern.ts @@ -6,7 +6,7 @@ import { SavedObjectsErrorHelpers } from '../../../../../../src/core/server'; import { apmIndexPattern, - APM_STATIC_INDEX_PATTERN_ID + APM_STATIC_INDEX_PATTERN_ID, } from '../../../../../../src/plugins/apm_oss/server'; import { hasHistoricalAgentData } from '../services/get_services/has_historical_agent_data'; import { Setup } from '../helpers/setup_request'; @@ -38,7 +38,7 @@ export async function createStaticIndexPattern( 'index-pattern', { ...apmIndexPattern.attributes, - title: apmIndexPatternTitle + title: apmIndexPatternTitle, }, { id: APM_STATIC_INDEX_PATTERN_ID, overwrite: false } ); diff --git a/x-pack/plugins/embeddable_enhanced/public/plugin.ts b/x-pack/plugins/embeddable_enhanced/public/plugin.ts index d26acb4459a717..1b8a69871afb58 100644 --- a/x-pack/plugins/embeddable_enhanced/public/plugin.ts +++ b/x-pack/plugins/embeddable_enhanced/public/plugin.ts @@ -127,17 +127,19 @@ export class EmbeddableEnhancedPlugin }); dynamicActions.start().catch((error) => { - /* eslint-disable */ - console.log('Failed to start embeddable dynamic actions', embeddable); - console.error(error); + /* eslint-disable */ + + console.log('Failed to start embeddable dynamic actions', embeddable); + console.error(error); /* eslint-enable */ }); const stop = () => { dynamicActions.stop().catch((error) => { - /* eslint-disable */ - console.log('Failed to stop embeddable dynamic actions', embeddable); - console.error(error); + /* eslint-disable */ + + console.log('Failed to stop embeddable dynamic actions', embeddable); + console.error(error); /* eslint-enable */ }); }; diff --git a/x-pack/plugins/license_management/public/application/store/actions/start_basic.js b/x-pack/plugins/license_management/public/application/store/actions/start_basic.js index 5ae93bf84c2f86..bce6195caecf09 100644 --- a/x-pack/plugins/license_management/public/application/store/actions/start_basic.js +++ b/x-pack/plugins/license_management/public/application/store/actions/start_basic.js @@ -45,7 +45,8 @@ export const startBasicLicense = (currentLicenseType, ack) => async ( 'xpack.licenseMgmt.replacingCurrentLicenseWithBasicLicenseWarningMessage', { //eslint-disable-next-line - defaultMessage: 'Some functionality will be lost if you replace your {currentLicenseType} license with a BASIC license. Review the list of features below.', + defaultMessage: + 'Some functionality will be lost if you replace your {currentLicenseType} license with a BASIC license. Review the list of features below.', values: { currentLicenseType: currentLicenseType.toUpperCase(), }, diff --git a/x-pack/plugins/siem/public/timelines/components/open_timeline/helpers.ts b/x-pack/plugins/siem/public/timelines/components/open_timeline/helpers.ts index f521ffa9b6b5d0..c8a47798f169ce 100644 --- a/x-pack/plugins/siem/public/timelines/components/open_timeline/helpers.ts +++ b/x-pack/plugins/siem/public/timelines/components/open_timeline/helpers.ts @@ -221,7 +221,7 @@ export const queryTimelineById = ({ variables: { id: timelineId }, }) // eslint-disable-next-line - .then(result => { + .then((result) => { const timelineToOpen: TimelineResult = omitTypenameInTimeline( getOr({}, 'data.getOneTimeline', result) ); From af145ca538add210e8155ca91aba29f20a90c4af Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Tue, 9 Jun 2020 15:41:58 -0700 Subject: [PATCH 8/8] Export Privileges/MissingPrivileges Signed-off-by: Tyler Smalley --- src/plugins/es_ui_shared/public/authorization/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/es_ui_shared/public/authorization/index.ts b/src/plugins/es_ui_shared/public/authorization/index.ts index 510f84b6643f29..e18ab32ffdfa86 100644 --- a/src/plugins/es_ui_shared/public/authorization/index.ts +++ b/src/plugins/es_ui_shared/public/authorization/index.ts @@ -18,11 +18,13 @@ */ export { - WithPrivileges, - NotAuthorizedSection, - AuthorizationProvider, AuthorizationContext, - SectionError, + AuthorizationProvider, Error, + MissingPrivileges, + NotAuthorizedSection, + Privileges, + SectionError, useAuthorizationContext, + WithPrivileges, } from '../../__packages_do_not_import__/authorization';