Kibana Sustainable Architecture: Expose StatusResponse in core-status-common (#200524)

## Summary

- Exposes the interfaces that define the format of the response of the
`/api/status` endpoint.
- Moves them from `@kbn/core-status-common-internal` to
`@kbn/core-status-common`.
- Removes the former package, as it no longer contains anything.
- Fixes some of the illegal dependencies uncovered by
https://github.com/elastic/kibana/pull/199630.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Gerard Soldevila 2024-11-18 14:34:54 +01:00 committed by GitHub
parent 55134abbed
commit ab0375f56f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 35 additions and 130 deletions

1
.github/CODEOWNERS vendored
View file

@ -225,7 +225,6 @@ packages/core/security/core-security-server @elastic/kibana-core
packages/core/security/core-security-server-internal @elastic/kibana-core
packages/core/security/core-security-server-mocks @elastic/kibana-core
packages/core/status/core-status-common @elastic/kibana-core
packages/core/status/core-status-common-internal @elastic/kibana-core
packages/core/status/core-status-server @elastic/kibana-core
packages/core/status/core-status-server-internal @elastic/kibana-core
packages/core/status/core-status-server-mocks @elastic/kibana-core

View file

@ -384,7 +384,6 @@
"@kbn/core-security-server-internal": "link:packages/core/security/core-security-server-internal",
"@kbn/core-security-server-mocks": "link:packages/core/security/core-security-server-mocks",
"@kbn/core-status-common": "link:packages/core/status/core-status-common",
"@kbn/core-status-common-internal": "link:packages/core/status/core-status-common-internal",
"@kbn/core-status-server": "link:packages/core/status/core-status-server",
"@kbn/core-status-server-internal": "link:packages/core/status/core-status-server-internal",
"@kbn/core-test-helpers-deprecations-getters": "link:packages/core/test-helpers/core-test-helpers-deprecations-getters",

View file

@ -9,7 +9,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import type { StatusInfoServiceStatus as ServiceStatus } from '@kbn/core-status-common-internal';
import type { StatusInfoServiceStatus as ServiceStatus } from '@kbn/core-status-common';
import { StatusTable } from './status_table';
const state = {

View file

@ -9,7 +9,7 @@
import React from 'react';
import { mountWithIntl, findTestSubject } from '@kbn/test-jest-helpers';
import type { ServerVersion } from '@kbn/core-status-common-internal';
import type { ServerVersion } from '@kbn/core-status-common';
import { VersionHeader } from './version_header';
const buildServerVersion = (parts: Partial<ServerVersion> = {}): ServerVersion => ({

View file

@ -10,7 +10,7 @@
import React, { FC } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import type { ServerVersion } from '@kbn/core-status-common-internal';
import type { ServerVersion } from '@kbn/core-status-common';
interface VersionHeaderProps {
version: ServerVersion;

View file

@ -8,7 +8,7 @@
*/
import { httpServiceMock } from '@kbn/core-http-browser-mocks';
import type { StatusResponse } from '@kbn/core-status-common-internal';
import type { StatusResponse } from '@kbn/core-status-common';
import { notificationServiceMock } from '@kbn/core-notifications-browser-mocks';
import { mocked } from '@kbn/core-metrics-collectors-server-mocks';
import { loadStatus } from './load_status';

View file

@ -11,11 +11,11 @@ import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
import type { HttpSetup } from '@kbn/core-http-browser';
import type { NotificationsSetup } from '@kbn/core-notifications-browser';
import type { ServiceStatusLevelId } from '@kbn/core-status-common';
import type {
ServiceStatusLevelId,
StatusResponse,
StatusInfoServiceStatus as ServiceStatus,
} from '@kbn/core-status-common-internal';
} from '@kbn/core-status-common';
import type { DataType } from './format_number';
interface MetricMeta {

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import type { StatusInfoServiceStatus as ServiceStatus } from '@kbn/core-status-common-internal';
import type { StatusInfoServiceStatus as ServiceStatus } from '@kbn/core-status-common';
import { getLevelSortValue, groupByLevel, getHighestStatus } from './status_level';
import { FormattedStatus, StatusState } from './load_status';

View file

@ -24,7 +24,6 @@
"@kbn/core-application-browser",
"@kbn/core-application-browser-internal",
"@kbn/core-mount-utils-browser-internal",
"@kbn/core-status-common-internal",
"@kbn/core-http-browser-internal",
"@kbn/core-application-browser-mocks",
"@kbn/core-notifications-browser-mocks",

View file

@ -1,3 +0,0 @@
# @kbn/core-status-common-internal
This package contains the common internal types for Core's `status` domain.

View file

@ -1,17 +0,0 @@
/*
* 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 type {
StatusInfoCoreStatus,
StatusInfoServiceStatus,
StatusInfo,
StatusResponse,
ServerVersion,
ServerMetrics,
} from './src';

View file

@ -1,14 +0,0 @@
/*
* 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".
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/status/core-status-common-internal'],
};

View file

@ -1,5 +0,0 @@
{
"type": "shared-common",
"id": "@kbn/core-status-common-internal",
"owner": "@elastic/kibana-core"
}

View file

@ -1,7 +0,0 @@
{
"name": "@kbn/core-status-common-internal",
"private": true,
"version": "1.0.0",
"author": "Kibana Core",
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0"
}

View file

@ -1,17 +0,0 @@
/*
* 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 type {
StatusInfo,
StatusInfoCoreStatus,
StatusInfoServiceStatus,
StatusResponse,
ServerVersion,
ServerMetrics,
} from './status';

View file

@ -1,22 +0,0 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node"
]
},
"include": [
"**/*.ts",
"**/*.tsx",
],
"kbn_references": [
"@kbn/core-status-common",
"@kbn/core-metrics-server",
"@kbn/config"
],
"exclude": [
"target/**/*",
]
}

View file

@ -7,5 +7,14 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { ServiceStatusLevels } from './src';
export type { ServiceStatus, ServiceStatusLevel, ServiceStatusLevelId, CoreStatus } from './src';
export { ServiceStatusLevels } from './src/service_status';
export type { CoreStatus } from './src/core_status';
export type { ServiceStatus, ServiceStatusLevel, ServiceStatusLevelId } from './src/service_status';
export type {
StatusInfo,
StatusInfoCoreStatus,
StatusInfoServiceStatus,
StatusResponse,
ServerVersion,
ServerMetrics,
} from './src/status';

View file

@ -10,5 +10,5 @@
module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/status/core-status-common-internal'],
roots: ['<rootDir>/packages/core/status/core-status-common'],
};

View file

@ -1,12 +0,0 @@
/*
* 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 { ServiceStatusLevels } from './service_status';
export type { ServiceStatus, ServiceStatusLevel, ServiceStatusLevelId } from './service_status';
export type { CoreStatus } from './core_status';

View file

@ -8,8 +8,9 @@
*/
import type { BuildFlavor } from '@kbn/config';
import type { ServiceStatusLevelId, ServiceStatus, CoreStatus } from '@kbn/core-status-common';
import type { OpsMetrics } from '@kbn/core-metrics-server';
import type { ServiceStatusLevelId, ServiceStatus } from './service_status';
import type { CoreStatus } from './core_status';
export interface StatusInfoServiceStatus extends Omit<ServiceStatus, 'level'> {
level: ServiceStatusLevelId;

View file

@ -12,7 +12,9 @@
"**/*.tsx",
],
"kbn_references": [
"@kbn/std"
"@kbn/std",
"@kbn/config",
"@kbn/core-metrics-server"
],
"exclude": [
"target/**/*",

View file

@ -15,7 +15,7 @@ import type { IRouter } from '@kbn/core-http-server';
import type { MetricsServiceSetup } from '@kbn/core-metrics-server';
import type { CoreIncrementUsageCounter } from '@kbn/core-usage-data-server';
import { type ServiceStatus, type CoreStatus, ServiceStatusLevels } from '@kbn/core-status-common';
import { StatusResponse } from '@kbn/core-status-common-internal';
import type { StatusResponse } from '@kbn/core-status-common';
import { calculateLegacyStatus, type LegacyStatusInfo } from '../legacy_status';
import { statusResponse, type RedactedStatusHttpBody } from './status_response_schemas';

View file

@ -9,15 +9,15 @@
import { schema, type Type, type TypeOf } from '@kbn/config-schema';
import type { BuildFlavor } from '@kbn/config';
import type { ServiceStatusLevelId, ServiceStatus } from '@kbn/core-status-common';
import type {
ServiceStatusLevelId,
ServiceStatus,
StatusResponse,
StatusInfoCoreStatus,
ServerMetrics,
StatusInfo,
ServerVersion,
} from '@kbn/core-status-common-internal';
} from '@kbn/core-status-common';
const serviceStatusLevelId: () => Type<ServiceStatusLevelId> = () =>
schema.oneOf(

View file

@ -29,7 +29,6 @@
"@kbn/core-saved-objects-server-internal",
"@kbn/core-status-server",
"@kbn/core-status-common",
"@kbn/core-status-common-internal",
"@kbn/core-usage-data-base-server-internal",
"@kbn/core-base-server-mocks",
"@kbn/core-environment-server-mocks",

View file

@ -37,7 +37,7 @@ export const runKbnManifestCli = () => {
--list all List all the manifests
--package [packageId] Select a package to update.
--plugin [pluginId] Select a plugin to update.
--set [property] [value] Set the desired "[property]": "[value]"
--set [property]=[value] Set the desired "[property]": "[value]"
--unset [property] Removes the desired "[property]: value" from the manifest
`,
},

View file

@ -15,7 +15,7 @@ import useAsyncFn from 'react-use/lib/useAsyncFn';
import useTimeoutFn from 'react-use/lib/useTimeoutFn';
import type { IHttpFetchError } from '@kbn/core-http-browser';
import type { StatusResponse } from '@kbn/core-status-common-internal';
import type { StatusResponse } from '@kbn/core-status-common';
import { i18n } from '@kbn/i18n';
import { useKibana } from './use_kibana';

View file

@ -14,7 +14,7 @@
"@kbn/i18n",
"@kbn/ui-theme",
"@kbn/core-http-browser",
"@kbn/core-status-common-internal",
"@kbn/core-status-common",
"@kbn/safer-lodash-set",
"@kbn/test-jest-helpers",
"@kbn/config-schema",

View file

@ -606,8 +606,6 @@
"@kbn/core-security-server-mocks/*": ["packages/core/security/core-security-server-mocks/*"],
"@kbn/core-status-common": ["packages/core/status/core-status-common"],
"@kbn/core-status-common/*": ["packages/core/status/core-status-common/*"],
"@kbn/core-status-common-internal": ["packages/core/status/core-status-common-internal"],
"@kbn/core-status-common-internal/*": ["packages/core/status/core-status-common-internal/*"],
"@kbn/core-status-server": ["packages/core/status/core-status-server"],
"@kbn/core-status-server/*": ["packages/core/status/core-status-server/*"],
"@kbn/core-status-server-internal": ["packages/core/status/core-status-server-internal"],

View file

@ -7,7 +7,7 @@
import { KbnClient } from '@kbn/test';
import type { Client } from '@elastic/elasticsearch';
import type { StatusResponse } from '@kbn/core-status-common-internal';
import type { StatusResponse } from '@kbn/core-status-common';
import { catchAxiosErrorFormatAndThrow } from '../format_axios_error';
export const fetchKibanaStatus = async (kbnClient: KbnClient): Promise<StatusResponse> => {
@ -15,11 +15,11 @@ export const fetchKibanaStatus = async (kbnClient: KbnClient): Promise<StatusRes
// client (created by `x-pack/plugins/security_solution/scripts/endpoint/common/stack_services.ts:267`)
// which could be using an API key (which the core KbnClient does not support)
return kbnClient
.request({
.request<StatusResponse>({
method: 'GET',
path: '/api/status',
})
.then((response) => response.data as StatusResponse)
.then(({ data }) => data)
.catch(catchAxiosErrorFormatAndThrow);
};
/**

View file

@ -126,7 +126,7 @@
"@kbn/dev-cli-errors",
"@kbn/dev-utils",
"@kbn/tooling-log",
"@kbn/core-status-common-internal",
"@kbn/core-status-common",
"@kbn/repo-info",
"@kbn/storybook",
"@kbn/controls-plugin",

View file

@ -4458,10 +4458,6 @@
version "0.0.0"
uid ""
"@kbn/core-status-common-internal@link:packages/core/status/core-status-common-internal":
version "0.0.0"
uid ""
"@kbn/core-status-common@link:packages/core/status/core-status-common":
version "0.0.0"
uid ""