Skip to content

Commit

Permalink
split package exports for optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
semd committed Aug 28, 2023
1 parent 594d65d commit 5c93286
Show file tree
Hide file tree
Showing 30 changed files with 132 additions and 94 deletions.
8 changes: 1 addition & 7 deletions src/plugins/files/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@
* Side Public License, v 1.
*/

export {
PLUGIN_ID,
PLUGIN_NAME,
ES_FIXED_SIZE_INDEX_BLOB_STORE,
FILE_SO_TYPE,
FILE_SHARE_SO_TYPE,
} from './constants';
export { FILE_SO_TYPE, PLUGIN_ID, PLUGIN_NAME, ES_FIXED_SIZE_INDEX_BLOB_STORE } from './constants';

export type {
File,
Expand Down
10 changes: 10 additions & 0 deletions x-pack/packages/security-solution/features/app_features.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export { getSecurityFeature } from './src/security';
export { getCasesFeature } from './src/cases';
export { getAssistantFeature } from './src/assistant';
12 changes: 12 additions & 0 deletions x-pack/packages/security-solution/features/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export { securityDefaultAppFeaturesConfig } from './src/security/app_feature_config';
export { getCasesDefaultAppFeaturesConfig } from './src/cases/app_feature_config';
export { assistantDefaultAppFeaturesConfig } from './src/assistant/app_feature_config';

export { createEnabledAppFeaturesConfigMap } from './src/helpers';
13 changes: 0 additions & 13 deletions x-pack/packages/security-solution/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,4 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
export { AppFeaturesPrivileges } from './src/app_features_privileges';
export { ASSISTANT_FEATURE_ID, CASES_FEATURE_ID } from './src/constants';
export * from './src/app_features_keys';
export * from './src/types';

export { getSecurityFeature } from './src/security';
export { getCasesFeature } from './src/cases';
export { getAssistantFeature } from './src/assistant';

export { securityDefaultAppFeaturesConfig } from './src/security/app_feature_config';
export { getCasesDefaultAppFeaturesConfig } from './src/cases/app_feature_config';
export { assistantDefaultAppFeaturesConfig } from './src/assistant/app_feature_config';

export { createEnabledAppFeaturesConfigMap } from './src/helpers';
8 changes: 8 additions & 0 deletions x-pack/packages/security-solution/features/keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export * from './src/app_features_keys';
7 changes: 7 additions & 0 deletions x-pack/packages/security-solution/features/privileges.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
export { AppFeaturesPrivilegeId, AppFeaturesPrivileges } from './src/app_features_privileges';
12 changes: 8 additions & 4 deletions x-pack/packages/security-solution/features/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": ["jest", "node"]
"types": [
"jest",
"node",
"react",
]
},
"include": ["**/*.ts"],
"exclude": ["target/**/*"],
"include": ["**/*.ts", "**/*.tsx"],
"kbn_references": [
"@kbn/features-plugin",
"@kbn/utility-types",
Expand All @@ -14,5 +17,6 @@
"@kbn/cases-plugin",
"@kbn/securitysolution-rules",
"@kbn/securitysolution-list-constants",
]
],
"exclude": ["target/**/*"]
}
7 changes: 6 additions & 1 deletion x-pack/packages/security-solution/upselling/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@
* 2.0.
*/
export { UpsellingService } from './upselling_service';
export * from './types';
export type {
PageUpsellings,
SectionUpsellings,
UpsellingSectionId,
UpsellingMessageId,
} from './types';
4 changes: 2 additions & 2 deletions x-pack/plugins/security_solution/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

import { RuleNotifyWhen } from '@kbn/alerting-plugin/common';
import type { AddOptionsListControlProps } from '@kbn/controls-plugin/public';

import * as i18n from './translations';

export { SecurityPageName } from '@kbn/security-solution-navigation';
export { ASSISTANT_FEATURE_ID, CASES_FEATURE_ID } from '@kbn/security-solution-features';

