* Delete legacy search endpoint * Fix example * fix jest Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
0342399452
commit
fcc65c8359
7 changed files with 9 additions and 131 deletions
|
@ -33,8 +33,6 @@ import {
|
|||
import { DoSearch } from './do_search';
|
||||
import { GuideSection } from './guide_section';
|
||||
|
||||
// @ts-ignore
|
||||
import serverPlugin from '!!raw-loader!./../../../src/plugins/data/server/search/es_search/es_search_service';
|
||||
// @ts-ignore
|
||||
import serverStrategy from '!!raw-loader!./../../../src/plugins/data/server/search/es_search/es_search_strategy';
|
||||
|
||||
|
@ -127,10 +125,7 @@ export class EsSearchTest extends React.Component<Props, State> {
|
|||
},
|
||||
{
|
||||
title: 'Server',
|
||||
code: [
|
||||
{ description: 'es_search_service.ts', snippet: serverPlugin },
|
||||
{ description: 'es_search_strategy.ts', snippet: serverStrategy },
|
||||
],
|
||||
code: [{ description: 'es_search_strategy.ts', snippet: serverStrategy }],
|
||||
},
|
||||
]}
|
||||
demo={this.renderDemo()}
|
||||
|
|
|
@ -1,42 +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 { coreMock } from '../../../../../core/server/mocks';
|
||||
import { EsSearchService } from './es_search_service';
|
||||
import { searchSetupMock } from '../mocks';
|
||||
|
||||
describe('ES search strategy service', () => {
|
||||
let service: EsSearchService;
|
||||
|
||||
const mockCoreSetup = coreMock.createSetup();
|
||||
const context = coreMock.createPluginInitializerContext();
|
||||
|
||||
beforeEach(() => {
|
||||
service = new EsSearchService(context);
|
||||
});
|
||||
|
||||
describe('setup()', () => {
|
||||
it('registers the ES search strategy', async () => {
|
||||
service.setup(mockCoreSetup, {
|
||||
search: searchSetupMock,
|
||||
});
|
||||
expect(searchSetupMock.registerSearchStrategyProvider).toBeCalled();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,42 +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 { ISearchSetup } from '../i_search_setup';
|
||||
import { PluginInitializerContext, CoreSetup, Plugin } from '../../../../../core/server';
|
||||
import { esSearchStrategyProvider } from './es_search_strategy';
|
||||
import { ES_SEARCH_STRATEGY } from '../../../common/search';
|
||||
|
||||
interface IEsSearchDependencies {
|
||||
search: ISearchSetup;
|
||||
}
|
||||
|
||||
export class EsSearchService implements Plugin<void, void, IEsSearchDependencies> {
|
||||
constructor(private initializerContext: PluginInitializerContext) {}
|
||||
|
||||
public setup(core: CoreSetup, deps: IEsSearchDependencies) {
|
||||
deps.search.registerSearchStrategyProvider(
|
||||
this.initializerContext.opaqueId,
|
||||
ES_SEARCH_STRATEGY,
|
||||
esSearchStrategyProvider
|
||||
);
|
||||
}
|
||||
|
||||
public start() {}
|
||||
public stop() {}
|
||||
}
|
|
@ -17,11 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from '../../../../../core/server';
|
||||
import { EsSearchService } from './es_search_service';
|
||||
export { esSearchStrategyProvider } from './es_search_strategy';
|
||||
|
||||
export { ES_SEARCH_STRATEGY, IEsSearchRequest, IEsSearchResponse } from '../../../common/search';
|
||||
|
||||
export function esSearchService(initializerContext: PluginInitializerContext) {
|
||||
return new EsSearchService(initializerContext);
|
||||
}
|
||||
|
|
|
@ -17,12 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { IContextProvider, APICaller } from 'kibana/server';
|
||||
import { IContextProvider } from 'kibana/server';
|
||||
import { ISearchContext } from './i_search_context';
|
||||
import { IResponseTypesMap, IRequestTypesMap } from './i_search';
|
||||
import { TRegisterSearchStrategyProvider, TSearchStrategyProvider } from './i_search_strategy';
|
||||
import { TStrategyTypes } from './strategy_types';
|
||||
import { DEFAULT_SEARCH_STRATEGY } from '../../common/search';
|
||||
|
||||
/**
|
||||
* The setup contract exposed by the Search plugin exposes the search strategy extension
|
||||
|
@ -40,12 +37,4 @@ export interface ISearchSetup {
|
|||
* strategies.
|
||||
*/
|
||||
registerSearchStrategyProvider: TRegisterSearchStrategyProvider;
|
||||
|
||||
__LEGACY: {
|
||||
search: <T extends TStrategyTypes = typeof DEFAULT_SEARCH_STRATEGY>(
|
||||
caller: APICaller,
|
||||
request: IRequestTypesMap[T],
|
||||
strategyName?: T
|
||||
) => Promise<IResponseTypesMap[T]>;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -42,15 +42,6 @@ describe('Search service', () => {
|
|||
const setup = plugin.setup(mockCoreSetup);
|
||||
expect(setup).toHaveProperty('registerSearchStrategyContext');
|
||||
expect(setup).toHaveProperty('registerSearchStrategyProvider');
|
||||
expect(setup).toHaveProperty('__LEGACY');
|
||||
});
|
||||
});
|
||||
|
||||
describe('__LEGACY', () => {
|
||||
it('calls searchAPI.search', async () => {
|
||||
const setup = plugin.setup(mockCoreSetup);
|
||||
setup.__LEGACY.search(jest.fn(), {}, 'foo');
|
||||
expect(mockSearchApi.search).toBeCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ import {
|
|||
TRegisterSearchStrategyProvider,
|
||||
} from './i_search_strategy';
|
||||
import { IRouteHandlerSearchContext } from './i_route_handler_search_context';
|
||||
import { esSearchService } from './es_search';
|
||||
import { ES_SEARCH_STRATEGY, esSearchStrategyProvider } from './es_search';
|
||||
|
||||
declare module 'kibana/server' {
|
||||
interface RequestHandlerContext {
|
||||
|
@ -71,15 +71,6 @@ export class SearchService implements Plugin<ISearchSetup, void> {
|
|||
const api: ISearchSetup = {
|
||||
registerSearchStrategyContext: this.contextContainer!.registerContext,
|
||||
registerSearchStrategyProvider,
|
||||
__LEGACY: {
|
||||
search: (caller, request, strategyName) => {
|
||||
const searchAPI = createApi({
|
||||
caller,
|
||||
searchStrategies: this.searchStrategies,
|
||||
});
|
||||
return searchAPI.search(request, {}, strategyName);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
api.registerSearchStrategyContext(this.initializerContext.opaqueId, 'core', () => core);
|
||||
|
@ -89,10 +80,11 @@ export class SearchService implements Plugin<ISearchSetup, void> {
|
|||
() => this.initializerContext.config.legacy.globalConfig$
|
||||
);
|
||||
|
||||
// ES search capabilities are written in a way that it could easily be a separate plugin,
|
||||
// however these two plugins are tightly coupled due to the default search strategy using
|
||||
// es search types.
|
||||
esSearchService(this.initializerContext).setup(core, { search: api });
|
||||
api.registerSearchStrategyProvider(
|
||||
this.initializerContext.opaqueId,
|
||||
ES_SEARCH_STRATEGY,
|
||||
esSearchStrategyProvider
|
||||
);
|
||||
|
||||
return api;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue