Extract src/core in a separate TS project (#76785)

* break dependency on data plugin TS code

* move global typings to @kbn/utility-types

* import types from @kbn/utility-types

* remove type dependency on plugins

* add intermediate js files to break dependency on outter TS code

* temp type declaration for query-string

* declare src/core project

* export types to reference in the built d.ts files

* reference core project

* move jest types out of kbn/utility-types due to a clash with mocha types

* fix wrong es_kuery path and ts project paths

* reference core from packages consuming it

* x-pack & oss should use the same lodash version

* Revert "x-pack & oss should use the same lodash version"

This reverts commit 79cec5781e.

* use the same lodash version

* fix @types/lodash TS2300: Duplicate identifier error

* fix wrong imports

* update docs

* update docs

* add a comment why file is needed
This commit is contained in:
Mikhail Shustov 2020-09-15 13:41:27 +03:00 committed by GitHub
parent aae704ab41
commit e7d8ea3927
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
104 changed files with 399 additions and 102 deletions

View file

@ -11,5 +11,8 @@
"common/**/*.ts",
"../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -11,5 +11,8 @@
"server/**/*.ts",
"../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -11,5 +11,8 @@
"server/**/*.ts",
"../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -11,5 +11,8 @@
"server/**/*.ts",
"../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -12,5 +12,8 @@
"server/**/*.ts",
"../../typings/**/*"
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -11,5 +11,8 @@
"server/**/*.ts",
"../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -12,5 +12,8 @@
"common/**/*.ts",
"../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -12,5 +12,8 @@
"server/**/*.ts",
"../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -12,5 +12,8 @@
"common/**/*.ts",
"../../typings/**/*"
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -11,5 +11,8 @@
"server/**/*.ts",
"../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -10,5 +10,8 @@
"public/**/*.tsx",
"../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -11,5 +11,8 @@
"server/**/*.ts",
"../../typings/**/*"
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -11,5 +11,8 @@
"server/**/*.ts",
"../../typings/**/*"
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
]
}

View file

@ -98,3 +98,15 @@ export type PublicKeys<T> = keyof T;
* Returns an object with public keys only.
*/
export type PublicContract<T> = Pick<T, PublicKeys<T>>;
/**
* Returns public method names
*/
export type MethodKeysOf<T> = {
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
}[keyof T];
/**
* Returns an object with public methods only.
*/
export type PublicMethodsOf<T> = Pick<T, MethodKeysOf<T>>;

View file

@ -7,7 +7,6 @@
"stripInternal": true,
"declarationMap": true,
"types": [
"jest",
"node"
]
},

View file

@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { CapabilitiesService, CapabilitiesStart } from './capabilities_service';
import { deepFreeze } from '../../../utils';

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { AppUnmount, Mounter } from './types';
import { ApplicationService } from './application_service';

View file

