Skip to content

Commit

Permalink
Kibana Sustainable Architecture: Expose StatusResponse in core-stat…
Browse files Browse the repository at this point in the history
…us-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
#199630.

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
gsoldevila and kibanamachine authored Nov 18, 2024
1 parent 55134ab commit ab0375f
Show file tree
Hide file tree
Showing 31 changed files with 35 additions and 130 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions packages/core/status/core-status-common-internal/README.md

This file was deleted.

17 changes: 0 additions & 17 deletions packages/core/status/core-status-common-internal/index.ts

This file was deleted.

14 changes: 0 additions & 14 deletions packages/core/status/core-status-common-internal/jest.config.js

This file was deleted.

5 changes: 0 additions & 5 deletions packages/core/status/core-status-common-internal/kibana.jsonc

This file was deleted.

7 changes: 0 additions & 7 deletions packages/core/status/core-status-common-internal/package.json

This file was deleted.

17 changes: 0 additions & 17 deletions packages/core/status/core-status-common-internal/src/index.ts

This file was deleted.

22 changes: 0 additions & 22 deletions packages/core/status/core-status-common-internal/tsconfig.json

This file was deleted.

13 changes: 11 additions & 2 deletions packages/core/status/core-status-common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
2 changes: 1 addition & 1 deletion packages/core/status/core-status-common/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
};
12 changes: 0 additions & 12 deletions packages/core/status/core-status-common/src/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion packages/core/status/core-status-common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"**/*.tsx",
],
"kbn_references": [
"@kbn/std"
"@kbn/std",
"@kbn/config",
"@kbn/core-metrics-server"
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-manifest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/interactive_setup/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

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> => {
// We DO NOT use `kbnClient.status.get()` here because the `kbnClient` passed on input could be our enhanced
// 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);
};
/**
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/security_solution/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 0 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down

0 comments on commit ab0375f

Please sign in to comment.