/**
* as const
Expand All @@ -22,6 +20,8 @@ export { ASSISTANT_FEATURE_ID, CASES_FEATURE_ID } from '@kbn/security-solution-f
*/
export const APP_ID = 'securitySolution' as const;
export const APP_UI_ID = 'securitySolutionUI' as const;
export const ASSISTANT_FEATURE_ID = 'securitySolutionAssistant' as const;
export const CASES_FEATURE_ID = 'securitySolutionCases' as const;
export const SERVER_APP_ID = 'siem' as const;
export const APP_NAME = 'Security' as const;
export const APP_ICON = 'securityAnalyticsApp' as const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { Logger } from '@kbn/logging';
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import type { EndpointInternalFleetServicesInterface } from '../services/fleet';

import { ALL_APP_FEATURE_KEYS } from '../../../common';
import { ALL_APP_FEATURE_KEYS } from '@kbn/security-solution-features/keys';
import { turnOffPolicyProtectionsIfNotSupported } from './turn_off_policy_protections';
import { FleetPackagePolicyGenerator } from '../../../common/endpoint/data_generators/fleet_package_policy_generator';
import type { PolicyData } from '../../../common/endpoint/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type { Logger, ElasticsearchClient } from '@kbn/core/server';
import type { UpdatePackagePolicy } from '@kbn/fleet-plugin/common';
import type { AuthenticatedUser } from '@kbn/security-plugin/common';
import { AppFeatureSecurityKey } from '@kbn/security-solution-features';
import { AppFeatureSecurityKey } from '@kbn/security-solution-features/keys';
import {
isPolicySetToEventCollectionOnly,
ensureOnlyEventCollectionIsAllowed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { createPackagePolicyServiceMock } from '@kbn/fleet-plugin/server/mocks';
import type { ExceptionListClient } from '@kbn/lists-plugin/server';
import { listMock } from '@kbn/lists-plugin/server/mocks';
import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types';
import type { AppFeatureKeys } from '@kbn/security-solution-features';
import {
createPackagePolicyWithInitialManifestMock,
createPackagePolicyWithManifestMock,
Expand All @@ -28,7 +29,6 @@ import type { ManifestManagerContext } from './manifest_manager';
import { ManifestManager } from './manifest_manager';
import { parseExperimentalConfigValue } from '../../../../../common/experimental_features';
import { createAppFeaturesServiceMock } from '../../../../lib/app_features_service/mocks';
import type { AppFeatureKeys } from '../../../../../common';
import type { AppFeaturesService } from '../../../../lib/app_features_service/app_features_service';

export const createExceptionListResponse = (data: ExceptionListItemSchema[], total?: number) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import type { ListResult, PackagePolicy } from '@kbn/fleet-plugin/common';
import type { Artifact, PackagePolicyClient } from '@kbn/fleet-plugin/server';
import type { ExceptionListClient } from '@kbn/lists-plugin/server';
import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types';
import { AppFeatureKey } from '@kbn/security-solution-features/keys';
import type { AppFeaturesService } from '../../../../lib/app_features_service/app_features_service';
import { AppFeatureKey, type ExperimentalFeatures } from '../../../../../common';
import type { ExperimentalFeatures } from '../../../../../common';
import type { ManifestSchemaVersion } from '../../../../../common/endpoint/schema/common';
import {
manifestDispatchSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
getPackagePolicyUpdateCallback,
} from './fleet_integration';
import type { KibanaRequest } from '@kbn/core/server';
import { ALL_APP_FEATURE_KEYS } from '@kbn/security-solution-features/keys';
import { requestContextMock } from '../lib/detection_engine/routes/__mocks__';
import { requestContextFactoryMock } from '../request_context_factory.mock';
import type { EndpointAppContextServiceStartContract } from '../endpoint/endpoint_app_context_services';
Expand All @@ -54,7 +55,6 @@ import { createMockPolicyData } from '../endpoint/services/feature_usage/mocks';
import { ALL_ENDPOINT_ARTIFACT_LIST_IDS } from '../../common/endpoint/service/artifacts/constants';
import { ENDPOINT_EVENT_FILTERS_LIST_ID } from '@kbn/securitysolution-list-constants';
import { disableProtections } from '../../common/endpoint/models/policy_config_helpers';
import { ALL_APP_FEATURE_KEYS } from '../../common';
import type { AppFeaturesService } from '../lib/app_features_service/app_features_service';
import { createAppFeaturesServiceMock } from '../lib/app_features_service/mocks';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
} from '@kbn/fleet-plugin/common';
import type { CloudSetup } from '@kbn/cloud-plugin/server';
import type { InfoResponse } from '@elastic/elasticsearch/lib/api/types';
import { AppFeatureSecurityKey } from '@kbn/security-solution-features';
import { AppFeatureSecurityKey } from '@kbn/security-solution-features/keys';
import {
isPolicySetToEventCollectionOnly,
ensureOnlyEventCollectionIsAllowed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Subject } from 'rxjs';
import type { ILicense } from '@kbn/licensing-plugin/common/types';
import { licenseMock } from '@kbn/licensing-plugin/common/licensing.mock';
import { cloudMock } from '@kbn/cloud-plugin/server/mocks';
import { ALL_APP_FEATURE_KEYS } from '@kbn/security-solution-features/keys';
import { LicenseService } from '../../../common/license';
import { createDefaultPolicy } from './create_default_policy';
import { ProtectionModes } from '../../../common/endpoint/types';
Expand All @@ -19,7 +20,6 @@ import type {
PolicyCreateCloudConfig,
PolicyCreateEndpointConfig,
} from '../types';
import { ALL_APP_FEATURE_KEYS } from '../../../common';
import type { AppFeaturesService } from '../../lib/app_features_service/app_features_service';
import { createAppFeaturesServiceMock } from '../../lib/app_features_service/mocks';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import type { CloudSetup } from '@kbn/cloud-plugin/server';
import type { InfoResponse } from '@elastic/elasticsearch/lib/api/types';
import { AppFeatureSecurityKey } from '@kbn/security-solution-features';
import { AppFeatureSecurityKey } from '@kbn/security-solution-features/keys';
import {
policyFactory as policyConfigFactory,
policyFactoryWithoutPaidFeatures as policyConfigFactoryWithoutPaidFeatures,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
getSecurityFeature,
getCasesFeature,
getAssistantFeature,
} from '@kbn/security-solution-features';
} from '@kbn/security-solution-features/app_features';
import type { ExperimentalFeatures } from '../../../common';
import { AppFeatures } from './app_features';
import type { AppFeaturesConfigurator } from './types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import type { PluginSetupContract as FeaturesPluginSetup } from '@kbn/features-p
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { featuresPluginMock } from '@kbn/features-plugin/server/mocks';