@ -17,6 +17,7 @@
* under the License.
*/
import { BehaviorSubject } from 'rxjs';
import type { PublicMethodsOf } from '@kbn/utility-types';
import { ChromeBadge, ChromeBrand, ChromeBreadcrumb, ChromeService, InternalChromeStart } from './';
const createStartContractMock = () => {

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { ContextService, ContextSetup } from './context_service';
import { contextMock } from '../../utils/context.mock';

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { CoreApp } from './core_app';
type CoreAppContract = PublicMethodsOf<CoreApp>;

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { injectedMetadataServiceMock } from '../injected_metadata/injected_metadata_service.mock';
import { DocLinksService, DocLinksStart } from './doc_links_service';

View file

@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { FatalErrorsService, FatalErrorsSetup } from './fatal_errors_service';
const createSetupContractMock = () => {

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { HttpService } from './http_service';
import { HttpSetup } from './types';
import { BehaviorSubject } from 'rxjs';

View file

@ -19,6 +19,7 @@
import { LoadingCountSetup, LoadingCountService } from './loading_count_service';
import { BehaviorSubject } from 'rxjs';
import type { PublicMethodsOf } from '@kbn/utility-types';
const createSetupContractMock = () => {
const setupContract: jest.Mocked<LoadingCountSetup> = {

View file

@ -18,6 +18,8 @@
*/
import React from 'react';
import type { PublicMethodsOf } from '@kbn/utility-types';
import { I18nService, I18nStart } from './i18n_service';
const PassThroughComponent = ({ children }: { children: React.ReactNode }) => children;

View file

@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { InjectedMetadataService, InjectedMetadataSetup } from './injected_metadata_service';
const createSetupContractMock = () => {

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { IntegrationsService } from './integrations_service';
type IntegrationsServiceContract = PublicMethodsOf<IntegrationsService>;

View file

@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import {
NotificationsService,
NotificationsSetup,

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { OverlayBannersStart, OverlayBannersService } from './banners_service';
const createStartContractMock = () => {

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { FlyoutService, OverlayFlyoutStart } from './flyout_service';
const createStartContractMock = () => {

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { ModalService, OverlayModalStart } from './modal_service';
const createStartContractMock = () => {

View file

@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { OverlayService, OverlayStart } from './overlay_service';
import { overlayBannersServiceMock } from './banners/banners_service.mock';
import { overlayFlyoutServiceMock } from './flyout/flyout_service.mock';

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { PluginsService, PluginsServiceSetup } from './plugins_service';
const createSetupContractMock = () => {

View file

@ -7,7 +7,6 @@
import { Action } from 'history';
import { ApiResponse } from '@elastic/elasticsearch/lib/Transport';
import Boom from 'boom';
import { ErrorToastOptions as ErrorToastOptions_2 } from 'src/core/public/notifications';
import { EuiBreadcrumb } from '@elastic/eui';
import { EuiButtonEmptyProps } from '@elastic/eui';
import { EuiConfirmModalProps } from '@elastic/eui';
@ -24,13 +23,12 @@ import { MaybePromise } from '@kbn/utility-types';
import { Observable } from 'rxjs';
import { ParsedQuery } from 'query-string';
import { Path } from 'history';
import { PublicMethodsOf } from '@kbn/utility-types';
import { PublicUiSettingsParams as PublicUiSettingsParams_2 } from 'src/core/server/types';
import React from 'react';
import { RecursiveReadonly } from '@kbn/utility-types';
import * as Rx from 'rxjs';
import { SavedObject as SavedObject_2 } from 'src/core/server';
import { ShallowPromise } from '@kbn/utility-types';
import { ToastInputFields as ToastInputFields_2 } from 'src/core/public/notifications';
import { TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport';
import { TransportRequestParams } from '@elastic/elasticsearch/lib/Transport';
import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport';

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { RenderingService } from './rendering_service';
type RenderingServiceContract = PublicMethodsOf<RenderingService>;

View file

@ -19,6 +19,7 @@
import { cloneDeep, pick, throttle } from 'lodash';
import { resolve as resolveUrl } from 'url';
import type { PublicMethodsOf } from '@kbn/utility-types';
import {
SavedObject,

View file

@ -17,6 +17,7 @@
* under the License.
*/
import * as Rx from 'rxjs';
import type { PublicMethodsOf } from '@kbn/utility-types';
import { UiSettingsService } from './';
import { IUiSettingsClient } from './types';

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { AuditTrailSetup, AuditTrailStart, Auditor } from './types';
import { AuditTrailService } from './audit_trail_service';

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { CapabilitiesService, CapabilitiesSetup, CapabilitiesStart } from './capabilities_service';
const createSetupContractMock = () => {

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { Type } from '@kbn/config-schema';
import { isEqual } from 'lodash';
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { RawConfigService } from './raw_config_service';
import { Observable, of } from 'rxjs';

View file

@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { ContextService, ContextSetup } from './context_service';
import { contextMock } from '../../utils/context.mock';

View file

@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
import { CoreContext } from './core_context';
import { getEnvOptions } from './config/__mocks__/env';
import { Env, IConfigService } from './config';

View file

@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Client, ApiResponse } from '@elastic/elasticsearch';
import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport';
import { ElasticsearchClient } from './types';
@ -75,7 +74,7 @@ export type ElasticsearchClientMock = DeeplyMockedKeys<ElasticsearchClient>;
const createClientMock = (): ElasticsearchClientMock =>
(createInternalClientMock() as unknown) as ElasticsearchClientMock;
interface ScopedClusterClientMock {
export interface ScopedClusterClientMock {
asInternalUser: ElasticsearchClientMock;
asCurrentUser: ElasticsearchClientMock;
}

View file

@ -18,6 +18,8 @@
*/
import { BehaviorSubject } from 'rxjs';
import type { PublicMethodsOf } from '@kbn/utility-types';
import { ILegacyClusterClient, ILegacyCustomClusterClient } from './legacy';
import {
elasticsearchClientMock,
@ -32,7 +34,7 @@ import { InternalElasticsearchServiceSetup, ElasticsearchStatusMeta } from './ty
import { NodesVersionCompatibility } from './version_check/ensure_es_version';
import { ServiceStatus, ServiceStatusLevels } from '../status';
interface MockedElasticSearchServiceSetup {
export interface MockedElasticSearchServiceSetup {
legacy: {
config$: BehaviorSubject<ElasticsearchConfig>;
createClient: jest.Mock<ILegacyCustomClusterClient, any>;

View file

@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { EnvironmentService, InternalEnvironmentServiceSetup } from './environment_service';

View file

@ -18,6 +18,8 @@
*/
import { Server } from 'hapi';
import type { PublicMethodsOf } from '@kbn/utility-types';
import { CspConfig } from '../csp';
import { mockRouter, RouterMock } from './router/router.mock';
import { configMock } from '../config/config.mock';

View file

@ -20,7 +20,6 @@
import supertest from 'supertest';
import { BehaviorSubject } from 'rxjs';
import { ByteSizeValue } from '@kbn/config-schema';
import pkg from '../../../../../package.json';
import { createHttpServer } from '../test_utils';
import { HttpService } from '../http_service';
@ -30,6 +29,9 @@ import { IRouter, RouteRegistrar } from '../router';
import { configServiceMock } from '../../config/config_service.mock';
import { contextServiceMock } from '../../context/context_service.mock';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkg = require('../../../../../package.json');
const actualVersion = pkg.version;
const versionHeader = 'kbn-version';
const xsrfHeader = 'kbn-xsrf';

View file

@ -0,0 +1,20 @@
/*
* 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 { startRepl } from '../../../cli/repl';

View file

@ -0,0 +1,20 @@
/*
* 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 { ClusterManager } from '../../../cli/cluster/cluster_manager';

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { LegacyService } from './legacy_service';
import { LegacyConfig, LegacyServiceDiscoverPlugins, LegacyServiceSetupDeps } from './types';

View file

@ -18,8 +18,7 @@
*/
jest.mock('../../../legacy/server/kbn_server');
jest.mock('../../../cli/cluster/cluster_manager');
jest.mock('./cluster_manager');
import {
findLegacyPluginSpecsMock,
logLegacyThirdPartyPluginDeprecationWarningMock,
@ -27,7 +26,8 @@ import {
import { BehaviorSubject, throwError } from 'rxjs';
import { ClusterManager as MockClusterManager } from '../../../cli/cluster/cluster_manager';
// @ts-expect-error js file to remove TS dependency on cli
import { ClusterManager as MockClusterManager } from './cluster_manager';
import KbnServer from '../../../legacy/server/kbn_server';
import { Config, Env, ObjectToConfigAdapter } from '../config';
import { getEnvOptions } from '../config/__mocks__/env';

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { combineLatest, ConnectableObservable, EMPTY, Observable, Subscription } from 'rxjs';
import { first, map, publishReplay, tap } from 'rxjs/operators';
@ -233,7 +233,7 @@ export class LegacyService implements CoreService {
: EMPTY;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { ClusterManager } = require('../../../cli/cluster/cluster_manager');
const { ClusterManager } = require('./cluster_manager');
return new ClusterManager(
this.coreContext.env.cliArgs,
config,
@ -368,7 +368,7 @@ export class LegacyService implements CoreService {
// We only want one REPL.
if (this.coreContext.env.cliArgs.repl && process.env.kbnWorkerType === 'server') {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('../../../cli/repl').startRepl(kbnServer);
require('./cli').startRepl(kbnServer);
}
const { autoListen } = await this.httpConfig$.pipe(first()).toPromise();

View file

@ -0,0 +1,21 @@
/*
* 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.
*/
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
export { collectUiExports } from '../../../../legacy/ui/ui_exports/collect_ui_exports';

View file

@ -25,12 +25,12 @@ import {
defaultConfig,
// @ts-expect-error
} from '../../../../legacy/plugin_discovery/find_plugin_specs.js';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { collectUiExports as collectLegacyUiExports } from '../../../../legacy/ui/ui_exports/collect_ui_exports';
// @ts-expect-error
import { collectUiExports as collectLegacyUiExports } from './collect_ui_exports';
import { LoggerFactory } from '../../logging';
import { PackageInfo } from '../../config';
import { LegacyPluginSpec, LegacyPluginPack, LegacyConfig } from '../types';
import { LegacyUiExports, LegacyPluginSpec, LegacyPluginPack, LegacyConfig } from '../types';
export async function findLegacyPluginSpecs(
settings: unknown,
@ -123,7 +123,7 @@ export async function findLegacyPluginSpecs(
spec$.pipe(toArray()),
log$.pipe(toArray())
).toPromise();
const uiExports = collectLegacyUiExports(pluginSpecs);
const uiExports: LegacyUiExports = collectLegacyUiExports(pluginSpecs);
return {
disabledPluginSpecs,

View file

@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import {
LoggingService,

View file

@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { Appenders, DisposableAppender } from './appenders/appenders';
import { BufferAppender } from './appenders/buffer/buffer_appender';
import { LogLevel } from './log_level';

View file

@ -17,6 +17,8 @@
* under the License.
*/
import { BehaviorSubject } from 'rxjs';
import type { PublicMethodsOf } from '@kbn/utility-types';
import { MetricsService } from './metrics_service';
import {
InternalMetricsServiceSetup,

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { PluginsService, PluginsServiceSetup } from './plugins_service';
type PluginsServiceMock = jest.Mocked<PublicMethodsOf<PluginsService>>;

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { RenderingService as Service } from '../rendering_service';
import { InternalRenderingServiceSetup } from '../types';
import { mockRenderingServiceParams } from './params';

View file

@ -0,0 +1,21 @@
/*
* 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.
*/
// a temporary file to remove circular deps in TS code between platform & data plugin
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
export { esKuery } from '../../../plugins/data/server';

View file

@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { KibanaMigrator, KibanaMigratorStatus } from './kibana_migrator';
import { buildActiveMappings } from '../core';

View file

@ -18,6 +18,7 @@
*/
import { BehaviorSubject } from 'rxjs';
import type { PublicMethodsOf } from '@kbn/utility-types';
import {
SavedObjectsService,

View file

@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { esKuery } from '../../../../../plugins/data/server';
// @ts-expect-error no ts
import { esKuery } from '../../es_query';
import { validateFilterKueryNode, validateConvertFilterToKueryNode } from './filter_utils';

View file

@ -21,8 +21,9 @@ import { set } from '@elastic/safer-lodash-set';
import { get } from 'lodash';
import { SavedObjectsErrorHelpers } from './errors';
import { IndexMapping } from '../../mappings';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { esKuery, KueryNode } from '../../../../../plugins/data/server';
// @ts-expect-error no ts
import { esKuery } from '../../es_query';
type KueryNode = any;
const astFunctionType = ['is', 'range', 'nested'];

View file

@ -25,8 +25,8 @@ import { encodeHitVersion } from '../../version';
import { SavedObjectTypeRegistry } from '../../saved_objects_type_registry';
import { DocumentMigrator } from '../../migrations/core/document_migrator';
import { elasticsearchClientMock } from '../../../elasticsearch/client/mocks';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { nodeTypes } from '../../../../../plugins/data/common/es_query';
import { esKuery } from '../../es_query';
const { nodeTypes } = esKuery;
jest.mock('./search_dsl/search_dsl', () => ({ getSearchDsl: jest.fn() }));

View file

@ -17,8 +17,9 @@
* under the License.
*/
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { esKuery, KueryNode } from '../../../../../../plugins/data/server';
// @ts-expect-error no ts
import { esKuery } from '../../../es_query';
type KueryNode = any;
import { typeRegistryMock } from '../../../saved_objects_type_registry.mock';
import { getQueryParams } from './query_params';

View file

@ -16,8 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { esKuery, KueryNode } from '../../../../../../plugins/data/server';
// @ts-expect-error no ts
import { esKuery } from '../../../es_query';
type KueryNode = any;
import { getRootPropertiesObjects, IndexMapping } from '../../../mappings';
import { ISavedObjectTypeRegistry } from '../../../saved_objects_type_registry';

View file

@ -22,10 +22,10 @@ import Boom from 'boom';
import { IndexMapping } from '../../../mappings';
import { getQueryParams } from './query_params';
import { getSortingParams } from './sorting_params';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { KueryNode } from '../../../../../../plugins/data/server';
import { ISavedObjectTypeRegistry } from '../../../saved_objects_type_registry';
type KueryNode = any;
interface GetSearchDslOptions {
type: string | string[];
search?: string;

View file

@ -35,8 +35,7 @@ export {
import { SavedObject } from '../../types';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { KueryNode } from '../../../plugins/data/common';
type KueryNode = any;
export {
SavedObjectAttributes,

View file

@ -40,7 +40,6 @@ import { DeleteScriptParams } from 'elasticsearch';
import { DeleteTemplateParams } from 'elasticsearch';
import { DetailedPeerCertificate } from 'tls';
import { Duration } from 'moment';
import { ErrorToastOptions } from 'src/core/public/notifications';
import { ExistsParams } from 'elasticsearch';
import { ExplainParams } from 'elasticsearch';
import { FieldStatsParams } from 'elasticsearch';
@ -119,7 +118,6 @@ import { RenderSearchTemplateParams } from 'elasticsearch';
import { Request } from 'hapi';
import { ResponseObject } from 'hapi';
import { ResponseToolkit } from 'hapi';
import { SavedObject as SavedObject_2 } from 'src/core/server';
import { SchemaTypeError } from '@kbn/config-schema';
import { ScrollParams } from 'elasticsearch';
import { SearchParams } from 'elasticsearch';
@ -143,7 +141,6 @@ import { TasksCancelParams } from 'elasticsearch';
import { TasksGetParams } from 'elasticsearch';
import { TasksListParams } from 'elasticsearch';
import { TermvectorsParams } from 'elasticsearch';
import { ToastInputFields } from 'src/core/public/notifications';
import { TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport';
import { TransportRequestParams } from '@elastic/elasticsearch/lib/Transport';
import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport';

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { StatusService } from './status_service';
import {
InternalStatusServiceSetup,

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import {
IUiSettingsClient,
InternalUiSettingsServiceSetup,

22
src/core/tsconfig.json Normal file
View file

@ -0,0 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"public/**/*",
"server/**/*",
"types/**/*",
"test_helpers/**/*",
"utils/**/*",
"index.ts",
"typings.ts"
],
"references": [
{ "path": "../test_utils/" }
]
}

55
src/core/typings.ts Normal file
View file

@ -0,0 +1,55 @@
/*
* 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.
*/
declare module 'query-string' {
type ArrayFormat = 'bracket' | 'index' | 'none';
export interface ParseOptions {
arrayFormat?: ArrayFormat;
sort: ((itemLeft: string, itemRight: string) => number) | false;
}
export interface ParsedQuery<T = string> {
[key: string]: T | T[] | null | undefined;
}
export function parse(str: string, options?: ParseOptions): ParsedQuery;
export function parseUrl(str: string, options?: ParseOptions): { url: string; query: any };
export interface StringifyOptions {
strict?: boolean;
encode?: boolean;
arrayFormat?: ArrayFormat;
sort: ((itemLeft: string, itemRight: string) => number) | false;
}
export function stringify(obj: object, options?: StringifyOptions): string;
export function extract(str: string): string;
}
type DeeplyMockedKeys<T> = {
[P in keyof T]: T[P] extends (...args: any[]) => any
? jest.MockInstance<ReturnType<T[P]>, Parameters<T[P]>>
: DeeplyMockedKeys<T[P]>;
} &
T;
type MockedKeys<T> = { [P in keyof T]: jest.Mocked<T[P]> };

View file

@ -25,6 +25,7 @@ import { Project } from './project';
export const PROJECTS = [
new Project(resolve(REPO_ROOT, 'tsconfig.json')),
new Project(resolve(REPO_ROOT, 'src/test_utils/tsconfig.json')),
new Project(resolve(REPO_ROOT, 'src/core/tsconfig.json')),
new Project(resolve(REPO_ROOT, 'test/tsconfig.json'), { name: 'kibana/test' }),
new Project(resolve(REPO_ROOT, 'x-pack/tsconfig.json')),
new Project(resolve(REPO_ROOT, 'x-pack/test/tsconfig.json'), { name: 'x-pack/test' }),

View file

@ -21,6 +21,7 @@ import { i18n, i18nLoader } from '@kbn/i18n';
import { basename } from 'path';
import { Server } from 'hapi';
import { fromRoot } from '../../../core/server/utils';
import type { UsageCollectionSetup } from '../../../plugins/usage_collection/server';
import { getTranslationPaths } from './get_translations_path';
import { I18N_RC } from './constants';
import KbnServer, { KibanaConfig } from '../kbn_server';
@ -64,7 +65,10 @@ export async function i18nMixin(kbnServer: KbnServer, server: Server, config: Ki
server.decorate('server', 'getTranslationsFilePaths', getTranslationsFilePaths);
if (kbnServer.newPlatform.setup.plugins.usageCollection) {
registerLocalizationUsageCollector(kbnServer.newPlatform.setup.plugins.usageCollection, {
const { usageCollection } = kbnServer.newPlatform.setup.plugins as {
usageCollection: UsageCollectionSetup;
};
registerLocalizationUsageCollector(usageCollection, {
getLocale: () => config.get('i18n.locale') as string,
getTranslationsFilePaths,
});

View file

@ -19,7 +19,6 @@
import { Server } from 'hapi';
import { TelemetryCollectionManagerPluginSetup } from 'src/plugins/telemetry_collection_manager/server';
import {
CoreSetup,
CoreStart,
@ -35,8 +34,6 @@ import { LegacyConfig, ILegacyInternals } from '../../core/server/legacy';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { UiPlugins } from '../../core/server/plugins';
import { ElasticsearchPlugin } from '../core_plugins/elasticsearch';
import { UsageCollectionSetup } from '../../plugins/usage_collection/server';
import { HomeServerPluginSetup } from '../../plugins/home/server';
// lot of legacy code was assuming this type only had these two methods
export type KibanaConfig = Pick<LegacyConfig, 'get' | 'has'>;
@ -60,9 +57,6 @@ declare module 'hapi' {
type KbnMixinFunc = (kbnServer: KbnServer, server: Server, config: any) => Promise<any> | void;
export interface PluginsSetup {
usageCollection: UsageCollectionSetup;
telemetryCollectionManager: TelemetryCollectionManagerPluginSetup;
home: HomeServerPluginSetup;
[key: string]: object;
}

View file

@ -49,6 +49,7 @@ import { Path } from 'history';
import { Plugin as Plugin_2 } from 'src/core/public';
import { PluginInitializerContext as PluginInitializerContext_2 } from 'src/core/public';
import { PopoverAnchorPosition } from '@elastic/eui';
import { PublicMethodsOf } from '@kbn/utility-types';
import { PublicUiSettingsParams } from 'src/core/server/types';
import React from 'react';
import * as React_2 from 'react';

View file

@ -10,5 +10,8 @@
"public/**/*.tsx",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -10,5 +10,8 @@
"public/**/*.tsx",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -11,5 +11,8 @@
"server/**/*.ts",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -10,5 +10,8 @@
"public/**/*.tsx",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -11,5 +11,8 @@
"server/**/*.ts",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -10,5 +10,8 @@
"public/**/*.tsx",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -8,5 +8,8 @@
"server/**/*.ts",
"../../../../typings/**/*"
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -10,5 +10,8 @@
"public/**/*.tsx",
"../../../../typings/**/*"
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -10,5 +10,8 @@
"public/**/*.ts",
"../../../../typings/**/*"
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -10,5 +10,8 @@
"public/**/*.tsx",
"../../../../typings/**/*"
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -8,5 +8,8 @@
"server/**/*.ts",
"../../../../typings/**/*"
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -10,5 +10,8 @@
"server/**/*.tsx",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -10,5 +10,8 @@
"public/**/*.tsx",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -11,5 +11,8 @@
"server/**/*.ts",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -15,5 +15,8 @@
"public/**/*.tsx",
"../../../../typings/**/*"
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -10,5 +10,8 @@
"public/**/*.tsx",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -11,5 +11,8 @@
"server/**/*.ts",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -8,5 +8,8 @@
"server/**/*.ts",
"../../../../typings/**/*",
],
"exclude": []
"exclude": [],
"references": [
{ "path": "../../../../src/core/tsconfig.json" }
]
}

View file

@ -16,5 +16,8 @@
"exclude": [
"plugin_functional/plugins/**/*",
"interpreter_functional/plugins/**/*"
],
"references": [
{ "path": "../src/core/tsconfig.json" }
]
}

View file

@ -1,7 +1,7 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"tsBuildInfoFile": "./build/tsbuildinfo/kibana",
"tsBuildInfoFile": "./build/tsbuildinfo/kibana"
},
"include": [
"kibana.d.ts",
@ -11,7 +11,8 @@
],
"exclude": [
"src/**/__fixtures__/**/*",
"src/test_utils/**/*"
"src/test_utils/**/*",
"src/core/**/*"
// In the build we actually exclude **/public/**/* from this config so that
// we can run the TSC on both this and the .browser version of this config
// file, but if we did it during development IDEs would not be able to find
@ -19,6 +20,7 @@
// "src/**/public/**/*"
],
"references": [
{ "path": "./src/test_utils/tsconfig.json" }
{ "path": "./src/test_utils/tsconfig.json" },
{ "path": "./src/core/tsconfig.json" }
]
}

View file

@ -1,6 +1,7 @@
{
"include": [],
"references": [
{ "path": "./src/test_utils" }
{ "path": "./src/test_utils" },
{ "path": "./src/core" },
]
}

Some files were not shown because too many files have changed in this diff Show more