Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
a788a5b
@kbn/ml-common-types
walterra Oct 8, 2025
a3e50c2
update imports
walterra Oct 8, 2025
1f1f4cb
update imports
walterra Oct 8, 2025
6f2a9c1
fix imports
walterra Oct 8, 2025
cd767b1
linting
walterra Oct 8, 2025
f664929
linting
walterra Oct 8, 2025
b0d3f28
linting
walterra Oct 8, 2025
7c48b16
linting
walterra Oct 8, 2025
6f62802
fix imports
walterra Oct 9, 2025
794e223
fix import
walterra Oct 10, 2025
8b65de2
fix import
walterra Oct 10, 2025
6d4682a
Merge branch 'main' into 237808-ml-common-types
elasticmachine Oct 13, 2025
4df566a
Merge remote-tracking branch 'upstream/main' into 237808-ml-common-types
walterra Oct 13, 2025
f6bedfb
Merge remote-tracking branch 'upstream/main' into 237808-ml-common-types
walterra Oct 30, 2025
2146836
Merge remote-tracking branch 'upstream/main' into 237808-ml-common-types
walterra Oct 30, 2025
74a1c83
Changes from node scripts/lint_ts_projects --fix
kibanamachine Oct 30, 2025
a78e0a2
Merge remote-tracking branch 'upstream/main' into 237808-ml-common-types
rbrtj Apr 14, 2026
59a900c
resolve remaining conflicts
rbrtj Apr 14, 2026
97cfe74
Changes from node scripts/lint_ts_projects --fix
kibanamachine Apr 14, 2026
16293c2
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Apr 14, 2026
e8865c5
move embeddable schemas to a new kbn/ml-common-api-schemas package
rbrtj Apr 15, 2026
bce0d82
Changes from node scripts/lint_ts_projects --fix
kibanamachine Apr 15, 2026
ef090ae
Changes from node scripts/generate codeowners
kibanamachine Apr 15, 2026
a715214
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Apr 15, 2026
35ebeb0
fix import in ml locator
rbrtj Apr 15, 2026
411220a
make common-api-schemas server-side
rbrtj Apr 15, 2026
323932c
Changes from node scripts/lint_ts_projects --fix
kibanamachine Apr 15, 2026
b79917d
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Apr 15, 2026
b29f41c
update remaining imports
rbrtj Apr 15, 2026
9f0aea0
export AnomalySwimLaneProps
rbrtj Apr 15, 2026
7010872
fix remaining imports
rbrtj Apr 15, 2026
e7d37f8
Changes from node scripts/lint_ts_projects --fix
kibanamachine Apr 15, 2026
a22c8aa
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Apr 15, 2026
4975dc8
update common-types to use kebab-case
rbrtj Apr 15, 2026
d515d86
rename ml-common-api-schemas to server-schemas
rbrtj Apr 15, 2026
e4201b4
Changes from node scripts/lint.js --fix
kibanamachine Apr 15, 2026
f1b2e3a
TO FIX: Run node 'scripts/yarn_deduplicate && yarn kbn bootstrap' loc…
kibanamachine Apr 15, 2026
fabab6a
Changes from node scripts/generate codeowners
kibanamachine Apr 15, 2026
2821b67
Merge branch 'main' into 237808-ml-common-types
rbrtj Apr 15, 2026
8b832ca
remove CloudInfo re-export
rbrtj Apr 15, 2026
8d57b76
Merge remote-tracking branch 'upstream/main' into 237808-ml-common-types
rbrtj Apr 21, 2026
6307559
Merge branch 'main' into 237808-ml-common-types
rbrtj Apr 21, 2026
320a196
Merge branch 'main' into 237808-ml-common-types
rbrtj Apr 22, 2026
8b4ced4
Merge branch 'main' into 237808-ml-common-types
rbrtj Apr 22, 2026
52eedb2
Merge branch 'main' into 237808-ml-common-types
rbrtj Apr 22, 2026
c9fb256
update commented import code
rbrtj Apr 22, 2026
ab87fb2
Merge branch 'main' into 237808-ml-common-types
rbrtj Apr 22, 2026
342f909
Merge branch 'main' into 237808-ml-common-types
rbrtj Apr 22, 2026
ec0efb2
Merge branch 'main' into 237808-ml-common-types
rbrtj Apr 22, 2026
fa41889
Merge remote-tracking branch 'upstream/main' into 237808-ml-common-types
rbrtj Apr 27, 2026
0a0b16c
Merge remote-tracking branch 'upstream/main' into 237808-ml-common-types
rbrtj Apr 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ x-pack/platform/packages/shared/ml/aiops_log_pattern_analysis @elastic/ml-ui
x-pack/platform/packages/shared/ml/aiops_log_rate_analysis @elastic/ml-ui
x-pack/platform/packages/shared/ml/anomaly_utils @elastic/ml-ui
x-pack/platform/packages/shared/ml/chi2test @elastic/ml-ui
x-pack/platform/packages/shared/ml/common_types @elastic/ml-ui
x-pack/platform/packages/shared/ml/error_utils @elastic/ml-ui
x-pack/platform/packages/shared/ml/random_sampler_utils @elastic/ml-ui
x-pack/platform/packages/shared/ml/response_stream @elastic/ml-ui
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@
"@kbn/ml-cancellable-search": "link:x-pack/platform/packages/private/ml/cancellable_search",
"@kbn/ml-category-validator": "link:x-pack/platform/packages/private/ml/category_validator",
"@kbn/ml-chi2test": "link:x-pack/platform/packages/shared/ml/chi2test",
"@kbn/ml-common-types": "link:x-pack/platform/packages/shared/ml/common_types",
"@kbn/ml-creation-wizard-utils": "link:x-pack/platform/packages/private/ml/creation_wizard_utils",
"@kbn/ml-data-frame-analytics-utils": "link:x-pack/platform/packages/private/ml/data_frame_analytics_utils",
"@kbn/ml-data-grid": "link:x-pack/platform/packages/private/ml/data_grid",
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,8 @@
"@kbn/ml-category-validator/*": ["x-pack/platform/packages/private/ml/category_validator/*"],
"@kbn/ml-chi2test": ["x-pack/platform/packages/shared/ml/chi2test"],
"@kbn/ml-chi2test/*": ["x-pack/platform/packages/shared/ml/chi2test/*"],
"@kbn/ml-common-types": ["x-pack/platform/packages/shared/ml/common_types"],
"@kbn/ml-common-types/*": ["x-pack/platform/packages/shared/ml/common_types/*"],
"@kbn/ml-creation-wizard-utils": ["x-pack/platform/packages/private/ml/creation_wizard_utils"],
"@kbn/ml-creation-wizard-utils/*": ["x-pack/platform/packages/private/ml/creation_wizard_utils/*"],
"@kbn/ml-data-frame-analytics-utils": ["x-pack/platform/packages/private/ml/data_frame_analytics_utils"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type Boom from '@hapi/boom';
import type { estypes } from '@elastic/elasticsearch';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';

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

Expand All @@ -24,7 +23,7 @@ export interface DeleteDataFrameAnalyticsWithIndexStatus {
/**
* Optional error
*/
error?: EsErrorBody | Boom.Boom;
error?: estypes.ErrorResponseBase | Boom.Boom;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"kbn_references": [
"@kbn/ml-is-populated-object",
"@kbn/field-types",
"@kbn/ml-error-utils",
"@kbn/ml-anomaly-utils",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { type MlCapabilitiesResponse } from '@kbn/ml-plugin/public';
import type { MlCapabilitiesResponse } from '@kbn/ml-common-types/capabilities';
import { createActor, toPromise } from 'xstate5';
import {
loadMlCapabilitiesActor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
"@kbn/core-theme-browser-mocks",
"@kbn/core-ui-settings-browser-mocks",
"@kbn/react-hooks",
"@kbn/ml-common-types",
]
}
3 changes: 3 additions & 0 deletions x-pack/platform/packages/shared/ml/common_types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/ml-common-types

This package contains TypeScript type definitions for ML-related data structures, including anomaly detection jobs, datafeeds, trained models, annotations, and more.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
*/

import type { RuleTypeParams, Rule } from '@kbn/alerting-plugin/common';
import { type MlAnomalyResultType, ML_ANOMALY_RESULT_TYPE } from '@kbn/ml-anomaly-utils';
import type { MlAnomalyResultType } from '@kbn/ml-anomaly-utils';
import { ML_ANOMALY_RESULT_TYPE } from '@kbn/ml-anomaly-utils/constants';
import { ML_ANOMALY_DETECTION_RULE_TYPE_ID } from '@kbn/rule-data-utils';

export const ML_ALERT_TYPES = {
ANOMALY_DETECTION: ML_ANOMALY_DETECTION_RULE_TYPE_ID,
AD_JOBS_HEALTH: 'xpack.ml.anomaly_detection_jobs_health',
} as const;

export type PreviewResultsKeys = 'record_results' | 'bucket_results' | 'influencer_results';
export type TopHitsResultsKeys = 'top_record_hits' | 'top_bucket_hits' | 'top_influencer_hits';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ANNOTATION_TYPE } from '../constants/annotations';
import { ANNOTATION_TYPE } from './annotations';

import { isAnnotation, isAnnotations } from './annotations';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@
// }

import type { MlPartitionFieldsType } from '@kbn/ml-anomaly-utils';
import { ANNOTATION_TYPE } from '../constants/annotations';

export enum ANNOTATION_TYPE {
ANNOTATION = 'annotation',
COMMENT = 'comment',
}

export type AnnotationFieldName = 'partition_field_name' | 'over_field_name' | 'by_field_name';
export type AnnotationFieldValue = 'partition_field_value' | 'over_field_value' | 'by_field_value';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import type { MlCustomSettings } from '@elastic/elasticsearch/lib/api/types';
import type { CombinedJob, CombinedJobWithStats } from './combined_job';
import type { MlAnomalyDetectionAlertRule } from '../alerts';
import type { MlJobBlocked } from './job';
import type { JobActionState } from '../../constants/job_actions';
export type { Datafeed } from './datafeed';
export type { DatafeedStats } from './datafeed_stats';

export type JobActionState = 'deleting' | 'resetting' | 'reverting';

export type SummaryJobState = estypes.MlJobState | JobActionState;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { ForwardRefExoticComponent, RefAttributes } from 'react';

import type { KibanaExecutionContext } from '@kbn/core/public';
import type { Filter, Query, TimeRange } from '@kbn/es-query';
import type { RefreshInterval } from '@kbn/data-plugin/common';

import type { JobId } from './anomaly_detection_jobs/job';

// local definition to avoid circular dependency
// import type { SwimlaneType } from '@kbn/ml-common-constants/explorer';
type SwimlaneType = 'overall' | 'viewBy';

/** Manual input by the user */
export interface AnomalySwimlaneEmbeddableUserInput {
jobIds: JobId[];
panelTitle?: string;
swimlaneType: SwimlaneType;
viewBy?: string;
}

export interface AnomalySwimlaneEmbeddableCustomInput
extends Omit<AnomalySwimlaneEmbeddableUserInput, 'panelTitle'> {
id?: string;
perPage?: number;

// Embeddable inputs which are not included in the default interface
filters?: Filter[];
query?: Query;
refreshConfig?: RefreshInterval;
timeRange: TimeRange | undefined;
}

export interface AnomalySwimLaneProps extends AnomalySwimlaneEmbeddableCustomInput {
id?: string;
executionContext: KibanaExecutionContext;
}

export type AnomalySwimLaneComponentType = ForwardRefExoticComponent<
AnomalySwimLaneProps & RefAttributes<{}>
>;
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
import type { KibanaRequest } from '@kbn/core/server';
import { AlertConsumers, DEPRECATED_ALERTING_CONSUMERS } from '@kbn/rule-data-utils';
import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common';
import { PLUGIN_ID } from '../constants/app';

import { ML_ALERT_TYPES } from './alerts';

// cannot import because of cyclic dependency
// import { PLUGIN_ID } from '@kbn/ml-common-constants/app';
const PLUGIN_ID = 'ml';

import {
ML_JOB_SAVED_OBJECT_TYPE,
ML_MODULE_SAVED_OBJECT_TYPE,
ML_TRAINED_MODEL_SAVED_OBJECT_TYPE,
} from './saved_objects';
import { ML_ALERT_TYPES } from '../constants/alerts';

export const apmUserMlCapabilities = {
canGetJobs: false,
Expand Down Expand Up @@ -103,7 +108,7 @@ export const basicLicenseMlCapabilities: MlCapabilitiesKey[] = [
'canGetMlInfo',
];

export function getDefaultCapabilities(): MlCapabilities {
export function getDefaultMlCapabilities(): MlCapabilities {
Copy link
Copy Markdown
Member

@jgowdyelastic jgowdyelastic Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the three errors from x-pack/platform/plugins/shared/ml/server/lib/capabilities/errors.ts could also be moved to live along side this file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These errors are used only on the server side path, I'm not sure if it is worth extracting them to the common package.

return {
...featureMlCapabilities,
...userMlCapabilities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type { MlPages } from '../constants/locator';
import type { MlPages } from './locator_ml_pages';

export interface Dictionary<TValue> {
[id: string]: TValue;
Expand Down
141 changes: 141 additions & 0 deletions x-pack/platform/packages/shared/ml/common_types/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type Boom from '@hapi/boom';

import type { estypes } from '@elastic/elasticsearch';

import type { IHttpFetchError } from '@kbn/core-http-browser';

/**
* Short hand type of estypes.ErrorCause.
* @typedef {EsErrorRootCause}
*/
export type EsErrorRootCause = estypes.ErrorCause;

/**
* Short hand type of estypes.ErrorResponseBase.
* @typedef {EsErrorBody}
*/
export type EsErrorBody = estypes.ErrorResponseBase;

/**
* ML Response error
* @export
* @interface MLResponseError
* @typedef {MLResponseError}
*/
export interface MLResponseError {
/**
* statusCode
* @type {number}
*/
statusCode: number;
/**
* error
* @type {string}
*/
error: string;
/**
* message
* @type {string}
*/
message: string;
/**
* Optional attributes
* @type {?{
body: EsErrorBody;
}}
*/
attributes?: {
body: EsErrorBody;
};
}

/**
* Interface holding error message
* @export
* @interface ErrorMessage
* @typedef {ErrorMessage}
*/
export interface ErrorMessage {
/**
* message
* @type {string}
*/
message: string;
}

/**
* To be used for client side errors related to search query bars.
*/
export interface QueryErrorMessage extends ErrorMessage {
/**
* query
* @type {string}
*/
query: string;
}

/**
* ML Error Object
* @export
* @interface MLErrorObject
* @typedef {MLErrorObject}
*/
export interface MLErrorObject {
/**
* Optional causedBy
* @type {?string}
*/
causedBy?: string;
/**
* message
* @type {string}
*/
message: string;
/**
* Optional statusCode
* @type {?number}
*/
statusCode?: number;
/**
* Optional fullError
* @type {?EsErrorBody}
*/
fullError?: EsErrorBody;
}

/**
* MLHttpFetchErrorBase
* @export
* @interface MLHttpFetchErrorBase
* @typedef {MLHttpFetchErrorBase}
* @template T
* @extends {IHttpFetchError<T>}
*/
export interface MLHttpFetchErrorBase<T> extends IHttpFetchError<T> {
/**
* body
* @type {T}
*/
body: T;
}

/**
* MLHttpFetchError
* @export
* @typedef {MLHttpFetchError}
*/
export type MLHttpFetchError = MLHttpFetchErrorBase<MLResponseError>;

/**
* Union type of error types
* @export
* @typedef {ErrorType}
*/
export type ErrorType = MLHttpFetchError | EsErrorBody | Boom.Boom | string | undefined;
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
* 2.0.
*/

export * from './job';
export type * from './job_stats';
export type * from './datafeed';
export type * from './datafeed_stats';
export * from './combined_job';
export type * from './summary_job';
export type * from './model_snapshot';
module.exports = {
preset: '@kbn/test',
rootDir: '../../../../../..',
roots: ['<rootDir>/x-pack/platform/packages/shared/ml/common_types'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
*/

import type { ES_AGGREGATION } from '@kbn/ml-anomaly-utils';
import type { ErrorType } from '@kbn/ml-error-utils';
import { type RuntimeMappings } from '@kbn/ml-runtime-field-utils';
import type { Job, JobStats, IndicesOptions } from './anomaly_detection_jobs';
import type { Job } from './anomaly_detection_jobs/job';
import type { JobStats } from './anomaly_detection_jobs/job_stats';
import type { IndicesOptions } from './anomaly_detection_jobs/datafeed';
import type { ErrorType } from './errors';

export interface MlJobsResponse {
jobs: Job[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type { ErrorType } from '@kbn/ml-error-utils';
import type { ErrorType } from './errors';

export interface DatafeedValidationResponse {
valid: boolean;
Expand Down
9 changes: 9 additions & 0 deletions x-pack/platform/packages/shared/ml/common_types/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "shared-common",
"id": "@kbn/ml-common-types",
"owner": [
"@elastic/ml-ui"
],
"group": "platform",
"visibility": "shared"
}
Loading