Skip to content

Commit 4adb65c

Browse files
walterraelasticmachinekibanamachinerbrtj
authored
[ML] @kbn/ml-common-types & @kbn/ml-server-schemas (#238060)
## Summary Part of #237808 and #189755. Related to #197967. - This PR moves ML type definitions from the ML plugin (`plugins/ml/common/types/*`) to a new package `@kbn/ml-common-types`. This refactoring is part of a larger effort to remove loading async bundles on page loads. - This means for solutions importing this code will now import from `@kbn/ml-common-types/...` instead of `@kbn/ml-plugin/...`. - Some barrel files/export (`export * from ...`) were removed and replaced with deep imports to reduce the risk of running into circular dependencies and bundle size explosion. - Some consts (or our variants of enums with `as const`) were moved to this package to avoid future circular dependency risk regarding the upcoming `@kbn/ml-common-constants` package. - Moves API schemas to a new `ml-server-schemas` package. This is a `shared-server` package, meaning that any `common` and `public` packages/plugins can import types from it, but no runtime code. It's convenient to expose types from the schemas, so I had to make `ml-common-types` depend on this new package. Review hint for teams being triggered for code owners review: Sorry this touches a lot of files but code touched outside the scope of ML should be just updated imports. ### Checklist - [x] 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. - [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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Robert Jaszczurek <robert.jaszczurek@elastic.co> Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com>
1 parent 47ab5bc commit 4adb65c

651 files changed

Lines changed: 1735 additions & 1463 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,10 +1045,12 @@ x-pack/platform/packages/shared/ml/aiops_log_pattern_analysis @elastic/ml-ui
10451045
x-pack/platform/packages/shared/ml/aiops_log_rate_analysis @elastic/ml-ui
10461046
x-pack/platform/packages/shared/ml/anomaly_utils @elastic/ml-ui
10471047
x-pack/platform/packages/shared/ml/chi2test @elastic/ml-ui
1048+
x-pack/platform/packages/shared/ml/common-types @elastic/ml-ui
10481049
x-pack/platform/packages/shared/ml/error_utils @elastic/ml-ui
10491050
x-pack/platform/packages/shared/ml/random_sampler_utils @elastic/ml-ui
10501051
x-pack/platform/packages/shared/ml/response_stream @elastic/ml-ui
10511052
x-pack/platform/packages/shared/ml/runtime_field_utils @elastic/ml-ui
1053+
x-pack/platform/packages/shared/ml/server-schemas @elastic/ml-ui
10521054
x-pack/platform/packages/shared/ml/trained_models_utils @elastic/ml-ui
10531055
x-pack/platform/packages/shared/response-ops/alert-snooze @elastic/response-ops
10541056
x-pack/platform/packages/shared/response-ops/alerting-v2-constants @elastic/rna-project-team

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@
822822
"@kbn/ml-cancellable-search": "link:x-pack/platform/packages/private/ml/cancellable_search",
823823
"@kbn/ml-category-validator": "link:x-pack/platform/packages/private/ml/category_validator",
824824
"@kbn/ml-chi2test": "link:x-pack/platform/packages/shared/ml/chi2test",
825+
"@kbn/ml-common-types": "link:x-pack/platform/packages/shared/ml/common-types",
825826
"@kbn/ml-creation-wizard-utils": "link:x-pack/platform/packages/private/ml/creation_wizard_utils",
826827
"@kbn/ml-data-frame-analytics-utils": "link:x-pack/platform/packages/private/ml/data_frame_analytics_utils",
827828
"@kbn/ml-data-grid": "link:x-pack/platform/packages/private/ml/data_grid",
@@ -843,6 +844,7 @@
843844
"@kbn/ml-response-stream": "link:x-pack/platform/packages/shared/ml/response_stream",
844845
"@kbn/ml-route-utils": "link:x-pack/platform/packages/private/ml/route_utils",
845846
"@kbn/ml-runtime-field-utils": "link:x-pack/platform/packages/shared/ml/runtime_field_utils",
847+
"@kbn/ml-server-schemas": "link:x-pack/platform/packages/shared/ml/server-schemas",
846848
"@kbn/ml-string-hash": "link:x-pack/platform/packages/private/ml/string_hash",
847849
"@kbn/ml-time-buckets": "link:x-pack/platform/packages/private/ml/time_buckets",
848850
"@kbn/ml-trained-models-utils": "link:x-pack/platform/packages/shared/ml/trained_models_utils",

tsconfig.base.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,8 @@
16181618
"@kbn/ml-category-validator/*": ["x-pack/platform/packages/private/ml/category_validator/*"],
16191619
"@kbn/ml-chi2test": ["x-pack/platform/packages/shared/ml/chi2test"],
16201620
"@kbn/ml-chi2test/*": ["x-pack/platform/packages/shared/ml/chi2test/*"],
1621+
"@kbn/ml-common-types": ["x-pack/platform/packages/shared/ml/common-types"],
1622+
"@kbn/ml-common-types/*": ["x-pack/platform/packages/shared/ml/common-types/*"],
16211623
"@kbn/ml-creation-wizard-utils": ["x-pack/platform/packages/private/ml/creation_wizard_utils"],
16221624
"@kbn/ml-creation-wizard-utils/*": ["x-pack/platform/packages/private/ml/creation_wizard_utils/*"],
16231625
"@kbn/ml-data-frame-analytics-utils": ["x-pack/platform/packages/private/ml/data_frame_analytics_utils"],
@@ -1660,6 +1662,8 @@
16601662
"@kbn/ml-route-utils/*": ["x-pack/platform/packages/private/ml/route_utils/*"],
16611663
"@kbn/ml-runtime-field-utils": ["x-pack/platform/packages/shared/ml/runtime_field_utils"],
16621664
"@kbn/ml-runtime-field-utils/*": ["x-pack/platform/packages/shared/ml/runtime_field_utils/*"],
1665+
"@kbn/ml-server-schemas": ["x-pack/platform/packages/shared/ml/server-schemas"],
1666+
"@kbn/ml-server-schemas/*": ["x-pack/platform/packages/shared/ml/server-schemas/*"],
16631667
"@kbn/ml-string-hash": ["x-pack/platform/packages/private/ml/string_hash"],
16641668
"@kbn/ml-string-hash/*": ["x-pack/platform/packages/private/ml/string_hash/*"],
16651669
"@kbn/ml-time-buckets": ["x-pack/platform/packages/private/ml/time_buckets"],

x-pack/platform/packages/private/ml/data_frame_analytics_utils/moon.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ project:
1919
dependsOn:
2020
- '@kbn/ml-is-populated-object'
2121
- '@kbn/field-types'
22-
- '@kbn/ml-error-utils'
2322
- '@kbn/ml-anomaly-utils'
2423
tags:
2524
- shared-common

x-pack/platform/packages/private/ml/data_frame_analytics_utils/src/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type Boom from '@hapi/boom';
99
import type { estypes } from '@elastic/elasticsearch';
1010
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
1111

12-
import type { EsErrorBody } from '@kbn/ml-error-utils';
1312
import type { MlUrlConfig } from '@kbn/ml-anomaly-utils';
1413
import type { ANALYSIS_CONFIG_TYPE } from './constants';
1514

@@ -24,7 +23,7 @@ export interface DeleteDataFrameAnalyticsWithIndexStatus {
2423
/**
2524
* Optional error
2625
*/
27-
error?: EsErrorBody | Boom.Boom;
26+
error?: estypes.ErrorResponseBase | Boom.Boom;
2827
}
2928

3029
/**

x-pack/platform/packages/private/ml/data_frame_analytics_utils/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"kbn_references": [
1919
"@kbn/ml-is-populated-object",
2020
"@kbn/field-types",
21-
"@kbn/ml-error-utils",
2221
"@kbn/ml-anomaly-utils",
2322
]
2423
}

x-pack/platform/packages/shared/logs-overview/moon.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ dependsOn:
4343
- '@kbn/core-theme-browser-mocks'
4444
- '@kbn/core-ui-settings-browser-mocks'
4545
- '@kbn/react-hooks'
46+
- '@kbn/ml-common-types'
4647
tags:
4748
- shared-browser
4849
- package

x-pack/platform/packages/shared/logs-overview/src/utils/ml_capabilities.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
import { type MlCapabilitiesResponse } from '@kbn/ml-plugin/public';
8+
import type { MlCapabilitiesResponse } from '@kbn/ml-common-types/capabilities';
99
import { createActor, toPromise } from 'xstate';
1010
import {
1111
loadMlCapabilitiesActor,

x-pack/platform/packages/shared/logs-overview/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@
4444
"@kbn/core-theme-browser-mocks",
4545
"@kbn/core-ui-settings-browser-mocks",
4646
"@kbn/react-hooks",
47+
"@kbn/ml-common-types",
4748
]
4849
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @kbn/ml-common-types
2+
3+
This package contains TypeScript type definitions for ML-related data structures, including anomaly detection jobs, datafeeds, trained models, annotations, and more.

0 commit comments

Comments
 (0)