From 34b9f1d7aef2397a8d4677a3a774dc834c32c614 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 25 May 2022 20:54:42 +0200 Subject: [PATCH 01/11] [ML] Create @kbn/ml-data-utils package. --- package.json | 2 + packages/BUILD.bazel | 2 + .../src/bazel_package_dirs.ts | 1 + x-pack/packages/ml/data-utils/BUILD.bazel | 121 ++++++++++++++++++ x-pack/packages/ml/data-utils/README.md | 3 + x-pack/packages/ml/data-utils/jest.config.js | 12 ++ x-pack/packages/ml/data-utils/package.json | 7 + .../src/build_sampler_aggregation.ts | 29 +++++ .../ml/data-utils/src/get_agg_intervals.ts | 101 +++++++++++++++ .../get_sampler_aggregations_response_path.ts | 14 ++ x-pack/packages/ml/data-utils/src/index.ts | 12 ++ .../src/is_populated_object.test.ts | 48 +++++++ .../ml/data-utils/src/is_populated_object.ts} | 0 .../ml/data-utils/src/string_hash.ts} | 0 x-pack/packages/ml/data-utils/tsconfig.json | 17 +++ .../common/types/field_stats.ts | 2 +- .../data_visualizer/common/types/index.ts | 2 +- .../common/utils/query_utils.ts | 29 ----- .../common/utils/runtime_field_utils.ts | 2 +- .../full_time_range_selector_service.ts | 2 +- .../requests/get_boolean_field_stats.ts | 4 +- .../requests/get_date_field_stats.ts | 4 +- .../requests/get_document_stats.ts | 2 +- .../requests/get_field_examples.ts | 2 +- .../requests/get_numeric_field_stats.ts | 10 +- .../requests/get_string_field_stats.ts | 6 +- .../search_strategy/requests/overall_stats.ts | 8 +- .../utils/error_utils.ts | 2 +- .../utils/query_utils.ts | 2 +- x-pack/plugins/file_upload/common/utils.ts | 19 --- .../file_upload/public/importer/importer.ts | 2 +- .../server/get_time_field_range.ts | 2 +- .../server/utils/runtime_field_utils.ts | 2 +- x-pack/plugins/ml/common/index.ts | 1 - x-pack/plugins/ml/common/types/es_client.ts | 2 +- .../ml/common/types/feature_importance.ts | 2 +- .../ml/common/util/errors/process_errors.ts | 2 +- .../ml/common/util/group_color_utils.ts | 2 +- x-pack/plugins/ml/common/util/job_utils.ts | 3 +- x-pack/plugins/ml/common/util/object_utils.ts | 30 +---- x-pack/plugins/ml/common/util/query_utils.ts | 2 +- .../ml/common/util/runtime_field_utils.ts | 2 +- x-pack/plugins/ml/common/util/string_utils.ts | 17 --- x-pack/plugins/ml/common/util/validators.ts | 2 +- ...aly_detection_jobs_health_rule_trigger.tsx | 2 +- .../components/data_grid/data_grid.tsx | 2 +- .../full_time_range_selector_service.ts | 2 +- .../scatterplot_matrix/scatterplot_matrix.tsx | 2 +- .../runtime_mappings/runtime_mappings.tsx | 2 +- .../hooks/use_exploration_url_state.ts | 2 +- .../jobs/jobs_list/components/utils.js | 2 +- .../ml/public/application/jobs/jobs_utils.ts | 2 +- .../util/filter_runtime_mappings.ts | 2 +- .../jobs/new_job/recognize/page.tsx | 2 +- .../anomaly_explorer_charts_service.ts | 2 +- .../services/anomaly_timeline_service.ts | 2 +- .../results_service/result_service_rx.ts | 2 +- .../results_service/results_service.js | 3 +- .../models_management/expanded_row.tsx | 2 +- .../models_management/models_list.tsx | 2 +- .../models_management/test_models/utils.ts | 3 +- .../ml/public/application/util/url_state.tsx | 2 +- x-pack/plugins/ml/public/embeddables/types.ts | 2 +- x-pack/plugins/ml/server/lib/query_utils.ts | 30 ----- .../models/data_recognizer/data_recognizer.ts | 2 +- .../models/data_visualizer/data_visualizer.ts | 86 ++----------- .../models/fields_service/fields_service.ts | 2 +- .../ml/server/models/job_service/jobs.ts | 2 +- .../models/results_service/anomaly_charts.ts | 3 +- .../common/api_schemas/type_guards.ts | 3 +- .../transform/common/shared_imports.ts | 1 - .../transform/common/types/data_view.ts | 3 +- .../transform/common/types/transform.ts | 2 +- .../transform/common/types/transform_stats.ts | 3 +- .../plugins/transform/common/utils/errors.ts | 2 +- .../transform/public/app/common/pivot_aggs.ts | 2 +- .../public/app/common/pivot_group_by.ts | 2 +- .../transform/public/app/common/request.ts | 2 +- .../lib/authorization/components/common.ts | 2 +- .../step_create/step_create_form.tsx | 2 +- .../filter_agg/components/filter_agg_form.tsx | 2 +- .../common/top_metrics_agg/config.ts | 2 +- .../components/step_define/common/types.ts | 3 +- .../use_edit_transform_flyout.ts | 2 +- .../transform_list/expanded_row.tsx | 18 +-- .../server/routes/api/transforms_nodes.ts | 3 +- .../apis/ml/modules/get_module.ts | 2 +- yarn.lock | 8 ++ 88 files changed, 471 insertions(+), 294 deletions(-) create mode 100644 x-pack/packages/ml/data-utils/BUILD.bazel create mode 100644 x-pack/packages/ml/data-utils/README.md create mode 100644 x-pack/packages/ml/data-utils/jest.config.js create mode 100644 x-pack/packages/ml/data-utils/package.json create mode 100644 x-pack/packages/ml/data-utils/src/build_sampler_aggregation.ts create mode 100644 x-pack/packages/ml/data-utils/src/get_agg_intervals.ts create mode 100644 x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.ts create mode 100644 x-pack/packages/ml/data-utils/src/index.ts create mode 100644 x-pack/packages/ml/data-utils/src/is_populated_object.test.ts rename x-pack/{plugins/data_visualizer/common/utils/object_utils.ts => packages/ml/data-utils/src/is_populated_object.ts} (100%) rename x-pack/{plugins/data_visualizer/common/utils/string_utils.ts => packages/ml/data-utils/src/string_hash.ts} (100%) create mode 100644 x-pack/packages/ml/data-utils/tsconfig.json delete mode 100644 x-pack/plugins/file_upload/common/utils.ts diff --git a/package.json b/package.json index 0cf2676cdc17..c25f9468bad0 100644 --- a/package.json +++ b/package.json @@ -188,6 +188,7 @@ "@kbn/logging": "link:bazel-bin/packages/kbn-logging", "@kbn/logging-mocks": "link:bazel-bin/packages/kbn-logging-mocks", "@kbn/mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl", + "@kbn/ml-data-utils": "link:bazel-bin/x-pack/packages/ml/data-utils", "@kbn/monaco": "link:bazel-bin/packages/kbn-monaco", "@kbn/plugin-discovery": "link:bazel-bin/packages/kbn-plugin-discovery", "@kbn/react-field": "link:bazel-bin/packages/kbn-react-field", @@ -722,6 +723,7 @@ "@types/kbn__logging": "link:bazel-bin/packages/kbn-logging/npm_module_types", "@types/kbn__logging-mocks": "link:bazel-bin/packages/kbn-logging-mocks/npm_module_types", "@types/kbn__mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl/npm_module_types", + "@types/kbn__ml-data-utils": "link:bazel-bin/x-pack/packages/ml/data-utils/npm_module_types", "@types/kbn__monaco": "link:bazel-bin/packages/kbn-monaco/npm_module_types", "@types/kbn__optimizer": "link:bazel-bin/packages/kbn-optimizer/npm_module_types", "@types/kbn__optimizer-webpack-helpers": "link:bazel-bin/packages/kbn-optimizer-webpack-helpers/npm_module_types", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index cc5c0e13dccc..237ebd3c619f 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -150,6 +150,7 @@ filegroup( "//packages/shared-ux/page/analytics_no_data:build", "//packages/shared-ux/page/kibana_no_data:build", "//packages/shared-ux/prompt/no_data_views:build", + "//x-pack/packages/ml/data-utils:build", ], ) @@ -283,6 +284,7 @@ filegroup( "//packages/shared-ux/page/analytics_no_data:build_types", "//packages/shared-ux/page/kibana_no_data:build_types", "//packages/shared-ux/prompt/no_data_views:build_types", + "//x-pack/packages/ml/data-utils:build_types", ], ) diff --git a/packages/kbn-bazel-packages/src/bazel_package_dirs.ts b/packages/kbn-bazel-packages/src/bazel_package_dirs.ts index 5c0bfb5d4595..ed295cffd7ed 100644 --- a/packages/kbn-bazel-packages/src/bazel_package_dirs.ts +++ b/packages/kbn-bazel-packages/src/bazel_package_dirs.ts @@ -27,6 +27,7 @@ export const BAZEL_PACKAGE_DIRS = [ 'packages/analytics/shippers', 'packages/analytics/shippers/elastic_v3', 'packages/core/*', + 'x-pack/packages/ml', ]; /** diff --git a/x-pack/packages/ml/data-utils/BUILD.bazel b/x-pack/packages/ml/data-utils/BUILD.bazel new file mode 100644 index 000000000000..44a77e683e18 --- /dev/null +++ b/x-pack/packages/ml/data-utils/BUILD.bazel @@ -0,0 +1,121 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") + +PKG_DIRNAME = "data-utils" +PKG_REQUIRE_NAME = "@kbn/ml-data-utils" + +SOURCE_FILES = glob( + [ + "src/**/*.ts", + ], + exclude = [ + "**/*.test.*", + ], +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", +] + +# In this array place runtime dependencies, including other packages and NPM packages +# which must be available for this code to run. +# +# To reference other packages use: +# "//repo/relative/path/to/package" +# eg. "//packages/kbn-utils" +# +# To reference a NPM package use: +# "@npm//name-of-package" +# eg. "@npm//lodash" +RUNTIME_DEPS = [ + "@npm//@elastic/elasticsearch", + "@npm//lodash", + "//packages/kbn-field-types", +] + +# In this array place dependencies necessary to build the types, which will include the +# :npm_module_types target of other packages and packages from NPM, including @types/* +# packages. +# +# To reference the types for another package use: +# "//repo/relative/path/to/package:npm_module_types" +# eg. "//packages/kbn-utils:npm_module_types" +# +# References to NPM packages work the same as RUNTIME_DEPS +TYPES_DEPS = [ + "@npm//@types/node", + "@npm//@types/jest", + "@npm//@types/lodash", + "@npm//@elastic/elasticsearch", + "@npm//tslib", + "//packages/kbn-field-types:npm_module_types", +] + +jsts_transpiler( + name = "target_node", + srcs = SRCS, + build_pkg_name = package_name(), +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + "//:tsconfig.bazel.json", + ], +) + +ts_project( + name = "tsc_types", + args = ['--pretty'], + srcs = SRCS, + deps = TYPES_DEPS, + declaration = True, + emit_declaration_only = True, + out_dir = "target_types", + root_dir = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_DIRNAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = RUNTIME_DEPS + [":target_node"], + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + deps = [":" + PKG_DIRNAME], +) + +filegroup( + name = "build", + srcs = [":npm_module"], + visibility = ["//visibility:public"], +) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [":npm_module_types"], + visibility = ["//visibility:public"], +) diff --git a/x-pack/packages/ml/data-utils/README.md b/x-pack/packages/ml/data-utils/README.md new file mode 100644 index 000000000000..643a41127a41 --- /dev/null +++ b/x-pack/packages/ml/data-utils/README.md @@ -0,0 +1,3 @@ +# @kbn/ml-data-utils + +Empty package generated by @kbn/generate diff --git a/x-pack/packages/ml/data-utils/jest.config.js b/x-pack/packages/ml/data-utils/jest.config.js new file mode 100644 index 000000000000..d6b5dc628aa6 --- /dev/null +++ b/x-pack/packages/ml/data-utils/jest.config.js @@ -0,0 +1,12 @@ +/* + * 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. + */ + +module.exports = { + preset: '@kbn/test/jest_node', + rootDir: '../../../..', + roots: ['/x-pack/packages/ml/data-utils'], +}; diff --git a/x-pack/packages/ml/data-utils/package.json b/x-pack/packages/ml/data-utils/package.json new file mode 100644 index 000000000000..0c64681dceb6 --- /dev/null +++ b/x-pack/packages/ml/data-utils/package.json @@ -0,0 +1,7 @@ +{ + "name": "@kbn/ml-data-utils", + "private": true, + "version": "1.0.0", + "main": "./target_node/index.js", + "license": "SSPL-1.0 OR Elastic License 2.0" +} diff --git a/x-pack/packages/ml/data-utils/src/build_sampler_aggregation.ts b/x-pack/packages/ml/data-utils/src/build_sampler_aggregation.ts new file mode 100644 index 000000000000..321b35bd488e --- /dev/null +++ b/x-pack/packages/ml/data-utils/src/build_sampler_aggregation.ts @@ -0,0 +1,29 @@ +/* + * 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 * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; + +// Wraps the supplied aggregations in a sampler aggregation. +// A supplied samplerShardSize (the shard_size parameter of the sampler aggregation) +// of less than 1 indicates no sampling, and the aggs are returned as-is. +export function buildSamplerAggregation( + aggs: any, + samplerShardSize: number +): Record { + if (samplerShardSize < 1) { + return aggs; + } + + return { + sample: { + sampler: { + shard_size: samplerShardSize, + }, + aggs, + }, + }; +} diff --git a/x-pack/packages/ml/data-utils/src/get_agg_intervals.ts b/x-pack/packages/ml/data-utils/src/get_agg_intervals.ts new file mode 100644 index 000000000000..fb8abff7a661 --- /dev/null +++ b/x-pack/packages/ml/data-utils/src/get_agg_intervals.ts @@ -0,0 +1,101 @@ +/* + * 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 { get } from 'lodash'; + +import type { Client } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; + +import { KBN_FIELD_TYPES } from '@kbn/field-types'; + +import { buildSamplerAggregation } from './build_sampler_aggregation'; +import { getSamplerAggregationsResponsePath } from './get_sampler_aggregations_response_path'; +import { isPopulatedObject } from './is_populated_object'; +import { stringHash } from './string_hash'; + +// TODO Temporary type definition until we can import from `@kbn/core`. +/** + * Client used to query the elasticsearch cluster. + * + * @public + */ +export type ElasticsearchClient = Omit< + Client, + 'connectionPool' | 'serializer' | 'extend' | 'close' | 'diagnostic' +>; + +const MAX_CHART_COLUMNS = 20; + +export interface HistogramField { + fieldName: string; + type: string; +} + +interface NumericColumnStats { + interval: number; + min: number; + max: number; +} +type NumericColumnStatsMap = Record; + +export const getAggIntervals = async ( + client: ElasticsearchClient, + indexPattern: string, + query: any, + fields: HistogramField[], + samplerShardSize: number, + runtimeMappings?: estypes.MappingRuntimeFields +): Promise => { + const numericColumns = fields.filter((field) => { + return field.type === KBN_FIELD_TYPES.NUMBER || field.type === KBN_FIELD_TYPES.DATE; + }); + + if (numericColumns.length === 0) { + return {}; + } + + const minMaxAggs = numericColumns.reduce((aggs, c) => { + const id = stringHash(c.fieldName); + aggs[id] = { + stats: { + field: c.fieldName, + }, + }; + return aggs; + }, {} as Record); + + const body = await client.search({ + index: indexPattern, + size: 0, + body: { + query, + aggs: buildSamplerAggregation(minMaxAggs, samplerShardSize), + size: 0, + ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), + }, + }); + + const aggsPath = getSamplerAggregationsResponsePath(samplerShardSize); + const aggregations = aggsPath.length > 0 ? get(body.aggregations, aggsPath) : body.aggregations; + + return Object.keys(aggregations).reduce((p, aggName) => { + const stats = [aggregations[aggName].min, aggregations[aggName].max]; + if (!stats.includes(null)) { + const delta = aggregations[aggName].max - aggregations[aggName].min; + + let aggInterval = 1; + + if (delta > MAX_CHART_COLUMNS || delta <= 1) { + aggInterval = delta / (MAX_CHART_COLUMNS - 1); + } + + p[aggName] = { interval: aggInterval, min: stats[0], max: stats[1] }; + } + + return p; + }, {} as NumericColumnStatsMap); +}; diff --git a/x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.ts b/x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.ts new file mode 100644 index 000000000000..48a9e5051cac --- /dev/null +++ b/x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.ts @@ -0,0 +1,14 @@ +/* + * 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. + */ + +// Returns the path of aggregations in the elasticsearch response, as an array, +// depending on whether sampling is being used. +// A supplied samplerShardSize (the shard_size parameter of the sampler aggregation) +// of less than 1 indicates no sampling, and an empty array is returned. +export function getSamplerAggregationsResponsePath(samplerShardSize: number): string[] { + return samplerShardSize > 0 ? ['sample'] : []; +} diff --git a/x-pack/packages/ml/data-utils/src/index.ts b/x-pack/packages/ml/data-utils/src/index.ts new file mode 100644 index 000000000000..0db6555b00c0 --- /dev/null +++ b/x-pack/packages/ml/data-utils/src/index.ts @@ -0,0 +1,12 @@ +/* + * 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. + */ + +export { buildSamplerAggregation } from './build_sampler_aggregation'; +export { getAggIntervals } from './get_agg_intervals'; +export { getSamplerAggregationsResponsePath } from './get_sampler_aggregations_response_path'; +export { isPopulatedObject } from './is_populated_object'; +export { stringHash } from './string_hash'; diff --git a/x-pack/packages/ml/data-utils/src/is_populated_object.test.ts b/x-pack/packages/ml/data-utils/src/is_populated_object.test.ts new file mode 100644 index 000000000000..9c5ce512944c --- /dev/null +++ b/x-pack/packages/ml/data-utils/src/is_populated_object.test.ts @@ -0,0 +1,48 @@ +/* + * 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 { isPopulatedObject } from './is_populated_object'; + +describe('isPopulatedObject()', () => { + it('does not allow numbers', () => { + expect(isPopulatedObject(0)).toBe(false); + }); + it('does not allow strings', () => { + expect(isPopulatedObject('')).toBe(false); + }); + it('does not allow null', () => { + expect(isPopulatedObject(null)).toBe(false); + }); + it('does not allow an empty object', () => { + expect(isPopulatedObject({})).toBe(false); + }); + it('allows an object with an attribute', () => { + expect(isPopulatedObject({ attribute: 'value' })).toBe(true); + }); + it('does not allow an object with a non-existing required attribute', () => { + expect(isPopulatedObject({ attribute: 'value' }, ['otherAttribute'])).toBe(false); + }); + it('allows an object with an existing required attribute', () => { + expect(isPopulatedObject({ attribute: 'value' }, ['attribute'])).toBe(true); + }); + it('allows an object with two existing required attributes', () => { + expect( + isPopulatedObject({ attribute1: 'value1', attribute2: 'value2' }, [ + 'attribute1', + 'attribute2', + ]) + ).toBe(true); + }); + it('does not allow an object with two required attributes where one does not exist', () => { + expect( + isPopulatedObject({ attribute1: 'value1', attribute2: 'value2' }, [ + 'attribute1', + 'otherAttribute', + ]) + ).toBe(false); + }); +}); diff --git a/x-pack/plugins/data_visualizer/common/utils/object_utils.ts b/x-pack/packages/ml/data-utils/src/is_populated_object.ts similarity index 100% rename from x-pack/plugins/data_visualizer/common/utils/object_utils.ts rename to x-pack/packages/ml/data-utils/src/is_populated_object.ts diff --git a/x-pack/plugins/data_visualizer/common/utils/string_utils.ts b/x-pack/packages/ml/data-utils/src/string_hash.ts similarity index 100% rename from x-pack/plugins/data_visualizer/common/utils/string_utils.ts rename to x-pack/packages/ml/data-utils/src/string_hash.ts diff --git a/x-pack/packages/ml/data-utils/tsconfig.json b/x-pack/packages/ml/data-utils/tsconfig.json new file mode 100644 index 000000000000..b74cfcda5ee7 --- /dev/null +++ b/x-pack/packages/ml/data-utils/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../../tsconfig.bazel.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "target_types", + "rootDir": "src", + "stripInternal": false, + "types": [ + "jest", + "node", + ], + }, + "include": [ + "src/**/*", + ] +} diff --git a/x-pack/plugins/data_visualizer/common/types/field_stats.ts b/x-pack/plugins/data_visualizer/common/types/field_stats.ts index 9cc1f7d84f4e..2d12b8b4fc8f 100644 --- a/x-pack/plugins/data_visualizer/common/types/field_stats.ts +++ b/x-pack/plugins/data_visualizer/common/types/field_stats.ts @@ -8,7 +8,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Query } from '@kbn/es-query'; import { IKibanaSearchResponse } from '@kbn/data-plugin/common'; -import { isPopulatedObject } from '../utils/object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { TimeBucketsInterval } from '../services/time_buckets'; export interface FieldData { diff --git a/x-pack/plugins/data_visualizer/common/types/index.ts b/x-pack/plugins/data_visualizer/common/types/index.ts index 6ab0649bfb9e..f66d9a9da136 100644 --- a/x-pack/plugins/data_visualizer/common/types/index.ts +++ b/x-pack/plugins/data_visualizer/common/types/index.ts @@ -6,7 +6,7 @@ */ import type { SimpleSavedObject } from '@kbn/core/public'; -import { isPopulatedObject } from '../utils/object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; export type { JobFieldType } from './job_field_type'; export type { FieldRequestConfig, diff --git a/x-pack/plugins/data_visualizer/common/utils/query_utils.ts b/x-pack/plugins/data_visualizer/common/utils/query_utils.ts index dc21bbcae96c..9f0f746f8909 100644 --- a/x-pack/plugins/data_visualizer/common/utils/query_utils.ts +++ b/x-pack/plugins/data_visualizer/common/utils/query_utils.ts @@ -40,35 +40,6 @@ export function buildBaseFilterCriteria( return filterCriteria; } -// Wraps the supplied aggregations in a sampler aggregation. -// A supplied samplerShardSize (the shard_size parameter of the sampler aggregation) -// of less than 1 indicates no sampling, and the aggs are returned as-is. -export function buildSamplerAggregation( - aggs: any, - samplerShardSize: number -): Record { - if (samplerShardSize < 1) { - return aggs; - } - - return { - sample: { - sampler: { - shard_size: samplerShardSize, - }, - aggs, - }, - }; -} - -// Returns the path of aggregations in the elasticsearch response, as an array, -// depending on whether sampling is being used. -// A supplied samplerShardSize (the shard_size parameter of the sampler aggregation) -// of less than 1 indicates no sampling, and an empty array is returned. -export function getSamplerAggregationsResponsePath(samplerShardSize: number): string[] { - return samplerShardSize > 0 ? ['sample'] : []; -} - // Returns a name which is safe to use in elasticsearch aggregations for the supplied // field name. Aggregation names must be alpha-numeric and can only contain '_' and '-' characters, // so if the supplied field names contains disallowed characters, the provided index diff --git a/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts b/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts index 6b2cb78d7327..e65b33e825ff 100644 --- a/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts +++ b/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RUNTIME_FIELD_TYPES } from '@kbn/data-plugin/common'; -import { isPopulatedObject } from './object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; type RuntimeType = typeof RUNTIME_FIELD_TYPES[number]; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts index c7cfc11c4d63..0f7a0c92fa15 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts @@ -12,7 +12,7 @@ import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import { i18n } from '@kbn/i18n'; import type { ToastsStart } from '@kbn/core/public'; import { DataView } from '@kbn/data-views-plugin/public'; -import { isPopulatedObject } from '../../../../../common/utils/object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { getTimeFieldRange } from '../../services/time_field_range'; import type { GetTimeFieldRangeResponse } from '../../../../../common/types/time_field_request'; import { addExcludeFrozenToQuery } from '../../utils/query_utils'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts index bceb354295d9..fb05e3abaf88 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts @@ -17,8 +17,8 @@ import type { import { buildSamplerAggregation, getSamplerAggregationsResponsePath, -} from '../../../../../common/utils/query_utils'; -import { isPopulatedObject } from '../../../../../common/utils/object_utils'; + isPopulatedObject, +} from '@kbn/ml-data-utils'; import type { Field, BooleanFieldStats, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts index 705fe8c00231..7664a13a90de 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts @@ -18,8 +18,8 @@ import type { import { buildSamplerAggregation, getSamplerAggregationsResponsePath, -} from '../../../../../common/utils/query_utils'; -import { isPopulatedObject } from '../../../../../common/utils/object_utils'; + isPopulatedObject, +} from '@kbn/ml-data-utils'; import type { FieldStatsCommonRequestParams } from '../../../../../common/types/field_stats'; import type { Field, DateFieldStats, Aggs } from '../../../../../common/types/field_stats'; import { FieldStatsError, isIKibanaSearchResponse } from '../../../../../common/types/field_stats'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_document_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_document_stats.ts index 6cd04de16fa6..5642179a7dd3 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_document_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_document_stats.ts @@ -7,8 +7,8 @@ import { each, get } from 'lodash'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { buildBaseFilterCriteria } from '../../../../../common/utils/query_utils'; -import { isPopulatedObject } from '../../../../../common/utils/object_utils'; import type { DocumentCountStats, OverallStatsSearchStrategyParams, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_field_examples.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_field_examples.ts index 8b057caecee7..b7b69019a230 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_field_examples.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_field_examples.ts @@ -14,8 +14,8 @@ import type { ISearchOptions, ISearchStart, } from '@kbn/data-plugin/public'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { buildBaseFilterCriteria } from '../../../../../common/utils/query_utils'; -import { isPopulatedObject } from '../../../../../common/utils/object_utils'; import type { Field, FieldExamples, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts index 163cb2585f3a..b870ab375106 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts @@ -16,17 +16,17 @@ import { ISearchOptions, } from '@kbn/data-plugin/common'; import type { ISearchStart } from '@kbn/data-plugin/public'; +import { + buildSamplerAggregation, + getSamplerAggregationsResponsePath, + isPopulatedObject, +} from '@kbn/ml-data-utils'; import { MAX_PERCENT, PERCENTILE_SPACING, SAMPLER_TOP_TERMS_SHARD_SIZE, SAMPLER_TOP_TERMS_THRESHOLD, } from './constants'; -import { - buildSamplerAggregation, - getSamplerAggregationsResponsePath, -} from '../../../../../common/utils/query_utils'; -import { isPopulatedObject } from '../../../../../common/utils/object_utils'; import type { Aggs, FieldStatsCommonRequestParams } from '../../../../../common/types/field_stats'; import type { Field, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts index af4777a677bf..bd542c74898e 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts @@ -15,12 +15,12 @@ import type { ISearchOptions, ISearchStart, } from '@kbn/data-plugin/public'; -import { SAMPLER_TOP_TERMS_SHARD_SIZE, SAMPLER_TOP_TERMS_THRESHOLD } from './constants'; import { buildSamplerAggregation, getSamplerAggregationsResponsePath, -} from '../../../../../common/utils/query_utils'; -import { isPopulatedObject } from '../../../../../common/utils/object_utils'; + isPopulatedObject, +} from '@kbn/ml-data-utils'; +import { SAMPLER_TOP_TERMS_SHARD_SIZE, SAMPLER_TOP_TERMS_THRESHOLD } from './constants'; import type { Aggs, Bucket, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts index 6a25fac65efe..67e8c608033d 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts @@ -10,13 +10,15 @@ import { get } from 'lodash'; import { Query } from '@kbn/es-query'; import { IKibanaSearchResponse } from '@kbn/data-plugin/common'; import { - buildBaseFilterCriteria, buildSamplerAggregation, - getSafeAggregationName, getSamplerAggregationsResponsePath, + isPopulatedObject, +} from '@kbn/ml-data-utils'; +import { + buildBaseFilterCriteria, + getSafeAggregationName, } from '../../../../../common/utils/query_utils'; import { getDatafeedAggregations } from '../../../../../common/utils/datafeed_utils'; -import { isPopulatedObject } from '../../../../../common/utils/object_utils'; import { AggregatableField, NonAggregatableField } from '../../types/overall_stats'; import { AggCardinality, Aggs } from '../../../../../common/types/field_stats'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/error_utils.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/error_utils.ts index d89a9aca112b..284f3c330942 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/error_utils.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/error_utils.ts @@ -7,7 +7,7 @@ import { HttpFetchError } from '@kbn/core/public'; import Boom from '@hapi/boom'; -import { isPopulatedObject } from '../../../../common/utils/object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; export interface WrappedError { body: { diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/query_utils.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/query_utils.ts index 43c5d49d1986..e0131a42971a 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/query_utils.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/query_utils.ts @@ -7,7 +7,7 @@ import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import { cloneDeep } from 'lodash'; -import { isPopulatedObject } from '../../../../common/utils/object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; export const addExcludeFrozenToQuery = (originalQuery: QueryDslQueryContainer | undefined) => { const FROZEN_TIER_TERM = { diff --git a/x-pack/plugins/file_upload/common/utils.ts b/x-pack/plugins/file_upload/common/utils.ts deleted file mode 100644 index 5ef6c56392e5..000000000000 --- a/x-pack/plugins/file_upload/common/utils.ts +++ /dev/null @@ -1,19 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export const isPopulatedObject = ( - arg: unknown, - requiredAttributes: U[] = [] -): arg is Record => { - return ( - typeof arg === 'object' && - arg !== null && - Object.keys(arg).length > 0 && - (requiredAttributes.length === 0 || - requiredAttributes.every((d) => ({}.hasOwnProperty.call(arg, d)))) - ); -}; diff --git a/x-pack/plugins/file_upload/public/importer/importer.ts b/x-pack/plugins/file_upload/public/importer/importer.ts index 58809e736720..6ed59261d4f1 100644 --- a/x-pack/plugins/file_upload/public/importer/importer.ts +++ b/x-pack/plugins/file_upload/public/importer/importer.ts @@ -8,6 +8,7 @@ import { chunk, intersection } from 'lodash'; import moment from 'moment'; import { i18n } from '@kbn/i18n'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { getHttp } from '../kibana_services'; import { MB } from '../../common/constants'; import type { @@ -19,7 +20,6 @@ import type { IngestPipeline, } from '../../common/types'; import { CreateDocsResponse, IImporter, ImportResults } from './types'; -import { isPopulatedObject } from '../../common/utils'; const CHUNK_SIZE = 5000; const REDUCED_CHUNK_SIZE = 100; diff --git a/x-pack/plugins/file_upload/server/get_time_field_range.ts b/x-pack/plugins/file_upload/server/get_time_field_range.ts index e8b21e6807a8..1f434b8b7558 100644 --- a/x-pack/plugins/file_upload/server/get_time_field_range.ts +++ b/x-pack/plugins/file_upload/server/get_time_field_range.ts @@ -7,7 +7,7 @@ import { IScopedClusterClient } from '@kbn/core/server'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; -import { isPopulatedObject } from '../common/utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; export async function getTimeFieldRange( client: IScopedClusterClient, diff --git a/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts b/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts index 0daf9713d826..6901cf95ad1f 100644 --- a/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts +++ b/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts @@ -7,7 +7,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RUNTIME_FIELD_TYPES } from '@kbn/data-plugin/common'; -import { isPopulatedObject } from '../../common/utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; type RuntimeType = typeof RUNTIME_FIELD_TYPES[number]; diff --git a/x-pack/plugins/ml/common/index.ts b/x-pack/plugins/ml/common/index.ts index cfed678a804a..8d419f120a56 100644 --- a/x-pack/plugins/ml/common/index.ts +++ b/x-pack/plugins/ml/common/index.ts @@ -14,7 +14,6 @@ export { SEVERITY_COLORS, } from './constants/anomalies'; export { getSeverityColor, getSeverityType } from './util/anomaly_utils'; -export { isPopulatedObject } from './util/object_utils'; export { composeValidators, patternValidator } from './util/validators'; export { isRuntimeMappings, isRuntimeField } from './util/runtime_field_utils'; export { extractErrorMessage } from './util/errors'; diff --git a/x-pack/plugins/ml/common/types/es_client.ts b/x-pack/plugins/ml/common/types/es_client.ts index 44425619af39..4ebcf6af9e98 100644 --- a/x-pack/plugins/ml/common/types/es_client.ts +++ b/x-pack/plugins/ml/common/types/es_client.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { isPopulatedObject } from '../util/object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; export function isMultiBucketAggregate( arg: unknown diff --git a/x-pack/plugins/ml/common/types/feature_importance.ts b/x-pack/plugins/ml/common/types/feature_importance.ts index 111c8432dd43..02f45183b4ff 100644 --- a/x-pack/plugins/ml/common/types/feature_importance.ts +++ b/x-pack/plugins/ml/common/types/feature_importance.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '../util/object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; export type FeatureImportanceClassName = string | number | boolean; diff --git a/x-pack/plugins/ml/common/util/errors/process_errors.ts b/x-pack/plugins/ml/common/util/errors/process_errors.ts index e5c6ed38161a..2fb7a32f3511 100644 --- a/x-pack/plugins/ml/common/util/errors/process_errors.ts +++ b/x-pack/plugins/ml/common/util/errors/process_errors.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { ErrorType, MLErrorObject, @@ -14,7 +15,6 @@ import { isEsErrorBody, isMLResponseError, } from './types'; -import { isPopulatedObject } from '../object_utils'; export const extractErrorProperties = (error: ErrorType): MLErrorObject => { // extract properties of the error object from within the response error diff --git a/x-pack/plugins/ml/common/util/group_color_utils.ts b/x-pack/plugins/ml/common/util/group_color_utils.ts index b9709671475b..fc7e7c1c3c04 100644 --- a/x-pack/plugins/ml/common/util/group_color_utils.ts +++ b/x-pack/plugins/ml/common/util/group_color_utils.ts @@ -7,7 +7,7 @@ import { euiDarkVars as euiVars } from '@kbn/ui-theme'; -import { stringHash } from './string_utils'; +import { stringHash } from '@kbn/ml-data-utils'; const COLORS = [ euiVars.euiColorVis0, diff --git a/x-pack/plugins/ml/common/util/job_utils.ts b/x-pack/plugins/ml/common/util/job_utils.ts index f1991118d4e3..d3083f32d59a 100644 --- a/x-pack/plugins/ml/common/util/job_utils.ts +++ b/x-pack/plugins/ml/common/util/job_utils.ts @@ -12,6 +12,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // @ts-ignore import numeral from '@elastic/numeral'; import { i18n } from '@kbn/i18n'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { ALLOWED_DATA_UNITS, JOB_ID_MAX_LENGTH } from '../constants/validation'; import { parseInterval } from './parse_interval'; import { maxLengthValidator } from './validators'; @@ -24,7 +25,7 @@ import { ES_AGGREGATION, ML_JOB_AGGREGATION } from '../constants/aggregation_typ import { MLCATEGORY } from '../constants/field_types'; import { getAggregations, getDatafeedAggregations } from './datafeed_utils'; import { findAggField } from './validation_utils'; -import { getFirstKeyInObject, isPopulatedObject } from './object_utils'; +import { getFirstKeyInObject } from './object_utils'; import { isDefined } from '../types/guards'; export interface ValidationResults { diff --git a/x-pack/plugins/ml/common/util/object_utils.ts b/x-pack/plugins/ml/common/util/object_utils.ts index cd62ca006725..ab6c6575b1e2 100644 --- a/x-pack/plugins/ml/common/util/object_utils.ts +++ b/x-pack/plugins/ml/common/util/object_utils.ts @@ -5,35 +5,7 @@ * 2.0. */ -/* - * A type guard to check record like object structures. - * - * Examples: - * - `isPopulatedObject({...})` - * Limits type to Record - * - * - `isPopulatedObject({...}, ['attribute'])` - * Limits type to Record<'attribute', unknown> - * - * - `isPopulatedObject({...})` - * Limits type to a record with keys of the given interface. - * Note that you might want to add keys from the interface to the - * array of requiredAttributes to satisfy runtime requirements. - * Otherwise you'd just satisfy TS requirements but might still - * run into runtime issues. - */ -export const isPopulatedObject = ( - arg: unknown, - requiredAttributes: U[] = [] -): arg is Record => { - return ( - typeof arg === 'object' && - arg !== null && - Object.keys(arg).length > 0 && - (requiredAttributes.length === 0 || - requiredAttributes.every((d) => ({}.hasOwnProperty.call(arg, d)))) - ); -}; +import { isPopulatedObject } from '@kbn/ml-data-utils'; /** * Get the first key in the object diff --git a/x-pack/plugins/ml/common/util/query_utils.ts b/x-pack/plugins/ml/common/util/query_utils.ts index 22c0f45f2f23..e0131a42971a 100644 --- a/x-pack/plugins/ml/common/util/query_utils.ts +++ b/x-pack/plugins/ml/common/util/query_utils.ts @@ -7,7 +7,7 @@ import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import { cloneDeep } from 'lodash'; -import { isPopulatedObject } from './object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; export const addExcludeFrozenToQuery = (originalQuery: QueryDslQueryContainer | undefined) => { const FROZEN_TIER_TERM = { diff --git a/x-pack/plugins/ml/common/util/runtime_field_utils.ts b/x-pack/plugins/ml/common/util/runtime_field_utils.ts index 6b2cb78d7327..e65b33e825ff 100644 --- a/x-pack/plugins/ml/common/util/runtime_field_utils.ts +++ b/x-pack/plugins/ml/common/util/runtime_field_utils.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RUNTIME_FIELD_TYPES } from '@kbn/data-plugin/common'; -import { isPopulatedObject } from './object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; type RuntimeType = typeof RUNTIME_FIELD_TYPES[number]; diff --git a/x-pack/plugins/ml/common/util/string_utils.ts b/x-pack/plugins/ml/common/util/string_utils.ts index 044b34d166a8..d55d007ceb22 100644 --- a/x-pack/plugins/ml/common/util/string_utils.ts +++ b/x-pack/plugins/ml/common/util/string_utils.ts @@ -24,23 +24,6 @@ export function getMedianStringLength(strings: string[]) { return sortedStringLengths[Math.floor(sortedStringLengths.length / 2)] || 0; } -/** - * Creates a deterministic number based hash out of a string. - */ -export function stringHash(str: string): number { - let hash = 0; - let chr = 0; - if (str.length === 0) { - return hash; - } - for (let i = 0; i < str.length; i++) { - chr = str.charCodeAt(i); - hash = (hash << 5) - hash + chr; // eslint-disable-line no-bitwise - hash |= 0; // eslint-disable-line no-bitwise - } - return hash < 0 ? hash * -2 : hash; -} - export function getGroupQueryText(groupIds: string[]): string { return `groups:(${groupIds.join(' or ')})`; } diff --git a/x-pack/plugins/ml/common/util/validators.ts b/x-pack/plugins/ml/common/util/validators.ts index 0936efbcb00f..7a7b0c930591 100644 --- a/x-pack/plugins/ml/common/util/validators.ts +++ b/x-pack/plugins/ml/common/util/validators.ts @@ -5,9 +5,9 @@ * 2.0. */ +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { ALLOWED_DATA_UNITS } from '../constants/validation'; import { parseInterval } from './parse_interval'; -import { isPopulatedObject } from './object_utils'; /** * Provides a validator function for maximum allowed input length. diff --git a/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx b/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx index dcbf580461e0..9e5c82b06723 100644 --- a/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx +++ b/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx @@ -11,13 +11,13 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import useDebounce from 'react-use/lib/useDebounce'; import { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plugin/public'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { MlAnomalyDetectionJobsHealthRuleParams } from '../../../common/types/alerts'; import { JobSelectorControl } from '../job_selector'; import { jobsApiProvider } from '../../application/services/ml_api_service/jobs'; import { HttpService } from '../../application/services/http_service'; import { useMlKibana } from '../../application/contexts/kibana'; import { TestsSelectionControl } from './tests_selection_control'; -import { isPopulatedObject } from '../../../common'; import { ALL_JOBS_SELECTION } from '../../../common/constants/alerts'; import { BetaBadge } from '../beta_badge'; import { isDefined } from '../../../common/types/guards'; diff --git a/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx b/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx index 82ae72503838..e03f6ed3224e 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx +++ b/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx @@ -27,6 +27,7 @@ import { } from '@elastic/eui'; import { CoreSetup } from '@kbn/core/public'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { DEFAULT_SAMPLER_SHARD_SIZE } from '../../../../common/constants/field_histograms'; import { ANALYSIS_CONFIG_TYPE, INDEX_STATUS } from '../../data_frame_analytics/common'; @@ -44,7 +45,6 @@ import { FeatureImportance, TopClasses, } from '../../../../common/types/feature_importance'; -import { isPopulatedObject } from '../../../../common/util/object_utils'; import { DEFAULT_RESULTS_FIELD } from '../../../../common/constants/data_frame_analytics'; import { DataFrameAnalysisConfigType } from '../../../../common/types/data_frame_analytics'; diff --git a/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts b/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts index c83836164221..6ae9471e8795 100644 --- a/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts +++ b/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts @@ -11,9 +11,9 @@ import { i18n } from '@kbn/i18n'; import dateMath from '@kbn/datemath'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import type { DataView } from '@kbn/data-views-plugin/public'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { getTimefilter, getToastNotifications } from '../../util/dependency_cache'; import { ml, GetTimeFieldRangeResponse } from '../../services/ml_api_service'; -import { isPopulatedObject } from '../../../../common/util/object_utils'; import type { RuntimeMappings } from '../../../../common/types/fields'; import { addExcludeFrozenToQuery } from '../../../../common/util/query_utils'; diff --git a/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx b/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx index b93ba79830f9..f4a9a6ce8888 100644 --- a/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx +++ b/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx @@ -25,9 +25,9 @@ import { import { i18n } from '@kbn/i18n'; import { DataView } from '@kbn/data-views-plugin/public'; +import { stringHash } from '@kbn/ml-data-utils'; import { extractErrorMessage } from '../../../../common'; import { isRuntimeMappings } from '../../../../common/util/runtime_field_utils'; -import { stringHash } from '../../../../common/util/string_utils'; import { RuntimeMappings } from '../../../../common/types/fields'; import type { ResultsSearchQuery } from '../../data_frame_analytics/common/analytics'; import { getCombinedRuntimeMappings } from '../data_grid'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/runtime_mappings/runtime_mappings.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/runtime_mappings/runtime_mappings.tsx index 9de32fdd5bd3..f5dc259ffb84 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/runtime_mappings/runtime_mappings.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/runtime_mappings/runtime_mappings.tsx @@ -21,10 +21,10 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { XJsonMode } from '@kbn/ace'; import { XJson } from '@kbn/es-ui-shared-plugin/public'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { useMlContext } from '../../../../../contexts/ml'; import { CreateAnalyticsFormProps } from '../../../analytics_management/hooks/use_create_analytics_form'; import { getCombinedRuntimeMappings } from '../../../../../components/data_grid/common'; -import { isPopulatedObject } from '../../../../../../../common/util/object_utils'; import { RuntimeMappingsEditor } from './runtime_mappings_editor'; import { isRuntimeMappings } from '../../../../../../../common'; import { SwitchModal } from './switch_modal'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts index dac1a85211c2..fc1151da9a98 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts @@ -5,11 +5,11 @@ * 2.0. */ +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { usePageUrlState } from '../../../../util/url_state'; import { ML_PAGES } from '../../../../../../common/constants/locator'; import { ExplorationPageUrlState } from '../../../../../../common/types/locator'; import { SEARCH_QUERY_LANGUAGE } from '../../../../../../common/constants/search'; -import { isPopulatedObject } from '../../../../../../common/util/object_utils'; export function getDefaultExplorationPageUrlState( overrides?: Partial diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js index d6926950dce7..d826c90a2021 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js @@ -21,7 +21,7 @@ import { JOB_STATE, DATAFEED_STATE } from '../../../../../common/constants/state import { JOB_ACTION } from '../../../../../common/constants/job_actions'; import { parseInterval } from '../../../../../common/util/parse_interval'; import { mlCalendarService } from '../../../services/calendar_service'; -import { isPopulatedObject } from '../../../../../common/util/object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; export function loadFullJob(jobId) { return new Promise((resolve, reject) => { diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_utils.ts b/x-pack/plugins/ml/public/application/jobs/jobs_utils.ts index 103f079b88ff..85b18fc159dc 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_utils.ts +++ b/x-pack/plugins/ml/public/application/jobs/jobs_utils.ts @@ -6,7 +6,7 @@ */ import { MlJob } from '@elastic/elasticsearch/lib/api/types'; -import { isPopulatedObject } from '../../../common'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { MlSummaryJob } from '../../../common/types/anomaly_detection_jobs'; export const isManagedJob = (job: MlSummaryJob | MlJob) => { diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.ts index 9f6f30189174..14ba4151e4a8 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.ts @@ -5,9 +5,9 @@ * 2.0. */ +import { isPopulatedObject } from '@kbn/ml-data-utils'; import type { RuntimeMappings } from '../../../../../../../common/types/fields'; import type { Datafeed, Job } from '../../../../../../../common/types/anomaly_detection_jobs'; -import { isPopulatedObject } from '../../../../../../../common/util/object_utils'; interface Response { runtime_mappings: RuntimeMappings; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx index c370778b178c..094ba883c1fd 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx @@ -19,6 +19,7 @@ import { } from '@elastic/eui'; import { merge } from 'lodash'; import moment from 'moment'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { useMlKibana, useMlLocator } from '../../../contexts/kibana'; import { ml } from '../../../services/ml_api_service'; import { useMlContext } from '../../../contexts/ml'; @@ -40,7 +41,6 @@ import { JobId } from '../../../../../common/types/anomaly_detection_jobs'; import { ML_PAGES } from '../../../../../common/constants/locator'; import { TIME_FORMAT } from '../../../../../common/constants/time_format'; import { JobsAwaitingNodeWarning } from '../../../components/jobs_awaiting_node_warning'; -import { isPopulatedObject } from '../../../../../common/util/object_utils'; import { RuntimeMappings } from '../../../../../common/types/fields'; import { addExcludeFrozenToQuery } from '../../../../../common/util/query_utils'; import { MlPageHeader } from '../../../components/page_header'; diff --git a/x-pack/plugins/ml/public/application/services/anomaly_explorer_charts_service.ts b/x-pack/plugins/ml/public/application/services/anomaly_explorer_charts_service.ts index 0ed3b511b669..69401dc5c59f 100644 --- a/x-pack/plugins/ml/public/application/services/anomaly_explorer_charts_service.ts +++ b/x-pack/plugins/ml/public/application/services/anomaly_explorer_charts_service.ts @@ -9,12 +9,12 @@ import { Observable, of } from 'rxjs'; import { map as mapObservable } from 'rxjs/operators'; import type { TimeRange } from '@kbn/es-query'; import type { TimefilterContract } from '@kbn/data-plugin/public'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import type { RecordForInfluencer } from './results_service/results_service'; import type { EntityField } from '../../../common/util/anomaly_utils'; import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs'; import type { MlApiServices } from './ml_api_service'; import type { MlResultsService } from './results_service'; -import { isPopulatedObject } from '../../../common/util/object_utils'; import { ExplorerChartsData } from '../explorer/explorer_charts/explorer_charts_container_service'; import type { TimeRangeBounds } from '../util/time_buckets'; import { isDefined } from '../../../common/types/guards'; diff --git a/x-pack/plugins/ml/public/application/services/anomaly_timeline_service.ts b/x-pack/plugins/ml/public/application/services/anomaly_timeline_service.ts index cbe4017a0283..929826a7f3f5 100644 --- a/x-pack/plugins/ml/public/application/services/anomaly_timeline_service.ts +++ b/x-pack/plugins/ml/public/application/services/anomaly_timeline_service.ts @@ -8,6 +8,7 @@ import { IUiSettingsClient } from '@kbn/core/public'; import type { TimeRange } from '@kbn/es-query'; import { TimefilterContract, UI_SETTINGS } from '@kbn/data-plugin/public'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { getBoundsRoundedToInterval, TimeBuckets, @@ -24,7 +25,6 @@ import { OVERALL_LABEL, VIEW_BY_JOB_LABEL } from '../explorer/explorer_constants import { MlResultsService } from './results_service'; import { EntityField } from '../../../common/util/anomaly_utils'; import { InfluencersFilterQuery } from '../../../common/types/es_client'; -import { isPopulatedObject } from '../../../common'; /** * Service for retrieving anomaly swim lanes data. diff --git a/x-pack/plugins/ml/public/application/services/results_service/result_service_rx.ts b/x-pack/plugins/ml/public/application/services/results_service/result_service_rx.ts index 54dece80f22c..5972317c3dff 100644 --- a/x-pack/plugins/ml/public/application/services/results_service/result_service_rx.ts +++ b/x-pack/plugins/ml/public/application/services/results_service/result_service_rx.ts @@ -15,6 +15,7 @@ import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { each, get } from 'lodash'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { Dictionary } from '../../../../common/types/common'; import { ML_MEDIAN_PERCENTS } from '../../../../common/util/job_utils'; import { Datafeed, JobId } from '../../../../common/types/anomaly_detection_jobs'; @@ -24,7 +25,6 @@ import { findAggField } from '../../../../common/util/validation_utils'; import { getDatafeedAggregations } from '../../../../common/util/datafeed_utils'; import { aggregationTypeTransform, EntityField } from '../../../../common/util/anomaly_utils'; import { ES_AGGREGATION } from '../../../../common/constants/aggregation_types'; -import { isPopulatedObject } from '../../../../common/util/object_utils'; import { InfluencersFilterQuery } from '../../../../common/types/es_client'; import { RecordForInfluencer } from './results_service'; import { isRuntimeMappings } from '../../../../common'; diff --git a/x-pack/plugins/ml/public/application/services/results_service/results_service.js b/x-pack/plugins/ml/public/application/services/results_service/results_service.js index bb6f6b5969ac..97f0f7cae917 100644 --- a/x-pack/plugins/ml/public/application/services/results_service/results_service.js +++ b/x-pack/plugins/ml/public/application/services/results_service/results_service.js @@ -7,6 +7,8 @@ import { each, get } from 'lodash'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; + import { ML_MEDIAN_PERCENTS } from '../../../../common/util/job_utils'; import { escapeForElasticsearchQuery } from '../../util/string_utils'; import { @@ -14,7 +16,6 @@ import { SWIM_LANE_DEFAULT_PAGE_SIZE, } from '../../explorer/explorer_constants'; import { aggregationTypeTransform } from '../../../../common/util/anomaly_utils'; -import { isPopulatedObject } from '../../../../common/util/object_utils'; /** * Service for carrying out Elasticsearch queries to obtain data for the Ml Results dashboards. diff --git a/x-pack/plugins/ml/public/application/trained_models/models_management/expanded_row.tsx b/x-pack/plugins/ml/public/application/trained_models/models_management/expanded_row.tsx index 8b868a088499..49d1127a96b1 100644 --- a/x-pack/plugins/ml/public/application/trained_models/models_management/expanded_row.tsx +++ b/x-pack/plugins/ml/public/application/trained_models/models_management/expanded_row.tsx @@ -23,9 +23,9 @@ import { import type { EuiDescriptionListProps } from '@elastic/eui/src/components/description_list/description_list'; import { FormattedMessage } from '@kbn/i18n-react'; import { FIELD_FORMAT_IDS } from '@kbn/field-formats-plugin/common'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import type { ModelItemFull } from './models_list'; import { isDefined } from '../../../../common/types/guards'; -import { isPopulatedObject } from '../../../../common'; import { ModelPipelines } from './pipelines'; import { AllocatedModels } from '../nodes_overview/allocated_models'; import type { AllocatedModel } from '../../../../common/types/trained_models'; diff --git a/x-pack/plugins/ml/public/application/trained_models/models_management/models_list.tsx b/x-pack/plugins/ml/public/application/trained_models/models_management/models_list.tsx index 4f3cef2eeda1..4a9c80c02e41 100644 --- a/x-pack/plugins/ml/public/application/trained_models/models_management/models_list.tsx +++ b/x-pack/plugins/ml/public/application/trained_models/models_management/models_list.tsx @@ -26,6 +26,7 @@ import { EuiBasicTableColumn } from '@elastic/eui/src/components/basic_table/bas import { EuiTableSelectionType } from '@elastic/eui/src/components/basic_table/table_types'; import { Action } from '@elastic/eui/src/components/basic_table/action_types'; import { FIELD_FORMAT_IDS } from '@kbn/field-formats-plugin/common'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { getAnalysisType } from '../../data_frame_analytics/common'; import { ModelsTableToConfigMapping } from '.'; import { ModelsBarStats, StatsBar } from '../../components/stats_bar'; @@ -44,7 +45,6 @@ import { ML_PAGES } from '../../../../common/constants/locator'; import { ListingPageUrlState } from '../../../../common/types/common'; import { usePageUrlState } from '../../util/url_state'; import { ExpandedRow } from './expanded_row'; -import { isPopulatedObject } from '../../../../common'; import { useTableSettings } from '../../data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings'; import { useToastNotificationService } from '../../services/toast_notification_service'; import { useFieldFormatter } from '../../contexts/kibana/use_field_formatter'; diff --git a/x-pack/plugins/ml/public/application/trained_models/models_management/test_models/utils.ts b/x-pack/plugins/ml/public/application/trained_models/models_management/test_models/utils.ts index 3ac6ec77f576..4c9f7d2188ac 100644 --- a/x-pack/plugins/ml/public/application/trained_models/models_management/test_models/utils.ts +++ b/x-pack/plugins/ml/public/application/trained_models/models_management/test_models/utils.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { TRAINED_MODEL_TYPE, DEPLOYMENT_STATE, @@ -13,8 +14,6 @@ import { import type { SupportedPytorchTasksType } from '../../../../../common/constants/trained_models'; import type { ModelItem } from '../models_list'; -import { isPopulatedObject } from '../../../../../common'; - const PYTORCH_TYPES = Object.values(SUPPORTED_PYTORCH_TASKS); export function isTestable(modelItem: ModelItem) { diff --git a/x-pack/plugins/ml/public/application/util/url_state.tsx b/x-pack/plugins/ml/public/application/util/url_state.tsx index 42d5c012b9c1..19866f701d20 100644 --- a/x-pack/plugins/ml/public/application/util/url_state.tsx +++ b/x-pack/plugins/ml/public/application/util/url_state.tsx @@ -21,11 +21,11 @@ import { useHistory, useLocation } from 'react-router-dom'; import { BehaviorSubject, Observable } from 'rxjs'; import { distinctUntilChanged } from 'rxjs/operators'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { Dictionary } from '../../../common/types/common'; import { getNestedProperty } from './object_utils'; import { MlPages } from '../../../common/constants/locator'; -import { isPopulatedObject } from '../../../common'; type Accessor = '_a' | '_g'; export type SetUrlState = ( diff --git a/x-pack/plugins/ml/public/embeddables/types.ts b/x-pack/plugins/ml/public/embeddables/types.ts index 2ba4af15f746..7127ba6a62f3 100644 --- a/x-pack/plugins/ml/public/embeddables/types.ts +++ b/x-pack/plugins/ml/public/embeddables/types.ts @@ -10,6 +10,7 @@ import type { Filter, Query, TimeRange } from '@kbn/es-query'; import type { RefreshInterval } from '@kbn/data-plugin/common'; import type { EmbeddableInput, EmbeddableOutput, IEmbeddable } from '@kbn/embeddable-plugin/public'; import type { DataView } from '@kbn/data-views-plugin/common'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import type { JobId } from '../../common/types/anomaly_detection_jobs'; import type { SwimlaneType } from '../application/explorer/explorer_constants'; import type { AnomalyDetectorService } from '../application/services/anomaly_detector_service'; @@ -18,7 +19,6 @@ import type { MlDependencies } from '../application/app'; import type { AppStateSelectedCells } from '../application/explorer/explorer_utils'; import { AnomalyExplorerChartsService } from '../application/services/anomaly_explorer_charts_service'; import { EntityField } from '../../common/util/anomaly_utils'; -import { isPopulatedObject } from '../../common/util/object_utils'; import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE, ANOMALY_SWIMLANE_EMBEDDABLE_TYPE, diff --git a/x-pack/plugins/ml/server/lib/query_utils.ts b/x-pack/plugins/ml/server/lib/query_utils.ts index cfaa5abaf7f2..a60622583781 100644 --- a/x-pack/plugins/ml/server/lib/query_utils.ts +++ b/x-pack/plugins/ml/server/lib/query_utils.ts @@ -5,7 +5,6 @@ * 2.0. */ -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; /* * Contains utility functions for building and processing queries. */ @@ -37,32 +36,3 @@ export function buildBaseFilterCriteria( return filterCriteria; } - -// Wraps the supplied aggregations in a sampler aggregation. -// A supplied samplerShardSize (the shard_size parameter of the sampler aggregation) -// of less than 1 indicates no sampling, and the aggs are returned as-is. -export function buildSamplerAggregation( - aggs: any, - samplerShardSize: number -): Record { - if (samplerShardSize < 1) { - return aggs; - } - - return { - sample: { - sampler: { - shard_size: samplerShardSize, - }, - aggs, - }, - }; -} - -// Returns the path of aggregations in the elasticsearch response, as an array, -// depending on whether sampling is being used. -// A supplied samplerShardSize (the shard_size parameter of the sampler aggregation) -// of less than 1 indicates no sampling, and an empty array is returned. -export function getSamplerAggregationsResponsePath(samplerShardSize: number): string[] { - return samplerShardSize > 0 ? ['sample'] : []; -} 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 9bf107106a05..9c3d4dcfb1a0 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 @@ -17,6 +17,7 @@ import type { import moment from 'moment'; import { merge } from 'lodash'; import type { DataViewsService } from '@kbn/data-views-plugin/common'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import type { AnalysisLimits } from '../../../common/types/anomaly_detection_jobs'; import { getAuthorizationHeader } from '../../lib/request_authorization'; import type { MlClient } from '../../lib/ml_client'; @@ -54,7 +55,6 @@ import type { JobExistResult, JobStat } from '../../../common/types/data_recogni import type { Datafeed } from '../../../common/types/anomaly_detection_jobs'; import type { MLSavedObjectService } from '../../saved_objects'; import { isDefined } from '../../../common/types/guards'; -import { isPopulatedObject } from '../../../common/util/object_utils'; const ML_DIR = 'ml'; const KIBANA_DIR = 'kibana'; 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 bbfc43257caf..e96d27e49669 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 @@ -5,21 +5,23 @@ * 2.0. */ -import { IScopedClusterClient } from '@kbn/core/server'; import { get, each, last, find } from 'lodash'; + +import { IScopedClusterClient } from '@kbn/core/server'; import { KBN_FIELD_TYPES } from '@kbn/data-plugin/server'; -import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types'; -import { getSafeAggregationName } from '../../../common/util/job_utils'; -import { stringHash } from '../../../common/util/string_utils'; import { - buildBaseFilterCriteria, buildSamplerAggregation, + getAggIntervals, getSamplerAggregationsResponsePath, -} from '../../lib/query_utils'; + isPopulatedObject, + stringHash, +} from '@kbn/ml-data-utils'; +import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types'; +import { getSafeAggregationName } from '../../../common/util/job_utils'; +import { buildBaseFilterCriteria } from '../../lib/query_utils'; import { AggCardinality, RuntimeMappings } from '../../../common/types/fields'; import { getDatafeedAggregations } from '../../../common/util/datafeed_utils'; import { Datafeed } from '../../../common/types/anomaly_detection_jobs'; -import { isPopulatedObject } from '../../../common/util/object_utils'; const SAMPLER_TOP_TERMS_THRESHOLD = 100000; const SAMPLER_TOP_TERMS_SHARD_SIZE = 5000; @@ -112,13 +114,6 @@ interface FieldExamples { examples: any[]; } -interface NumericColumnStats { - interval: number; - min: number; - max: number; -} -type NumericColumnStatsMap = Record; - interface AggHistogram { histogram: { field: string; @@ -178,67 +173,6 @@ type BatchStats = | DocumentCountStats | FieldExamples; -const getAggIntervals = async ( - { asCurrentUser }: IScopedClusterClient, - indexPattern: string, - query: any, - fields: HistogramField[], - samplerShardSize: number, - runtimeMappings?: RuntimeMappings -): Promise => { - const numericColumns = fields.filter((field) => { - return field.type === KBN_FIELD_TYPES.NUMBER || field.type === KBN_FIELD_TYPES.DATE; - }); - - if (numericColumns.length === 0) { - return {}; - } - - const minMaxAggs = numericColumns.reduce((aggs, c) => { - const id = stringHash(c.fieldName); - aggs[id] = { - stats: { - field: c.fieldName, - }, - }; - return aggs; - }, {} as Record); - - const body = await asCurrentUser.search( - { - index: indexPattern, - size: 0, - body: { - query, - aggs: buildSamplerAggregation(minMaxAggs, samplerShardSize), - size: 0, - ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), - }, - }, - { maxRetries: 0 } - ); - - const aggsPath = getSamplerAggregationsResponsePath(samplerShardSize); - const aggregations = aggsPath.length > 0 ? get(body.aggregations, aggsPath) : body.aggregations; - - return Object.keys(aggregations).reduce((p, aggName) => { - const stats = [aggregations[aggName].min, aggregations[aggName].max]; - if (!stats.includes(null)) { - const delta = aggregations[aggName].max - aggregations[aggName].min; - - let aggInterval = 1; - - if (delta > MAX_CHART_COLUMNS || delta <= 1) { - aggInterval = delta / (MAX_CHART_COLUMNS - 1); - } - - p[aggName] = { interval: aggInterval, min: stats[0], max: stats[1] }; - } - - return p; - }, {} as NumericColumnStatsMap); -}; - // export for re-use by transforms plugin export const getHistogramsForFields = async ( client: IScopedClusterClient, @@ -250,7 +184,7 @@ export const getHistogramsForFields = async ( ) => { const { asCurrentUser } = client; const aggIntervals = await getAggIntervals( - client, + client.asCurrentUser, indexPattern, query, fields, 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 64348a065600..2417eb18ff0c 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 @@ -8,6 +8,7 @@ import Boom from '@hapi/boom'; import { IScopedClusterClient } from '@kbn/core/server'; import { duration } from 'moment'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { parseInterval } from '../../../common/util/parse_interval'; import { initCardinalityFieldsCache } from './fields_aggs_cache'; import { AggCardinality } from '../../../common/types/fields'; @@ -15,7 +16,6 @@ import { isValidAggregationField } from '../../../common/util/validation_utils'; import { getDatafeedAggregations } from '../../../common/util/datafeed_utils'; import { Datafeed, IndicesOptions } from '../../../common/types/anomaly_detection_jobs'; import { RuntimeMappings } from '../../../common/types/fields'; -import { isPopulatedObject } from '../../../common/util/object_utils'; /** * Service for carrying out queries to obtain data 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 1ffa9687fca9..b6b0ba151842 100644 --- a/x-pack/plugins/ml/server/models/job_service/jobs.ts +++ b/x-pack/plugins/ml/server/models/job_service/jobs.ts @@ -9,6 +9,7 @@ import { uniq } from 'lodash'; import Boom from '@hapi/boom'; import { IScopedClusterClient } from '@kbn/core/server'; import type { RulesClient } from '@kbn/alerting-plugin/server'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { getSingleMetricViewerJobErrorMessage, parseTimeIntervalForJob, @@ -47,7 +48,6 @@ import { } from '../../../common/util/job_utils'; import { groupsProvider } from './groups'; import type { MlClient } from '../../lib/ml_client'; -import { isPopulatedObject } from '../../../common/util/object_utils'; import { ML_ALERT_TYPES } from '../../../common/constants/alerts'; import { MlAnomalyDetectionAlertParams } from '../../routes/schemas/alerting_schema'; import type { AuthorizationHeader } from '../../lib/request_authorization'; diff --git a/x-pack/plugins/ml/server/models/results_service/anomaly_charts.ts b/x-pack/plugins/ml/server/models/results_service/anomaly_charts.ts index dd7e2b3373e8..689e0e5addbf 100644 --- a/x-pack/plugins/ml/server/models/results_service/anomaly_charts.ts +++ b/x-pack/plugins/ml/server/models/results_service/anomaly_charts.ts @@ -10,8 +10,9 @@ import { i18n } from '@kbn/i18n'; import { each, find, get, keyBy, map, reduce, sortBy } from 'lodash'; import type * as estypes from '@elastic/elasticsearch/lib/api/types'; import { extent, max, min } from 'd3'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import type { MlClient } from '../../lib/ml_client'; -import { isPopulatedObject, isRuntimeMappings } from '../../../common'; +import { isRuntimeMappings } from '../../../common'; import type { MetricData, ModelPlotOutput, diff --git a/x-pack/plugins/transform/common/api_schemas/type_guards.ts b/x-pack/plugins/transform/common/api_schemas/type_guards.ts index 567eeb030e22..5d09f355e0e6 100644 --- a/x-pack/plugins/transform/common/api_schemas/type_guards.ts +++ b/x-pack/plugins/transform/common/api_schemas/type_guards.ts @@ -7,9 +7,10 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; + import type { EsIndex } from '../types/es_index'; import type { EsIngestPipeline } from '../types/es_ingest_pipeline'; -import { isPopulatedObject } from '../shared_imports'; // To be able to use the type guards on the client side, we need to make sure we don't import // the code of '@kbn/config-schema' but just its types, otherwise the client side code will diff --git a/x-pack/plugins/transform/common/shared_imports.ts b/x-pack/plugins/transform/common/shared_imports.ts index 0566086046d0..fd00440e07c5 100644 --- a/x-pack/plugins/transform/common/shared_imports.ts +++ b/x-pack/plugins/transform/common/shared_imports.ts @@ -8,7 +8,6 @@ export type { ChartData } from '@kbn/ml-plugin/common'; export { composeValidators, - isPopulatedObject, isRuntimeMappings, patternValidator, isRuntimeField, diff --git a/x-pack/plugins/transform/common/types/data_view.ts b/x-pack/plugins/transform/common/types/data_view.ts index 98787a1281db..72480aba56ef 100644 --- a/x-pack/plugins/transform/common/types/data_view.ts +++ b/x-pack/plugins/transform/common/types/data_view.ts @@ -6,8 +6,7 @@ */ import type { DataView } from '@kbn/data-views-plugin/common'; - -import { isPopulatedObject } from '../shared_imports'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; // Custom minimal type guard for DataView to check against the attributes used in transforms code. export function isDataView(arg: any): arg is DataView { diff --git a/x-pack/plugins/transform/common/types/transform.ts b/x-pack/plugins/transform/common/types/transform.ts index a196111bf667..2a51f3f84c1d 100644 --- a/x-pack/plugins/transform/common/types/transform.ts +++ b/x-pack/plugins/transform/common/types/transform.ts @@ -6,8 +6,8 @@ */ import type { EuiComboBoxOptionOption } from '@elastic/eui/src/components/combo_box/types'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import type { LatestFunctionConfig, PutTransformsRequestSchema } from '../api_schemas/transforms'; -import { isPopulatedObject } from '../shared_imports'; import type { PivotGroupByDict } from './pivot_group_by'; import type { PivotAggDict } from './pivot_aggs'; import type { TransformHealthAlertRule } from './alerting'; diff --git a/x-pack/plugins/transform/common/types/transform_stats.ts b/x-pack/plugins/transform/common/types/transform_stats.ts index 00ffa40b84d3..feee0f6e47b3 100644 --- a/x-pack/plugins/transform/common/types/transform_stats.ts +++ b/x-pack/plugins/transform/common/types/transform_stats.ts @@ -5,8 +5,9 @@ * 2.0. */ +import { isPopulatedObject } from '@kbn/ml-data-utils'; + import { TransformState, TRANSFORM_STATE } from '../constants'; -import { isPopulatedObject } from '../shared_imports'; import { TransformId } from './transform'; export interface TransformStats { diff --git a/x-pack/plugins/transform/common/utils/errors.ts b/x-pack/plugins/transform/common/utils/errors.ts index 2aff8f332b13..cff47f4e5998 100644 --- a/x-pack/plugins/transform/common/utils/errors.ts +++ b/x-pack/plugins/transform/common/utils/errors.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '../shared_imports'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; export interface ErrorResponse { body: { diff --git a/x-pack/plugins/transform/public/app/common/pivot_aggs.ts b/x-pack/plugins/transform/public/app/common/pivot_aggs.ts index 9045191a779c..bff971cfb9e4 100644 --- a/x-pack/plugins/transform/public/app/common/pivot_aggs.ts +++ b/x-pack/plugins/transform/public/app/common/pivot_aggs.ts @@ -8,13 +8,13 @@ import { FC } from 'react'; import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/data-plugin/common'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import type { AggName } from '../../../common/types/aggregations'; import type { Dictionary } from '../../../common/types/common'; import type { EsFieldName } from '../../../common/types/fields'; import type { PivotAgg, PivotSupportedAggs } from '../../../common/types/pivot_aggs'; import { PIVOT_SUPPORTED_AGGS } from '../../../common/types/pivot_aggs'; -import { isPopulatedObject } from '../../../common/shared_imports'; import { getAggFormConfig } from '../sections/create_transform/components/step_define/common/get_agg_form_config'; import { PivotAggsConfigFilter } from '../sections/create_transform/components/step_define/common/filter_agg/types'; diff --git a/x-pack/plugins/transform/public/app/common/pivot_group_by.ts b/x-pack/plugins/transform/public/app/common/pivot_group_by.ts index dd9a63088e79..1f11b5046367 100644 --- a/x-pack/plugins/transform/public/app/common/pivot_group_by.ts +++ b/x-pack/plugins/transform/public/app/common/pivot_group_by.ts @@ -6,11 +6,11 @@ */ import { KBN_FIELD_TYPES } from '@kbn/data-plugin/common'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { AggName } from '../../../common/types/aggregations'; import { Dictionary } from '../../../common/types/common'; import { EsFieldName } from '../../../common/types/fields'; import { GenericAgg } from '../../../common/types/pivot_group_by'; -import { isPopulatedObject } from '../../../common/shared_imports'; import { PivotAggsConfigWithUiSupport } from './pivot_aggs'; export enum PIVOT_SUPPORTED_GROUP_BY_AGGS { diff --git a/x-pack/plugins/transform/public/app/common/request.ts b/x-pack/plugins/transform/public/app/common/request.ts index 350f57a3bcf5..a4812882c835 100644 --- a/x-pack/plugins/transform/public/app/common/request.ts +++ b/x-pack/plugins/transform/public/app/common/request.ts @@ -9,6 +9,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HttpFetchError } from '@kbn/core/public'; import type { DataView } from '@kbn/data-views-plugin/public'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { DEFAULT_CONTINUOUS_MODE_DELAY, @@ -23,7 +24,6 @@ import type { PutTransformsPivotRequestSchema, PutTransformsRequestSchema, } from '../../../common/api_schemas/transforms'; -import { isPopulatedObject } from '../../../common/shared_imports'; import { DateHistogramAgg, HistogramAgg, TermsAgg } from '../../../common/types/pivot_group_by'; import { isDataView } from '../../../common/types/data_view'; diff --git a/x-pack/plugins/transform/public/app/lib/authorization/components/common.ts b/x-pack/plugins/transform/public/app/lib/authorization/components/common.ts index 659d52564396..d18eda3cce31 100644 --- a/x-pack/plugins/transform/public/app/lib/authorization/components/common.ts +++ b/x-pack/plugins/transform/public/app/lib/authorization/components/common.ts @@ -6,9 +6,9 @@ */ import { i18n } from '@kbn/i18n'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { Privileges } from '../../../../../common/types/privileges'; -import { isPopulatedObject } from '../../../../../common/shared_imports'; export interface Capabilities { canGetTransform: boolean; diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx index 649683182dca..dff865b19c01 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx @@ -30,6 +30,7 @@ import { DISCOVER_APP_LOCATOR } from '@kbn/discover-plugin/public'; import { DuplicateDataViewError } from '@kbn/data-plugin/public'; import type { RuntimeField } from '@kbn/data-views-plugin/common'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import type { PutTransformsResponseSchema } from '../../../../../../common/api_schemas/transforms'; import { isGetTransformsStatsResponseSchema, @@ -49,7 +50,6 @@ import { PutTransformsLatestRequestSchema, PutTransformsPivotRequestSchema, } from '../../../../../../common/api_schemas/transforms'; -import { isPopulatedObject } from '../../../../../../common/shared_imports'; import { isContinuousTransform, isLatestTransform } from '../../../../../../common/types/transform'; import { TransformAlertFlyout } from '../../../../../alerting/transform_alerting_flyout'; diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_agg_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_agg_form.tsx index 6f590a0e1789..551c0133cd18 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_agg_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_agg_form.tsx @@ -10,13 +10,13 @@ import { EuiFormRow, EuiIcon, EuiSelect, EuiToolTip } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import useUpdateEffect from 'react-use/lib/useUpdateEffect'; import { DataView } from '@kbn/data-views-plugin/public'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { CreateTransformWizardContext } from '../../../../wizard/wizard'; import { commonFilterAggs, filterAggsFieldSupport } from '../constants'; import { getFilterAggTypeConfig } from '../config'; import type { FilterAggType, PivotAggsConfigFilter } from '../types'; import type { RuntimeMappings } from '../../types'; import { getKibanaFieldTypeFromEsType } from '../../get_pivot_dropdown_options'; -import { isPopulatedObject } from '../../../../../../../../../common/shared_imports'; /** * Resolves supported filters for provided field. diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts index 56d17e7973e1..eb40f64312f8 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { isPivotAggsConfigWithUiSupport, isSpecialSortField, @@ -16,7 +17,6 @@ import { } from '../../../../../../common/pivot_aggs'; import { PivotAggsConfigTopMetrics } from './types'; import { TopMetricsAggForm } from './components/top_metrics_agg_form'; -import { isPopulatedObject } from '../../../../../../../../common/shared_imports'; /** * Gets initial basic configuration of the top_metrics aggregation. diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/types.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/types.ts index e97d47864313..59d21f65af8d 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/types.ts +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/types.ts @@ -6,6 +6,7 @@ */ import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { EsFieldName } from '../../../../../../../common/types/fields'; @@ -24,7 +25,7 @@ import { } from '../../../../../../../common/types/transform'; import { LatestFunctionConfig } from '../../../../../../../common/api_schemas/transforms'; -import { isPopulatedObject, RUNTIME_FIELD_TYPES } from '../../../../../../../common/shared_imports'; +import { RUNTIME_FIELD_TYPES } from '../../../../../../../common/shared_imports'; export interface ErrorMessage { query: string; diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/use_edit_transform_flyout.ts b/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/use_edit_transform_flyout.ts index eb9adbb45b5b..f65f94baf563 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/use_edit_transform_flyout.ts +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/use_edit_transform_flyout.ts @@ -11,8 +11,8 @@ import { merge } from 'lodash'; import { useReducer } from 'react'; import { i18n } from '@kbn/i18n'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; -import { isPopulatedObject } from '../../../../../../common/shared_imports'; import { PostTransformsUpdateRequestSchema } from '../../../../../../common/api_schemas/update_transforms'; import { DEFAULT_TRANSFORM_FREQUENCY, diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx index 84110e67d701..2a352c2882c1 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx @@ -10,6 +10,7 @@ import React, { FC } from 'react'; import { EuiButtonEmpty, EuiTabbedContent } from '@elastic/eui'; import { Optional } from '@kbn/utility-types'; import { i18n } from '@kbn/i18n'; +import { stringHash } from '@kbn/ml-data-utils'; import moment from 'moment-timezone'; import { TransformListRow } from '../../../../common'; @@ -28,23 +29,6 @@ function getItemDescription(value: any) { return value.toString(); } -/** - * Creates a deterministic number based hash out of a string. - */ -export function stringHash(str: string): number { - let hash = 0; - let chr = 0; - if (str.length === 0) { - return hash; - } - for (let i = 0; i < str.length; i++) { - chr = str.charCodeAt(i); - hash = (hash << 5) - hash + chr; // eslint-disable-line no-bitwise - hash |= 0; // eslint-disable-line no-bitwise - } - return hash < 0 ? hash * -2 : hash; -} - type Item = SectionItem; interface Props { diff --git a/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts b/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts index 426dc3d4fa34..2d1f4120c322 100644 --- a/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts +++ b/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts @@ -7,8 +7,9 @@ import Boom from '@hapi/boom'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; + import { NODES_INFO_PRIVILEGES } from '../../../common/constants'; -import { isPopulatedObject } from '../../../common/shared_imports'; import { RouteDependencies } from '../../types'; diff --git a/x-pack/test/api_integration/apis/ml/modules/get_module.ts b/x-pack/test/api_integration/apis/ml/modules/get_module.ts index 5810b4bf7e6c..3ae294fb22d1 100644 --- a/x-pack/test/api_integration/apis/ml/modules/get_module.ts +++ b/x-pack/test/api_integration/apis/ml/modules/get_module.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; -import { isPopulatedObject } from '@kbn/ml-plugin/common/util/object_utils'; +import { isPopulatedObject } from '@kbn/ml-data-utils'; import { FtrProviderContext } from '../../../ftr_provider_context'; import { USER } from '../../../../functional/services/ml/security_common'; import { COMMON_REQUEST_HEADERS } from '../../../../functional/services/ml/common_api'; diff --git a/yarn.lock b/yarn.lock index 649e628ecf74..80b352cbe0fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3235,6 +3235,10 @@ version "0.0.0" uid "" +"@kbn/ml-data-utils@link:bazel-bin/x-pack/packages/ml/data-utils": + version "0.0.0" + uid "" + "@kbn/monaco@link:bazel-bin/packages/kbn-monaco": version "0.0.0" uid "" @@ -6610,6 +6614,10 @@ version "0.0.0" uid "" +"@types/kbn__ml-data-utils@link:bazel-bin/x-pack/packages/ml/data-utils/npm_module_types": + version "0.0.0" + uid "" + "@types/kbn__monaco@link:bazel-bin/packages/kbn-monaco/npm_module_types": version "0.0.0" uid "" From 31cfdcc996a98e7e50680fb725e2d1b3db1683bf Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Tue, 21 Jun 2022 11:45:19 +0200 Subject: [PATCH 02/11] [ML] Fix tests. --- .../src/build_sampler_aggregation.test.ts | 31 ++++++++++++++ ...sampler_aggregations_response_path.test.ts | 18 ++++++++ .../src/is_populated_object.test.ts | 2 +- .../ml/data-utils/src/string_hash.test.ts | 16 +++++++ .../ml/common/util/object_utils.test.ts | 42 +------------------ .../ml/common/util/string_utils.test.ts | 15 +------ .../plugins/ml/server/lib/query_utils.test.ts | 39 +---------------- 7 files changed, 69 insertions(+), 94 deletions(-) create mode 100644 x-pack/packages/ml/data-utils/src/build_sampler_aggregation.test.ts create mode 100644 x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.test.ts create mode 100644 x-pack/packages/ml/data-utils/src/string_hash.test.ts diff --git a/x-pack/packages/ml/data-utils/src/build_sampler_aggregation.test.ts b/x-pack/packages/ml/data-utils/src/build_sampler_aggregation.test.ts new file mode 100644 index 000000000000..c792b331ef5b --- /dev/null +++ b/x-pack/packages/ml/data-utils/src/build_sampler_aggregation.test.ts @@ -0,0 +1,31 @@ +/* + * 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 { buildSamplerAggregation } from './build_sampler_aggregation'; + +describe('buildSamplerAggregation', () => { + const testAggs = { + bytes_stats: { + stats: { field: 'bytes' }, + }, + }; + + test('returns wrapped sampler aggregation for sampler shard size of 1000', () => { + expect(buildSamplerAggregation(testAggs, 1000)).toEqual({ + sample: { + sampler: { + shard_size: 1000, + }, + aggs: testAggs, + }, + }); + }); + + test('returns un-sampled aggregation as-is for sampler shard size of 0', () => { + expect(buildSamplerAggregation(testAggs, 0)).toEqual(testAggs); + }); +}); diff --git a/x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.test.ts b/x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.test.ts new file mode 100644 index 000000000000..78b30d27aada --- /dev/null +++ b/x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.test.ts @@ -0,0 +1,18 @@ +/* + * 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 { getSamplerAggregationsResponsePath } from './get_sampler_aggregations_response_path'; + +describe('getSamplerAggregationsResponsePath', () => { + test('returns correct path for sampler shard size of 1000', () => { + expect(getSamplerAggregationsResponsePath(1000)).toEqual(['sample']); + }); + + test('returns correct path for sampler shard size of 0', () => { + expect(getSamplerAggregationsResponsePath(0)).toEqual([]); + }); +}); diff --git a/x-pack/packages/ml/data-utils/src/is_populated_object.test.ts b/x-pack/packages/ml/data-utils/src/is_populated_object.test.ts index 9c5ce512944c..c606c0677cf6 100644 --- a/x-pack/packages/ml/data-utils/src/is_populated_object.test.ts +++ b/x-pack/packages/ml/data-utils/src/is_populated_object.test.ts @@ -7,7 +7,7 @@ import { isPopulatedObject } from './is_populated_object'; -describe('isPopulatedObject()', () => { +describe('isPopulatedObject', () => { it('does not allow numbers', () => { expect(isPopulatedObject(0)).toBe(false); }); diff --git a/x-pack/packages/ml/data-utils/src/string_hash.test.ts b/x-pack/packages/ml/data-utils/src/string_hash.test.ts new file mode 100644 index 000000000000..3354e3645579 --- /dev/null +++ b/x-pack/packages/ml/data-utils/src/string_hash.test.ts @@ -0,0 +1,16 @@ +/* + * 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 { stringHash } from './string_hash'; + +describe('stringHash', () => { + test('should return a unique number based off a string', () => { + const hash1 = stringHash('the-string-1'); + const hash2 = stringHash('the-string-2'); + expect(hash1).not.toBe(hash2); + }); +}); diff --git a/x-pack/plugins/ml/common/util/object_utils.test.ts b/x-pack/plugins/ml/common/util/object_utils.test.ts index d6d500cdb82c..e6a0617c6335 100644 --- a/x-pack/plugins/ml/common/util/object_utils.test.ts +++ b/x-pack/plugins/ml/common/util/object_utils.test.ts @@ -5,49 +5,9 @@ * 2.0. */ -import { getFirstKeyInObject, isPopulatedObject } from './object_utils'; +import { getFirstKeyInObject } from './object_utils'; describe('object_utils', () => { - describe('isPopulatedObject()', () => { - it('does not allow numbers', () => { - expect(isPopulatedObject(0)).toBe(false); - }); - it('does not allow strings', () => { - expect(isPopulatedObject('')).toBe(false); - }); - it('does not allow null', () => { - expect(isPopulatedObject(null)).toBe(false); - }); - it('does not allow an empty object', () => { - expect(isPopulatedObject({})).toBe(false); - }); - it('allows an object with an attribute', () => { - expect(isPopulatedObject({ attribute: 'value' })).toBe(true); - }); - it('does not allow an object with a non-existing required attribute', () => { - expect(isPopulatedObject({ attribute: 'value' }, ['otherAttribute'])).toBe(false); - }); - it('allows an object with an existing required attribute', () => { - expect(isPopulatedObject({ attribute: 'value' }, ['attribute'])).toBe(true); - }); - it('allows an object with two existing required attributes', () => { - expect( - isPopulatedObject({ attribute1: 'value1', attribute2: 'value2' }, [ - 'attribute1', - 'attribute2', - ]) - ).toBe(true); - }); - it('does not allow an object with two required attributes where one does not exist', () => { - expect( - isPopulatedObject({ attribute1: 'value1', attribute2: 'value2' }, [ - 'attribute1', - 'otherAttribute', - ]) - ).toBe(false); - }); - }); - describe('getFirstKeyInObject()', () => { it('gets the first key in object', () => { expect(getFirstKeyInObject({ attribute1: 'value', attribute2: 'value2' })).toBe('attribute1'); diff --git a/x-pack/plugins/ml/common/util/string_utils.test.ts b/x-pack/plugins/ml/common/util/string_utils.test.ts index 52a3c10da8b5..43acc8011000 100644 --- a/x-pack/plugins/ml/common/util/string_utils.test.ts +++ b/x-pack/plugins/ml/common/util/string_utils.test.ts @@ -5,12 +5,7 @@ * 2.0. */ -import { - renderTemplate, - getMedianStringLength, - stringHash, - getGroupQueryText, -} from './string_utils'; +import { renderTemplate, getMedianStringLength, getGroupQueryText } from './string_utils'; const strings: string[] = [ 'foo', @@ -53,14 +48,6 @@ describe('ML - string utils', () => { }); }); - describe('stringHash', () => { - test('should return a unique number based off a string', () => { - const hash1 = stringHash('the-string-1'); - const hash2 = stringHash('the-string-2'); - expect(hash1).not.toBe(hash2); - }); - }); - describe('getGroupQueryText', () => { const groupIdOne = 'test_group_id_1'; const groupIdTwo = 'test_group_id_2'; diff --git a/x-pack/plugins/ml/server/lib/query_utils.test.ts b/x-pack/plugins/ml/server/lib/query_utils.test.ts index a83265ed1262..c505a8a9b1fa 100644 --- a/x-pack/plugins/ml/server/lib/query_utils.test.ts +++ b/x-pack/plugins/ml/server/lib/query_utils.test.ts @@ -5,11 +5,7 @@ * 2.0. */ -import { - buildBaseFilterCriteria, - buildSamplerAggregation, - getSamplerAggregationsResponsePath, -} from './query_utils'; +import { buildBaseFilterCriteria } from './query_utils'; describe('ML - query utils', () => { describe('buildBaseFilterCriteria', () => { @@ -52,37 +48,4 @@ describe('ML - query utils', () => { ]); }); }); - - describe('buildSamplerAggregation', () => { - const testAggs = { - bytes_stats: { - stats: { field: 'bytes' }, - }, - }; - - test('returns wrapped sampler aggregation for sampler shard size of 1000', () => { - expect(buildSamplerAggregation(testAggs, 1000)).toEqual({ - sample: { - sampler: { - shard_size: 1000, - }, - aggs: testAggs, - }, - }); - }); - - test('returns un-sampled aggregation as-is for sampler shard size of 0', () => { - expect(buildSamplerAggregation(testAggs, 0)).toEqual(testAggs); - }); - }); - - describe('getSamplerAggregationsResponsePath', () => { - test('returns correct path for sampler shard size of 1000', () => { - expect(getSamplerAggregationsResponsePath(1000)).toEqual(['sample']); - }); - - test('returns correct path for sampler shard size of 0', () => { - expect(getSamplerAggregationsResponsePath(0)).toEqual([]); - }); - }); }); From 253de5f9e916216edd83fc0f58020ea8f7f4dac7 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Tue, 21 Jun 2022 12:17:06 +0200 Subject: [PATCH 03/11] [ML] Fix directory name. --- package.json | 4 ++-- packages/BUILD.bazel | 4 ++-- x-pack/packages/ml/{data-utils => data_utils}/BUILD.bazel | 0 x-pack/packages/ml/{data-utils => data_utils}/README.md | 0 x-pack/packages/ml/{data-utils => data_utils}/jest.config.js | 2 +- x-pack/packages/ml/{data-utils => data_utils}/package.json | 0 .../src/build_sampler_aggregation.test.ts | 0 .../src/build_sampler_aggregation.ts | 0 .../ml/{data-utils => data_utils}/src/get_agg_intervals.ts | 0 .../src/get_sampler_aggregations_response_path.test.ts | 0 .../src/get_sampler_aggregations_response_path.ts | 0 x-pack/packages/ml/{data-utils => data_utils}/src/index.ts | 0 .../src/is_populated_object.test.ts | 0 .../ml/{data-utils => data_utils}/src/is_populated_object.ts | 0 .../ml/{data-utils => data_utils}/src/string_hash.test.ts | 0 .../packages/ml/{data-utils => data_utils}/src/string_hash.ts | 0 x-pack/packages/ml/{data-utils => data_utils}/tsconfig.json | 0 yarn.lock | 4 ++-- 18 files changed, 7 insertions(+), 7 deletions(-) rename x-pack/packages/ml/{data-utils => data_utils}/BUILD.bazel (100%) rename x-pack/packages/ml/{data-utils => data_utils}/README.md (100%) rename x-pack/packages/ml/{data-utils => data_utils}/jest.config.js (86%) rename x-pack/packages/ml/{data-utils => data_utils}/package.json (100%) rename x-pack/packages/ml/{data-utils => data_utils}/src/build_sampler_aggregation.test.ts (100%) rename x-pack/packages/ml/{data-utils => data_utils}/src/build_sampler_aggregation.ts (100%) rename x-pack/packages/ml/{data-utils => data_utils}/src/get_agg_intervals.ts (100%) rename x-pack/packages/ml/{data-utils => data_utils}/src/get_sampler_aggregations_response_path.test.ts (100%) rename x-pack/packages/ml/{data-utils => data_utils}/src/get_sampler_aggregations_response_path.ts (100%) rename x-pack/packages/ml/{data-utils => data_utils}/src/index.ts (100%) rename x-pack/packages/ml/{data-utils => data_utils}/src/is_populated_object.test.ts (100%) rename x-pack/packages/ml/{data-utils => data_utils}/src/is_populated_object.ts (100%) rename x-pack/packages/ml/{data-utils => data_utils}/src/string_hash.test.ts (100%) rename x-pack/packages/ml/{data-utils => data_utils}/src/string_hash.ts (100%) rename x-pack/packages/ml/{data-utils => data_utils}/tsconfig.json (100%) diff --git a/package.json b/package.json index c25f9468bad0..3ee392df7b12 100644 --- a/package.json +++ b/package.json @@ -188,7 +188,7 @@ "@kbn/logging": "link:bazel-bin/packages/kbn-logging", "@kbn/logging-mocks": "link:bazel-bin/packages/kbn-logging-mocks", "@kbn/mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl", - "@kbn/ml-data-utils": "link:bazel-bin/x-pack/packages/ml/data-utils", + "@kbn/ml-data-utils": "link:bazel-bin/x-pack/packages/ml/data_utils", "@kbn/monaco": "link:bazel-bin/packages/kbn-monaco", "@kbn/plugin-discovery": "link:bazel-bin/packages/kbn-plugin-discovery", "@kbn/react-field": "link:bazel-bin/packages/kbn-react-field", @@ -723,7 +723,7 @@ "@types/kbn__logging": "link:bazel-bin/packages/kbn-logging/npm_module_types", "@types/kbn__logging-mocks": "link:bazel-bin/packages/kbn-logging-mocks/npm_module_types", "@types/kbn__mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl/npm_module_types", - "@types/kbn__ml-data-utils": "link:bazel-bin/x-pack/packages/ml/data-utils/npm_module_types", + "@types/kbn__ml-data-utils": "link:bazel-bin/x-pack/packages/ml/data_utils/npm_module_types", "@types/kbn__monaco": "link:bazel-bin/packages/kbn-monaco/npm_module_types", "@types/kbn__optimizer": "link:bazel-bin/packages/kbn-optimizer/npm_module_types", "@types/kbn__optimizer-webpack-helpers": "link:bazel-bin/packages/kbn-optimizer-webpack-helpers/npm_module_types", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index 237ebd3c619f..79c57cd7d9f6 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -150,7 +150,7 @@ filegroup( "//packages/shared-ux/page/analytics_no_data:build", "//packages/shared-ux/page/kibana_no_data:build", "//packages/shared-ux/prompt/no_data_views:build", - "//x-pack/packages/ml/data-utils:build", + "//x-pack/packages/ml/data_utils:build", ], ) @@ -284,7 +284,7 @@ filegroup( "//packages/shared-ux/page/analytics_no_data:build_types", "//packages/shared-ux/page/kibana_no_data:build_types", "//packages/shared-ux/prompt/no_data_views:build_types", - "//x-pack/packages/ml/data-utils:build_types", + "//x-pack/packages/ml/data_utils:build_types", ], ) diff --git a/x-pack/packages/ml/data-utils/BUILD.bazel b/x-pack/packages/ml/data_utils/BUILD.bazel similarity index 100% rename from x-pack/packages/ml/data-utils/BUILD.bazel rename to x-pack/packages/ml/data_utils/BUILD.bazel diff --git a/x-pack/packages/ml/data-utils/README.md b/x-pack/packages/ml/data_utils/README.md similarity index 100% rename from x-pack/packages/ml/data-utils/README.md rename to x-pack/packages/ml/data_utils/README.md diff --git a/x-pack/packages/ml/data-utils/jest.config.js b/x-pack/packages/ml/data_utils/jest.config.js similarity index 86% rename from x-pack/packages/ml/data-utils/jest.config.js rename to x-pack/packages/ml/data_utils/jest.config.js index d6b5dc628aa6..232fa7ed891b 100644 --- a/x-pack/packages/ml/data-utils/jest.config.js +++ b/x-pack/packages/ml/data_utils/jest.config.js @@ -8,5 +8,5 @@ module.exports = { preset: '@kbn/test/jest_node', rootDir: '../../../..', - roots: ['/x-pack/packages/ml/data-utils'], + roots: ['/x-pack/packages/ml/data_utils'], }; diff --git a/x-pack/packages/ml/data-utils/package.json b/x-pack/packages/ml/data_utils/package.json similarity index 100% rename from x-pack/packages/ml/data-utils/package.json rename to x-pack/packages/ml/data_utils/package.json diff --git a/x-pack/packages/ml/data-utils/src/build_sampler_aggregation.test.ts b/x-pack/packages/ml/data_utils/src/build_sampler_aggregation.test.ts similarity index 100% rename from x-pack/packages/ml/data-utils/src/build_sampler_aggregation.test.ts rename to x-pack/packages/ml/data_utils/src/build_sampler_aggregation.test.ts diff --git a/x-pack/packages/ml/data-utils/src/build_sampler_aggregation.ts b/x-pack/packages/ml/data_utils/src/build_sampler_aggregation.ts similarity index 100% rename from x-pack/packages/ml/data-utils/src/build_sampler_aggregation.ts rename to x-pack/packages/ml/data_utils/src/build_sampler_aggregation.ts diff --git a/x-pack/packages/ml/data-utils/src/get_agg_intervals.ts b/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts similarity index 100% rename from x-pack/packages/ml/data-utils/src/get_agg_intervals.ts rename to x-pack/packages/ml/data_utils/src/get_agg_intervals.ts diff --git a/x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.test.ts b/x-pack/packages/ml/data_utils/src/get_sampler_aggregations_response_path.test.ts similarity index 100% rename from x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.test.ts rename to x-pack/packages/ml/data_utils/src/get_sampler_aggregations_response_path.test.ts diff --git a/x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.ts b/x-pack/packages/ml/data_utils/src/get_sampler_aggregations_response_path.ts similarity index 100% rename from x-pack/packages/ml/data-utils/src/get_sampler_aggregations_response_path.ts rename to x-pack/packages/ml/data_utils/src/get_sampler_aggregations_response_path.ts diff --git a/x-pack/packages/ml/data-utils/src/index.ts b/x-pack/packages/ml/data_utils/src/index.ts similarity index 100% rename from x-pack/packages/ml/data-utils/src/index.ts rename to x-pack/packages/ml/data_utils/src/index.ts diff --git a/x-pack/packages/ml/data-utils/src/is_populated_object.test.ts b/x-pack/packages/ml/data_utils/src/is_populated_object.test.ts similarity index 100% rename from x-pack/packages/ml/data-utils/src/is_populated_object.test.ts rename to x-pack/packages/ml/data_utils/src/is_populated_object.test.ts diff --git a/x-pack/packages/ml/data-utils/src/is_populated_object.ts b/x-pack/packages/ml/data_utils/src/is_populated_object.ts similarity index 100% rename from x-pack/packages/ml/data-utils/src/is_populated_object.ts rename to x-pack/packages/ml/data_utils/src/is_populated_object.ts diff --git a/x-pack/packages/ml/data-utils/src/string_hash.test.ts b/x-pack/packages/ml/data_utils/src/string_hash.test.ts similarity index 100% rename from x-pack/packages/ml/data-utils/src/string_hash.test.ts rename to x-pack/packages/ml/data_utils/src/string_hash.test.ts diff --git a/x-pack/packages/ml/data-utils/src/string_hash.ts b/x-pack/packages/ml/data_utils/src/string_hash.ts similarity index 100% rename from x-pack/packages/ml/data-utils/src/string_hash.ts rename to x-pack/packages/ml/data_utils/src/string_hash.ts diff --git a/x-pack/packages/ml/data-utils/tsconfig.json b/x-pack/packages/ml/data_utils/tsconfig.json similarity index 100% rename from x-pack/packages/ml/data-utils/tsconfig.json rename to x-pack/packages/ml/data_utils/tsconfig.json diff --git a/yarn.lock b/yarn.lock index 80b352cbe0fd..43dbf7a1913c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3235,7 +3235,7 @@ version "0.0.0" uid "" -"@kbn/ml-data-utils@link:bazel-bin/x-pack/packages/ml/data-utils": +"@kbn/ml-data-utils@link:bazel-bin/x-pack/packages/ml/data_utils": version "0.0.0" uid "" @@ -6614,7 +6614,7 @@ version "0.0.0" uid "" -"@types/kbn__ml-data-utils@link:bazel-bin/x-pack/packages/ml/data-utils/npm_module_types": +"@types/kbn__ml-data-utils@link:bazel-bin/x-pack/packages/ml/data_utils/npm_module_types": version "0.0.0" uid "" From d657ce46f2d506ce1f4691ce051058817796ea4d Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Tue, 21 Jun 2022 13:52:07 +0200 Subject: [PATCH 04/11] [ML] Create @kbn/ml-is-populated-object package. --- package.json | 2 + packages/BUILD.bazel | 2 + x-pack/packages/ml/data_utils/BUILD.bazel | 2 + x-pack/packages/ml/data_utils/README.md | 2 +- .../ml/data_utils/src/get_agg_intervals.ts | 2 +- x-pack/packages/ml/data_utils/src/index.ts | 1 - .../ml/is_populated_object/BUILD.bazel | 114 ++++++++++++++++++ .../packages/ml/is_populated_object/README.md | 3 + .../ml/is_populated_object/jest.config.js | 12 ++ .../ml/is_populated_object/package.json | 7 ++ .../ml/is_populated_object/src/index.ts | 8 ++ .../src/is_populated_object.test.ts | 0 .../src/is_populated_object.ts | 0 .../ml/is_populated_object/tsconfig.json | 17 +++ .../common/types/field_stats.ts | 2 +- .../data_visualizer/common/types/index.ts | 2 +- .../common/utils/runtime_field_utils.ts | 2 +- .../full_time_range_selector_service.ts | 2 +- .../requests/get_boolean_field_stats.ts | 8 +- .../requests/get_date_field_stats.ts | 7 +- .../requests/get_document_stats.ts | 2 +- .../requests/get_field_examples.ts | 2 +- .../requests/get_numeric_field_stats.ts | 7 +- .../requests/get_string_field_stats.ts | 7 +- .../search_strategy/requests/overall_stats.ts | 7 +- .../utils/error_utils.ts | 2 +- .../utils/query_utils.ts | 2 +- .../file_upload/public/importer/importer.ts | 2 +- .../server/get_time_field_range.ts | 2 +- .../server/utils/runtime_field_utils.ts | 2 +- x-pack/plugins/ml/common/types/es_client.ts | 2 +- .../ml/common/types/feature_importance.ts | 2 +- .../ml/common/util/errors/process_errors.ts | 2 +- x-pack/plugins/ml/common/util/job_utils.ts | 2 +- x-pack/plugins/ml/common/util/object_utils.ts | 2 +- x-pack/plugins/ml/common/util/query_utils.ts | 2 +- .../ml/common/util/runtime_field_utils.ts | 2 +- x-pack/plugins/ml/common/util/validators.ts | 2 +- ...aly_detection_jobs_health_rule_trigger.tsx | 2 +- .../components/data_grid/data_grid.tsx | 2 +- .../full_time_range_selector_service.ts | 2 +- .../runtime_mappings/runtime_mappings.tsx | 2 +- .../hooks/use_exploration_url_state.ts | 2 +- .../jobs/jobs_list/components/utils.js | 2 +- .../ml/public/application/jobs/jobs_utils.ts | 2 +- .../util/filter_runtime_mappings.ts | 2 +- .../jobs/new_job/recognize/page.tsx | 2 +- .../anomaly_explorer_charts_service.ts | 2 +- .../services/anomaly_timeline_service.ts | 2 +- .../results_service/result_service_rx.ts | 2 +- .../results_service/results_service.js | 2 +- .../models_management/expanded_row.tsx | 2 +- .../models_management/models_list.tsx | 2 +- .../models_management/test_models/utils.ts | 2 +- .../ml/public/application/util/url_state.tsx | 2 +- x-pack/plugins/ml/public/embeddables/types.ts | 2 +- .../models/data_recognizer/data_recognizer.ts | 2 +- .../models/data_visualizer/data_visualizer.ts | 2 +- .../models/fields_service/fields_service.ts | 2 +- .../ml/server/models/job_service/jobs.ts | 2 +- .../models/results_service/anomaly_charts.ts | 2 +- .../common/api_schemas/type_guards.ts | 2 +- .../transform/common/types/data_view.ts | 2 +- .../transform/common/types/transform.ts | 2 +- .../transform/common/types/transform_stats.ts | 2 +- .../plugins/transform/common/utils/errors.ts | 2 +- .../transform/public/app/common/pivot_aggs.ts | 2 +- .../public/app/common/pivot_group_by.ts | 2 +- .../transform/public/app/common/request.ts | 2 +- .../lib/authorization/components/common.ts | 2 +- .../step_create/step_create_form.tsx | 2 +- .../filter_agg/components/filter_agg_form.tsx | 2 +- .../common/top_metrics_agg/config.ts | 2 +- .../components/step_define/common/types.ts | 2 +- .../use_edit_transform_flyout.ts | 2 +- .../server/routes/api/transforms_nodes.ts | 2 +- .../apis/ml/modules/get_module.ts | 2 +- yarn.lock | 24 ++-- 78 files changed, 254 insertions(+), 94 deletions(-) create mode 100644 x-pack/packages/ml/is_populated_object/BUILD.bazel create mode 100644 x-pack/packages/ml/is_populated_object/README.md create mode 100644 x-pack/packages/ml/is_populated_object/jest.config.js create mode 100644 x-pack/packages/ml/is_populated_object/package.json create mode 100644 x-pack/packages/ml/is_populated_object/src/index.ts rename x-pack/packages/ml/{data_utils => is_populated_object}/src/is_populated_object.test.ts (100%) rename x-pack/packages/ml/{data_utils => is_populated_object}/src/is_populated_object.ts (100%) create mode 100644 x-pack/packages/ml/is_populated_object/tsconfig.json diff --git a/package.json b/package.json index 3ee392df7b12..9118d989e319 100644 --- a/package.json +++ b/package.json @@ -189,6 +189,7 @@ "@kbn/logging-mocks": "link:bazel-bin/packages/kbn-logging-mocks", "@kbn/mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl", "@kbn/ml-data-utils": "link:bazel-bin/x-pack/packages/ml/data_utils", + "@kbn/ml-is-populated-object": "link:bazel-bin/x-pack/packages/ml/is_populated_object", "@kbn/monaco": "link:bazel-bin/packages/kbn-monaco", "@kbn/plugin-discovery": "link:bazel-bin/packages/kbn-plugin-discovery", "@kbn/react-field": "link:bazel-bin/packages/kbn-react-field", @@ -724,6 +725,7 @@ "@types/kbn__logging-mocks": "link:bazel-bin/packages/kbn-logging-mocks/npm_module_types", "@types/kbn__mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl/npm_module_types", "@types/kbn__ml-data-utils": "link:bazel-bin/x-pack/packages/ml/data_utils/npm_module_types", + "@types/kbn__ml-is-populated-object": "link:bazel-bin/x-pack/packages/ml/is_populated_object/npm_module_types", "@types/kbn__monaco": "link:bazel-bin/packages/kbn-monaco/npm_module_types", "@types/kbn__optimizer": "link:bazel-bin/packages/kbn-optimizer/npm_module_types", "@types/kbn__optimizer-webpack-helpers": "link:bazel-bin/packages/kbn-optimizer-webpack-helpers/npm_module_types", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index 79c57cd7d9f6..cbffb0b6cbaf 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -151,6 +151,7 @@ filegroup( "//packages/shared-ux/page/kibana_no_data:build", "//packages/shared-ux/prompt/no_data_views:build", "//x-pack/packages/ml/data_utils:build", + "//x-pack/packages/ml/is_populated_object:build", ], ) @@ -285,6 +286,7 @@ filegroup( "//packages/shared-ux/page/kibana_no_data:build_types", "//packages/shared-ux/prompt/no_data_views:build_types", "//x-pack/packages/ml/data_utils:build_types", + "//x-pack/packages/ml/is_populated_object:build_types", ], ) diff --git a/x-pack/packages/ml/data_utils/BUILD.bazel b/x-pack/packages/ml/data_utils/BUILD.bazel index 44a77e683e18..1314f055032a 100644 --- a/x-pack/packages/ml/data_utils/BUILD.bazel +++ b/x-pack/packages/ml/data_utils/BUILD.bazel @@ -39,6 +39,7 @@ RUNTIME_DEPS = [ "@npm//@elastic/elasticsearch", "@npm//lodash", "//packages/kbn-field-types", + "//x-pack/packages/ml/is_populated_object", ] # In this array place dependencies necessary to build the types, which will include the @@ -57,6 +58,7 @@ TYPES_DEPS = [ "@npm//@elastic/elasticsearch", "@npm//tslib", "//packages/kbn-field-types:npm_module_types", + "//x-pack/packages/ml/is_populated_object:npm_module_types", ] jsts_transpiler( diff --git a/x-pack/packages/ml/data_utils/README.md b/x-pack/packages/ml/data_utils/README.md index 643a41127a41..ff0ee54cf3a8 100644 --- a/x-pack/packages/ml/data_utils/README.md +++ b/x-pack/packages/ml/data_utils/README.md @@ -1,3 +1,3 @@ # @kbn/ml-data-utils -Empty package generated by @kbn/generate +This package includes utility functions provided by the ML team to be used in Kibana plugins related to data manipulation and verification. diff --git a/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts b/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts index fb8abff7a661..3a305823749b 100644 --- a/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts +++ b/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts @@ -11,10 +11,10 @@ import type { Client } from '@elastic/elasticsearch'; import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { KBN_FIELD_TYPES } from '@kbn/field-types'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { buildSamplerAggregation } from './build_sampler_aggregation'; import { getSamplerAggregationsResponsePath } from './get_sampler_aggregations_response_path'; -import { isPopulatedObject } from './is_populated_object'; import { stringHash } from './string_hash'; // TODO Temporary type definition until we can import from `@kbn/core`. diff --git a/x-pack/packages/ml/data_utils/src/index.ts b/x-pack/packages/ml/data_utils/src/index.ts index 0db6555b00c0..fbed0682b8ff 100644 --- a/x-pack/packages/ml/data_utils/src/index.ts +++ b/x-pack/packages/ml/data_utils/src/index.ts @@ -8,5 +8,4 @@ export { buildSamplerAggregation } from './build_sampler_aggregation'; export { getAggIntervals } from './get_agg_intervals'; export { getSamplerAggregationsResponsePath } from './get_sampler_aggregations_response_path'; -export { isPopulatedObject } from './is_populated_object'; export { stringHash } from './string_hash'; diff --git a/x-pack/packages/ml/is_populated_object/BUILD.bazel b/x-pack/packages/ml/is_populated_object/BUILD.bazel new file mode 100644 index 000000000000..e89b39af7c98 --- /dev/null +++ b/x-pack/packages/ml/is_populated_object/BUILD.bazel @@ -0,0 +1,114 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") + +PKG_DIRNAME = "is_populated_object" +PKG_REQUIRE_NAME = "@kbn/ml-is-populated-object" + +SOURCE_FILES = glob( + [ + "src/**/*.ts", + ], + exclude = [ + "**/*.test.*", + ], +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", +] + +# In this array place runtime dependencies, including other packages and NPM packages +# which must be available for this code to run. +# +# To reference other packages use: +# "//repo/relative/path/to/package" +# eg. "//packages/kbn-utils" +# +# To reference a NPM package use: +# "@npm//name-of-package" +# eg. "@npm//lodash" +RUNTIME_DEPS = [ +] + +# In this array place dependencies necessary to build the types, which will include the +# :npm_module_types target of other packages and packages from NPM, including @types/* +# packages. +# +# To reference the types for another package use: +# "//repo/relative/path/to/package:npm_module_types" +# eg. "//packages/kbn-utils:npm_module_types" +# +# References to NPM packages work the same as RUNTIME_DEPS +TYPES_DEPS = [ + "@npm//@types/node", + "@npm//@types/jest", +] + +jsts_transpiler( + name = "target_node", + srcs = SRCS, + build_pkg_name = package_name(), +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + "//:tsconfig.bazel.json", + ], +) + +ts_project( + name = "tsc_types", + args = ['--pretty'], + srcs = SRCS, + deps = TYPES_DEPS, + declaration = True, + emit_declaration_only = True, + out_dir = "target_types", + root_dir = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_DIRNAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = RUNTIME_DEPS + [":target_node"], + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + deps = [":" + PKG_DIRNAME], +) + +filegroup( + name = "build", + srcs = [":npm_module"], + visibility = ["//visibility:public"], +) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [":npm_module_types"], + visibility = ["//visibility:public"], +) diff --git a/x-pack/packages/ml/is_populated_object/README.md b/x-pack/packages/ml/is_populated_object/README.md new file mode 100644 index 000000000000..74734eb52f66 --- /dev/null +++ b/x-pack/packages/ml/is_populated_object/README.md @@ -0,0 +1,3 @@ +# @kbn/ml-is-populated-object + + A type guard to check record like object structures. diff --git a/x-pack/packages/ml/is_populated_object/jest.config.js b/x-pack/packages/ml/is_populated_object/jest.config.js new file mode 100644 index 000000000000..8ce420d82a0a --- /dev/null +++ b/x-pack/packages/ml/is_populated_object/jest.config.js @@ -0,0 +1,12 @@ +/* + * 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. + */ + +module.exports = { + preset: '@kbn/test/jest_node', + rootDir: '../../../..', + roots: ['/x-pack/packages/ml/is_populated_object'], +}; diff --git a/x-pack/packages/ml/is_populated_object/package.json b/x-pack/packages/ml/is_populated_object/package.json new file mode 100644 index 000000000000..5cd4cc805427 --- /dev/null +++ b/x-pack/packages/ml/is_populated_object/package.json @@ -0,0 +1,7 @@ +{ + "name": "@kbn/ml-is-populated-object", + "private": true, + "version": "1.0.0", + "main": "./target_node/index.js", + "license": "SSPL-1.0 OR Elastic License 2.0" +} diff --git a/x-pack/packages/ml/is_populated_object/src/index.ts b/x-pack/packages/ml/is_populated_object/src/index.ts new file mode 100644 index 000000000000..b2b153273962 --- /dev/null +++ b/x-pack/packages/ml/is_populated_object/src/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { isPopulatedObject } from './is_populated_object'; diff --git a/x-pack/packages/ml/data_utils/src/is_populated_object.test.ts b/x-pack/packages/ml/is_populated_object/src/is_populated_object.test.ts similarity index 100% rename from x-pack/packages/ml/data_utils/src/is_populated_object.test.ts rename to x-pack/packages/ml/is_populated_object/src/is_populated_object.test.ts diff --git a/x-pack/packages/ml/data_utils/src/is_populated_object.ts b/x-pack/packages/ml/is_populated_object/src/is_populated_object.ts similarity index 100% rename from x-pack/packages/ml/data_utils/src/is_populated_object.ts rename to x-pack/packages/ml/is_populated_object/src/is_populated_object.ts diff --git a/x-pack/packages/ml/is_populated_object/tsconfig.json b/x-pack/packages/ml/is_populated_object/tsconfig.json new file mode 100644 index 000000000000..97a3644c3c70 --- /dev/null +++ b/x-pack/packages/ml/is_populated_object/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../../tsconfig.bazel.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "target_types", + "rootDir": "src", + "stripInternal": false, + "types": [ + "jest", + "node" + ] + }, + "include": [ + "src/**/*" + ] +} diff --git a/x-pack/plugins/data_visualizer/common/types/field_stats.ts b/x-pack/plugins/data_visualizer/common/types/field_stats.ts index 2d12b8b4fc8f..75fa662281fb 100644 --- a/x-pack/plugins/data_visualizer/common/types/field_stats.ts +++ b/x-pack/plugins/data_visualizer/common/types/field_stats.ts @@ -8,7 +8,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Query } from '@kbn/es-query'; import { IKibanaSearchResponse } from '@kbn/data-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { TimeBucketsInterval } from '../services/time_buckets'; export interface FieldData { diff --git a/x-pack/plugins/data_visualizer/common/types/index.ts b/x-pack/plugins/data_visualizer/common/types/index.ts index f66d9a9da136..395c9f2f595c 100644 --- a/x-pack/plugins/data_visualizer/common/types/index.ts +++ b/x-pack/plugins/data_visualizer/common/types/index.ts @@ -6,7 +6,7 @@ */ import type { SimpleSavedObject } from '@kbn/core/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; export type { JobFieldType } from './job_field_type'; export type { FieldRequestConfig, diff --git a/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts b/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts index e65b33e825ff..10179d5e5173 100644 --- a/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts +++ b/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RUNTIME_FIELD_TYPES } from '@kbn/data-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; type RuntimeType = typeof RUNTIME_FIELD_TYPES[number]; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts index 0f7a0c92fa15..36b84afadfb0 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts @@ -12,7 +12,7 @@ import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import { i18n } from '@kbn/i18n'; import type { ToastsStart } from '@kbn/core/public'; import { DataView } from '@kbn/data-views-plugin/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { getTimeFieldRange } from '../../services/time_field_range'; import type { GetTimeFieldRangeResponse } from '../../../../../common/types/time_field_request'; import { addExcludeFrozenToQuery } from '../../utils/query_utils'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts index fb05e3abaf88..0c2cfc05256c 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts @@ -14,11 +14,9 @@ import type { ISearchOptions, ISearchStart, } from '@kbn/data-plugin/public'; -import { - buildSamplerAggregation, - getSamplerAggregationsResponsePath, - isPopulatedObject, -} from '@kbn/ml-data-utils'; +import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; + import type { Field, BooleanFieldStats, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts index 7664a13a90de..9d15080cd1ca 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts @@ -15,11 +15,8 @@ import type { ISearchOptions, ISearchStart, } from '@kbn/data-plugin/public'; -import { - buildSamplerAggregation, - getSamplerAggregationsResponsePath, - isPopulatedObject, -} from '@kbn/ml-data-utils'; +import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { FieldStatsCommonRequestParams } from '../../../../../common/types/field_stats'; import type { Field, DateFieldStats, Aggs } from '../../../../../common/types/field_stats'; import { FieldStatsError, isIKibanaSearchResponse } from '../../../../../common/types/field_stats'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_document_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_document_stats.ts index 5642179a7dd3..dd654e312e0e 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_document_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_document_stats.ts @@ -7,7 +7,7 @@ import { each, get } from 'lodash'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { buildBaseFilterCriteria } from '../../../../../common/utils/query_utils'; import type { DocumentCountStats, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_field_examples.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_field_examples.ts index b7b69019a230..0e04665256e2 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_field_examples.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_field_examples.ts @@ -14,7 +14,7 @@ import type { ISearchOptions, ISearchStart, } from '@kbn/data-plugin/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { buildBaseFilterCriteria } from '../../../../../common/utils/query_utils'; import type { Field, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts index b870ab375106..e729b4e0ede8 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts @@ -16,11 +16,8 @@ import { ISearchOptions, } from '@kbn/data-plugin/common'; import type { ISearchStart } from '@kbn/data-plugin/public'; -import { - buildSamplerAggregation, - getSamplerAggregationsResponsePath, - isPopulatedObject, -} from '@kbn/ml-data-utils'; +import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { MAX_PERCENT, PERCENTILE_SPACING, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts index bd542c74898e..a66ffd9e2e05 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts @@ -15,11 +15,8 @@ import type { ISearchOptions, ISearchStart, } from '@kbn/data-plugin/public'; -import { - buildSamplerAggregation, - getSamplerAggregationsResponsePath, - isPopulatedObject, -} from '@kbn/ml-data-utils'; +import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { SAMPLER_TOP_TERMS_SHARD_SIZE, SAMPLER_TOP_TERMS_THRESHOLD } from './constants'; import type { Aggs, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts index 67e8c608033d..cb52ff41a44d 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts @@ -9,11 +9,8 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { get } from 'lodash'; import { Query } from '@kbn/es-query'; import { IKibanaSearchResponse } from '@kbn/data-plugin/common'; -import { - buildSamplerAggregation, - getSamplerAggregationsResponsePath, - isPopulatedObject, -} from '@kbn/ml-data-utils'; +import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { buildBaseFilterCriteria, getSafeAggregationName, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/error_utils.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/error_utils.ts index 284f3c330942..e8992764a7f9 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/error_utils.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/error_utils.ts @@ -7,7 +7,7 @@ import { HttpFetchError } from '@kbn/core/public'; import Boom from '@hapi/boom'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; export interface WrappedError { body: { diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/query_utils.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/query_utils.ts index e0131a42971a..5ceda44fa44b 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/query_utils.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/query_utils.ts @@ -7,7 +7,7 @@ import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import { cloneDeep } from 'lodash'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; export const addExcludeFrozenToQuery = (originalQuery: QueryDslQueryContainer | undefined) => { const FROZEN_TIER_TERM = { diff --git a/x-pack/plugins/file_upload/public/importer/importer.ts b/x-pack/plugins/file_upload/public/importer/importer.ts index 6ed59261d4f1..8928c4849435 100644 --- a/x-pack/plugins/file_upload/public/importer/importer.ts +++ b/x-pack/plugins/file_upload/public/importer/importer.ts @@ -8,7 +8,7 @@ import { chunk, intersection } from 'lodash'; import moment from 'moment'; import { i18n } from '@kbn/i18n'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { getHttp } from '../kibana_services'; import { MB } from '../../common/constants'; import type { diff --git a/x-pack/plugins/file_upload/server/get_time_field_range.ts b/x-pack/plugins/file_upload/server/get_time_field_range.ts index 1f434b8b7558..32bf1766f8d9 100644 --- a/x-pack/plugins/file_upload/server/get_time_field_range.ts +++ b/x-pack/plugins/file_upload/server/get_time_field_range.ts @@ -7,7 +7,7 @@ import { IScopedClusterClient } from '@kbn/core/server'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; export async function getTimeFieldRange( client: IScopedClusterClient, diff --git a/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts b/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts index 6901cf95ad1f..75c2aa886ef6 100644 --- a/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts +++ b/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts @@ -7,7 +7,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RUNTIME_FIELD_TYPES } from '@kbn/data-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; type RuntimeType = typeof RUNTIME_FIELD_TYPES[number]; diff --git a/x-pack/plugins/ml/common/types/es_client.ts b/x-pack/plugins/ml/common/types/es_client.ts index 4ebcf6af9e98..9d8f5f3dbed9 100644 --- a/x-pack/plugins/ml/common/types/es_client.ts +++ b/x-pack/plugins/ml/common/types/es_client.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; export function isMultiBucketAggregate( arg: unknown diff --git a/x-pack/plugins/ml/common/types/feature_importance.ts b/x-pack/plugins/ml/common/types/feature_importance.ts index 02f45183b4ff..3333f11ecd2e 100644 --- a/x-pack/plugins/ml/common/types/feature_importance.ts +++ b/x-pack/plugins/ml/common/types/feature_importance.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; export type FeatureImportanceClassName = string | number | boolean; diff --git a/x-pack/plugins/ml/common/util/errors/process_errors.ts b/x-pack/plugins/ml/common/util/errors/process_errors.ts index 2fb7a32f3511..0da2650fa5fd 100644 --- a/x-pack/plugins/ml/common/util/errors/process_errors.ts +++ b/x-pack/plugins/ml/common/util/errors/process_errors.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { ErrorType, MLErrorObject, diff --git a/x-pack/plugins/ml/common/util/job_utils.ts b/x-pack/plugins/ml/common/util/job_utils.ts index d3083f32d59a..28e03acbab02 100644 --- a/x-pack/plugins/ml/common/util/job_utils.ts +++ b/x-pack/plugins/ml/common/util/job_utils.ts @@ -12,7 +12,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // @ts-ignore import numeral from '@elastic/numeral'; import { i18n } from '@kbn/i18n'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { ALLOWED_DATA_UNITS, JOB_ID_MAX_LENGTH } from '../constants/validation'; import { parseInterval } from './parse_interval'; import { maxLengthValidator } from './validators'; diff --git a/x-pack/plugins/ml/common/util/object_utils.ts b/x-pack/plugins/ml/common/util/object_utils.ts index ab6c6575b1e2..2bf2e301f947 100644 --- a/x-pack/plugins/ml/common/util/object_utils.ts +++ b/x-pack/plugins/ml/common/util/object_utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; /** * Get the first key in the object diff --git a/x-pack/plugins/ml/common/util/query_utils.ts b/x-pack/plugins/ml/common/util/query_utils.ts index e0131a42971a..5ceda44fa44b 100644 --- a/x-pack/plugins/ml/common/util/query_utils.ts +++ b/x-pack/plugins/ml/common/util/query_utils.ts @@ -7,7 +7,7 @@ import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import { cloneDeep } from 'lodash'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; export const addExcludeFrozenToQuery = (originalQuery: QueryDslQueryContainer | undefined) => { const FROZEN_TIER_TERM = { diff --git a/x-pack/plugins/ml/common/util/runtime_field_utils.ts b/x-pack/plugins/ml/common/util/runtime_field_utils.ts index e65b33e825ff..10179d5e5173 100644 --- a/x-pack/plugins/ml/common/util/runtime_field_utils.ts +++ b/x-pack/plugins/ml/common/util/runtime_field_utils.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RUNTIME_FIELD_TYPES } from '@kbn/data-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; type RuntimeType = typeof RUNTIME_FIELD_TYPES[number]; diff --git a/x-pack/plugins/ml/common/util/validators.ts b/x-pack/plugins/ml/common/util/validators.ts index 7a7b0c930591..b28e120b1f19 100644 --- a/x-pack/plugins/ml/common/util/validators.ts +++ b/x-pack/plugins/ml/common/util/validators.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { ALLOWED_DATA_UNITS } from '../constants/validation'; import { parseInterval } from './parse_interval'; diff --git a/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx b/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx index 9e5c82b06723..1b88b3878855 100644 --- a/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx +++ b/x-pack/plugins/ml/public/alerting/jobs_health_rule/anomaly_detection_jobs_health_rule_trigger.tsx @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import useDebounce from 'react-use/lib/useDebounce'; import { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plugin/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { MlAnomalyDetectionJobsHealthRuleParams } from '../../../common/types/alerts'; import { JobSelectorControl } from '../job_selector'; import { jobsApiProvider } from '../../application/services/ml_api_service/jobs'; diff --git a/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx b/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx index e03f6ed3224e..3edc757c1184 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx +++ b/x-pack/plugins/ml/public/application/components/data_grid/data_grid.tsx @@ -27,7 +27,7 @@ import { } from '@elastic/eui'; import { CoreSetup } from '@kbn/core/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { DEFAULT_SAMPLER_SHARD_SIZE } from '../../../../common/constants/field_histograms'; import { ANALYSIS_CONFIG_TYPE, INDEX_STATUS } from '../../data_frame_analytics/common'; diff --git a/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts b/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts index 6ae9471e8795..edaa2c30662b 100644 --- a/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts +++ b/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector_service.ts @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n'; import dateMath from '@kbn/datemath'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import type { DataView } from '@kbn/data-views-plugin/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { getTimefilter, getToastNotifications } from '../../util/dependency_cache'; import { ml, GetTimeFieldRangeResponse } from '../../services/ml_api_service'; import type { RuntimeMappings } from '../../../../common/types/fields'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/runtime_mappings/runtime_mappings.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/runtime_mappings/runtime_mappings.tsx index f5dc259ffb84..962a06410ca5 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/runtime_mappings/runtime_mappings.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/runtime_mappings/runtime_mappings.tsx @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { XJsonMode } from '@kbn/ace'; import { XJson } from '@kbn/es-ui-shared-plugin/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { useMlContext } from '../../../../../contexts/ml'; import { CreateAnalyticsFormProps } from '../../../analytics_management/hooks/use_create_analytics_form'; import { getCombinedRuntimeMappings } from '../../../../../components/data_grid/common'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts index fc1151da9a98..1a26cce465d8 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { usePageUrlState } from '../../../../util/url_state'; import { ML_PAGES } from '../../../../../../common/constants/locator'; import { ExplorationPageUrlState } from '../../../../../../common/types/locator'; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js index d826c90a2021..364cdd1be55d 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js @@ -21,7 +21,7 @@ import { JOB_STATE, DATAFEED_STATE } from '../../../../../common/constants/state import { JOB_ACTION } from '../../../../../common/constants/job_actions'; import { parseInterval } from '../../../../../common/util/parse_interval'; import { mlCalendarService } from '../../../services/calendar_service'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; export function loadFullJob(jobId) { return new Promise((resolve, reject) => { diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_utils.ts b/x-pack/plugins/ml/public/application/jobs/jobs_utils.ts index 85b18fc159dc..79952312723f 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_utils.ts +++ b/x-pack/plugins/ml/public/application/jobs/jobs_utils.ts @@ -6,7 +6,7 @@ */ import { MlJob } from '@elastic/elasticsearch/lib/api/types'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { MlSummaryJob } from '../../../common/types/anomaly_detection_jobs'; export const isManagedJob = (job: MlSummaryJob | MlJob) => { diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.ts index 14ba4151e4a8..2f081369ca68 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/filter_runtime_mappings.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { RuntimeMappings } from '../../../../../../../common/types/fields'; import type { Datafeed, Job } from '../../../../../../../common/types/anomaly_detection_jobs'; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx index 094ba883c1fd..59176d06d92c 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx @@ -19,7 +19,7 @@ import { } from '@elastic/eui'; import { merge } from 'lodash'; import moment from 'moment'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { useMlKibana, useMlLocator } from '../../../contexts/kibana'; import { ml } from '../../../services/ml_api_service'; import { useMlContext } from '../../../contexts/ml'; diff --git a/x-pack/plugins/ml/public/application/services/anomaly_explorer_charts_service.ts b/x-pack/plugins/ml/public/application/services/anomaly_explorer_charts_service.ts index 69401dc5c59f..d1e42dd72dda 100644 --- a/x-pack/plugins/ml/public/application/services/anomaly_explorer_charts_service.ts +++ b/x-pack/plugins/ml/public/application/services/anomaly_explorer_charts_service.ts @@ -9,7 +9,7 @@ import { Observable, of } from 'rxjs'; import { map as mapObservable } from 'rxjs/operators'; import type { TimeRange } from '@kbn/es-query'; import type { TimefilterContract } from '@kbn/data-plugin/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { RecordForInfluencer } from './results_service/results_service'; import type { EntityField } from '../../../common/util/anomaly_utils'; import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs'; diff --git a/x-pack/plugins/ml/public/application/services/anomaly_timeline_service.ts b/x-pack/plugins/ml/public/application/services/anomaly_timeline_service.ts index 929826a7f3f5..38bf80be1ffe 100644 --- a/x-pack/plugins/ml/public/application/services/anomaly_timeline_service.ts +++ b/x-pack/plugins/ml/public/application/services/anomaly_timeline_service.ts @@ -8,7 +8,7 @@ import { IUiSettingsClient } from '@kbn/core/public'; import type { TimeRange } from '@kbn/es-query'; import { TimefilterContract, UI_SETTINGS } from '@kbn/data-plugin/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { getBoundsRoundedToInterval, TimeBuckets, diff --git a/x-pack/plugins/ml/public/application/services/results_service/result_service_rx.ts b/x-pack/plugins/ml/public/application/services/results_service/result_service_rx.ts index 5972317c3dff..d5da65875594 100644 --- a/x-pack/plugins/ml/public/application/services/results_service/result_service_rx.ts +++ b/x-pack/plugins/ml/public/application/services/results_service/result_service_rx.ts @@ -15,7 +15,7 @@ import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { each, get } from 'lodash'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { Dictionary } from '../../../../common/types/common'; import { ML_MEDIAN_PERCENTS } from '../../../../common/util/job_utils'; import { Datafeed, JobId } from '../../../../common/types/anomaly_detection_jobs'; diff --git a/x-pack/plugins/ml/public/application/services/results_service/results_service.js b/x-pack/plugins/ml/public/application/services/results_service/results_service.js index 97f0f7cae917..b26e52f5f32f 100644 --- a/x-pack/plugins/ml/public/application/services/results_service/results_service.js +++ b/x-pack/plugins/ml/public/application/services/results_service/results_service.js @@ -7,7 +7,7 @@ import { each, get } from 'lodash'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { ML_MEDIAN_PERCENTS } from '../../../../common/util/job_utils'; import { escapeForElasticsearchQuery } from '../../util/string_utils'; diff --git a/x-pack/plugins/ml/public/application/trained_models/models_management/expanded_row.tsx b/x-pack/plugins/ml/public/application/trained_models/models_management/expanded_row.tsx index 49d1127a96b1..6ab9261213d5 100644 --- a/x-pack/plugins/ml/public/application/trained_models/models_management/expanded_row.tsx +++ b/x-pack/plugins/ml/public/application/trained_models/models_management/expanded_row.tsx @@ -23,7 +23,7 @@ import { import type { EuiDescriptionListProps } from '@elastic/eui/src/components/description_list/description_list'; import { FormattedMessage } from '@kbn/i18n-react'; import { FIELD_FORMAT_IDS } from '@kbn/field-formats-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { ModelItemFull } from './models_list'; import { isDefined } from '../../../../common/types/guards'; import { ModelPipelines } from './pipelines'; diff --git a/x-pack/plugins/ml/public/application/trained_models/models_management/models_list.tsx b/x-pack/plugins/ml/public/application/trained_models/models_management/models_list.tsx index 4a9c80c02e41..07b1e876d412 100644 --- a/x-pack/plugins/ml/public/application/trained_models/models_management/models_list.tsx +++ b/x-pack/plugins/ml/public/application/trained_models/models_management/models_list.tsx @@ -26,7 +26,7 @@ import { EuiBasicTableColumn } from '@elastic/eui/src/components/basic_table/bas import { EuiTableSelectionType } from '@elastic/eui/src/components/basic_table/table_types'; import { Action } from '@elastic/eui/src/components/basic_table/action_types'; import { FIELD_FORMAT_IDS } from '@kbn/field-formats-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { getAnalysisType } from '../../data_frame_analytics/common'; import { ModelsTableToConfigMapping } from '.'; import { ModelsBarStats, StatsBar } from '../../components/stats_bar'; diff --git a/x-pack/plugins/ml/public/application/trained_models/models_management/test_models/utils.ts b/x-pack/plugins/ml/public/application/trained_models/models_management/test_models/utils.ts index 4c9f7d2188ac..e340170ce46c 100644 --- a/x-pack/plugins/ml/public/application/trained_models/models_management/test_models/utils.ts +++ b/x-pack/plugins/ml/public/application/trained_models/models_management/test_models/utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { TRAINED_MODEL_TYPE, DEPLOYMENT_STATE, diff --git a/x-pack/plugins/ml/public/application/util/url_state.tsx b/x-pack/plugins/ml/public/application/util/url_state.tsx index 19866f701d20..a31b57468182 100644 --- a/x-pack/plugins/ml/public/application/util/url_state.tsx +++ b/x-pack/plugins/ml/public/application/util/url_state.tsx @@ -21,7 +21,7 @@ import { useHistory, useLocation } from 'react-router-dom'; import { BehaviorSubject, Observable } from 'rxjs'; import { distinctUntilChanged } from 'rxjs/operators'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { Dictionary } from '../../../common/types/common'; import { getNestedProperty } from './object_utils'; diff --git a/x-pack/plugins/ml/public/embeddables/types.ts b/x-pack/plugins/ml/public/embeddables/types.ts index 7127ba6a62f3..6a990db33398 100644 --- a/x-pack/plugins/ml/public/embeddables/types.ts +++ b/x-pack/plugins/ml/public/embeddables/types.ts @@ -10,7 +10,7 @@ import type { Filter, Query, TimeRange } from '@kbn/es-query'; import type { RefreshInterval } from '@kbn/data-plugin/common'; import type { EmbeddableInput, EmbeddableOutput, IEmbeddable } from '@kbn/embeddable-plugin/public'; import type { DataView } from '@kbn/data-views-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { JobId } from '../../common/types/anomaly_detection_jobs'; import type { SwimlaneType } from '../application/explorer/explorer_constants'; import type { AnomalyDetectorService } from '../application/services/anomaly_detector_service'; 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 9c3d4dcfb1a0..7060d935b0fe 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 @@ -17,7 +17,7 @@ import type { import moment from 'moment'; import { merge } from 'lodash'; import type { DataViewsService } from '@kbn/data-views-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { AnalysisLimits } from '../../../common/types/anomaly_detection_jobs'; import { getAuthorizationHeader } from '../../lib/request_authorization'; import type { MlClient } from '../../lib/ml_client'; 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 e96d27e49669..6cc7608e9960 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 @@ -13,9 +13,9 @@ import { buildSamplerAggregation, getAggIntervals, getSamplerAggregationsResponsePath, - isPopulatedObject, stringHash, } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types'; import { getSafeAggregationName } from '../../../common/util/job_utils'; import { buildBaseFilterCriteria } from '../../lib/query_utils'; 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 2417eb18ff0c..fd661063bde5 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 @@ -8,7 +8,7 @@ import Boom from '@hapi/boom'; import { IScopedClusterClient } from '@kbn/core/server'; import { duration } from 'moment'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { parseInterval } from '../../../common/util/parse_interval'; import { initCardinalityFieldsCache } from './fields_aggs_cache'; import { AggCardinality } from '../../../common/types/fields'; 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 b6b0ba151842..f3cb4c584f27 100644 --- a/x-pack/plugins/ml/server/models/job_service/jobs.ts +++ b/x-pack/plugins/ml/server/models/job_service/jobs.ts @@ -9,7 +9,7 @@ import { uniq } from 'lodash'; import Boom from '@hapi/boom'; import { IScopedClusterClient } from '@kbn/core/server'; import type { RulesClient } from '@kbn/alerting-plugin/server'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { getSingleMetricViewerJobErrorMessage, parseTimeIntervalForJob, diff --git a/x-pack/plugins/ml/server/models/results_service/anomaly_charts.ts b/x-pack/plugins/ml/server/models/results_service/anomaly_charts.ts index 689e0e5addbf..9456e529eb03 100644 --- a/x-pack/plugins/ml/server/models/results_service/anomaly_charts.ts +++ b/x-pack/plugins/ml/server/models/results_service/anomaly_charts.ts @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import { each, find, get, keyBy, map, reduce, sortBy } from 'lodash'; import type * as estypes from '@elastic/elasticsearch/lib/api/types'; import { extent, max, min } from 'd3'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { MlClient } from '../../lib/ml_client'; import { isRuntimeMappings } from '../../../common'; import type { diff --git a/x-pack/plugins/transform/common/api_schemas/type_guards.ts b/x-pack/plugins/transform/common/api_schemas/type_guards.ts index 5d09f355e0e6..821eda892deb 100644 --- a/x-pack/plugins/transform/common/api_schemas/type_guards.ts +++ b/x-pack/plugins/transform/common/api_schemas/type_guards.ts @@ -7,7 +7,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { EsIndex } from '../types/es_index'; import type { EsIngestPipeline } from '../types/es_ingest_pipeline'; diff --git a/x-pack/plugins/transform/common/types/data_view.ts b/x-pack/plugins/transform/common/types/data_view.ts index 72480aba56ef..b541254971c3 100644 --- a/x-pack/plugins/transform/common/types/data_view.ts +++ b/x-pack/plugins/transform/common/types/data_view.ts @@ -6,7 +6,7 @@ */ import type { DataView } from '@kbn/data-views-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; // Custom minimal type guard for DataView to check against the attributes used in transforms code. export function isDataView(arg: any): arg is DataView { diff --git a/x-pack/plugins/transform/common/types/transform.ts b/x-pack/plugins/transform/common/types/transform.ts index 2a51f3f84c1d..f4f9437e05d1 100644 --- a/x-pack/plugins/transform/common/types/transform.ts +++ b/x-pack/plugins/transform/common/types/transform.ts @@ -6,7 +6,7 @@ */ import type { EuiComboBoxOptionOption } from '@elastic/eui/src/components/combo_box/types'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { LatestFunctionConfig, PutTransformsRequestSchema } from '../api_schemas/transforms'; import type { PivotGroupByDict } from './pivot_group_by'; import type { PivotAggDict } from './pivot_aggs'; diff --git a/x-pack/plugins/transform/common/types/transform_stats.ts b/x-pack/plugins/transform/common/types/transform_stats.ts index feee0f6e47b3..2f9319201fd6 100644 --- a/x-pack/plugins/transform/common/types/transform_stats.ts +++ b/x-pack/plugins/transform/common/types/transform_stats.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { TransformState, TRANSFORM_STATE } from '../constants'; import { TransformId } from './transform'; diff --git a/x-pack/plugins/transform/common/utils/errors.ts b/x-pack/plugins/transform/common/utils/errors.ts index cff47f4e5998..c9d81b740f72 100644 --- a/x-pack/plugins/transform/common/utils/errors.ts +++ b/x-pack/plugins/transform/common/utils/errors.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; export interface ErrorResponse { body: { diff --git a/x-pack/plugins/transform/public/app/common/pivot_aggs.ts b/x-pack/plugins/transform/public/app/common/pivot_aggs.ts index bff971cfb9e4..4b986659fe63 100644 --- a/x-pack/plugins/transform/public/app/common/pivot_aggs.ts +++ b/x-pack/plugins/transform/public/app/common/pivot_aggs.ts @@ -8,7 +8,7 @@ import { FC } from 'react'; import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/data-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { AggName } from '../../../common/types/aggregations'; import type { Dictionary } from '../../../common/types/common'; diff --git a/x-pack/plugins/transform/public/app/common/pivot_group_by.ts b/x-pack/plugins/transform/public/app/common/pivot_group_by.ts index 1f11b5046367..b0fa78e8a902 100644 --- a/x-pack/plugins/transform/public/app/common/pivot_group_by.ts +++ b/x-pack/plugins/transform/public/app/common/pivot_group_by.ts @@ -6,7 +6,7 @@ */ import { KBN_FIELD_TYPES } from '@kbn/data-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { AggName } from '../../../common/types/aggregations'; import { Dictionary } from '../../../common/types/common'; import { EsFieldName } from '../../../common/types/fields'; diff --git a/x-pack/plugins/transform/public/app/common/request.ts b/x-pack/plugins/transform/public/app/common/request.ts index a4812882c835..4700e42a3d94 100644 --- a/x-pack/plugins/transform/public/app/common/request.ts +++ b/x-pack/plugins/transform/public/app/common/request.ts @@ -9,7 +9,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HttpFetchError } from '@kbn/core/public'; import type { DataView } from '@kbn/data-views-plugin/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { DEFAULT_CONTINUOUS_MODE_DELAY, diff --git a/x-pack/plugins/transform/public/app/lib/authorization/components/common.ts b/x-pack/plugins/transform/public/app/lib/authorization/components/common.ts index d18eda3cce31..c3db9834a5b5 100644 --- a/x-pack/plugins/transform/public/app/lib/authorization/components/common.ts +++ b/x-pack/plugins/transform/public/app/lib/authorization/components/common.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { Privileges } from '../../../../../common/types/privileges'; diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx index dff865b19c01..59f80d743a9a 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx @@ -30,7 +30,7 @@ import { DISCOVER_APP_LOCATOR } from '@kbn/discover-plugin/public'; import { DuplicateDataViewError } from '@kbn/data-plugin/public'; import type { RuntimeField } from '@kbn/data-views-plugin/common'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { PutTransformsResponseSchema } from '../../../../../../common/api_schemas/transforms'; import { isGetTransformsStatsResponseSchema, diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_agg_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_agg_form.tsx index 551c0133cd18..55ecc18863aa 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_agg_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_agg_form.tsx @@ -10,7 +10,7 @@ import { EuiFormRow, EuiIcon, EuiSelect, EuiToolTip } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import useUpdateEffect from 'react-use/lib/useUpdateEffect'; import { DataView } from '@kbn/data-views-plugin/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { CreateTransformWizardContext } from '../../../../wizard/wizard'; import { commonFilterAggs, filterAggsFieldSupport } from '../constants'; import { getFilterAggTypeConfig } from '../config'; diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts index eb40f64312f8..49be7b299712 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/top_metrics_agg/config.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { isPivotAggsConfigWithUiSupport, isSpecialSortField, diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/types.ts b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/types.ts index 59d21f65af8d..a8a9b5c1e35b 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/types.ts +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/types.ts @@ -6,7 +6,7 @@ */ import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { EsFieldName } from '../../../../../../../common/types/fields'; diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/use_edit_transform_flyout.ts b/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/use_edit_transform_flyout.ts index f65f94baf563..a2dc9148bf03 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/use_edit_transform_flyout.ts +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/use_edit_transform_flyout.ts @@ -11,7 +11,7 @@ import { merge } from 'lodash'; import { useReducer } from 'react'; import { i18n } from '@kbn/i18n'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { PostTransformsUpdateRequestSchema } from '../../../../../../common/api_schemas/update_transforms'; import { diff --git a/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts b/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts index 2d1f4120c322..a5f8f014430c 100644 --- a/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts +++ b/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts @@ -7,7 +7,7 @@ import Boom from '@hapi/boom'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { NODES_INFO_PRIVILEGES } from '../../../common/constants'; diff --git a/x-pack/test/api_integration/apis/ml/modules/get_module.ts b/x-pack/test/api_integration/apis/ml/modules/get_module.ts index 3ae294fb22d1..4ff71201d9ad 100644 --- a/x-pack/test/api_integration/apis/ml/modules/get_module.ts +++ b/x-pack/test/api_integration/apis/ml/modules/get_module.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; -import { isPopulatedObject } from '@kbn/ml-data-utils'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { FtrProviderContext } from '../../../ftr_provider_context'; import { USER } from '../../../../functional/services/ml/security_common'; import { COMMON_REQUEST_HEADERS } from '../../../../functional/services/ml/common_api'; diff --git a/yarn.lock b/yarn.lock index 43dbf7a1913c..f39d9ab96d01 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3239,6 +3239,10 @@ version "0.0.0" uid "" +"@kbn/ml-is-populated-object@link:bazel-bin/x-pack/packages/ml/is_populated_object": + version "0.0.0" + uid "" + "@kbn/monaco@link:bazel-bin/packages/kbn-monaco": version "0.0.0" uid "" @@ -3355,6 +3359,10 @@ version "0.0.0" uid "" +"@kbn/shared-ux-button-toolbar@link:bazel-bin/packages/shared-ux/button_toolbar": + version "0.0.0" + uid "" + "@kbn/shared-ux-components@link:bazel-bin/packages/kbn-shared-ux-components": version "0.0.0" uid "" @@ -3379,10 +3387,6 @@ version "0.0.0" uid "" -"@kbn/shared-ux-button-toolbar@link:bazel-bin/packages/shared-ux/button_toolbar": - version "0.0.0" - uid "" - "@kbn/shared-ux-storybook@link:bazel-bin/packages/kbn-shared-ux-storybook": version "0.0.0" uid "" @@ -6618,6 +6622,10 @@ version "0.0.0" uid "" +"@types/kbn__ml-is-populated-object@link:bazel-bin/x-pack/packages/ml/is_populated_object/npm_module_types": + version "0.0.0" + uid "" + "@types/kbn__monaco@link:bazel-bin/packages/kbn-monaco/npm_module_types": version "0.0.0" uid "" @@ -6730,6 +6738,10 @@ version "0.0.0" uid "" +"@types/kbn__shared-ux-button-toolbar@link:bazel-bin/packages/shared-ux/button_toolbar/npm_module_types": + version "0.0.0" + uid "" + "@types/kbn__shared-ux-components@link:bazel-bin/packages/kbn-shared-ux-components/npm_module_types": version "0.0.0" uid "" @@ -6754,10 +6766,6 @@ version "0.0.0" uid "" -"@types/kbn__shared-ux-button-toolbar@link:bazel-bin/packages/shared-ux/button_toolbar/npm_module_types": - version "0.0.0" - uid "" - "@types/kbn__shared-ux-storybook@link:bazel-bin/packages/kbn-shared-ux-storybook/npm_module_types": version "0.0.0" uid "" From 21429bfc81d34867afcf40f6a52c822d7a9fe19a Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 22 Jun 2022 10:59:58 +0200 Subject: [PATCH 05/11] [ML] Updated comment. --- x-pack/packages/ml/data_utils/src/get_agg_intervals.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts b/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts index 3a305823749b..fd0f6ffcc351 100644 --- a/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts +++ b/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts @@ -18,9 +18,12 @@ import { getSamplerAggregationsResponsePath } from './get_sampler_aggregations_r import { stringHash } from './string_hash'; // TODO Temporary type definition until we can import from `@kbn/core`. +// Copied from src/core/server/elasticsearch/client/types.ts +// as these types aren't part of any package yet. Once they are, remove this completely + /** * Client used to query the elasticsearch cluster. - * + * @deprecated At some point use the one from src/core/server/elasticsearch/client/types.ts when it is made into a package. If it never is, then keep using this one. * @public */ export type ElasticsearchClient = Omit< From 7fb36a6d67bdd24dc175fcb670fb9c6cbc8924dd Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 22 Jun 2022 12:38:33 +0200 Subject: [PATCH 06/11] [ML] Improve docs. --- x-pack/packages/ml/data_utils/README.md | 39 +++ x-pack/packages/ml/data_utils/package.json | 8 +- .../src/build_sampler_aggregation.ts | 8 +- .../ml/data_utils/src/get_agg_intervals.ts | 7 +- x-pack/packages/ml/data_utils/yarn.lock | 300 ++++++++++++++++++ .../packages/ml/is_populated_object/README.md | 23 +- .../ml/is_populated_object/package.json | 8 +- .../src/is_populated_object.ts | 2 +- .../packages/ml/is_populated_object/yarn.lock | 300 ++++++++++++++++++ 9 files changed, 686 insertions(+), 9 deletions(-) create mode 100644 x-pack/packages/ml/data_utils/yarn.lock create mode 100644 x-pack/packages/ml/is_populated_object/yarn.lock diff --git a/x-pack/packages/ml/data_utils/README.md b/x-pack/packages/ml/data_utils/README.md index ff0ee54cf3a8..60144fa03e01 100644 --- a/x-pack/packages/ml/data_utils/README.md +++ b/x-pack/packages/ml/data_utils/README.md @@ -1,3 +1,42 @@ # @kbn/ml-data-utils This package includes utility functions provided by the ML team to be used in Kibana plugins related to data manipulation and verification. + + + +### `buildSamplerAggregation` (function) + +Wraps the supplied aggregations in a sampler aggregation. +A supplied samplerShardSize (the shard_size parameter of the sampler aggregation) +of less than 1 indicates no sampling, and the aggs are returned as-is. + +**Parameters:** + +- aggs (`any`) +- samplerShardSize (`number`) + +**returns:** Record + +### `getSamplerAggregationsResponsePath` (function) + +**Parameters:** + +- samplerShardSize (`number`) + +**returns:** string[] + +### `stringHash` (function) + +Creates a deterministic number based hash out of a string. + +**Parameters:** + +- str (`string`) + +**returns:** number + +### `getAggIntervals` (function) + +Returns aggregation intervals for the supplied document fields. + + diff --git a/x-pack/packages/ml/data_utils/package.json b/x-pack/packages/ml/data_utils/package.json index 0c64681dceb6..fd87b48cae53 100644 --- a/x-pack/packages/ml/data_utils/package.json +++ b/x-pack/packages/ml/data_utils/package.json @@ -3,5 +3,11 @@ "private": true, "version": "1.0.0", "main": "./target_node/index.js", - "license": "SSPL-1.0 OR Elastic License 2.0" + "license": "SSPL-1.0 OR Elastic License 2.0", + "devDependencies": { + "ts-readme": "^1.1.3" + }, + "scripts": { + "generate-docs": "ts-readme src/index.ts" + } } diff --git a/x-pack/packages/ml/data_utils/src/build_sampler_aggregation.ts b/x-pack/packages/ml/data_utils/src/build_sampler_aggregation.ts index 321b35bd488e..30345b00caf2 100644 --- a/x-pack/packages/ml/data_utils/src/build_sampler_aggregation.ts +++ b/x-pack/packages/ml/data_utils/src/build_sampler_aggregation.ts @@ -7,9 +7,11 @@ import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -// Wraps the supplied aggregations in a sampler aggregation. -// A supplied samplerShardSize (the shard_size parameter of the sampler aggregation) -// of less than 1 indicates no sampling, and the aggs are returned as-is. +/** + * Wraps the supplied aggregations in a sampler aggregation. + * A supplied samplerShardSize (the shard_size parameter of the sampler aggregation) + * of less than 1 indicates no sampling, and the aggs are returned as-is. + */ export function buildSamplerAggregation( aggs: any, samplerShardSize: number diff --git a/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts b/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts index fd0f6ffcc351..ad17f3a69c23 100644 --- a/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts +++ b/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts @@ -26,14 +26,14 @@ import { stringHash } from './string_hash'; * @deprecated At some point use the one from src/core/server/elasticsearch/client/types.ts when it is made into a package. If it never is, then keep using this one. * @public */ -export type ElasticsearchClient = Omit< +type ElasticsearchClient = Omit< Client, 'connectionPool' | 'serializer' | 'extend' | 'close' | 'diagnostic' >; const MAX_CHART_COLUMNS = 20; -export interface HistogramField { +interface HistogramField { fieldName: string; type: string; } @@ -45,6 +45,9 @@ interface NumericColumnStats { } type NumericColumnStatsMap = Record; +/** + * Returns aggregation intervals for the supplied document fields. + */ export const getAggIntervals = async ( client: ElasticsearchClient, indexPattern: string, diff --git a/x-pack/packages/ml/data_utils/yarn.lock b/x-pack/packages/ml/data_utils/yarn.lock new file mode 100644 index 000000000000..e826cf14c9da --- /dev/null +++ b/x-pack/packages/ml/data_utils/yarn.lock @@ -0,0 +1,300 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" + +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== + +"@nodelib/fs.walk@^1.2.3": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== + dependencies: + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" + +"@types/command-line-args@^5.0.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@types/command-line-args/-/command-line-args-5.2.0.tgz#adbb77980a1cc376bb208e3f4142e907410430f6" + integrity sha512-UuKzKpJJ/Ief6ufIaIzr3A/0XnluX7RvFgwkV89Yzvm77wCh1kFaFmqN8XEnGcN62EuHdedQjEMb8mYxFLGPyA== + +"@types/command-line-usage@^5.0.1": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@types/command-line-usage/-/command-line-usage-5.0.2.tgz#ba5e3f6ae5a2009d466679cc431b50635bf1a064" + integrity sha512-n7RlEEJ+4x4TS7ZQddTmNSxP+zziEG0TNsMfiRIxcIVXt71ENJ9ojeXmGO3wPoTdn7pJcU2xc3CJYMktNT6DPg== + +ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +array-back@^3.0.1, array-back@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" + integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== + +array-back@^4.0.1, array-back@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.2.tgz#8004e999a6274586beeb27342168652fdb89fa1e" + integrity sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg== + +braces@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +chalk@^2.4.1, chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== + +command-line-application@^0.9.6: + version "0.9.6" + resolved "https://registry.yarnpkg.com/command-line-application/-/command-line-application-0.9.6.tgz#03da3db29a0dbee1af601f03198a2f2425d67803" + integrity sha512-7wc7YX7s/hqZWKp4r37IBlW/Bhh92HWeQW2VV++Mt9x35AKFntz9f7A94Zz+AsImHZmRGHd8iNW5m0jUd4GQpg== + dependencies: + "@types/command-line-args" "^5.0.0" + "@types/command-line-usage" "^5.0.1" + chalk "^2.4.1" + command-line-args "^5.1.1" + command-line-usage "^6.0.0" + meant "^1.0.1" + remove-markdown "^0.3.0" + tslib "1.10.0" + +command-line-args@^5.1.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-5.2.1.tgz#c44c32e437a57d7c51157696893c5909e9cec42e" + integrity sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg== + dependencies: + array-back "^3.1.0" + find-replace "^3.0.0" + lodash.camelcase "^4.3.0" + typical "^4.0.0" + +command-line-usage@^6.0.0: + version "6.1.3" + resolved "https://registry.yarnpkg.com/command-line-usage/-/command-line-usage-6.1.3.tgz#428fa5acde6a838779dfa30e44686f4b6761d957" + integrity sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw== + dependencies: + array-back "^4.0.2" + chalk "^2.4.2" + table-layout "^1.0.2" + typical "^5.2.0" + +deep-extend@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== + +fast-glob@^3.1.1: + version "3.2.11" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" + integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + +fastq@^1.6.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" + integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== + dependencies: + reusify "^1.0.4" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-replace@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-3.0.0.tgz#3e7e23d3b05167a76f770c9fbd5258b0def68c38" + integrity sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ== + dependencies: + array-back "^3.0.1" + +glob-parent@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-glob@^4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +lodash.camelcase@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== + +meant@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/meant/-/meant-1.0.3.tgz#67769af9de1d158773e928ae82c456114903554c" + integrity sha512-88ZRGcNxAq4EH38cQ4D85PM57pikCwS8Z99EWHODxN7KBY+UuPiqzRTtZzS8KTXO/ywSWbdjjJST2Hly/EQxLw== + +merge2@^1.3.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + +micromatch@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + +picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +prettier@1.19.1: + version "1.19.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" + integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== + +queue-microtask@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== + +reduce-flatten@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27" + integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w== + +remove-markdown@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/remove-markdown/-/remove-markdown-0.3.0.tgz#5e4b667493a93579728f3d52ecc1db9ca505dc98" + integrity sha512-5392eIuy1mhjM74739VunOlsOYKjsH82rQcTBlJ1bkICVC3dQ3ksQzTHh4jGHQFnM+1xzLzcFOMH+BofqXhroQ== + +reusify@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" + integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== + +run-parallel@^1.1.9: + version "1.2.0" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== + dependencies: + queue-microtask "^1.2.2" + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +table-layout@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.2.tgz#c4038a1853b0136d63365a734b6931cf4fad4a04" + integrity sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A== + dependencies: + array-back "^4.0.1" + deep-extend "~0.6.0" + typical "^5.2.0" + wordwrapjs "^4.0.0" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +ts-readme@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/ts-readme/-/ts-readme-1.1.3.tgz#18a73d21f3bb50ee8e2df819bcbbe3a76385b15a" + integrity sha512-GvI+Vu3m/LGBlgrWwzSmvslnz8msJLNrZ7hQ3Ko2B6PMxeXidqsn6fi20IWgepFjOzhKGw/WlG8NmM7jl3DWeg== + dependencies: + command-line-application "^0.9.6" + fast-glob "^3.1.1" + prettier "1.19.1" + +tslib@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" + integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== + +typical@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" + integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== + +typical@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066" + integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg== + +wordwrapjs@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-4.0.1.tgz#d9790bccfb110a0fc7836b5ebce0937b37a8b98f" + integrity sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA== + dependencies: + reduce-flatten "^2.0.0" + typical "^5.2.0" diff --git a/x-pack/packages/ml/is_populated_object/README.md b/x-pack/packages/ml/is_populated_object/README.md index 74734eb52f66..8d2d47329a3f 100644 --- a/x-pack/packages/ml/is_populated_object/README.md +++ b/x-pack/packages/ml/is_populated_object/README.md @@ -1,3 +1,24 @@ # @kbn/ml-is-populated-object - A type guard to check record like object structures. + + +### `isPopulatedObject` (function) + +A type guard to check record like object structures. + +Examples: + +- `isPopulatedObject({...})` + Limits type to Record + +- `isPopulatedObject({...}, ['attribute'])` + Limits type to Record<'attribute', unknown> + +- `isPopulatedObject({...})` + Limits type to a record with keys of the given interface. + Note that you might want to add keys from the interface to the + array of requiredAttributes to satisfy runtime requirements. + Otherwise you'd just satisfy TS requirements but might still + run into runtime issues. + + diff --git a/x-pack/packages/ml/is_populated_object/package.json b/x-pack/packages/ml/is_populated_object/package.json index 5cd4cc805427..3ca3e0fcffb0 100644 --- a/x-pack/packages/ml/is_populated_object/package.json +++ b/x-pack/packages/ml/is_populated_object/package.json @@ -3,5 +3,11 @@ "private": true, "version": "1.0.0", "main": "./target_node/index.js", - "license": "SSPL-1.0 OR Elastic License 2.0" + "license": "SSPL-1.0 OR Elastic License 2.0", + "devDependencies": { + "ts-readme": "^1.1.3" + }, + "scripts": { + "generate-docs": "ts-readme src/index.ts" + } } diff --git a/x-pack/packages/ml/is_populated_object/src/is_populated_object.ts b/x-pack/packages/ml/is_populated_object/src/is_populated_object.ts index 537ee9202b4d..43c529206bb6 100644 --- a/x-pack/packages/ml/is_populated_object/src/is_populated_object.ts +++ b/x-pack/packages/ml/is_populated_object/src/is_populated_object.ts @@ -5,7 +5,7 @@ * 2.0. */ -/* +/** * A type guard to check record like object structures. * * Examples: diff --git a/x-pack/packages/ml/is_populated_object/yarn.lock b/x-pack/packages/ml/is_populated_object/yarn.lock new file mode 100644 index 000000000000..e826cf14c9da --- /dev/null +++ b/x-pack/packages/ml/is_populated_object/yarn.lock @@ -0,0 +1,300 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" + +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== + +"@nodelib/fs.walk@^1.2.3": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== + dependencies: + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" + +"@types/command-line-args@^5.0.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@types/command-line-args/-/command-line-args-5.2.0.tgz#adbb77980a1cc376bb208e3f4142e907410430f6" + integrity sha512-UuKzKpJJ/Ief6ufIaIzr3A/0XnluX7RvFgwkV89Yzvm77wCh1kFaFmqN8XEnGcN62EuHdedQjEMb8mYxFLGPyA== + +"@types/command-line-usage@^5.0.1": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@types/command-line-usage/-/command-line-usage-5.0.2.tgz#ba5e3f6ae5a2009d466679cc431b50635bf1a064" + integrity sha512-n7RlEEJ+4x4TS7ZQddTmNSxP+zziEG0TNsMfiRIxcIVXt71ENJ9ojeXmGO3wPoTdn7pJcU2xc3CJYMktNT6DPg== + +ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +array-back@^3.0.1, array-back@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" + integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== + +array-back@^4.0.1, array-back@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.2.tgz#8004e999a6274586beeb27342168652fdb89fa1e" + integrity sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg== + +braces@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +chalk@^2.4.1, chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== + +command-line-application@^0.9.6: + version "0.9.6" + resolved "https://registry.yarnpkg.com/command-line-application/-/command-line-application-0.9.6.tgz#03da3db29a0dbee1af601f03198a2f2425d67803" + integrity sha512-7wc7YX7s/hqZWKp4r37IBlW/Bhh92HWeQW2VV++Mt9x35AKFntz9f7A94Zz+AsImHZmRGHd8iNW5m0jUd4GQpg== + dependencies: + "@types/command-line-args" "^5.0.0" + "@types/command-line-usage" "^5.0.1" + chalk "^2.4.1" + command-line-args "^5.1.1" + command-line-usage "^6.0.0" + meant "^1.0.1" + remove-markdown "^0.3.0" + tslib "1.10.0" + +command-line-args@^5.1.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-5.2.1.tgz#c44c32e437a57d7c51157696893c5909e9cec42e" + integrity sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg== + dependencies: + array-back "^3.1.0" + find-replace "^3.0.0" + lodash.camelcase "^4.3.0" + typical "^4.0.0" + +command-line-usage@^6.0.0: + version "6.1.3" + resolved "https://registry.yarnpkg.com/command-line-usage/-/command-line-usage-6.1.3.tgz#428fa5acde6a838779dfa30e44686f4b6761d957" + integrity sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw== + dependencies: + array-back "^4.0.2" + chalk "^2.4.2" + table-layout "^1.0.2" + typical "^5.2.0" + +deep-extend@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== + +fast-glob@^3.1.1: + version "3.2.11" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" + integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + +fastq@^1.6.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" + integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== + dependencies: + reusify "^1.0.4" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-replace@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-3.0.0.tgz#3e7e23d3b05167a76f770c9fbd5258b0def68c38" + integrity sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ== + dependencies: + array-back "^3.0.1" + +glob-parent@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-glob@^4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +lodash.camelcase@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== + +meant@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/meant/-/meant-1.0.3.tgz#67769af9de1d158773e928ae82c456114903554c" + integrity sha512-88ZRGcNxAq4EH38cQ4D85PM57pikCwS8Z99EWHODxN7KBY+UuPiqzRTtZzS8KTXO/ywSWbdjjJST2Hly/EQxLw== + +merge2@^1.3.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + +micromatch@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + +picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +prettier@1.19.1: + version "1.19.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" + integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== + +queue-microtask@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== + +reduce-flatten@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27" + integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w== + +remove-markdown@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/remove-markdown/-/remove-markdown-0.3.0.tgz#5e4b667493a93579728f3d52ecc1db9ca505dc98" + integrity sha512-5392eIuy1mhjM74739VunOlsOYKjsH82rQcTBlJ1bkICVC3dQ3ksQzTHh4jGHQFnM+1xzLzcFOMH+BofqXhroQ== + +reusify@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" + integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== + +run-parallel@^1.1.9: + version "1.2.0" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== + dependencies: + queue-microtask "^1.2.2" + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +table-layout@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.2.tgz#c4038a1853b0136d63365a734b6931cf4fad4a04" + integrity sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A== + dependencies: + array-back "^4.0.1" + deep-extend "~0.6.0" + typical "^5.2.0" + wordwrapjs "^4.0.0" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +ts-readme@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/ts-readme/-/ts-readme-1.1.3.tgz#18a73d21f3bb50ee8e2df819bcbbe3a76385b15a" + integrity sha512-GvI+Vu3m/LGBlgrWwzSmvslnz8msJLNrZ7hQ3Ko2B6PMxeXidqsn6fi20IWgepFjOzhKGw/WlG8NmM7jl3DWeg== + dependencies: + command-line-application "^0.9.6" + fast-glob "^3.1.1" + prettier "1.19.1" + +tslib@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" + integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== + +typical@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" + integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== + +typical@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066" + integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg== + +wordwrapjs@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-4.0.1.tgz#d9790bccfb110a0fc7836b5ebce0937b37a8b98f" + integrity sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA== + dependencies: + reduce-flatten "^2.0.0" + typical "^5.2.0" From 76794bd51023db9215479fc5debdd65c19a89b87 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 22 Jun 2022 12:43:36 +0200 Subject: [PATCH 07/11] [ML] Remove unnecessary ts-ignore. --- x-pack/plugins/ml/common/util/job_utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/ml/common/util/job_utils.ts b/x-pack/plugins/ml/common/util/job_utils.ts index 28e03acbab02..d7faf732a7c8 100644 --- a/x-pack/plugins/ml/common/util/job_utils.ts +++ b/x-pack/plugins/ml/common/util/job_utils.ts @@ -9,7 +9,6 @@ import { each, isEmpty, isEqual, pick } from 'lodash'; import semverGte from 'semver/functions/gte'; import moment, { Duration } from 'moment'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -// @ts-ignore import numeral from '@elastic/numeral'; import { i18n } from '@kbn/i18n'; import { isPopulatedObject } from '@kbn/ml-is-populated-object'; From 407dce36aca630f69668c4866efe05a150ef4207 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 22 Jun 2022 12:46:26 +0200 Subject: [PATCH 08/11] [ML] Improve types. --- x-pack/packages/ml/data_utils/src/get_agg_intervals.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts b/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts index ad17f3a69c23..49ce6e653e88 100644 --- a/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts +++ b/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts @@ -51,7 +51,7 @@ type NumericColumnStatsMap = Record; export const getAggIntervals = async ( client: ElasticsearchClient, indexPattern: string, - query: any, + query: estypes.QueryDslQueryContainer, fields: HistogramField[], samplerShardSize: number, runtimeMappings?: estypes.MappingRuntimeFields From fd7767eec5de9e7bac2ea92fcc3cf11f5d2f4580 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 22 Jun 2022 12:49:47 +0200 Subject: [PATCH 09/11] [ML] Update CODEOWNERS. --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2682f1fc9c7c..6813dcaa33c0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -202,6 +202,7 @@ /x-pack/test/functional/apps/transform/ @elastic/ml-ui /x-pack/test/functional/services/transform/ @elastic/ml-ui /x-pack/test/functional_basic/apps/transform/ @elastic/ml-ui +/x-pack/packages/ml/ @elastic/ml-ui /packages/kbn-aiops-utils @elastic/ml-ui /examples/response_stream/ @elastic/ml-ui From 14f7221d356b753d224f622bc47534a80c4f5c5b Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 22 Jun 2022 13:40:26 +0200 Subject: [PATCH 10/11] [ML] Create @kbn/ml-string-hash package. Rename @kbn/ml-data-utils to @kbn/ml-agg-utils. --- package.json | 6 +- packages/BUILD.bazel | 6 +- .../ml/{data_utils => agg_utils}/BUILD.bazel | 6 +- .../ml/{data_utils => agg_utils}/README.md | 2 +- .../{data_utils => agg_utils}/jest.config.js | 2 +- .../ml/{data_utils => agg_utils}/package.json | 2 +- .../src/build_sampler_aggregation.test.ts | 0 .../src/build_sampler_aggregation.ts | 0 .../src/get_agg_intervals.ts | 2 +- ...sampler_aggregations_response_path.test.ts | 0 .../get_sampler_aggregations_response_path.ts | 0 .../ml/{data_utils => agg_utils}/src/index.ts | 1 - .../{data_utils => agg_utils}/tsconfig.json | 0 .../ml/{data_utils => agg_utils}/yarn.lock | 0 x-pack/packages/ml/string_hash/BUILD.bazel | 114 ++++++++++++++++++ x-pack/packages/ml/string_hash/README.md | 5 + x-pack/packages/ml/string_hash/jest.config.js | 12 ++ x-pack/packages/ml/string_hash/package.json | 7 ++ x-pack/packages/ml/string_hash/src/index.ts | 8 ++ .../src/string_hash.test.ts | 0 .../src/string_hash.ts | 0 x-pack/packages/ml/string_hash/tsconfig.json | 17 +++ .../requests/get_boolean_field_stats.ts | 2 +- .../requests/get_date_field_stats.ts | 2 +- .../requests/get_numeric_field_stats.ts | 2 +- .../requests/get_string_field_stats.ts | 2 +- .../search_strategy/requests/overall_stats.ts | 2 +- .../ml/common/util/group_color_utils.ts | 2 +- .../scatterplot_matrix/scatterplot_matrix.tsx | 2 +- .../models/data_visualizer/data_visualizer.ts | 4 +- .../transform_list/expanded_row.tsx | 2 +- yarn.lock | 12 +- 32 files changed, 199 insertions(+), 23 deletions(-) rename x-pack/packages/ml/{data_utils => agg_utils}/BUILD.bazel (94%) rename x-pack/packages/ml/{data_utils => agg_utils}/README.md (97%) rename x-pack/packages/ml/{data_utils => agg_utils}/jest.config.js (86%) rename x-pack/packages/ml/{data_utils => agg_utils}/package.json (88%) rename x-pack/packages/ml/{data_utils => agg_utils}/src/build_sampler_aggregation.test.ts (100%) rename x-pack/packages/ml/{data_utils => agg_utils}/src/build_sampler_aggregation.ts (100%) rename x-pack/packages/ml/{data_utils => agg_utils}/src/get_agg_intervals.ts (98%) rename x-pack/packages/ml/{data_utils => agg_utils}/src/get_sampler_aggregations_response_path.test.ts (100%) rename x-pack/packages/ml/{data_utils => agg_utils}/src/get_sampler_aggregations_response_path.ts (100%) rename x-pack/packages/ml/{data_utils => agg_utils}/src/index.ts (91%) rename x-pack/packages/ml/{data_utils => agg_utils}/tsconfig.json (100%) rename x-pack/packages/ml/{data_utils => agg_utils}/yarn.lock (100%) create mode 100644 x-pack/packages/ml/string_hash/BUILD.bazel create mode 100644 x-pack/packages/ml/string_hash/README.md create mode 100644 x-pack/packages/ml/string_hash/jest.config.js create mode 100644 x-pack/packages/ml/string_hash/package.json create mode 100644 x-pack/packages/ml/string_hash/src/index.ts rename x-pack/packages/ml/{data_utils => string_hash}/src/string_hash.test.ts (100%) rename x-pack/packages/ml/{data_utils => string_hash}/src/string_hash.ts (100%) create mode 100644 x-pack/packages/ml/string_hash/tsconfig.json diff --git a/package.json b/package.json index 78974ca0b21e..bb6cff1518ff 100644 --- a/package.json +++ b/package.json @@ -187,8 +187,9 @@ "@kbn/logging": "link:bazel-bin/packages/kbn-logging", "@kbn/logging-mocks": "link:bazel-bin/packages/kbn-logging-mocks", "@kbn/mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl", - "@kbn/ml-data-utils": "link:bazel-bin/x-pack/packages/ml/data_utils", + "@kbn/ml-agg-utils": "link:bazel-bin/x-pack/packages/ml/agg_utils", "@kbn/ml-is-populated-object": "link:bazel-bin/x-pack/packages/ml/is_populated_object", + "@kbn/ml-string-hash": "link:bazel-bin/x-pack/packages/ml/string_hash", "@kbn/monaco": "link:bazel-bin/packages/kbn-monaco", "@kbn/plugin-discovery": "link:bazel-bin/packages/kbn-plugin-discovery", "@kbn/react-field": "link:bazel-bin/packages/kbn-react-field", @@ -724,8 +725,9 @@ "@types/kbn__logging": "link:bazel-bin/packages/kbn-logging/npm_module_types", "@types/kbn__logging-mocks": "link:bazel-bin/packages/kbn-logging-mocks/npm_module_types", "@types/kbn__mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl/npm_module_types", - "@types/kbn__ml-data-utils": "link:bazel-bin/x-pack/packages/ml/data_utils/npm_module_types", + "@types/kbn__ml-agg-utils": "link:bazel-bin/x-pack/packages/ml/agg_utils/npm_module_types", "@types/kbn__ml-is-populated-object": "link:bazel-bin/x-pack/packages/ml/is_populated_object/npm_module_types", + "@types/kbn__ml-string-hash": "link:bazel-bin/x-pack/packages/ml/string_hash/npm_module_types", "@types/kbn__monaco": "link:bazel-bin/packages/kbn-monaco/npm_module_types", "@types/kbn__optimizer": "link:bazel-bin/packages/kbn-optimizer/npm_module_types", "@types/kbn__optimizer-webpack-helpers": "link:bazel-bin/packages/kbn-optimizer-webpack-helpers/npm_module_types", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index 87ce75d9a85d..07be99579114 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -151,8 +151,9 @@ filegroup( "//packages/shared-ux/page/analytics_no_data:build", "//packages/shared-ux/page/kibana_no_data:build", "//packages/shared-ux/prompt/no_data_views:build", - "//x-pack/packages/ml/data_utils:build", + "//x-pack/packages/ml/agg_utils:build", "//x-pack/packages/ml/is_populated_object:build", + "//x-pack/packages/ml/string_hash:build", ], ) @@ -287,8 +288,9 @@ filegroup( "//packages/shared-ux/page/analytics_no_data:build_types", "//packages/shared-ux/page/kibana_no_data:build_types", "//packages/shared-ux/prompt/no_data_views:build_types", - "//x-pack/packages/ml/data_utils:build_types", + "//x-pack/packages/ml/agg_utils:build_types", "//x-pack/packages/ml/is_populated_object:build_types", + "//x-pack/packages/ml/string_hash:build_types", ], ) diff --git a/x-pack/packages/ml/data_utils/BUILD.bazel b/x-pack/packages/ml/agg_utils/BUILD.bazel similarity index 94% rename from x-pack/packages/ml/data_utils/BUILD.bazel rename to x-pack/packages/ml/agg_utils/BUILD.bazel index 1314f055032a..0d59aca092fd 100644 --- a/x-pack/packages/ml/data_utils/BUILD.bazel +++ b/x-pack/packages/ml/agg_utils/BUILD.bazel @@ -2,8 +2,8 @@ load("@npm//@bazel/typescript:index.bzl", "ts_config") load("@build_bazel_rules_nodejs//:index.bzl", "js_library") load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") -PKG_DIRNAME = "data-utils" -PKG_REQUIRE_NAME = "@kbn/ml-data-utils" +PKG_DIRNAME = "agg_utils" +PKG_REQUIRE_NAME = "@kbn/ml-agg-utils" SOURCE_FILES = glob( [ @@ -40,6 +40,7 @@ RUNTIME_DEPS = [ "@npm//lodash", "//packages/kbn-field-types", "//x-pack/packages/ml/is_populated_object", + "//x-pack/packages/ml/string_hash", ] # In this array place dependencies necessary to build the types, which will include the @@ -59,6 +60,7 @@ TYPES_DEPS = [ "@npm//tslib", "//packages/kbn-field-types:npm_module_types", "//x-pack/packages/ml/is_populated_object:npm_module_types", + "//x-pack/packages/ml/string_hash:npm_module_types", ] jsts_transpiler( diff --git a/x-pack/packages/ml/data_utils/README.md b/x-pack/packages/ml/agg_utils/README.md similarity index 97% rename from x-pack/packages/ml/data_utils/README.md rename to x-pack/packages/ml/agg_utils/README.md index 60144fa03e01..9d8eff158661 100644 --- a/x-pack/packages/ml/data_utils/README.md +++ b/x-pack/packages/ml/agg_utils/README.md @@ -1,4 +1,4 @@ -# @kbn/ml-data-utils +# @kbn/ml-agg-utils This package includes utility functions provided by the ML team to be used in Kibana plugins related to data manipulation and verification. diff --git a/x-pack/packages/ml/data_utils/jest.config.js b/x-pack/packages/ml/agg_utils/jest.config.js similarity index 86% rename from x-pack/packages/ml/data_utils/jest.config.js rename to x-pack/packages/ml/agg_utils/jest.config.js index 232fa7ed891b..a22a76d5bf95 100644 --- a/x-pack/packages/ml/data_utils/jest.config.js +++ b/x-pack/packages/ml/agg_utils/jest.config.js @@ -8,5 +8,5 @@ module.exports = { preset: '@kbn/test/jest_node', rootDir: '../../../..', - roots: ['/x-pack/packages/ml/data_utils'], + roots: ['/x-pack/packages/ml/agg_utils'], }; diff --git a/x-pack/packages/ml/data_utils/package.json b/x-pack/packages/ml/agg_utils/package.json similarity index 88% rename from x-pack/packages/ml/data_utils/package.json rename to x-pack/packages/ml/agg_utils/package.json index fd87b48cae53..11f2fe9d4d45 100644 --- a/x-pack/packages/ml/data_utils/package.json +++ b/x-pack/packages/ml/agg_utils/package.json @@ -1,5 +1,5 @@ { - "name": "@kbn/ml-data-utils", + "name": "@kbn/ml-agg-utils", "private": true, "version": "1.0.0", "main": "./target_node/index.js", diff --git a/x-pack/packages/ml/data_utils/src/build_sampler_aggregation.test.ts b/x-pack/packages/ml/agg_utils/src/build_sampler_aggregation.test.ts similarity index 100% rename from x-pack/packages/ml/data_utils/src/build_sampler_aggregation.test.ts rename to x-pack/packages/ml/agg_utils/src/build_sampler_aggregation.test.ts diff --git a/x-pack/packages/ml/data_utils/src/build_sampler_aggregation.ts b/x-pack/packages/ml/agg_utils/src/build_sampler_aggregation.ts similarity index 100% rename from x-pack/packages/ml/data_utils/src/build_sampler_aggregation.ts rename to x-pack/packages/ml/agg_utils/src/build_sampler_aggregation.ts diff --git a/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts b/x-pack/packages/ml/agg_utils/src/get_agg_intervals.ts similarity index 98% rename from x-pack/packages/ml/data_utils/src/get_agg_intervals.ts rename to x-pack/packages/ml/agg_utils/src/get_agg_intervals.ts index 49ce6e653e88..67a6f28497d6 100644 --- a/x-pack/packages/ml/data_utils/src/get_agg_intervals.ts +++ b/x-pack/packages/ml/agg_utils/src/get_agg_intervals.ts @@ -12,10 +12,10 @@ import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { KBN_FIELD_TYPES } from '@kbn/field-types'; import { isPopulatedObject } from '@kbn/ml-is-populated-object'; +import { stringHash } from '@kbn/ml-string-hash'; import { buildSamplerAggregation } from './build_sampler_aggregation'; import { getSamplerAggregationsResponsePath } from './get_sampler_aggregations_response_path'; -import { stringHash } from './string_hash'; // TODO Temporary type definition until we can import from `@kbn/core`. // Copied from src/core/server/elasticsearch/client/types.ts diff --git a/x-pack/packages/ml/data_utils/src/get_sampler_aggregations_response_path.test.ts b/x-pack/packages/ml/agg_utils/src/get_sampler_aggregations_response_path.test.ts similarity index 100% rename from x-pack/packages/ml/data_utils/src/get_sampler_aggregations_response_path.test.ts rename to x-pack/packages/ml/agg_utils/src/get_sampler_aggregations_response_path.test.ts diff --git a/x-pack/packages/ml/data_utils/src/get_sampler_aggregations_response_path.ts b/x-pack/packages/ml/agg_utils/src/get_sampler_aggregations_response_path.ts similarity index 100% rename from x-pack/packages/ml/data_utils/src/get_sampler_aggregations_response_path.ts rename to x-pack/packages/ml/agg_utils/src/get_sampler_aggregations_response_path.ts diff --git a/x-pack/packages/ml/data_utils/src/index.ts b/x-pack/packages/ml/agg_utils/src/index.ts similarity index 91% rename from x-pack/packages/ml/data_utils/src/index.ts rename to x-pack/packages/ml/agg_utils/src/index.ts index fbed0682b8ff..6705a28579b4 100644 --- a/x-pack/packages/ml/data_utils/src/index.ts +++ b/x-pack/packages/ml/agg_utils/src/index.ts @@ -8,4 +8,3 @@ export { buildSamplerAggregation } from './build_sampler_aggregation'; export { getAggIntervals } from './get_agg_intervals'; export { getSamplerAggregationsResponsePath } from './get_sampler_aggregations_response_path'; -export { stringHash } from './string_hash'; diff --git a/x-pack/packages/ml/data_utils/tsconfig.json b/x-pack/packages/ml/agg_utils/tsconfig.json similarity index 100% rename from x-pack/packages/ml/data_utils/tsconfig.json rename to x-pack/packages/ml/agg_utils/tsconfig.json diff --git a/x-pack/packages/ml/data_utils/yarn.lock b/x-pack/packages/ml/agg_utils/yarn.lock similarity index 100% rename from x-pack/packages/ml/data_utils/yarn.lock rename to x-pack/packages/ml/agg_utils/yarn.lock diff --git a/x-pack/packages/ml/string_hash/BUILD.bazel b/x-pack/packages/ml/string_hash/BUILD.bazel new file mode 100644 index 000000000000..50e89a8975b5 --- /dev/null +++ b/x-pack/packages/ml/string_hash/BUILD.bazel @@ -0,0 +1,114 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") + +PKG_DIRNAME = "string_hash" +PKG_REQUIRE_NAME = "@kbn/ml-string-hash" + +SOURCE_FILES = glob( + [ + "src/**/*.ts", + ], + exclude = [ + "**/*.test.*", + ], +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", +] + +# In this array place runtime dependencies, including other packages and NPM packages +# which must be available for this code to run. +# +# To reference other packages use: +# "//repo/relative/path/to/package" +# eg. "//packages/kbn-utils" +# +# To reference a NPM package use: +# "@npm//name-of-package" +# eg. "@npm//lodash" +RUNTIME_DEPS = [ +] + +# In this array place dependencies necessary to build the types, which will include the +# :npm_module_types target of other packages and packages from NPM, including @types/* +# packages. +# +# To reference the types for another package use: +# "//repo/relative/path/to/package:npm_module_types" +# eg. "//packages/kbn-utils:npm_module_types" +# +# References to NPM packages work the same as RUNTIME_DEPS +TYPES_DEPS = [ + "@npm//@types/node", + "@npm//@types/jest", +] + +jsts_transpiler( + name = "target_node", + srcs = SRCS, + build_pkg_name = package_name(), +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + "//:tsconfig.bazel.json", + ], +) + +ts_project( + name = "tsc_types", + args = ['--pretty'], + srcs = SRCS, + deps = TYPES_DEPS, + declaration = True, + emit_declaration_only = True, + out_dir = "target_types", + root_dir = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_DIRNAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = RUNTIME_DEPS + [":target_node"], + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + deps = [":" + PKG_DIRNAME], +) + +filegroup( + name = "build", + srcs = [":npm_module"], + visibility = ["//visibility:public"], +) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [":npm_module_types"], + visibility = ["//visibility:public"], +) diff --git a/x-pack/packages/ml/string_hash/README.md b/x-pack/packages/ml/string_hash/README.md new file mode 100644 index 000000000000..8398d2678996 --- /dev/null +++ b/x-pack/packages/ml/string_hash/README.md @@ -0,0 +1,5 @@ +# @kbn/ml-string-hash + + + + diff --git a/x-pack/packages/ml/string_hash/jest.config.js b/x-pack/packages/ml/string_hash/jest.config.js new file mode 100644 index 000000000000..4f9fe0d1c70e --- /dev/null +++ b/x-pack/packages/ml/string_hash/jest.config.js @@ -0,0 +1,12 @@ +/* + * 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. + */ + +module.exports = { + preset: '@kbn/test/jest_node', + rootDir: '../../../..', + roots: ['/x-pack/packages/ml/string_hash'], +}; diff --git a/x-pack/packages/ml/string_hash/package.json b/x-pack/packages/ml/string_hash/package.json new file mode 100644 index 000000000000..5d256e3a47a5 --- /dev/null +++ b/x-pack/packages/ml/string_hash/package.json @@ -0,0 +1,7 @@ +{ + "name": "@kbn/ml-string-hash", + "private": true, + "version": "1.0.0", + "main": "./target_node/index.js", + "license": "SSPL-1.0 OR Elastic License 2.0" +} diff --git a/x-pack/packages/ml/string_hash/src/index.ts b/x-pack/packages/ml/string_hash/src/index.ts new file mode 100644 index 000000000000..f833c95914fb --- /dev/null +++ b/x-pack/packages/ml/string_hash/src/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { stringHash } from './string_hash'; diff --git a/x-pack/packages/ml/data_utils/src/string_hash.test.ts b/x-pack/packages/ml/string_hash/src/string_hash.test.ts similarity index 100% rename from x-pack/packages/ml/data_utils/src/string_hash.test.ts rename to x-pack/packages/ml/string_hash/src/string_hash.test.ts diff --git a/x-pack/packages/ml/data_utils/src/string_hash.ts b/x-pack/packages/ml/string_hash/src/string_hash.ts similarity index 100% rename from x-pack/packages/ml/data_utils/src/string_hash.ts rename to x-pack/packages/ml/string_hash/src/string_hash.ts diff --git a/x-pack/packages/ml/string_hash/tsconfig.json b/x-pack/packages/ml/string_hash/tsconfig.json new file mode 100644 index 000000000000..97a3644c3c70 --- /dev/null +++ b/x-pack/packages/ml/string_hash/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../../tsconfig.bazel.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "target_types", + "rootDir": "src", + "stripInternal": false, + "types": [ + "jest", + "node" + ] + }, + "include": [ + "src/**/*" + ] +} diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts index 0c2cfc05256c..5b91d3716ffd 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_boolean_field_stats.ts @@ -14,7 +14,7 @@ import type { ISearchOptions, ISearchStart, } from '@kbn/data-plugin/public'; -import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-data-utils'; +import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-agg-utils'; import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts index 9d15080cd1ca..1f55f8117c1b 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_date_field_stats.ts @@ -15,7 +15,7 @@ import type { ISearchOptions, ISearchStart, } from '@kbn/data-plugin/public'; -import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-data-utils'; +import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-agg-utils'; import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { FieldStatsCommonRequestParams } from '../../../../../common/types/field_stats'; import type { Field, DateFieldStats, Aggs } from '../../../../../common/types/field_stats'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts index e729b4e0ede8..033f4469b0bc 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_numeric_field_stats.ts @@ -16,7 +16,7 @@ import { ISearchOptions, } from '@kbn/data-plugin/common'; import type { ISearchStart } from '@kbn/data-plugin/public'; -import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-data-utils'; +import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-agg-utils'; import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { MAX_PERCENT, diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts index a66ffd9e2e05..60306ded5d8f 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/get_string_field_stats.ts @@ -15,7 +15,7 @@ import type { ISearchOptions, ISearchStart, } from '@kbn/data-plugin/public'; -import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-data-utils'; +import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-agg-utils'; import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { SAMPLER_TOP_TERMS_SHARD_SIZE, SAMPLER_TOP_TERMS_THRESHOLD } from './constants'; import type { diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts index cb52ff41a44d..a25b3974d45b 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/search_strategy/requests/overall_stats.ts @@ -9,7 +9,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { get } from 'lodash'; import { Query } from '@kbn/es-query'; import { IKibanaSearchResponse } from '@kbn/data-plugin/common'; -import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-data-utils'; +import { buildSamplerAggregation, getSamplerAggregationsResponsePath } from '@kbn/ml-agg-utils'; import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { buildBaseFilterCriteria, diff --git a/x-pack/plugins/ml/common/util/group_color_utils.ts b/x-pack/plugins/ml/common/util/group_color_utils.ts index fc7e7c1c3c04..3c2398a18684 100644 --- a/x-pack/plugins/ml/common/util/group_color_utils.ts +++ b/x-pack/plugins/ml/common/util/group_color_utils.ts @@ -7,7 +7,7 @@ import { euiDarkVars as euiVars } from '@kbn/ui-theme'; -import { stringHash } from '@kbn/ml-data-utils'; +import { stringHash } from '@kbn/ml-string-hash'; const COLORS = [ euiVars.euiColorVis0, diff --git a/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx b/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx index f4a9a6ce8888..e11de5fea47d 100644 --- a/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx +++ b/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx @@ -25,7 +25,7 @@ import { import { i18n } from '@kbn/i18n'; import { DataView } from '@kbn/data-views-plugin/public'; -import { stringHash } from '@kbn/ml-data-utils'; +import { stringHash } from '@kbn/ml-string-hash'; import { extractErrorMessage } from '../../../../common'; import { isRuntimeMappings } from '../../../../common/util/runtime_field_utils'; import { RuntimeMappings } from '../../../../common/types/fields'; 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 6cc7608e9960..6946a2fbda90 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 @@ -13,8 +13,8 @@ import { buildSamplerAggregation, getAggIntervals, getSamplerAggregationsResponsePath, - stringHash, -} from '@kbn/ml-data-utils'; +} from '@kbn/ml-agg-utils'; +import { stringHash } from '@kbn/ml-string-hash'; import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types'; import { getSafeAggregationName } from '../../../common/util/job_utils'; diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx index 2a352c2882c1..6477e33a5c5a 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx @@ -10,7 +10,7 @@ import React, { FC } from 'react'; import { EuiButtonEmpty, EuiTabbedContent } from '@elastic/eui'; import { Optional } from '@kbn/utility-types'; import { i18n } from '@kbn/i18n'; -import { stringHash } from '@kbn/ml-data-utils'; +import { stringHash } from '@kbn/ml-string-hash'; import moment from 'moment-timezone'; import { TransformListRow } from '../../../../common'; diff --git a/yarn.lock b/yarn.lock index 1fb144dc3f2a..27205862d63d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3235,7 +3235,7 @@ version "0.0.0" uid "" -"@kbn/ml-data-utils@link:bazel-bin/x-pack/packages/ml/data_utils": +"@kbn/ml-agg-utils@link:bazel-bin/x-pack/packages/ml/agg_utils": version "0.0.0" uid "" @@ -3243,6 +3243,10 @@ version "0.0.0" uid "" +"@kbn/ml-string-hash@link:bazel-bin/x-pack/packages/ml/string_hash": + version "0.0.0" + uid "" + "@kbn/monaco@link:bazel-bin/packages/kbn-monaco": version "0.0.0" uid "" @@ -6622,7 +6626,7 @@ version "0.0.0" uid "" -"@types/kbn__ml-data-utils@link:bazel-bin/x-pack/packages/ml/data_utils/npm_module_types": +"@types/kbn__ml-agg-utils@link:bazel-bin/x-pack/packages/ml/agg_utils/npm_module_types": version "0.0.0" uid "" @@ -6630,6 +6634,10 @@ version "0.0.0" uid "" +"@types/kbn__ml-string-hash@link:bazel-bin/x-pack/packages/ml/string_hash/npm_module_types": + version "0.0.0" + uid "" + "@types/kbn__monaco@link:bazel-bin/packages/kbn-monaco/npm_module_types": version "0.0.0" uid "" From 138a51fcfc4e2bbbb91b7bc8455dfc15b28a255f Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 22 Jun 2022 13:47:37 +0200 Subject: [PATCH 11/11] [ML] Update package READMEs. --- x-pack/packages/ml/agg_utils/README.md | 10 - x-pack/packages/ml/string_hash/README.md | 10 + x-pack/packages/ml/string_hash/package.json | 8 +- x-pack/packages/ml/string_hash/yarn.lock | 300 ++++++++++++++++++++ 4 files changed, 317 insertions(+), 11 deletions(-) create mode 100644 x-pack/packages/ml/string_hash/yarn.lock diff --git a/x-pack/packages/ml/agg_utils/README.md b/x-pack/packages/ml/agg_utils/README.md index 9d8eff158661..63a30e1f1cbe 100644 --- a/x-pack/packages/ml/agg_utils/README.md +++ b/x-pack/packages/ml/agg_utils/README.md @@ -25,16 +25,6 @@ of less than 1 indicates no sampling, and the aggs are returned as-is. **returns:** string[] -### `stringHash` (function) - -Creates a deterministic number based hash out of a string. - -**Parameters:** - -- str (`string`) - -**returns:** number - ### `getAggIntervals` (function) Returns aggregation intervals for the supplied document fields. diff --git a/x-pack/packages/ml/string_hash/README.md b/x-pack/packages/ml/string_hash/README.md index 8398d2678996..32ea547e20f3 100644 --- a/x-pack/packages/ml/string_hash/README.md +++ b/x-pack/packages/ml/string_hash/README.md @@ -2,4 +2,14 @@ +### `stringHash` (function) + +Creates a deterministic number based hash out of a string. + +**Parameters:** + +- str (`string`) + +**returns:** number + diff --git a/x-pack/packages/ml/string_hash/package.json b/x-pack/packages/ml/string_hash/package.json index 5d256e3a47a5..81a0bf1c743f 100644 --- a/x-pack/packages/ml/string_hash/package.json +++ b/x-pack/packages/ml/string_hash/package.json @@ -3,5 +3,11 @@ "private": true, "version": "1.0.0", "main": "./target_node/index.js", - "license": "SSPL-1.0 OR Elastic License 2.0" + "license": "SSPL-1.0 OR Elastic License 2.0", + "devDependencies": { + "ts-readme": "^1.1.3" + }, + "scripts": { + "generate-docs": "ts-readme src/index.ts" + } } diff --git a/x-pack/packages/ml/string_hash/yarn.lock b/x-pack/packages/ml/string_hash/yarn.lock new file mode 100644 index 000000000000..e826cf14c9da --- /dev/null +++ b/x-pack/packages/ml/string_hash/yarn.lock @@ -0,0 +1,300 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" + +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== + +"@nodelib/fs.walk@^1.2.3": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== + dependencies: + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" + +"@types/command-line-args@^5.0.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@types/command-line-args/-/command-line-args-5.2.0.tgz#adbb77980a1cc376bb208e3f4142e907410430f6" + integrity sha512-UuKzKpJJ/Ief6ufIaIzr3A/0XnluX7RvFgwkV89Yzvm77wCh1kFaFmqN8XEnGcN62EuHdedQjEMb8mYxFLGPyA== + +"@types/command-line-usage@^5.0.1": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@types/command-line-usage/-/command-line-usage-5.0.2.tgz#ba5e3f6ae5a2009d466679cc431b50635bf1a064" + integrity sha512-n7RlEEJ+4x4TS7ZQddTmNSxP+zziEG0TNsMfiRIxcIVXt71ENJ9ojeXmGO3wPoTdn7pJcU2xc3CJYMktNT6DPg== + +ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +array-back@^3.0.1, array-back@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" + integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== + +array-back@^4.0.1, array-back@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.2.tgz#8004e999a6274586beeb27342168652fdb89fa1e" + integrity sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg== + +braces@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +chalk@^2.4.1, chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== + +command-line-application@^0.9.6: + version "0.9.6" + resolved "https://registry.yarnpkg.com/command-line-application/-/command-line-application-0.9.6.tgz#03da3db29a0dbee1af601f03198a2f2425d67803" + integrity sha512-7wc7YX7s/hqZWKp4r37IBlW/Bhh92HWeQW2VV++Mt9x35AKFntz9f7A94Zz+AsImHZmRGHd8iNW5m0jUd4GQpg== + dependencies: + "@types/command-line-args" "^5.0.0" + "@types/command-line-usage" "^5.0.1" + chalk "^2.4.1" + command-line-args "^5.1.1" + command-line-usage "^6.0.0" + meant "^1.0.1" + remove-markdown "^0.3.0" + tslib "1.10.0" + +command-line-args@^5.1.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-5.2.1.tgz#c44c32e437a57d7c51157696893c5909e9cec42e" + integrity sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg== + dependencies: + array-back "^3.1.0" + find-replace "^3.0.0" + lodash.camelcase "^4.3.0" + typical "^4.0.0" + +command-line-usage@^6.0.0: + version "6.1.3" + resolved "https://registry.yarnpkg.com/command-line-usage/-/command-line-usage-6.1.3.tgz#428fa5acde6a838779dfa30e44686f4b6761d957" + integrity sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw== + dependencies: + array-back "^4.0.2" + chalk "^2.4.2" + table-layout "^1.0.2" + typical "^5.2.0" + +deep-extend@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== + +fast-glob@^3.1.1: + version "3.2.11" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" + integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + +fastq@^1.6.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" + integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== + dependencies: + reusify "^1.0.4" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-replace@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-3.0.0.tgz#3e7e23d3b05167a76f770c9fbd5258b0def68c38" + integrity sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ== + dependencies: + array-back "^3.0.1" + +glob-parent@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-glob@^4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +lodash.camelcase@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== + +meant@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/meant/-/meant-1.0.3.tgz#67769af9de1d158773e928ae82c456114903554c" + integrity sha512-88ZRGcNxAq4EH38cQ4D85PM57pikCwS8Z99EWHODxN7KBY+UuPiqzRTtZzS8KTXO/ywSWbdjjJST2Hly/EQxLw== + +merge2@^1.3.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + +micromatch@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + +picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +prettier@1.19.1: + version "1.19.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" + integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== + +queue-microtask@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== + +reduce-flatten@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27" + integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w== + +remove-markdown@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/remove-markdown/-/remove-markdown-0.3.0.tgz#5e4b667493a93579728f3d52ecc1db9ca505dc98" + integrity sha512-5392eIuy1mhjM74739VunOlsOYKjsH82rQcTBlJ1bkICVC3dQ3ksQzTHh4jGHQFnM+1xzLzcFOMH+BofqXhroQ== + +reusify@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" + integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== + +run-parallel@^1.1.9: + version "1.2.0" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== + dependencies: + queue-microtask "^1.2.2" + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +table-layout@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.2.tgz#c4038a1853b0136d63365a734b6931cf4fad4a04" + integrity sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A== + dependencies: + array-back "^4.0.1" + deep-extend "~0.6.0" + typical "^5.2.0" + wordwrapjs "^4.0.0" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +ts-readme@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/ts-readme/-/ts-readme-1.1.3.tgz#18a73d21f3bb50ee8e2df819bcbbe3a76385b15a" + integrity sha512-GvI+Vu3m/LGBlgrWwzSmvslnz8msJLNrZ7hQ3Ko2B6PMxeXidqsn6fi20IWgepFjOzhKGw/WlG8NmM7jl3DWeg== + dependencies: + command-line-application "^0.9.6" + fast-glob "^3.1.1" + prettier "1.19.1" + +tslib@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" + integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== + +typical@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" + integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== + +typical@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066" + integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg== + +wordwrapjs@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-4.0.1.tgz#d9790bccfb110a0fc7836b5ebce0937b37a8b98f" + integrity sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA== + dependencies: + reduce-flatten "^2.0.0" + typical "^5.2.0"