Skip to content

Commit

Permalink
Merge branch 'main' into elastic#205329
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp authored Jan 2, 2025
2 parents 1facbfe + 50509d5 commit 3fd481f
Show file tree
Hide file tree
Showing 131 changed files with 908 additions and 691 deletions.
2 changes: 0 additions & 2 deletions packages/kbn-test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ export { getUrl } from './src/jest/get_url';

export { runCheckJestConfigsCli } from './src/jest/run_check_jest_configs_cli';

export { runCheckFtrCodeOwnersCli } from './src/functional_test_runner/run_check_ftr_code_owners';

export { runJest } from './src/jest/run';

export * from './src/kbn_archiver_cli';
Expand Down
48 changes: 48 additions & 0 deletions packages/kbn-test/src/functional_test_runner/cli/code_owners.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { run } from '@kbn/dev-cli-runner';
import { createFailError } from '@kbn/dev-cli-errors';
import { getRepoFiles } from '@kbn/get-repo-files';
import { getCodeOwnersEntries } from '@kbn/code-owners';
import ignore from 'ignore';

const TEST_DIRECTORIES = ['test', 'x-pack/test', 'x-pack/test_serverless'];

export async function checkFTRCodeOwnersCLI() {
await run(
async ({ log }) => {
const matcher = ignore().add(
getCodeOwnersEntries()
.filter((entry) => entry.teams.length > 0)
.map((entry) => entry.pattern)
);
const hasOwner = (path: string): boolean => matcher.test(path).ignored;

const testFiles = await getRepoFiles(TEST_DIRECTORIES);
const filesWithoutOwner = testFiles
.filter((repoPath) => !hasOwner(repoPath.repoRel))
.map((repoPath) => repoPath.repoRel);

log.info(`Checked ${testFiles.length} test files in ${process.uptime().toFixed(2)}s`);

if (filesWithoutOwner.length === 0) {
log.success(`All test files have a code owner 🥳`);
return;
}

log.write('Test files without a code owner:');
log.write(filesWithoutOwner.map((i) => ` - ${i}`).join('\n'));
throw createFailError(`Found ${filesWithoutOwner.length} test files without code owner`);
},
{
description: 'Check that all test files are covered by GitHub CODEOWNERS',
}
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { ToolingLog } from '@kbn/tooling-log';
import { getTimeReporter } from '@kbn/ci-stats-reporter';
import exitHook from 'exit-hook';

import { readConfigFile, EsVersion } from './lib';
import { FunctionalTestRunner } from './functional_test_runner';
import { readConfigFile, EsVersion } from '../lib';
import { FunctionalTestRunner } from '../functional_test_runner';

export function runFtrCli() {
const runStartTime = Date.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export * from '../../../common/lib/saved_object_embeddable';
export { Embeddable } from './embeddable';
export { EmbeddableErrorHandler } from './embeddable_error_handler';
export { ErrorEmbeddable } from './error_embeddable';
export type { EmbeddableInput, EmbeddableOutput, IEmbeddable } from './i_embeddable';
export { runFtrCli } from './ftr';
export { checkFTRCodeOwnersCLI } from './code_owners';
2 changes: 1 addition & 1 deletion packages/kbn-test/src/functional_test_runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export {
runCheckFtrConfigsCli,
DedicatedTaskRunner,
} from './lib';
export { runFtrCli } from './cli';
export * from './cli';
export * from './lib/docker_servers';
export * from './public_types';

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/check_ftr_code_owners.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
*/

require('../src/setup_node_env');
require('@kbn/test').runCheckFtrCodeOwnersCli();
void require('@kbn/test').checkFTRCodeOwnersCLI();
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export interface EmbeddableApiContext {
/**
* TODO: once all actions are entirely decoupled from the embeddable system, this key should be renamed to "api"
* to reflect the fact that this context could contain any api.
*/
embeddable: unknown;
}

export const isEmbeddableApiContext = (context: unknown): context is EmbeddableApiContext =>
!!context &&
typeof context === 'object' &&
!!(context as EmbeddableApiContext).embeddable &&
typeof (context as EmbeddableApiContext).embeddable === 'object';
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export interface EmbeddableApiContext {
/**
* TODO: once all actions are entirely decoupled from the embeddable system, this key should be renamed to "api"
* to reflect the fact that this context could contain any api.
*/
embeddable: unknown;
}
export { isEmbeddableApiContext, type EmbeddableApiContext } from './embeddable_api_context';

export {
getInitialValuesFromComparators,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ import {
ControlGroupSerializedState,
} from '@kbn/controls-plugin/public';
import { Filter, Query, TimeRange } from '@kbn/es-query';
import {
DefaultEmbeddableApi,
EmbeddablePackageState,
ErrorEmbeddable,
IEmbeddable,
} from '@kbn/embeddable-plugin/public';
import type { DefaultEmbeddableApi, EmbeddablePackageState } from '@kbn/embeddable-plugin/public';
import { Observable, Subject } from 'rxjs';
import { RefreshInterval, SearchSessionInfoProvider } from '@kbn/data-plugin/public';
import { IKbnUrlStateStorage } from '@kbn/kibana-utils-plugin/public';
Expand Down Expand Up @@ -175,9 +170,7 @@ export type DashboardApi = CanExpandPanels &
setTags: (tags: string[]) => void;
setTimeRange: (timeRange?: TimeRange | undefined) => void;
unifiedSearchFilters$: PublishesUnifiedSearch['filters$'];

// TODO remove types below this line - from legacy embeddable system
untilEmbeddableLoaded: (id: string) => Promise<IEmbeddable | ErrorEmbeddable>;
untilEmbeddableLoaded: (id: string) => Promise<unknown | undefined>;
};

export interface DashboardInternalApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ export const LATEST_DASHBOARD_CONTAINER_VERSION = convertNumberToDashboardVersio

export { LazyDashboardRenderer } from './external_api/lazy_dashboard_renderer';
export type { DashboardLocatorParams } from './types';
export type { IProvidesLegacyPanelPlacementSettings } from './panel_placement';
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export { placeClonePanel } from './place_clone_panel_strategy';

export { registerDashboardPanelPlacementSetting } from './panel_placement_registry';

export type { GetPanelPlacementSettings, IProvidesLegacyPanelPlacementSettings } from './types';
export type { GetPanelPlacementSettings } from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { EmbeddableInput } from '@kbn/embeddable-plugin/public';
import { MaybePromise } from '@kbn/utility-types';
import { DashboardPanelState } from '../../../common';
import type { GridData } from '../../../server/content_management';
Expand All @@ -30,16 +29,6 @@ export interface PanelPlacementProps {
currentPanels: { [key: string]: DashboardPanelState };
}

export interface IProvidesLegacyPanelPlacementSettings<
InputType extends EmbeddableInput = EmbeddableInput,
AttributesType = unknown
> {
getLegacyPanelPlacementSettings: (
input: InputType,
attributes?: AttributesType
) => Partial<PanelPlacementSettings>;
}

export type GetPanelPlacementSettings<SerializedState extends object = object> = (
serializedState?: SerializedState
) => MaybePromise<PanelPlacementSettings>;
1 change: 0 additions & 1 deletion src/platform/plugins/shared/dashboard/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export {
LazyDashboardRenderer as DashboardRenderer,
DASHBOARD_CONTAINER_TYPE,
type DashboardLocatorParams,
type IProvidesLegacyPanelPlacementSettings,
} from './dashboard_container';
export type { DashboardSetup, DashboardStart, DashboardFeatureFlagConfig } from './plugin';

Expand Down
7 changes: 0 additions & 7 deletions src/platform/plugins/shared/embeddable/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export {
CELL_VALUE_TRIGGER,
contextMenuTrigger,
CONTEXT_MENU_TRIGGER,
Embeddable,
EmbeddableStateTransfer,
ErrorEmbeddable,
isContextMenuTriggerContext,
isMultiValueClickTriggerContext,
isRangeSelectTriggerContext,
isRowClickTriggerContext,
Expand All @@ -41,12 +38,8 @@ export {
export type {
CellValueContext,
ChartActionContext,
EmbeddableContext,
EmbeddableEditorState,
EmbeddableInput,
EmbeddableOutput,
EmbeddablePackageState,
IEmbeddable,
MultiValueClickContext,
PropertySpec,
RangeSelectContext,
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/platform/plugins/shared/embeddable/public/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

export * from './errors';
export * from './embeddables';
export * from './types';
export * from './triggers';
export * from './state_transfer';
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ import type { EmbeddableApiContext } from '@kbn/presentation-publishing';
import { Datatable, DatatableColumnMeta } from '@kbn/expressions-plugin/common';
import { Trigger, RowClickContext } from '@kbn/ui-actions-plugin/public';
import { BooleanRelation } from '@kbn/es-query';
import { IEmbeddable } from '..';

/**
* @deprecated use `EmbeddableApiContext` from `@kbn/presentation-publishing`
*/
export interface EmbeddableContext<T extends IEmbeddable = IEmbeddable> {
embeddable: T;
}

export type ValueClickContext = Partial<EmbeddableApiContext> & {
data: {
Expand Down Expand Up @@ -192,9 +184,3 @@ export const isRowClickTriggerContext = (context: ChartActionContext): context i
!!context.data &&
typeof context.data === 'object' &&
typeof (context as RowClickContext).data.rowIndex === 'number';

export const isContextMenuTriggerContext = (context: unknown): context is EmbeddableContext =>
!!context &&
typeof context === 'object' &&
!!(context as EmbeddableContext).embeddable &&
typeof (context as EmbeddableContext).embeddable === 'object';
1 change: 0 additions & 1 deletion src/platform/plugins/shared/embeddable/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"@kbn/utility-types",
"@kbn/es-query",
"@kbn/i18n",
"@kbn/std",
"@kbn/expressions-plugin",
"@kbn/saved-objects-management-plugin",
"@kbn/saved-objects-tagging-oss-plugin",
Expand Down
Loading

0 comments on commit 3fd481f

Please sign in to comment.