diff --git a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed.ts b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed.ts index 5d7f3f934700b..2eb4242b7931e 100644 --- a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed.ts +++ b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed.ts @@ -5,48 +5,14 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; -// import { IndexPatternTitle } from '../kibana'; -// import { RuntimeMappings } from '../fields'; -// import { JobId } from './job'; +import { estypes } from '@elastic/elasticsearch'; + export type DatafeedId = string; export type Datafeed = estypes.Datafeed; -// export interface Datafeed extends estypes.DatafeedConfig { -// runtime_mappings?: RuntimeMappings; -// aggs?: Aggregation; -// } -// export interface Datafeed { -// datafeed_id: DatafeedId; -// aggregations?: Aggregation; -// aggs?: Aggregation; -// chunking_config?: ChunkingConfig; -// frequency?: string; -// indices: IndexPatternTitle[]; -// indexes?: IndexPatternTitle[]; // The datafeed can contain indexes and indices -// job_id: JobId; -// query: object; -// query_delay?: string; -// script_fields?: Record; -// runtime_mappings?: RuntimeMappings; -// scroll_size?: number; -// delayed_data_check_config?: object; -// indices_options?: IndicesOptions; -// } export type ChunkingConfig = estypes.ChunkingConfig; -// export interface ChunkingConfig { -// mode: 'auto' | 'manual' | 'off'; -// time_span?: string; -// } - export type Aggregation = Record; export type IndicesOptions = estypes.IndicesOptions; -// export interface IndicesOptions { -// expand_wildcards?: 'all' | 'open' | 'closed' | 'hidden' | 'none'; -// ignore_unavailable?: boolean; -// allow_no_indices?: boolean; -// ignore_throttled?: boolean; -// } diff --git a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed_stats.ts b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed_stats.ts index f13aa1843660e..dd0d3a5001f84 100644 --- a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed_stats.ts +++ b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed_stats.ts @@ -5,22 +5,6 @@ * 2.0. */ -import { Node } from './job_stats'; -import { DATAFEED_STATE } from '../../constants/states'; +import { estypes } from '@elastic/elasticsearch'; -export interface DatafeedStats { - datafeed_id: string; - state: DATAFEED_STATE; - node: Node; - assignment_explanation: string; - timing_stats: TimingStats; -} - -interface TimingStats { - job_id: string; - search_count: number; - bucket_count: number; - total_search_time_ms: number; - average_search_time_per_bucket_ms: number; - exponential_average_search_time_per_hour_ms: number; -} +export type DatafeedStats = estypes.DatafeedStats; diff --git a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts index 5e1d5e009a764..68544e7cb828f 100644 --- a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts +++ b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts @@ -6,103 +6,27 @@ */ import { estypes } from '@elastic/elasticsearch'; -import { UrlConfig } from '../custom_urls'; -import { CREATED_BY_LABEL } from '../../constants/new_job'; export type JobId = string; export type BucketSpan = string; -export interface CustomSettings { - custom_urls?: UrlConfig[]; - created_by?: CREATED_BY_LABEL; - job_tags?: { - [tag: string]: string; - }; -} - export type Job = estypes.Job; -// export interface Job { -// job_id: JobId; -// analysis_config: AnalysisConfig; -// analysis_limits?: AnalysisLimits; -// background_persist_interval?: string; -// custom_settings?: CustomSettings; -// data_description: DataDescription; -// description: string; -// groups: string[]; -// model_plot_config?: ModelPlotConfig; -// model_snapshot_retention_days?: number; -// daily_model_snapshot_retention_after_days?: number; -// renormalization_window_days?: number; -// results_index_name?: string; -// results_retention_days?: number; - -// // optional properties added when the job has been created -// create_time?: number; -// finished_time?: number; -// job_type?: 'anomaly_detector'; -// job_version?: string; -// model_snapshot_id?: string; -// deleting?: boolean; -// } export type AnalysisConfig = estypes.AnalysisConfig; -// export interface AnalysisConfig { -// bucket_span: BucketSpan; -// categorization_field_name?: string; -// categorization_filters?: string[]; -// categorization_analyzer?: object | string; -// detectors: Detector[]; -// influencers: string[]; -// latency?: number; -// multivariate_by_fields?: boolean; -// summary_count_field_name?: string; -// per_partition_categorization?: PerPartitionCategorization; -// } export type Detector = estypes.Detector; -// export interface Detector { -// by_field_name?: string; -// detector_description?: string; -// detector_index?: number; -// exclude_frequent?: string; -// field_name?: string; -// function: string; -// over_field_name?: string; -// partition_field_name?: string; -// use_null?: boolean; -// custom_rules?: CustomRule[]; -// } export type AnalysisLimits = estypes.AnalysisLimits; -// export interface AnalysisLimits { -// categorization_examples_limit?: number; -// model_memory_limit: string; -// } export type DataDescription = estypes.DataDescription; -// export interface DataDescription { -// format?: string; -// time_field: string; -// time_format?: string; -// } export type ModelPlotConfig = estypes.ModelPlotConfig; -// export interface ModelPlotConfig { -// enabled?: boolean; -// annotations_enabled?: boolean; -// terms?: string; -// } export type CustomRule = estypes.DetectionRule; -// TODO, finish this when it's needed -// export interface CustomRule { -// actions: string[]; -// scope?: object; -// conditions: any[]; -// } export interface PerPartitionCategorization { enabled?: boolean; stop_on_warn?: boolean; } + +export type CustomSettings = estypes.CustomSettings; diff --git a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job_stats.ts b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job_stats.ts index 1fd69d0c5f0b1..a53f1f2486699 100644 --- a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job_stats.ts +++ b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job_stats.ts @@ -5,93 +5,25 @@ * 2.0. */ -import { JOB_STATE } from '../../constants/states'; +import { estypes } from '@elastic/elasticsearch'; -export interface JobStats { - job_id: string; - data_counts: DataCounts; +export type JobStats = estypes.JobStats & { model_size_stats: ModelSizeStats; - forecasts_stats: ForecastsStats; - state: JOB_STATE; - node: Node; - assignment_explanation: string; - open_time: string; timing_stats: TimingStats; -} +}; -export interface DataCounts { - job_id: string; - processed_record_count: number; - processed_field_count: number; - input_bytes: number; - input_field_count: number; - invalid_date_count: number; - missing_field_count: number; - out_of_order_timestamp_count: number; - empty_bucket_count: number; - sparse_bucket_count: number; - bucket_count: number; - earliest_record_timestamp: number; - latest_record_timestamp: number; - last_data_time: number; - input_record_count: number; - latest_empty_bucket_timestamp: number; - latest_sparse_bucket_timestamp: number; - latest_bucket_timestamp?: number; // stat added by the UI -} +export type DataCounts = estypes.DataCounts; -export interface ModelSizeStats { - job_id: string; - result_type: string; - model_bytes: number; +export type ModelSizeStats = estypes.ModelSizeStats & { model_bytes_exceeded: number; model_bytes_memory_limit: number; peak_model_bytes?: number; - total_by_field_count: number; - total_over_field_count: number; - total_partition_field_count: number; - bucket_allocation_failures_count: number; - memory_status: 'ok' | 'soft_limit' | 'hard_limit'; - categorized_doc_count: number; - total_category_count: number; - frequent_category_count: number; - rare_category_count: number; - dead_category_count: number; - categorization_status: 'ok' | 'warn'; - log_time: number; - timestamp: number; -} +}; -export interface ForecastsStats { - total: number; - forecasted_jobs: number; - memory_bytes?: any; - records?: any; - processing_time_ms?: any; - status?: any; -} +export type TimingStats = estypes.TimingStats & { + total_bucket_processing_time_ms: number; +}; -export interface Node { - id: string; - name: string; - ephemeral_id: string; - transport_address: string; - attributes: { - 'transform.remote_connect'?: boolean; - 'ml.machine_memory'?: number; - 'xpack.installed'?: boolean; - 'transform.node'?: boolean; - 'ml.max_open_jobs'?: number; - }; -} +export type ForecastsStats = estypes.JobForecastStatistics; -interface TimingStats { - job_id: string; - bucket_count: number; - total_bucket_processing_time_ms: number; - minimum_bucket_processing_time_ms: number; - maximum_bucket_processing_time_ms: number; - average_bucket_processing_time_ms: number; - exponential_average_bucket_processing_time_ms: number; - exponential_average_bucket_processing_time_per_hour_ms: number; -} +export type Node = estypes.DiscoveryNode; diff --git a/x-pack/plugins/ml/common/util/job_utils.ts b/x-pack/plugins/ml/common/util/job_utils.ts index 78e565a491386..7e6d84f9efed7 100644 --- a/x-pack/plugins/ml/common/util/job_utils.ts +++ b/x-pack/plugins/ml/common/util/job_utils.ts @@ -8,7 +8,7 @@ import { each, isEmpty, isEqual, pick } from 'lodash'; import semverGte from 'semver/functions/gte'; import moment, { Duration } from 'moment'; -import type { estypes } from '@elastic/elasticsearch'; +import { estypes } from '@elastic/elasticsearch'; // @ts-ignore import numeral from '@elastic/numeral'; import { i18n } from '@kbn/i18n'; @@ -819,7 +819,7 @@ export function getLatestDataOrBucketTimestamp( * in the job wizards and so would be lost in a clone. */ export function processCreatedBy(customSettings: CustomSettings) { - if (Object.values(CREATED_BY_LABEL).includes(customSettings.created_by!)) { + if (Object.values(CREATED_BY_LABEL).includes(customSettings.created_by as CREATED_BY_LABEL)) { delete customSettings.created_by; } } diff --git a/x-pack/plugins/ml/public/application/components/data_grid/common.ts b/x-pack/plugins/ml/public/application/components/data_grid/common.ts index b897ca3dccc51..24a3cfb70d18d 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/common.ts +++ b/x-pack/plugins/ml/public/application/components/data_grid/common.ts @@ -6,6 +6,7 @@ */ import moment from 'moment-timezone'; +import { estypes } from '@elastic/elasticsearch'; import { useEffect, useMemo } from 'react'; import { @@ -18,7 +19,6 @@ import { i18n } from '@kbn/i18n'; import { CoreSetup } from 'src/core/public'; -import type { estypes } from '@elastic/elasticsearch'; import { IndexPattern, IFieldType, diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/combined_fields_form.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/combined_fields_form.tsx index 02ead5c26f959..5c63fd757b07b 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/combined_fields_form.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/combined_fields/combined_fields_form.tsx @@ -34,8 +34,8 @@ import { FindFileStructureResponse } from '../../../../../../../file_upload/comm interface Props { mappingsString: string; pipelineString: string; - onMappingsStringChange(): void; - onPipelineStringChange(): void; + onMappingsStringChange(mappings: string): void; + onPipelineStringChange(pipeline: string): void; combinedFields: CombinedField[]; onCombinedFieldsChange(combinedFields: CombinedField[]): void; results: FindFileStructureResponse; @@ -72,11 +72,9 @@ export class CombinedFieldsForm extends Component { const pipeline = this.parsePipeline(); this.props.onMappingsStringChange( - // @ts-expect-error JSON.stringify(addCombinedFieldsToMappings(mappings, [combinedField]), null, 2) ); this.props.onPipelineStringChange( - // @ts-expect-error JSON.stringify(addCombinedFieldsToPipeline(pipeline, [combinedField]), null, 2) ); this.props.onCombinedFieldsChange([...this.props.combinedFields, combinedField]); @@ -99,11 +97,9 @@ export class CombinedFieldsForm extends Component { const removedCombinedFields = updatedCombinedFields.splice(index, 1); this.props.onMappingsStringChange( - // @ts-expect-error JSON.stringify(removeCombinedFieldsFromMappings(mappings, removedCombinedFields), null, 2) ); this.props.onPipelineStringChange( - // @ts-expect-error JSON.stringify(removeCombinedFieldsFromPipeline(pipeline, removedCombinedFields), null, 2) ); this.props.onCombinedFieldsChange(updatedCombinedFields); diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/advanced.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/advanced.tsx index eb0e09973f0e3..5765c5de6c61b 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/advanced.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/advanced.tsx @@ -35,8 +35,8 @@ interface Props { mappingsString: string; pipelineString: string; onIndexSettingsStringChange(): void; - onMappingsStringChange(): void; - onPipelineStringChange(): void; + onMappingsStringChange(mappings: string): void; + onPipelineStringChange(pipeline: string): void; indexNameError: string; indexPatternNameError: string; combinedFields: CombinedField[]; @@ -175,7 +175,7 @@ export const AdvancedSettings: FC = ({ interface JsonEditorProps { initialized: boolean; data: string; - onChange(): void; + onChange(value: string): void; } const IndexSettings: FC = ({ initialized, data, onChange }) => { diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/import_settings.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/import_settings.tsx index 5a9597723a0b5..640e144e008b3 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/import_settings.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/import_settings.tsx @@ -27,8 +27,8 @@ interface Props { mappingsString: string; pipelineString: string; onIndexSettingsStringChange(): void; - onMappingsStringChange(): void; - onPipelineStringChange(): void; + onMappingsStringChange(mappings: string): void; + onPipelineStringChange(pipeline: string): void; indexNameError: string; indexPatternNameError: string; combinedFields: CombinedField[]; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts index 6693d1cd6de74..fe0329851758c 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts @@ -642,7 +642,6 @@ export class JobCreator { this._job_config.custom_settings !== undefined && this._job_config.custom_settings[setting] !== undefined ) { - // @ts-expect-error return this._job_config.custom_settings[setting]; } return null; @@ -711,13 +710,14 @@ export class JobCreator { } private _extractRuntimeMappings() { - const runtimeFieldMap = this._indexPattern.toSpec().runtimeFieldMap; + const runtimeFieldMap = this._indexPattern.toSpec().runtimeFieldMap as + | RuntimeMappings + | undefined; if (runtimeFieldMap !== undefined) { if (this._datafeed_config.runtime_mappings === undefined) { this._datafeed_config.runtime_mappings = {}; } Object.entries(runtimeFieldMap).forEach(([key, val]) => { - // @ts-expect-error this._datafeed_config.runtime_mappings![key] = val; }); } diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/default_configs.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/default_configs.ts index bf354b8ad984f..68476bb928121 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/default_configs.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/default_configs.ts @@ -11,7 +11,7 @@ import { Job, Datafeed, Detector } from '../../../../../../../common/types/anoma import { splitIndexPatternNames } from '../../../../../../../common/util/job_utils'; export function createEmptyJob(): Job { - // @ts-expect-error + // @ts-expect-error incomplete job return { job_id: '', description: '', @@ -28,7 +28,7 @@ export function createEmptyJob(): Job { } export function createEmptyDatafeed(indexPatternTitle: IndexPatternTitle): Datafeed { - // @ts-expect-error + // @ts-expect-error incomplete datafeed return { datafeed_id: '', job_id: '', diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.test.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.test.ts index 670447826dcdd..7f1ee2349c2c1 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.test.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.test.ts @@ -9,7 +9,7 @@ import { Job, Datafeed } from '../../../../../../../common/types/anomaly_detecti import { filterRuntimeMappings } from './filter_runtime_mappings'; function getJob(): Job { - // @ts-expect-error + // @ts-expect-error incomplete job type for test return { job_id: 'test', description: '', diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/advanced_detector_modal/advanced_detector_modal.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/advanced_detector_modal/advanced_detector_modal.tsx index 10c160f58ff77..d3108eef04983 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/advanced_detector_modal/advanced_detector_modal.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/advanced_detector_modal/advanced_detector_modal.tsx @@ -171,8 +171,10 @@ export const AdvancedDetectorModal: FC = ({ byField, overField, partitionField, - // @ts-expect-error - excludeFrequent: excludeFrequentOption.label !== '' ? excludeFrequentOption.label : null, + excludeFrequent: + excludeFrequentOption.label !== '' + ? (excludeFrequentOption.label as estypes.ExcludeFrequent) + : null, description: descriptionOption !== '' ? descriptionOption : null, customRules: null, }; diff --git a/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts b/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts index 1f5bbe8ac0fd4..1cefa48cf6c8c 100644 --- a/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts +++ b/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts @@ -180,13 +180,13 @@ export function calculateModelMemoryLimitProvider( // if max_model_memory_limit has been set, // make sure the estimated value is not greater than it. if (allowMMLGreaterThanMax === false) { - // @ts-expect-error + // @ts-expect-error numeral missing value const mmlBytes = numeral(estimatedModelMemoryLimit).value(); if (maxModelMemoryLimit !== undefined) { - // @ts-expect-error + // @ts-expect-error numeral missing value const maxBytes = numeral(maxModelMemoryLimit).value(); if (mmlBytes > maxBytes) { - // @ts-expect-error + // @ts-expect-error numeral missing value modelMemoryLimit = `${Math.floor(maxBytes / numeral('1MB').value())}MB`; mmlCappedAtMax = true; } @@ -195,10 +195,10 @@ export function calculateModelMemoryLimitProvider( // if we've not already capped the estimated mml at the hard max server setting // ensure that the estimated mml isn't greater than the effective max mml if (mmlCappedAtMax === false && effectiveMaxModelMemoryLimit !== undefined) { - // @ts-expect-error + // @ts-expect-error numeral missing value const effectiveMaxMmlBytes = numeral(effectiveMaxModelMemoryLimit).value(); if (mmlBytes > effectiveMaxMmlBytes) { - // @ts-expect-error + // @ts-expect-error numeral missing value modelMemoryLimit = `${Math.floor(effectiveMaxMmlBytes / numeral('1MB').value())}MB`; } } diff --git a/x-pack/plugins/ml/server/models/calendar/calendar_manager.ts b/x-pack/plugins/ml/server/models/calendar/calendar_manager.ts index 96bd74b9880a6..d08263f786354 100644 --- a/x-pack/plugins/ml/server/models/calendar/calendar_manager.ts +++ b/x-pack/plugins/ml/server/models/calendar/calendar_manager.ts @@ -47,8 +47,7 @@ export class CalendarManager { } async getAllCalendars() { - // @ts-expect-error missing size argument - const { body } = await this._mlClient.getCalendars({ size: 1000 }); + const { body } = await this._mlClient.getCalendars({ body: { page: { from: 0, size: 1000 } } }); const events: ScheduledEvent[] = await this._eventManager.getAllEvents(); const calendars: Calendar[] = body.calendars as Calendar[]; diff --git a/x-pack/plugins/ml/server/models/data_frame_analytics/validation.ts b/x-pack/plugins/ml/server/models/data_frame_analytics/validation.ts index bbfc304958f9a..39ccd36de0af5 100644 --- a/x-pack/plugins/ml/server/models/data_frame_analytics/validation.ts +++ b/x-pack/plugins/ml/server/models/data_frame_analytics/validation.ts @@ -243,11 +243,11 @@ async function getValidationCheckMessages( }, }); - // @ts-expect-error + // @ts-expect-error incorrect search response type const totalDocs = body.hits.total.value; if (body.aggregations) { - // @ts-expect-error + // @ts-expect-error incorrect search response type Object.entries(body.aggregations).forEach(([aggName, { doc_count: docCount, value }]) => { if (docCount !== undefined) { const empty = docCount / totalDocs; diff --git a/x-pack/plugins/ml/server/models/data_recognizer/data_recognizer.ts b/x-pack/plugins/ml/server/models/data_recognizer/data_recognizer.ts index 21ed258a0b764..81db7ca15b258 100644 --- a/x-pack/plugins/ml/server/models/data_recognizer/data_recognizer.ts +++ b/x-pack/plugins/ml/server/models/data_recognizer/data_recognizer.ts @@ -288,7 +288,7 @@ export class DataRecognizer { body: searchBody, }); - // @ts-expect-error fix search response + // @ts-expect-error incorrect search response type return body.hits.total.value > 0; } @@ -1181,13 +1181,13 @@ export class DataRecognizer { return; } - // @ts-expect-error + // @ts-expect-error numeral missing value const maxBytes: number = numeral(maxMml.toUpperCase()).value(); for (const job of moduleConfig.jobs) { const mml = job.config?.analysis_limits?.model_memory_limit; if (mml !== undefined) { - // @ts-expect-error + // @ts-expect-error numeral missing value const mmlBytes: number = numeral(mml.toUpperCase()).value(); if (mmlBytes > maxBytes) { // if the job's mml is over the max, @@ -1306,7 +1306,7 @@ export class DataRecognizer { const job = jobs.find((j) => j.id === `${jobPrefix}${jobSpecificOverride.job_id}`); if (job !== undefined) { // delete the job_id in the override as this shouldn't be overridden - // @ts-expect-error + // @ts-expect-error missing job_id delete jobSpecificOverride.job_id; merge(job.config, jobSpecificOverride); processArrayValues(job.config, jobSpecificOverride); diff --git a/x-pack/plugins/ml/server/models/data_visualizer/data_visualizer.ts b/x-pack/plugins/ml/server/models/data_visualizer/data_visualizer.ts index e7c723ba16aba..54173d75938d8 100644 --- a/x-pack/plugins/ml/server/models/data_visualizer/data_visualizer.ts +++ b/x-pack/plugins/ml/server/models/data_visualizer/data_visualizer.ts @@ -674,7 +674,7 @@ export class DataVisualizer { }); const aggregations = body.aggregations; - // @ts-expect-error fix search response + // @ts-expect-error incorrect search response type const totalCount = body.hits.total.value; const stats = { totalCount, @@ -762,7 +762,7 @@ export class DataVisualizer { size, body: searchBody, }); - // @ts-expect-error fix search response + // @ts-expect-error incorrect search response type return body.hits.total.value > 0; } @@ -1249,7 +1249,7 @@ export class DataVisualizer { fieldName: field, examples: [] as any[], }; - // @ts-expect-error fix search response + // @ts-expect-error incorrect search response type if (body.hits.total.value > 0) { const hits = body.hits.hits; for (let i = 0; i < hits.length; i++) { diff --git a/x-pack/plugins/ml/server/models/fields_service/fields_service.ts b/x-pack/plugins/ml/server/models/fields_service/fields_service.ts index eb4c32e1a1cc4..cfe0bcc532630 100644 --- a/x-pack/plugins/ml/server/models/fields_service/fields_service.ts +++ b/x-pack/plugins/ml/server/models/fields_service/fields_service.ts @@ -194,7 +194,7 @@ export function fieldsServiceProvider({ asCurrentUser }: IScopedClusterClient) { } const aggResult = fieldsToAgg.reduce((obj, field) => { - // @ts-expect-error fix search aggregation response + // @ts-expect-error incorrect search response type obj[field] = (aggregations[field] || { value: 0 }).value; return obj; }, {} as { [field: string]: number }); @@ -250,14 +250,14 @@ export function fieldsServiceProvider({ asCurrentUser }: IScopedClusterClient) { }); if (aggregations && aggregations.earliest && aggregations.latest) { - // @ts-expect-error fix search aggregation response + // @ts-expect-error incorrect search response type obj.start.epoch = aggregations.earliest.value; - // @ts-expect-error fix search aggregation response + // @ts-expect-error incorrect search response type obj.start.string = aggregations.earliest.value_as_string; - // @ts-expect-error fix search aggregation response + // @ts-expect-error incorrect search response type obj.end.epoch = aggregations.latest.value; - // @ts-expect-error fix search aggregation response + // @ts-expect-error incorrect search response type obj.end.string = aggregations.latest.value_as_string; } return obj; @@ -416,7 +416,7 @@ export function fieldsServiceProvider({ asCurrentUser }: IScopedClusterClient) { } const aggResult = fieldsToAgg.reduce((obj, field) => { - // @ts-expect-error fix search aggregation response + // @ts-expect-error incorrect search response type obj[field] = (aggregations[getMaxBucketAggKey(field)] || { value: 0 }).value ?? 0; return obj; }, {} as { [field: string]: number }); diff --git a/x-pack/plugins/ml/server/models/job_service/jobs.ts b/x-pack/plugins/ml/server/models/job_service/jobs.ts index d0d824a88f5a9..0dcef210c10ce 100644 --- a/x-pack/plugins/ml/server/models/job_service/jobs.ts +++ b/x-pack/plugins/ml/server/models/job_service/jobs.ts @@ -188,6 +188,7 @@ export function jobsProvider(client: IScopedClusterClient, mlClient: MlClient) { processed_record_count: job.data_counts?.processed_record_count, earliestStartTimestampMs: getEarliestDatafeedStartTime( dataCounts?.latest_record_timestamp, + // @ts-expect-error @elastic/elasticsearch data counts missing is missing latest_bucket_timestamp dataCounts?.latest_bucket_timestamp, parseTimeIntervalForJob(job.analysis_config?.bucket_span) ), @@ -203,6 +204,7 @@ export function jobsProvider(client: IScopedClusterClient, mlClient: MlClient) { earliestTimestampMs: dataCounts?.earliest_record_timestamp, latestResultsTimestampMs: getLatestDataOrBucketTimestamp( dataCounts?.latest_record_timestamp, + // @ts-expect-error @elastic/elasticsearch data counts missing is missing latest_bucket_timestamp dataCounts?.latest_bucket_timestamp ), isSingleMetricViewerJob: errorMessage === undefined, @@ -244,6 +246,7 @@ export function jobsProvider(client: IScopedClusterClient, mlClient: MlClient) { if (dataCounts !== undefined) { timeRange.to = getLatestDataOrBucketTimestamp( dataCounts.latest_record_timestamp as number, + // @ts-expect-error @elastic/elasticsearch data counts missing is missing latest_bucket_timestamp dataCounts.latest_bucket_timestamp as number ); timeRange.from = dataCounts.earliest_record_timestamp; @@ -319,7 +322,6 @@ export function jobsProvider(client: IScopedClusterClient, mlClient: MlClient) { (ds) => ds.datafeed_id === datafeed.datafeed_id ); if (datafeedStats) { - // @ts-expect-error datafeeds[datafeed.job_id] = { ...datafeed, ...datafeedStats }; } } @@ -388,7 +390,7 @@ export function jobsProvider(client: IScopedClusterClient, mlClient: MlClient) { if (jobStatsResults && jobStatsResults.jobs) { const jobStats = jobStatsResults.jobs.find((js) => js.job_id === tempJob.job_id); if (jobStats !== undefined) { - // @ts-expect-error + // @ts-expect-error @elastic-elasticsearch JobStats type is incomplete tempJob = { ...tempJob, ...jobStats }; if (jobStats.node) { tempJob.node = jobStats.node; @@ -401,6 +403,7 @@ export function jobsProvider(client: IScopedClusterClient, mlClient: MlClient) { const latestBucketTimestamp = latestBucketTimestampByJob && latestBucketTimestampByJob[tempJob.job_id]; if (latestBucketTimestamp) { + // @ts-expect-error @elastic/elasticsearch data counts missing is missing latest_bucket_timestamp tempJob.data_counts.latest_bucket_timestamp = latestBucketTimestamp; } } diff --git a/x-pack/plugins/ml/server/models/job_service/new_job/categorization/top_categories.ts b/x-pack/plugins/ml/server/models/job_service/new_job/categorization/top_categories.ts index 82d6f6ca3e103..87715d9d85dbf 100644 --- a/x-pack/plugins/ml/server/models/job_service/new_job/categorization/top_categories.ts +++ b/x-pack/plugins/ml/server/models/job_service/new_job/categorization/top_categories.ts @@ -81,7 +81,7 @@ export function topCategoriesProvider(mlClient: MlClient) { const catCounts: Array<{ id: CategoryId; count: number; - // @ts-expect-error + // @ts-expect-error incorrect search response type }> = body.aggregations?.cat_count?.buckets.map((c: any) => ({ id: c.key, count: c.doc_count, @@ -126,7 +126,7 @@ export function topCategoriesProvider(mlClient: MlClient) { [] ); - // @ts-expect-error + // @ts-expect-error incorrect search response type return body.hits.hits?.map((c: { _source: Category }) => c._source) || []; } diff --git a/x-pack/plugins/ml/server/models/job_validation/job_validation.test.ts b/x-pack/plugins/ml/server/models/job_validation/job_validation.test.ts index 64dfb84be8668..a5483491f1357 100644 --- a/x-pack/plugins/ml/server/models/job_validation/job_validation.test.ts +++ b/x-pack/plugins/ml/server/models/job_validation/job_validation.test.ts @@ -161,7 +161,7 @@ describe('ML - validateJob', () => { function: '', }); payload.job.analysis_config.detectors.push({ - // @ts-expect-error + // @ts-expect-error incorrect type on purpose for test function: undefined, }); diff --git a/x-pack/plugins/ml/server/models/job_validation/job_validation.ts b/x-pack/plugins/ml/server/models/job_validation/job_validation.ts index 94e9a8dc7bffb..00a51d1e4e153 100644 --- a/x-pack/plugins/ml/server/models/job_validation/job_validation.ts +++ b/x-pack/plugins/ml/server/models/job_validation/job_validation.ts @@ -13,7 +13,7 @@ import { getMessages, MessageId, JobValidationMessage } from '../../../common/co import { VALIDATION_STATUS } from '../../../common/constants/validation'; import { basicJobValidation, uniqWithIsEqual } from '../../../common/util/job_utils'; -// @ts-expect-error +// @ts-expect-error importing js file import { validateBucketSpan } from './validate_bucket_span'; import { validateCardinality } from './validate_cardinality'; import { validateInfluencers } from './validate_influencers'; diff --git a/x-pack/plugins/ml/server/models/job_validation/validate_model_memory_limit.test.ts b/x-pack/plugins/ml/server/models/job_validation/validate_model_memory_limit.test.ts index 44c5e3cabb18f..823d4c0adda49 100644 --- a/x-pack/plugins/ml/server/models/job_validation/validate_model_memory_limit.test.ts +++ b/x-pack/plugins/ml/server/models/job_validation/validate_model_memory_limit.test.ts @@ -216,7 +216,7 @@ describe('ML - validateModelMemoryLimit', () => { const dtrs = createDetectors(2); const job = getJobConfig(['instance'], dtrs); const duration = { start: 0, end: 1 }; - // @ts-expect-error + // @ts-expect-error incorrect type on purpose for test delete mlInfoResponse.limits.max_model_memory_limit; job.analysis_limits!.model_memory_limit = '10mb'; diff --git a/x-pack/plugins/ml/server/models/job_validation/validate_model_memory_limit.ts b/x-pack/plugins/ml/server/models/job_validation/validate_model_memory_limit.ts index 47e34626062d1..3c8a965333789 100644 --- a/x-pack/plugins/ml/server/models/job_validation/validate_model_memory_limit.ts +++ b/x-pack/plugins/ml/server/models/job_validation/validate_model_memory_limit.ts @@ -69,14 +69,14 @@ export async function validateModelMemoryLimit( true, job.datafeed_config ); - // @ts-expect-error + // @ts-expect-error numeral missing value const mmlEstimateBytes: number = numeral(modelMemoryLimit).value(); let runEstimateGreaterThenMml = true; // if max_model_memory_limit has been set, // make sure the estimated value is not greater than it. if (typeof maxModelMemoryLimit !== 'undefined') { - // @ts-expect-error + // @ts-expect-error numeral missing value const maxMmlBytes: number = numeral(maxModelMemoryLimit).value(); if (mmlEstimateBytes > maxMmlBytes) { runEstimateGreaterThenMml = false; @@ -93,7 +93,7 @@ export async function validateModelMemoryLimit( // do not run this if we've already found that it's larger than // the max mml if (runEstimateGreaterThenMml && mml !== null) { - // @ts-expect-error + // @ts-expect-error numeral missing value const mmlBytes: number = numeral(mml).value(); if (mmlBytes < MODEL_MEMORY_LIMIT_MINIMUM_BYTES) { messages.push({ @@ -120,11 +120,11 @@ export async function validateModelMemoryLimit( // make sure the user defined MML is not greater than it if (mml !== null) { let maxMmlExceeded = false; - // @ts-expect-error + // @ts-expect-error numeral missing value const mmlBytes = numeral(mml).value(); if (maxModelMemoryLimit !== undefined) { - // @ts-expect-error + // @ts-expect-error numeral missing value const maxMmlBytes = numeral(maxModelMemoryLimit).value(); if (mmlBytes > maxMmlBytes) { maxMmlExceeded = true; @@ -137,7 +137,7 @@ export async function validateModelMemoryLimit( } if (effectiveMaxModelMemoryLimit !== undefined && maxMmlExceeded === false) { - // @ts-expect-error + // @ts-expect-error numeral missing value const effectiveMaxMmlBytes = numeral(effectiveMaxModelMemoryLimit).value(); if (mmlBytes > effectiveMaxMmlBytes) { messages.push({ diff --git a/x-pack/plugins/ml/server/models/results_service/results_service.ts b/x-pack/plugins/ml/server/models/results_service/results_service.ts index 1996acd2cdb06..225a988298b1c 100644 --- a/x-pack/plugins/ml/server/models/results_service/results_service.ts +++ b/x-pack/plugins/ml/server/models/results_service/results_service.ts @@ -183,7 +183,7 @@ export function resultsServiceProvider(mlClient: MlClient) { anomalies: [], interval: 'second', }; - // @ts-expect-error update to correct search response + // @ts-expect-error incorrect search response type if (body.hits.total.value > 0) { let records: AnomalyRecordDoc[] = []; body.hits.hits.forEach((hit: any) => { @@ -402,7 +402,7 @@ export function resultsServiceProvider(mlClient: MlClient) { ); const examplesByCategoryId: { [key: string]: any } = {}; - // @ts-expect-error update to correct search response + // @ts-expect-error incorrect search response type if (body.hits.total.value > 0) { body.hits.hits.forEach((hit: any) => { if (maxExamples) { @@ -439,7 +439,7 @@ export function resultsServiceProvider(mlClient: MlClient) { ); const definition = { categoryId, terms: null, regex: null, examples: [] }; - // @ts-expect-error update to correct search response + // @ts-expect-error incorrect search response type if (body.hits.total.value > 0) { const source = body.hits.hits[0]._source; definition.categoryId = source.category_id; @@ -579,7 +579,7 @@ export function resultsServiceProvider(mlClient: MlClient) { ); if (fieldToBucket === JOB_ID) { finalResults = { - // @ts-expect-error update search response + // @ts-expect-error incorrect search response type jobs: results.aggregations?.unique_terms?.buckets.map( (b: { key: string; doc_count: number }) => b.key ), @@ -592,7 +592,7 @@ export function resultsServiceProvider(mlClient: MlClient) { }, {} ); - // @ts-expect-error update search response + // @ts-expect-error incorrect search response type results.aggregations.jobs.buckets.forEach( (bucket: { key: string | number; unique_stopped_partitions: { buckets: any[] } }) => { jobs[bucket.key] = bucket.unique_stopped_partitions.buckets.map((b) => b.key);