diff --git a/kibana.d.ts b/kibana.d.ts index 68538320e05a2..21e3e99abaa90 100644 --- a/kibana.d.ts +++ b/kibana.d.ts @@ -37,7 +37,6 @@ import * as LegacyKibanaServer from './src/legacy/server/kbn_server'; */ // eslint-disable-next-line @typescript-eslint/no-namespace export namespace Legacy { - export type IndexPatternsService = LegacyKibanaServer.IndexPatternsService; export type KibanaConfig = LegacyKibanaServer.KibanaConfig; export type Request = LegacyKibanaServer.Request; export type ResponseToolkit = LegacyKibanaServer.ResponseToolkit; diff --git a/src/legacy/server/index_patterns/index.ts b/src/legacy/server/index_patterns/index.ts deleted file mode 100644 index 75d0038cf9023..0000000000000 --- a/src/legacy/server/index_patterns/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 { indexPatternsMixin } from './mixin'; -export { - IndexPatternsFetcher, - FieldDescriptor, -} from '../../../plugins/data/server/index_patterns/fetcher'; -export { IndexPatternsServiceFactory } from './mixin'; diff --git a/src/legacy/server/index_patterns/mixin.ts b/src/legacy/server/index_patterns/mixin.ts deleted file mode 100644 index 6b04c3842007b..0000000000000 --- a/src/legacy/server/index_patterns/mixin.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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. - */ - -import { IndexPatternsFetcher } from '../../../plugins/data/server'; -import KbnServer from '../kbn_server'; -import { APICaller, CallAPIOptions } from '../../../core/server'; -import { Legacy } from '../../../../kibana'; - -export function indexPatternsMixin(kbnServer: KbnServer, server: Legacy.Server) { - /** - * Create an instance of the IndexPatternsService - * - * @method server.indexPatternsServiceFactory - * @type {IndexPatternsService} - */ - server.decorate('server', 'indexPatternsServiceFactory', ({ callCluster }) => { - return new IndexPatternsFetcher(callCluster); - }); - - /** - * Get an instance of the IndexPatternsService configured for use - * the current request - * - * @method request.getIndexPatternsService - * @type {IndexPatternsService} - */ - server.addMemoizedFactoryToRequest('getIndexPatternsService', (request: Legacy.Request) => { - const { callWithRequest } = request.server.plugins.elasticsearch.getCluster('data'); - const callCluster: APICaller = ( - endpoint: string, - params?: Record, - options?: CallAPIOptions - ) => callWithRequest(request, endpoint, params, options); - return server.indexPatternsServiceFactory({ callCluster }); - }); -} - -export type IndexPatternsServiceFactory = (args: { - callCluster: (endpoint: string, clientParams: any, options: any) => Promise; -}) => IndexPatternsFetcher; diff --git a/src/legacy/server/kbn_server.d.ts b/src/legacy/server/kbn_server.d.ts index d1e15699e1307..04f369ac26d7e 100644 --- a/src/legacy/server/kbn_server.d.ts +++ b/src/legacy/server/kbn_server.d.ts @@ -44,7 +44,6 @@ import { LegacyConfig, ILegacyService, ILegacyInternals } from '../../core/serve import { ApmOssPlugin } from '../core_plugins/apm_oss'; import { CallClusterWithRequest, ElasticsearchPlugin } from '../core_plugins/elasticsearch'; import { UsageCollectionSetup } from '../../plugins/usage_collection/server'; -import { IndexPatternsServiceFactory } from './index_patterns'; import { Capabilities } from '../../core/server'; import { UiSettingsServiceFactoryOptions } from '../../legacy/ui/ui_settings/ui_settings_service_factory'; import { HomeServerPluginSetup } from '../../plugins/home/server'; @@ -68,7 +67,6 @@ declare module 'hapi' { interface Server { config: () => KibanaConfig; - indexPatternsServiceFactory: IndexPatternsServiceFactory; savedObjects: SavedObjectsLegacyService; injectUiAppVars: (pluginName: string, getAppVars: () => { [key: string]: any }) => void; getHiddenUiAppById(appId: string): UiApp; @@ -175,5 +173,4 @@ export default class KbnServer { export { Server, Request, ResponseToolkit } from 'hapi'; // Re-export commonly accessed api types. -export { IndexPatternsFetcher as IndexPatternsService } from './index_patterns'; export { SavedObjectsLegacyService, SavedObjectsClient } from 'src/core/server'; diff --git a/src/legacy/server/kbn_server.js b/src/legacy/server/kbn_server.js index e06212d87e3e3..1168d24254911 100644 --- a/src/legacy/server/kbn_server.js +++ b/src/legacy/server/kbn_server.js @@ -33,7 +33,6 @@ import pidMixin from './pid'; import configCompleteMixin from './config/complete'; import optimizeMixin from '../../optimize'; import * as Plugins from './plugins'; -import { indexPatternsMixin } from './index_patterns'; import { savedObjectsMixin } from './saved_objects/saved_objects_mixin'; import { capabilitiesMixin } from './capabilities'; import { serverExtensionsMixin } from './server_extensions'; @@ -114,7 +113,6 @@ export default class KbnServer { // setup this.uiBundles uiMixin, - indexPatternsMixin, // setup saved object routes savedObjectsMixin, diff --git a/src/legacy/server/saved_objects/saved_objects_mixin.test.js b/src/legacy/server/saved_objects/saved_objects_mixin.test.js index 3fa9f9a936988..d49b18ee2ce6c 100644 --- a/src/legacy/server/saved_objects/saved_objects_mixin.test.js +++ b/src/legacy/server/saved_objects/saved_objects_mixin.test.js @@ -118,11 +118,6 @@ describe('Saved Objects Mixin', () => { get: stubConfig, }; }, - indexPatternsServiceFactory: () => { - return { - getFieldsForWildcard: jest.fn(), - }; - }, plugins: { elasticsearch: { getCluster: () => { diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts index a9e6c701d2988..e4a6a824232ba 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts @@ -21,9 +21,6 @@ export interface InfraServerPluginDeps { spaces: SpacesPluginSetup; usageCollection: UsageCollectionSetup; metrics: VisTypeTimeseriesSetup; - indexPatterns: { - indexPatternsServiceFactory: any; - }; features: FeaturesPluginSetup; apm: APMPluginContract; alerting: AlertingPluginContract; diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts index e2ff93ce356e6..b73acd6703054 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts @@ -7,7 +7,6 @@ /* eslint-disable @typescript-eslint/array-type */ import { GraphQLSchema } from 'graphql'; -import { Legacy } from 'kibana'; import { runHttpQuery } from 'apollo-server-core'; import { schema, TypeOf } from '@kbn/config-schema'; import { @@ -217,9 +216,7 @@ export class KibanaFramework { }); } - public getIndexPatternsService( - requestContext: RequestHandlerContext - ): Legacy.IndexPatternsService { + public getIndexPatternsService(requestContext: RequestHandlerContext): IndexPatternsFetcher { return new IndexPatternsFetcher((...rest: Parameters) => { rest[1] = rest[1] || {}; rest[1].allowNoIndices = true;