import { ALL_APP_FEATURE_KEYS, type AppFeatureKeys } from '@kbn/security-solution-features';
import type { AppFeatureKeys } from '@kbn/security-solution-features';
import { ALL_APP_FEATURE_KEYS } from '@kbn/security-solution-features/keys';
import { allowedExperimentalValues, type ExperimentalFeatures } from '../../../common';
import { AppFeaturesService } from './app_features_service';

Expand All @@ -26,7 +27,7 @@ const ASSISTANT_BASE_CONFIG = {
bar: 'bar',
};

jest.mock('@kbn/security-solution-features', () => ({
jest.mock('@kbn/security-solution-features/app_features', () => ({
getSecurityFeature: jest.fn(() => ({
baseKibanaFeature: SECURITY_BASE_CONFIG,
baseKibanaSubFeatureIds: ['subFeature1'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* 2.0.
*/

import type { AppFeaturesConfig } from '@kbn/security-solution-features';
import type {
AppFeaturesConfig,
SecuritySubFeatureId,
CasesSubFeatureId,
AssistantSubFeatureId,
} from '@kbn/security-solution-features';
} from '@kbn/security-solution-features/keys';
import type { ExperimentalFeatures } from '../../../common';

export interface AppFeaturesConfigurator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { AppFeatureCasesKey } from '@kbn/security-solution-features';
import type {
AppFeatureKibanaConfig,
AppFeaturesCasesConfig,
AppFeatureKeys,
} from '@kbn/security-solution-features';
import type { AppFeatureCasesKey, CasesSubFeatureId } from '@kbn/security-solution-features/keys';
import {
getCasesDefaultAppFeaturesConfig,
createEnabledAppFeaturesConfigMap,
type AppFeatureKibanaConfig,
type AppFeaturesCasesConfig,
type AppFeatureKeys,
type CasesSubFeatureId,
} from '@kbn/security-solution-features';
} from '@kbn/security-solution-features/config';

import {
CASES_CONNECTORS_CAPABILITY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { type ExperimentalFeatures } from '@kbn/security-solution-plugin/common';
import type { ExperimentalFeatures } from '@kbn/security-solution-plugin/common';
import type {
AppFeatureKeys,
AppFeatureKibanaConfig,
AppFeaturesSecurityConfig,
} from '@kbn/security-solution-features';
import {
AppFeatureSecurityKey,
AppFeaturesPrivileges,
type SecuritySubFeatureId,
} from '@kbn/security-solution-features/keys';
import {
securityDefaultAppFeaturesConfig,
createEnabledAppFeaturesConfigMap,
type AppFeatureKeys,
type AppFeatureKibanaConfig,
type AppFeaturesSecurityConfig,
type SecuritySubFeatureId,
} from '@kbn/security-solution-features';
import { AppFeaturesPrivilegeId } from '@kbn/security-solution-features/src/app_features_privileges';
} from '@kbn/security-solution-features/config';
import {
AppFeaturesPrivilegeId,
AppFeaturesPrivileges,
} from '@kbn/security-solution-features/privileges';

export const getSecurityAppFeaturesConfigurator =
(enabledAppFeatureKeys: AppFeatureKeys) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { AppFeatureAssistantKey } from '@kbn/security-solution-features';
import type {
AppFeatureKeys,
AppFeatureKibanaConfig,
AppFeaturesAssistantConfig,
} from '@kbn/security-solution-features';
import {
assistantDefaultAppFeaturesConfig,
createEnabledAppFeaturesConfigMap,
type AppFeatureKeys,
type AppFeatureKibanaConfig,
type AppFeaturesAssistantConfig,
type AssistantSubFeatureId,
} from '@kbn/security-solution-features';
} from '@kbn/security-solution-features/config';
import type {
AppFeatureAssistantKey,
AssistantSubFeatureId,
} from '@kbn/security-solution-features/keys';

export const getSecurityAssistantAppFeaturesConfigurator =
(enabledAppFeatureKeys: AppFeatureKeys) => (): AppFeaturesAssistantConfig => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* 2.0.
*/

import { AppFeatureKey, type AppFeatureKeys } from '@kbn/security-solution-features';
import type { AppFeatureKeys } from '@kbn/security-solution-features';
import { AppFeatureKey } from '@kbn/security-solution-features/keys';
import type { SecurityProductLine, SecurityProductTier } from '../config';

type PliAppFeatures = Readonly<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type { AppFeatureKeys } from '@kbn/security-solution-plugin/common';
import type { AppFeatureKeys } from '@kbn/security-solution-features/src/types';
import type { SecurityProductTypes } from '../config';
import { ProductTier } from '../product';
import { PLI_APP_FEATURES } from './pli_config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import { SecurityPageName } from '@kbn/security-solution-plugin/common';
import type {
MessageUpsellings,
UpsellingMessageId,
PageUpsellings,
SectionUpsellings,
UpsellingSectionId,
UpsellingMessageId,
UpsellingService,
} from '@kbn/security-solution-upselling/service';
} from '@kbn/security-solution-upselling/service/types';
import type { UpsellingService } from '@kbn/security-solution-upselling/service';
import React from 'react';
import { UPGRADE_INVESTIGATION_GUIDE } from '@kbn/security-solution-upselling/messages';
import { AppFeatureKey } from '@kbn/security-solution-features';
import { AppFeatureKey } from '@kbn/security-solution-features/src/app_features_keys';
import { EndpointPolicyProtectionsLazy } from './sections/endpoint_management';
import type { SecurityProductTypes } from '../../common/config';
import { getProductAppFeatures } from '../../common/pli/pli_features';
Expand Down
Loading

0 comments on commit 5c93286

Please sign in to comment.