Skip to content

Commit

Permalink
Merge branch 'main' into issue_180088
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Apr 9, 2024
2 parents 5816065 + 09228a3 commit 5469d08
Show file tree
Hide file tree
Showing 65 changed files with 307 additions and 292 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,7 @@
"@types/vinyl-fs": "^3.0.2",
"@types/watchpack": "^1.1.5",
"@types/webpack": "^4.41.3",
"@types/webpack-bundle-analyzer": "^4.7.0",
"@types/webpack-env": "^1.15.3",
"@types/webpack-merge": "^4.1.5",
"@types/webpack-sources": "^0.1.4",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-es-types/src/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ export interface ESQLSearchParams {
// https://github.com/elastic/elasticsearch/pull/102767
// time_zone?: string;
query: string;
version: string;
filter?: unknown;
locale?: string;
dropNullColumns?: boolean;
Expand Down
11 changes: 11 additions & 0 deletions packages/kbn-esql-utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

// we are expecting to retrieve this from an API instead
// https://github.com/elastic/elasticsearch/issues/107069
export const ESQL_LATEST_VERSION = '2024.04.01';
2 changes: 2 additions & 0 deletions packages/kbn-esql-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ export {
getESQLWithSafeLimit,
TextBasedLanguages,
} from './src';

export { ESQL_LATEST_VERSION } from './constants';
6 changes: 4 additions & 2 deletions packages/kbn-generate-csv/src/generate_csv_esql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { IKibanaSearchResponse } from '@kbn/data-plugin/common';
import { IScopedSearchClient } from '@kbn/data-plugin/server';
import { dataPluginMock } from '@kbn/data-plugin/server/mocks';
import { CancellationToken } from '@kbn/reporting-common';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import type { ReportingConfigType } from '@kbn/reporting-server';
import type { ESQLSearchReponse as ESQLSearchResponse } from '@kbn/es-types';
import {
Expand Down Expand Up @@ -311,7 +312,7 @@ describe('CsvESQLGenerator', () => {
);

expect(mockDataClientSearchFn).toBeCalledWith(
{ params: { filter: undefined, locale: 'en', query: '' } },
{ params: { filter: undefined, locale: 'en', query: '', version: ESQL_LATEST_VERSION } },
{
strategy: 'esql',
transport: {
Expand Down Expand Up @@ -389,7 +390,7 @@ describe('CsvESQLGenerator', () => {
);

expect(mockDataClientSearchFn).toBeCalledWith(
{ params: { filter: undefined, locale: 'en', query: '' } },
{ params: { filter: undefined, locale: 'en', query: '', version: ESQL_LATEST_VERSION } },
{
strategy: 'esql',
transport: {
Expand Down Expand Up @@ -485,6 +486,7 @@ describe('CsvESQLGenerator', () => {
},
locale: 'en',
query: '',
version: ESQL_LATEST_VERSION,
},
},
{
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-generate-csv/src/generate_csv_esql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { lastValueFrom } from 'rxjs';
import type { Writable } from 'stream';

import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { errors as esErrors } from '@elastic/elasticsearch';
import type { IScopedClusterClient, IUiSettingsClient, Logger } from '@kbn/core/server';
import {
Expand Down Expand Up @@ -100,6 +100,7 @@ export class CsvESQLGenerator {
// we will need to add it back in once it is supported again.
// https://github.com/elastic/elasticsearch/pull/102767
// timezone
version: ESQL_LATEST_VERSION,
},
};

Expand Down
1 change: 1 addition & 0 deletions packages/kbn-generate-csv/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
"@kbn/reporting-export-types-csv-common",
"@kbn/es-query",
"@kbn/es-types",
"@kbn/esql-utils",
]
}
7 changes: 7 additions & 0 deletions packages/kbn-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
import StatoscopeWebpackPlugin from '@statoscope/webpack-plugin';
// @ts-expect-error
import VisualizerPlugin from 'webpack-visualizer-plugin2';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';

import { Bundle, BundleRemotes, WorkerConfig, parseDllManifest } from '../common';
import { BundleRemotesPlugin } from './bundle_remotes_plugin';
Expand Down Expand Up @@ -92,6 +93,12 @@ export function getWebpackConfig(
saveReportTo: `${bundle.outputDir}/${bundle.id}.statoscope.html`,
}),
new VisualizerPlugin({ filename: `${bundle.id}.visualizer.html` }),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: `${bundle.id}.analyzer.html`,
openAnalyzer: false,
logLevel: 'silent',
}),
]
: []),
// @ts-ignore something is wrong with the StatoscopeWebpackPlugin type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
} from '@kbn/data-plugin/public';
import type { ESQLSearchParams, ESQLSearchReponse } from '@kbn/es-types';
import type { AggregateQuery } from '@kbn/es-query';
import { getESQLWithSafeLimit } from '@kbn/esql-utils';
import { ESQL_LATEST_VERSION, getESQLWithSafeLimit } from '@kbn/esql-utils';
import type { FieldStatsResponse } from '../../types';
import {
buildSearchFilter,
Expand Down Expand Up @@ -77,6 +77,7 @@ export const loadFieldStatsTextBased: LoadFieldStatsTextBasedHandler = async ({
params: {
...(filter ? { filter } : {}),
...body,
version: ESQL_LATEST_VERSION,
},
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data/common/search/expressions/esql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Observable, defer, throwError } from 'rxjs';
import { catchError, map, switchMap, tap } from 'rxjs';
import { buildEsQuery } from '@kbn/es-query';
import type { ESQLSearchReponse, ESQLSearchParams } from '@kbn/es-types';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { getEsQueryConfig } from '../../es_query';
import { getTime } from '../../query';
import {
Expand Down Expand Up @@ -130,6 +131,7 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => {
query,
// time_zone: timezone,
locale,
version: ESQL_LATEST_VERSION,
};
if (input) {
const esQueryConfigs = getEsQueryConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { firstValueFrom } from 'rxjs';
import { KbnServerError } from '@kbn/kibana-utils-plugin/server';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { KbnSearchError } from '../../report_search_error';
import { errors } from '@elastic/elasticsearch';
import indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json';
Expand Down Expand Up @@ -66,6 +67,7 @@ describe('ES|QL async search strategy', () => {
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);
const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
await esSearch
.search(
Expand All @@ -89,6 +91,7 @@ describe('ES|QL async search strategy', () => {

const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);

Expand All @@ -108,6 +111,7 @@ describe('ES|QL async search strategy', () => {
query: 'from logs* | limit 10',
wait_for_completion_timeout: '10s',
keep_alive: '5m',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);

Expand All @@ -123,7 +127,7 @@ describe('ES|QL async search strategy', () => {
it('sets transport options on POST requests', async () => {
const transportOptions = { maxRetries: 1 };
mockApiCaller.mockResolvedValueOnce(mockAsyncResponse);
const params = { query: 'from logs' };
const params = { query: 'from logs', version: ESQL_LATEST_VERSION };
const esSearch = esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);

await firstValueFrom(
Expand All @@ -140,6 +144,7 @@ describe('ES|QL async search strategy', () => {
wait_for_completion_timeout: '100ms',
keep_on_completion: false,
query: 'from logs',
version: ESQL_LATEST_VERSION,
},
}),
expect.objectContaining({ maxRetries: 1, meta: true, signal: undefined })
Expand All @@ -150,6 +155,7 @@ describe('ES|QL async search strategy', () => {
mockApiCaller.mockResolvedValueOnce(mockAsyncResponse);
const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);

Expand All @@ -175,6 +181,7 @@ describe('ES|QL async search strategy', () => {

const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);

Expand All @@ -197,6 +204,7 @@ describe('ES|QL async search strategy', () => {

const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);
const abortController = new AbortController();
Expand Down Expand Up @@ -230,6 +238,7 @@ describe('ES|QL async search strategy', () => {

const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);

Expand All @@ -253,6 +262,7 @@ describe('ES|QL async search strategy', () => {

const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"@kbn/bfetch-error",
"@kbn/es-types",
"@kbn/code-editor",
"@kbn/core-test-helpers-model-versions"
"@kbn/core-test-helpers-model-versions",
"@kbn/esql-utils"
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import './management_app.scss';
import React, { useState, useEffect, useCallback } from 'react';
import { BehaviorSubject } from 'rxjs';

import { I18nProvider } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import { AppMountParameters, ChromeBreadcrumb, ScopedHistory } from '@kbn/core/public';
import { CoreStart } from '@kbn/core/public';
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';

import { reactRouterNavigate, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
import { reactRouterNavigate } from '@kbn/kibana-react-plugin/public';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { KibanaPageTemplate, KibanaPageTemplateProps } from '@kbn/shared-ux-page-kibana-template';
import useObservable from 'react-use/lib/useObservable';
import { AppContextProvider } from './management_context';
Expand All @@ -32,7 +32,6 @@ import { SectionsServiceStart, NavigationCardsSubject } from '../../types';
interface ManagementAppProps {
appBasePath: string;
history: AppMountParameters['history'];
theme$: AppMountParameters['theme$'];
dependencies: ManagementAppDependencies;
}

Expand All @@ -45,13 +44,8 @@ export interface ManagementAppDependencies {
cardsNavigationConfig$: BehaviorSubject<NavigationCardsSubject>;
}

export const ManagementApp = ({
dependencies,
history,
theme$,
appBasePath,
}: ManagementAppProps) => {
const { setBreadcrumbs, isSidebarEnabled$, cardsNavigationConfig$ } = dependencies;
export const ManagementApp = ({ dependencies, history, appBasePath }: ManagementAppProps) => {
const { coreStart, setBreadcrumbs, isSidebarEnabled$, cardsNavigationConfig$ } = dependencies;
const [selectedId, setSelectedId] = useState<string>('');
const [sections, setSections] = useState<ManagementSection[]>();
const isSidebarEnabled = useObservable(isSidebarEnabled$);
Expand Down Expand Up @@ -114,30 +108,28 @@ export const ManagementApp = ({
};

return (
<RedirectAppLinks coreStart={dependencies.coreStart}>
<I18nProvider>
<KibanaRenderContextProvider i18n={coreStart.i18n} theme={coreStart.theme}>
<RedirectAppLinks coreStart={dependencies.coreStart}>
<AppContextProvider value={contextDependencies}>
<KibanaThemeProvider theme$={theme$}>
<KibanaPageTemplate
restrictWidth={false}
solutionNav={solution}
// @ts-expect-error Techincally `paddingSize` isn't supported but it is passed through,
// this is a stop-gap for Stack managmement specifically until page components can be converted to template components
mainProps={{ paddingSize: 'l' }}
panelled
>
<ManagementRouter
history={history}
theme$={theme$}
setBreadcrumbs={setBreadcrumbsScoped}
onAppMounted={onAppMounted}
sections={sections}
analytics={dependencies.coreStart.analytics}
/>
</KibanaPageTemplate>
</KibanaThemeProvider>
<KibanaPageTemplate
restrictWidth={false}
solutionNav={solution}
// @ts-expect-error Techincally `paddingSize` isn't supported but it is passed through,
// this is a stop-gap for Stack managmement specifically until page components can be converted to template components
mainProps={{ paddingSize: 'l' }}
panelled
>
<ManagementRouter
history={history}
theme={coreStart.theme}
setBreadcrumbs={setBreadcrumbsScoped}
onAppMounted={onAppMounted}
sections={sections}
analytics={coreStart.analytics}
/>
</KibanaPageTemplate>
</AppContextProvider>
</I18nProvider>
</RedirectAppLinks>
</RedirectAppLinks>
</KibanaRenderContextProvider>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
AppMountParameters,
ChromeBreadcrumb,
ScopedHistory,
ThemeServiceStart,
} from '@kbn/core/public';
import { KibanaErrorBoundary, KibanaErrorBoundaryProvider } from '@kbn/shared-ux-error-boundary';
import { ManagementAppWrapper } from '../management_app_wrapper';
Expand All @@ -22,7 +23,7 @@ import { ManagementSection } from '../../utils';

interface ManagementRouterProps {
history: AppMountParameters['history'];
theme$: AppMountParameters['theme$'];
theme: ThemeServiceStart;
setBreadcrumbs: (crumbs?: ChromeBreadcrumb[], appHistory?: ScopedHistory) => void;
onAppMounted: (id: string) => void;
sections: ManagementSection[];
Expand All @@ -35,7 +36,7 @@ export const ManagementRouter = memo(
setBreadcrumbs,
onAppMounted,
sections,
theme$,
theme,
analytics,
}: ManagementRouterProps) => {
return (
Expand All @@ -55,7 +56,7 @@ export const ManagementRouter = memo(
setBreadcrumbs={setBreadcrumbs}
onAppMounted={onAppMounted}
history={history}
theme$={theme$}
theme={theme}
/>
)}
/>
Expand Down
Loading

0 comments on commit 5469d08

Please sign in to comment.