[ML] Fix package imports. (#140488)

Previously, some types were not available yet in packages that needed to imported via kibana-core. Since they are now available, this PR replaces our own temporary types with the correct imports.
This commit is contained in:
Walter Rafelsberger 2022-09-13 10:48:25 +02:00 committed by GitHub
parent fceadb2e86
commit e490ca9e61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 33 deletions

View file

@ -68,6 +68,7 @@ TYPES_DEPS = [
"@npm//@types/lodash",
"@npm//@elastic/elasticsearch",
"@npm//tslib",
"//packages/core/elasticsearch/core-elasticsearch-server:npm_module_types",
"//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",

View file

@ -9,13 +9,14 @@ import { get } from 'lodash';
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
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 type { ElasticsearchClient, HistogramField, NumericColumnStatsMap } from './types';
import type { HistogramField, NumericColumnStatsMap } from './types';
const MAX_CHART_COLUMNS = 20;

View file

@ -9,6 +9,7 @@ import get from 'lodash/get';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
import { stringHash } from '@kbn/ml-string-hash';
@ -18,7 +19,6 @@ import { fetchAggIntervals } from './fetch_agg_intervals';
import { getSamplerAggregationsResponsePath } from './get_sampler_aggregations_response_path';
import type {
AggCardinality,
ElasticsearchClient,
HistogramField,
NumericColumnStats,
NumericColumnStatsMap,

View file

@ -5,23 +5,8 @@
* 2.0.
*/
import type { Client } from '@elastic/elasticsearch';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
// 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<
Client,
'connectionPool' | 'serializer' | 'extend' | 'close' | 'diagnostic'
>;
interface FieldAggCardinality {
field: string;
percent?: any;

View file

@ -64,6 +64,7 @@ TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/react",
"//packages/core/elasticsearch/core-elasticsearch-server:npm_module_types",
"//packages/kbn-logging:npm_module_types"
]

View file

@ -5,12 +5,7 @@
* 2.0.
*/
/**
* TODO: Replace these with kbn packaged versions once we have those available to us.
* At the moment imports from runtime plugins into packages are not supported.
* import type { Headers } from '@kbn/core/server';
*/
type Headers = Record<string, string | string[] | undefined>;
import type { Headers } from '@kbn/core-http-server';
function containsGzip(s: string) {
return s

View file

@ -9,16 +9,10 @@ import { Stream } from 'stream';
import * as zlib from 'zlib';
import type { Logger } from '@kbn/logging';
import type { Headers, ResponseHeaders } from '@kbn/core-http-server';
import { acceptCompression } from './accept_compression';
/**
* TODO: Replace these with kbn packaged versions once we have those available to us.
* At the moment imports from runtime plugins into packages are not supported.
* import type { Headers } from '@kbn/core/server';
*/
type Headers = Record<string, string | string[] | undefined>;
// We need this otherwise Kibana server will crash with a 'ERR_METHOD_NOT_IMPLEMENTED' error.
class ResponseStream extends Stream.PassThrough {
flush() {}
@ -35,9 +29,7 @@ interface StreamFactoryReturnType<T = unknown> {
push: (d: T) => void;
responseWithHeaders: {
body: zlib.Gzip | ResponseStream;
// TODO: Replace these with kbn packaged versions once we have those available to us.
// At the moment imports from runtime plugins into packages are not supported.
headers?: any;
headers?: ResponseHeaders;
};
}