mirror of
https://github.com/elastic/kibana.git
synced 2025-04-18 23:21:39 -04:00
[Query Rules]Query rules UI plugin (#215029)
## Summary Adds Query Rules UI Plugin. It is disabled and pretty much empty as we want to split the implementation in multiple parts and enable the feature once implementation is done. It is disabled for Security. It is disabled for Observability. It is enabled but behind a feature flag for Search while it is not useful to enable it with partial implementations. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
This commit is contained in:
parent
5b504f8f2a
commit
62f8027c57
38 changed files with 530 additions and 0 deletions
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -990,6 +990,7 @@ x-pack/solutions/search/plugins/search_indices @elastic/search-kibana
|
|||
x-pack/solutions/search/plugins/search_inference_endpoints @elastic/search-kibana
|
||||
x-pack/solutions/search/plugins/search_notebooks @elastic/search-kibana
|
||||
x-pack/solutions/search/plugins/search_playground @elastic/search-kibana
|
||||
x-pack/solutions/search/plugins/search_query_rules @elastic/search-kibana
|
||||
x-pack/solutions/search/plugins/search_solution/search_navigation @elastic/search-kibana
|
||||
x-pack/solutions/search/plugins/search_synonyms @elastic/search-kibana
|
||||
x-pack/solutions/search/plugins/serverless_search @elastic/search-kibana
|
||||
|
|
|
@ -134,3 +134,6 @@ xpack.observabilityAiAssistantManagement.visibilityEnabled: false
|
|||
|
||||
# Synonyms UI
|
||||
xpack.searchSynonyms.enabled: true
|
||||
|
||||
# Query Rules UI
|
||||
xpack.searchQueryRules.enabled: false
|
||||
|
|
|
@ -10,6 +10,8 @@ xpack.fleet.internal.retrySetupOnBoot: true
|
|||
xpack.fleet.internal.useMeteringApi: true
|
||||
xpack.searchSynonyms.enabled: false
|
||||
|
||||
xpack.searchQueryRules.enabled: false
|
||||
|
||||
## Fine-tune the feature privileges.
|
||||
xpack.features.overrides:
|
||||
dashboard:
|
||||
|
|
|
@ -827,6 +827,7 @@
|
|||
"@kbn/search-navigation": "link:x-pack/solutions/search/plugins/search_solution/search_navigation",
|
||||
"@kbn/search-notebooks": "link:x-pack/solutions/search/plugins/search_notebooks",
|
||||
"@kbn/search-playground": "link:x-pack/solutions/search/plugins/search_playground",
|
||||
"@kbn/search-query-rules": "link:x-pack/solutions/search/plugins/search_query_rules",
|
||||
"@kbn/search-response-warnings": "link:src/platform/packages/shared/kbn-search-response-warnings",
|
||||
"@kbn/search-shared-ui": "link:x-pack/solutions/search/packages/shared-ui",
|
||||
"@kbn/search-synonyms": "link:x-pack/solutions/search/plugins/search_synonyms",
|
||||
|
|
|
@ -146,6 +146,7 @@ pageLoadAssetSize:
|
|||
searchNotebooks: 18942
|
||||
searchPlayground: 19325
|
||||
searchprofiler: 67080
|
||||
searchQueryRules: 19708
|
||||
searchSynonyms: 20262
|
||||
security: 81771
|
||||
securitySolution: 98429
|
||||
|
|
|
@ -17,6 +17,7 @@ export const SERVERLESS_ES_WEB_CRAWLERS_ID = 'serverlessWebCrawlers';
|
|||
export const ES_SEARCH_PLAYGROUND_ID = 'searchPlayground';
|
||||
export const SERVERLESS_ES_SEARCH_INFERENCE_ENDPOINTS_ID = 'searchInferenceEndpoints';
|
||||
export const ES_SEARCH_SYNONYMS_ID = 'searchSynonyms';
|
||||
export const SEARCH_QUERY_RULES_ID = 'searchQueryRules';
|
||||
export const SEARCH_HOMEPAGE = 'searchHomepage';
|
||||
export const SEARCH_INDICES_START = 'elasticsearchStart';
|
||||
export const SEARCH_INDICES = 'elasticsearchIndices';
|
||||
|
|
|
@ -26,6 +26,7 @@ import {
|
|||
SEARCH_SEMANTIC_SEARCH,
|
||||
SEARCH_AI_SEARCH,
|
||||
ES_SEARCH_SYNONYMS_ID,
|
||||
SEARCH_QUERY_RULES_ID,
|
||||
SEARCH_INDEX_MANAGEMENT,
|
||||
} from './constants';
|
||||
|
||||
|
@ -39,6 +40,7 @@ export type ServerlessWebCrawlers = typeof SERVERLESS_ES_WEB_CRAWLERS_ID;
|
|||
export type SearchPlaygroundId = typeof ES_SEARCH_PLAYGROUND_ID;
|
||||
export type SearchInferenceEndpointsId = typeof SERVERLESS_ES_SEARCH_INFERENCE_ENDPOINTS_ID;
|
||||
export type SearchSynonymsId = typeof ES_SEARCH_SYNONYMS_ID;
|
||||
export type SearchQueryRulesId = typeof SEARCH_QUERY_RULES_ID;
|
||||
export type SearchHomepage = typeof SEARCH_HOMEPAGE;
|
||||
export type SearchStart = typeof SEARCH_INDICES_START;
|
||||
export type SearchIndices = typeof SEARCH_INDICES;
|
||||
|
@ -69,6 +71,7 @@ export type DeepLinkId =
|
|||
| SearchPlaygroundId
|
||||
| SearchInferenceEndpointsId
|
||||
| SearchSynonymsId
|
||||
| SearchQueryRulesId
|
||||
| SearchHomepage
|
||||
| `${EnterpriseSearchContentApp}:${ContentLinkId}`
|
||||
| `${EnterpriseSearchApplicationsApp}:${ApplicationsLinkId}`
|
||||
|
|
|
@ -1638,6 +1638,8 @@
|
|||
"@kbn/search-notebooks/*": ["x-pack/solutions/search/plugins/search_notebooks/*"],
|
||||
"@kbn/search-playground": ["x-pack/solutions/search/plugins/search_playground"],
|
||||
"@kbn/search-playground/*": ["x-pack/solutions/search/plugins/search_playground/*"],
|
||||
"@kbn/search-query-rules": ["x-pack/solutions/search/plugins/search_query_rules"],
|
||||
"@kbn/search-query-rules/*": ["x-pack/solutions/search/plugins/search_query_rules/*"],
|
||||
"@kbn/search-response-warnings": ["src/platform/packages/shared/kbn-search-response-warnings"],
|
||||
"@kbn/search-response-warnings/*": ["src/platform/packages/shared/kbn-search-response-warnings/*"],
|
||||
"@kbn/search-shared-ui": ["x-pack/solutions/search/packages/shared-ui"],
|
||||
|
|
|
@ -120,6 +120,14 @@ export const buildBaseClassicNavItems = (): ClassicNavItem[] => {
|
|||
},
|
||||
id: 'synonyms',
|
||||
},
|
||||
{
|
||||
'data-test-subj': 'searchSideNav-QueryRules',
|
||||
deepLink: {
|
||||
link: 'searchQueryRules',
|
||||
shouldShowActiveForSubroutes: true,
|
||||
},
|
||||
id: 'searchQueryRules',
|
||||
},
|
||||
],
|
||||
name: i18n.translate('xpack.enterpriseSearch.nav.relevanceTitle', {
|
||||
defaultMessage: 'Relevance',
|
||||
|
|
|
@ -208,6 +208,7 @@ export const getNavigationTreeDefinition = ({
|
|||
children: [
|
||||
{ link: 'searchInferenceEndpoints:inferenceEndpoints' },
|
||||
{ link: 'searchSynonyms:synonyms' },
|
||||
{ link: 'searchQueryRules' },
|
||||
],
|
||||
id: 'relevance',
|
||||
title: i18n.translate('xpack.enterpriseSearch.searchNav.relevance', {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# Search Query Rules
|
||||
|
||||
A plugin to manage Query Rules in Elasticsearch through Query Rules API
|
|
@ -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 const PLUGIN_ROUTE_ROOT = '/app/elasticsearch/query_rules';
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { DocLinks } from '@kbn/doc-links';
|
||||
|
||||
class QueryRulesDocLinks {
|
||||
public queryRulesApi: string = '';
|
||||
|
||||
constructor() {}
|
||||
|
||||
setDocLinks(newDocLinks: DocLinks) {}
|
||||
}
|
||||
|
||||
export const docLinks = new QueryRulesDocLinks();
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export const PLUGIN_ID = 'searchQueryRules';
|
||||
export const PLUGIN_NAME = 'Query Rules';
|
||||
|
||||
export const PLUGIN_TITLE = i18n.translate('xpack.searchQueryRules.pluginTitle', {
|
||||
defaultMessage: 'Query Rules',
|
||||
});
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* 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 const DEFAULT_PAGE_VALUE: Page = {
|
||||
from: 0,
|
||||
size: 25,
|
||||
};
|
||||
|
||||
export interface Pagination {
|
||||
pageIndex: number;
|
||||
pageSize: number;
|
||||
totalItemCount: number;
|
||||
}
|
||||
|
||||
export interface Page {
|
||||
from: number; // current page index, 0-based
|
||||
size: number;
|
||||
}
|
||||
|
||||
export interface Paginate<T> {
|
||||
_meta: Pagination;
|
||||
data: T[];
|
||||
}
|
||||
|
||||
export function paginationToPage(pagination: Pagination): Page {
|
||||
return {
|
||||
from: pagination.pageIndex * pagination.pageSize,
|
||||
size: pagination.pageSize,
|
||||
};
|
||||
}
|
||||
export function pageToPagination(page: { from: number; size: number; total: number }) {
|
||||
// Prevent divide-by-zero-error
|
||||
const pageIndex = page.size ? Math.trunc(page.from / page.size) : 0;
|
||||
return {
|
||||
pageIndex,
|
||||
pageSize: page.size,
|
||||
totalItemCount: page.total,
|
||||
};
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface SearchQueryRulesPluginSetup {}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface SearchQueryRulesPluginStart {}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface AppPluginSetupDependencies {}
|
||||
|
||||
export interface SearchQueryRulesConfigType {
|
||||
enabled: boolean;
|
||||
}
|
|
@ -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 const QUERY_RULES_UI_FLAG = 'queryRules:queryRulesEnabled';
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test',
|
||||
rootDir: '../../../../..',
|
||||
roots: ['<rootDir>/x-pack/solutions/search/plugins/search_query_rules'],
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/x-pack/plugins/search_query_rules',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: [
|
||||
'<rootDir>/x-pack/solutions/search/plugins/search_query_rules/{public,server}/**/*.{ts,tsx}',
|
||||
],
|
||||
};
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"type": "plugin",
|
||||
"id": "@kbn/search-query-rules",
|
||||
"owner": "@elastic/search-kibana",
|
||||
"group": "search",
|
||||
"visibility": "private",
|
||||
"plugin": {
|
||||
"id": "searchQueryRules",
|
||||
"server": true,
|
||||
"browser": true,
|
||||
"configPath": [
|
||||
"xpack",
|
||||
"searchQueryRules",
|
||||
],
|
||||
"requiredPlugins": [
|
||||
"features",
|
||||
],
|
||||
"optionalPlugins": [
|
||||
"console",
|
||||
"searchNavigation",
|
||||
],
|
||||
"requiredBundles": [
|
||||
"kibanaReact",
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { CoreStart } from '@kbn/core/public';
|
||||
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
|
||||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
|
||||
import { I18nProvider } from '@kbn/i18n-react';
|
||||
import { Router } from '@kbn/shared-ux-router';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { AppPluginStartDependencies } from './types';
|
||||
|
||||
const queryClient = new QueryClient({});
|
||||
export const renderApp = async (
|
||||
core: CoreStart,
|
||||
services: AppPluginStartDependencies,
|
||||
element: HTMLElement
|
||||
) => {
|
||||
const { QueryRulesRouter } = await import('./search_query_router');
|
||||
|
||||
ReactDOM.render(
|
||||
<KibanaRenderContextProvider {...core}>
|
||||
<KibanaContextProvider services={{ ...core, ...services }}>
|
||||
<I18nProvider>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<Router history={services.history}>
|
||||
<QueryRulesRouter />
|
||||
</Router>
|
||||
</QueryClientProvider>
|
||||
</I18nProvider>
|
||||
</KibanaContextProvider>
|
||||
</KibanaRenderContextProvider>,
|
||||
element
|
||||
);
|
||||
return () => ReactDOM.unmountComponentAtNode(element);
|
||||
};
|
|
@ -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.
|
||||
*/
|
||||
|
||||
import { QueryRulesPlugin } from './plugin';
|
||||
|
||||
export function plugin() {
|
||||
return new QueryRulesPlugin();
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import type { CoreSetup, Plugin, AppMountParameters, CoreStart } from '@kbn/core/public';
|
||||
import { PLUGIN_ID, PLUGIN_NAME, PLUGIN_TITLE } from '../common';
|
||||
import {
|
||||
AppPluginSetupDependencies,
|
||||
AppPluginStartDependencies,
|
||||
SearchQueryRulesPluginSetup,
|
||||
SearchQueryRulesPluginStart,
|
||||
} from './types';
|
||||
import { QUERY_RULES_UI_FLAG } from '../common/ui_flags';
|
||||
import { docLinks } from '../common/doc_links';
|
||||
import { PLUGIN_ROUTE_ROOT } from '../common/api_routes';
|
||||
|
||||
export class QueryRulesPlugin
|
||||
implements Plugin<SearchQueryRulesPluginSetup, SearchQueryRulesPluginStart>
|
||||
{
|
||||
constructor() {}
|
||||
|
||||
public setup(
|
||||
core: CoreSetup<AppPluginStartDependencies, SearchQueryRulesPluginStart>,
|
||||
_: AppPluginSetupDependencies
|
||||
): SearchQueryRulesPluginSetup {
|
||||
if (!core.settings.client.get<boolean>(QUERY_RULES_UI_FLAG, false)) {
|
||||
return {};
|
||||
}
|
||||
core.application.register({
|
||||
id: PLUGIN_ID,
|
||||
appRoute: PLUGIN_ROUTE_ROOT,
|
||||
title: PLUGIN_TITLE,
|
||||
async mount({ element, history }: AppMountParameters) {
|
||||
const { renderApp } = await import('./application');
|
||||
const [coreStart, depsStart] = await core.getStartServices();
|
||||
|
||||
coreStart.chrome.docTitle.change(PLUGIN_NAME);
|
||||
|
||||
const startDeps: AppPluginStartDependencies = {
|
||||
...depsStart,
|
||||
history,
|
||||
};
|
||||
|
||||
depsStart.searchNavigation?.handleOnAppMount();
|
||||
|
||||
return renderApp(coreStart, startDeps, element);
|
||||
},
|
||||
visibleIn: ['globalSearch'],
|
||||
});
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
public start(core: CoreStart): SearchQueryRulesPluginStart {
|
||||
docLinks.setDocLinks(core.docLinks.links);
|
||||
return {};
|
||||
}
|
||||
|
||||
public stop() {}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { Route, Routes } from '@kbn/shared-ux-router';
|
||||
import React from 'react';
|
||||
|
||||
export const QueryRulesRouter = () => {
|
||||
return (
|
||||
<Routes>
|
||||
<Route exact path="/">
|
||||
Query rules
|
||||
</Route>
|
||||
</Routes>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { SearchNavigationPluginStart } from '@kbn/search-navigation/public';
|
||||
import { AppMountParameters, CoreStart } from '@kbn/core/public';
|
||||
import type { ConsolePluginStart } from '@kbn/console-plugin/public';
|
||||
|
||||
export * from '../common/types';
|
||||
export interface AppPluginStartDependencies {
|
||||
history: AppMountParameters['history'];
|
||||
console?: ConsolePluginStart;
|
||||
searchNavigation?: SearchNavigationPluginStart;
|
||||
}
|
||||
|
||||
export type AppServicesContext = CoreStart & AppPluginStartDependencies;
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { schema, TypeOf } from '@kbn/config-schema';
|
||||
import { PluginConfigDescriptor } from '@kbn/core/server';
|
||||
|
||||
const configSchema = schema.object({
|
||||
enabled: schema.boolean({ defaultValue: true }),
|
||||
});
|
||||
|
||||
export type SearchQueryRulesConfig = TypeOf<typeof configSchema>;
|
||||
|
||||
export const config: PluginConfigDescriptor<SearchQueryRulesConfig> = {
|
||||
schema: configSchema,
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from '@kbn/core/server';
|
||||
|
||||
export { config } from './config';
|
||||
|
||||
export async function plugin(initializerContext: PluginInitializerContext) {
|
||||
const { SearchQueryRulesPlugin } = await import('./plugin');
|
||||
return new SearchQueryRulesPlugin(initializerContext);
|
||||
}
|
||||
|
||||
export type { SearchQueryRulesPluginSetup, SearchQueryRulesPluginStart } from './types';
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import {
|
||||
PluginInitializerContext,
|
||||
CoreSetup,
|
||||
CoreStart,
|
||||
Plugin,
|
||||
DEFAULT_APP_CATEGORIES,
|
||||
} from '@kbn/core/server';
|
||||
|
||||
import { KibanaFeatureScope } from '@kbn/features-plugin/common';
|
||||
import {
|
||||
SearchQueryRulesPluginSetup,
|
||||
SearchQueryRulesPluginSetupDependencies,
|
||||
SearchQueryRulesPluginStart,
|
||||
} from './types';
|
||||
|
||||
import { PLUGIN_ID, PLUGIN_TITLE } from '../common';
|
||||
|
||||
export class SearchQueryRulesPlugin
|
||||
implements Plugin<SearchQueryRulesPluginSetup, SearchQueryRulesPluginStart, {}, {}>
|
||||
{
|
||||
constructor(initializerContext: PluginInitializerContext) {}
|
||||
|
||||
public setup(core: CoreSetup, plugins: SearchQueryRulesPluginSetupDependencies) {
|
||||
plugins.features.registerKibanaFeature({
|
||||
id: PLUGIN_ID,
|
||||
name: PLUGIN_TITLE,
|
||||
order: 0,
|
||||
category: DEFAULT_APP_CATEGORIES.enterpriseSearch,
|
||||
app: ['kibana', PLUGIN_ID],
|
||||
scope: [KibanaFeatureScope.Spaces, KibanaFeatureScope.Security],
|
||||
catalogue: [PLUGIN_ID],
|
||||
privileges: {
|
||||
all: {
|
||||
app: ['kibana', PLUGIN_ID],
|
||||
api: ['manage_search_query_rules'],
|
||||
catalogue: [PLUGIN_ID],
|
||||
savedObject: {
|
||||
all: [],
|
||||
read: [],
|
||||
},
|
||||
ui: ['manage'],
|
||||
},
|
||||
read: {
|
||||
disabled: true,
|
||||
savedObject: {
|
||||
all: [],
|
||||
read: [],
|
||||
},
|
||||
ui: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
public start(_: CoreStart) {
|
||||
return {};
|
||||
}
|
||||
|
||||
public stop() {}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { FeaturesPluginSetup } from '@kbn/features-plugin/server';
|
||||
export * from '../common/types';
|
||||
|
||||
export interface SearchQueryRulesPluginSetupDependencies {
|
||||
features: FeaturesPluginSetup;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { RequestHandlerWrapper } from '@kbn/core-http-server';
|
||||
import { KibanaServerError } from '@kbn/kibana-utils-plugin/common';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
||||
function isKibanaServerError(error: any): error is KibanaServerError {
|
||||
return error.statusCode && error.message;
|
||||
}
|
||||
|
||||
export const errorHandler: (logger: Logger) => RequestHandlerWrapper = (logger) => (handler) => {
|
||||
return async (context, request, response) => {
|
||||
try {
|
||||
return await handler(context, request, response);
|
||||
} catch (e) {
|
||||
logger.error(e);
|
||||
if (isKibanaServerError(e)) {
|
||||
return response.customError({ statusCode: e.statusCode, body: e.message });
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"extends": "../../../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "target/types",
|
||||
},
|
||||
"include": [
|
||||
"__mocks__/**/*",
|
||||
"common/**/*",
|
||||
"public/**/*",
|
||||
"server/**/*",
|
||||
],
|
||||
"kbn_references": [
|
||||
"@kbn/config-schema",
|
||||
"@kbn/core",
|
||||
"@kbn/i18n",
|
||||
"@kbn/i18n-react",
|
||||
"@kbn/kibana-react-plugin",
|
||||
"@kbn/shared-ux-router",
|
||||
"@kbn/react-kibana-context-render",
|
||||
"@kbn/console-plugin",
|
||||
"@kbn/features-plugin",
|
||||
"@kbn/search-navigation",
|
||||
"@kbn/doc-links",
|
||||
"@kbn/core-http-server",
|
||||
"@kbn/kibana-utils-plugin",
|
||||
"@kbn/logging",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
]
|
||||
}
|
|
@ -110,6 +110,13 @@ export const navigationTree = ({ isAppRegistered }: ApplicationStart): Navigatio
|
|||
}),
|
||||
link: 'searchSynonyms',
|
||||
},
|
||||
{
|
||||
id: 'searchQueryRules',
|
||||
title: i18n.translate('xpack.serverlessSearch.nav.relevance.searchQueryRules', {
|
||||
defaultMessage: 'Query Rules',
|
||||
}),
|
||||
link: 'searchQueryRules',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -132,6 +132,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
'uptime',
|
||||
'searchInferenceEndpoints',
|
||||
'searchSynonyms',
|
||||
'searchQueryRules',
|
||||
'searchPlayground',
|
||||
'siemV2',
|
||||
'slo',
|
||||
|
@ -190,6 +191,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
'uptime',
|
||||
'searchInferenceEndpoints',
|
||||
'searchSynonyms',
|
||||
'searchQueryRules',
|
||||
'searchPlayground',
|
||||
'siem',
|
||||
'siemV2',
|
||||
|
|
|
@ -85,6 +85,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
slo: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchPlayground: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchSynonyms: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchQueryRules: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchInferenceEndpoints: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
fleetv2: [
|
||||
'all',
|
||||
|
|
|
@ -65,6 +65,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
securitySolutionSiemMigrations: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchPlayground: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchSynonyms: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchQueryRules: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchInferenceEndpoints: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
fleetv2: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
fleet: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
|
@ -186,6 +187,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
slo: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchPlayground: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchSynonyms: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchQueryRules: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
searchInferenceEndpoints: ['all', 'read', 'minimal_all', 'minimal_read'],
|
||||
fleetv2: [
|
||||
'agent_policies_all',
|
||||
|
|
|
@ -91,6 +91,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
searchInferenceEndpoints: 0,
|
||||
searchPlayground: 0,
|
||||
searchSynonyms: 0,
|
||||
searchQueryRules: 0,
|
||||
siem: 0,
|
||||
siemV2: 0,
|
||||
securitySolutionCases: 0,
|
||||
|
|
|
@ -84,6 +84,7 @@ export default function catalogueTests({ getService }: FtrProviderContext) {
|
|||
'searchPlayground',
|
||||
'searchInferenceEndpoints',
|
||||
'searchSynonyms',
|
||||
'searchQueryRules',
|
||||
'appSearch',
|
||||
'observabilityAIAssistant',
|
||||
'workplaceSearch',
|
||||
|
|
|
@ -62,6 +62,7 @@ export default function navLinksTests({ getService }: FtrProviderContext) {
|
|||
'enterpriseSearchAnalytics',
|
||||
'searchPlayground',
|
||||
'searchSynonyms',
|
||||
'searchQueryRules',
|
||||
'searchInferenceEndpoints',
|
||||
'guidedOnboardingFeature',
|
||||
'securitySolutionAssistant',
|
||||
|
|
|
@ -6954,6 +6954,10 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/search-query-rules@link:x-pack/solutions/search/plugins/search_query_rules":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/search-response-warnings@link:src/platform/packages/shared/kbn-search-response-warnings":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
|
Loading…
Add table
Reference in a new issue