Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency @elastic/elasticsearch to ^8.15.0 (main) #190378

Merged
merged 20 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"@elastic/datemath": "5.0.3",
"@elastic/ebt": "1.0.0",
"@elastic/ecs": "^8.11.1",
"@elastic/elasticsearch": "^8.14.0",
"@elastic/elasticsearch": "^8.15.0",
"@elastic/ems-client": "8.5.3",
"@elastic/eui": "95.7.0",
"@elastic/filesaver": "1.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import type {
PropertyName as EsPropertyName,
MappingProperty as EsMappingProperty,
MappingPropertyBase as EsMappingPropertyBase,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

/**
Expand Down Expand Up @@ -64,19 +65,20 @@ export interface SavedObjectsMappingProperties {
*
* @public
*/
export type SavedObjectsFieldMapping = EsMappingProperty & {
/**
* The dynamic property of the mapping, either `false` or `'strict'`. If
* unspecified `dynamic: 'strict'` will be inherited from the top-level
* index mappings.
*
* Note: To limit the number of mapping fields Saved Object types should
* *never* use `dynamic: true`.
*/
dynamic?: false | 'strict';
/**
* Some mapping types do not accept the `properties` attributes. Explicitly adding it as optional to our type
* to avoid type failures on all code using accessing them via `SavedObjectsFieldMapping.properties`.
*/
properties?: Record<EsPropertyName, EsMappingProperty>;
};
export type SavedObjectsFieldMapping = EsMappingProperty &
EsMappingPropertyBase & {
Copy link
Member

Choose a reason for hiding this comment

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

The new MappingSemanticTextProperty doesn't extend base, so it is missing the optional fields field

/**
* The dynamic property of the mapping, either `false` or `'strict'`. If
* unspecified `dynamic: 'strict'` will be inherited from the top-level
* index mappings.
*
* Note: To limit the number of mapping fields Saved Object types should
* *never* use `dynamic: true`.
*/
dynamic?: false | 'strict';
/**
* Some mapping types do not accept the `properties` attributes. Explicitly adding it as optional to our type
* to avoid type failures on all code using accessing them via `SavedObjectsFieldMapping.properties`.
*/
properties?: Record<EsPropertyName, EsMappingProperty>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type ScriptedPhraseFilter = Filter & {
meta: PhraseFilterMeta;
query: {
script: {
script: estypes.InlineScript;
script: estypes.Script;
Copy link
Member

Choose a reason for hiding this comment

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

renamed 🤷

};
};
};
Expand Down Expand Up @@ -134,7 +134,7 @@ export const getPhraseScript = (field: DataViewFieldBase, value: PhraseFilterVal
params: {
value: convertedValue,
},
} as estypes.InlineScript,
} as estypes.Script,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type ScriptedRangeFilter = Filter & {
meta: RangeFilterMeta;
query: {
script: {
script: estypes.InlineScript;
script: estypes.Script;
};
};
};
Expand Down Expand Up @@ -189,7 +189,7 @@ export const buildRangeFilter = (
* @internal
*/
export const getRangeScript = (field: DataViewFieldBase, params: RangeFilterParams) => {
const knownParams: estypes.InlineScript['params'] = mapValues(
const knownParams: estypes.Script['params'] = mapValues(
pickBy(params, (val, key) => key in operators),
(value) => (field.type === 'number' && typeof value === 'string' ? parseFloat(value) : value)
);
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-grouping/src/containers/query/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import type {
InlineScript,
Script,
MappingRuntimeField,
MappingRuntimeFields,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
Expand Down Expand Up @@ -52,7 +52,7 @@ export interface MainAggregation extends NamedAggregation {
}

export interface GroupingRuntimeField extends MappingRuntimeField {
script: InlineScript & {
script: Script & {
params: Record<string, any>;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { cloneDeep } from 'lodash';
import useDebounce from 'react-use/lib/useDebounce';
import type {
InferenceModelConfigContainer,
InferenceInferenceEndpointInfo,
MappingTypeMapping,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { createSemanticTextCombinedField, getFieldNames, getNameCollisionMsg } from './utils';
Expand Down Expand Up @@ -61,14 +61,14 @@ export const SemanticTextForm: FC<Props> = ({ addCombinedField, hasNameCollision

useEffect(() => {
http
.fetch<InferenceModelConfigContainer[]>('/internal/data_visualizer/inference_services', {
.fetch<InferenceInferenceEndpointInfo[]>('/internal/data_visualizer/inference_services', {
method: 'GET',
version: '1',
})
.then((response) => {
const inferenceServiceOptions = response.map((service) => ({
value: service.model_id,
text: service.model_id,
value: service.inference_id,
text: service.inference_id,
}));
setInferenceServices(inferenceServiceOptions);
setSelectedInference(inferenceServiceOptions[0]?.value ?? undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,8 @@ const getDataComparisonQuery = ({

if (rangeFilter && isPopulatedObject<string, QueryDslBoolQuery>(query, ['bool'])) {
if (Array.isArray(query.bool.filter)) {
// @ts-expect-error gte and lte can be numeric
query.bool.filter.push(rangeFilter);
} else {
// @ts-expect-error gte and lte can be numeric
query.bool.filter = [rangeFilter];
}
}
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/data_visualizer/server/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ export function routes(coreSetup: CoreSetup<StartDeps, unknown>, logger: Logger)
async (context, request, response) => {
try {
const esClient = (await context.core).elasticsearch.client;
// @ts-expect-error types are wrong
const { endpoints } = await esClient.asCurrentUser.inference.getModel({
const { endpoints } = await esClient.asCurrentUser.inference.get({
inference_id: '_all',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const getSemanticTextFields = (
return Object.entries(fields).flatMap(([key, value]) => {
const currentPath: string = path ? `${path}.${key}` : key;
const currentField: Array<{ path: string; source: SemanticTextProperty }> =
// @ts-expect-error because semantic_text type isn't incorporated in API type yet
value.type === 'semantic_text' ? [{ path: currentPath, source: value }] : [];
if (hasProperties(value)) {
const childSemanticTextFields: Array<{ path: string; source: SemanticTextProperty }> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n';
import { EuiAccordion, EuiSpacer } from '@elastic/eui';
import type { MlUrlConfig } from '@kbn/ml-anomaly-utils';
import type { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
import type { DeepPartial } from '../../../../../../../common/types/common';
import type { DeepPartial } from '@kbn/utility-types';
import { Description } from './description';
import { CustomUrlsWrapper } from '../../../../../components/custom_urls';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
type DataFrameAnalysisConfigType,
type FeatureProcessor,
} from '@kbn/ml-data-frame-analytics-utils';
import type { DeepPartial, DeepReadonly } from '../../../../../../../common/types/common';
import type { DeepPartial } from '@kbn/utility-types';
import type { DeepReadonly } from '../../../../../../../common/types/common';
import { checkPermission } from '../../../../../capabilities/check_capabilities';
import { mlNodesAvailable } from '../../../../../ml_nodes_check';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { isEqual } from 'lodash';
import type { Observable } from 'rxjs';
import { from, isObservable, Subject } from 'rxjs';
import { distinctUntilChanged, flatMap, scan, shareReplay } from 'rxjs';
import type { DeepPartial } from '../../../common/types/common';
import type { DeepPartial } from '@kbn/utility-types';
import { jobSelectionActionCreator } from './actions';
import { EXPLORER_ACTION } from './explorer_constants';
import type { ExplorerState } from './reducers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { useMemo } from 'react';

import type { DeepPartial } from '@kbn/utility-types';
import type { NewJobCapsResponse } from '@kbn/ml-anomaly-utils';
import type {
AnalyticsMapReturnType,
Expand All @@ -21,7 +22,6 @@ import type { HttpService } from '../http_service';
import { useMlKibana } from '../../contexts/kibana';

import type { ValidateAnalyticsJobResponse } from '../../../../common/constants/validation';
import type { DeepPartial } from '../../../../common/types/common';
import type { JobMessage } from '../../../../common/types/audit_message';
import type { PutDataFrameAnalyticsResponseSchema } from '../../../../server/routes/schemas/data_frame_analytics_schema';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import type { ModelConfig } from '@kbn/inference_integration_flyout/types';
import type { HttpService } from '../http_service';
import { ML_INTERNAL_BASE_PATH } from '../../../../common/constants/app';

// TODO remove inference_id when esType has been updated to include it
export interface GetInferenceEndpointsResponse extends estypes.InferenceModelConfigContainer {
inference_id: string;
}

export function inferenceModelsApiProvider(httpService: HttpService) {
return {
/**
Expand All @@ -29,7 +24,7 @@ export function inferenceModelsApiProvider(httpService: HttpService) {
taskType: InferenceTaskType,
modelConfig: ModelConfig
) {
const result = await httpService.http<estypes.InferencePutModelResponse>({
const result = await httpService.http<estypes.InferencePutResponse>({
path: `${ML_INTERNAL_BASE_PATH}/_inference/${taskType}/${inferenceId}`,
method: 'PUT',
body: JSON.stringify(modelConfig),
Expand All @@ -41,9 +36,7 @@ export function inferenceModelsApiProvider(httpService: HttpService) {
* Gets all inference endpoints
*/
async getAllInferenceEndpoints() {
const result = await httpService.http<{
endpoints: GetInferenceEndpointsResponse[];
}>({
const result = await httpService.http<estypes.InferenceGetResponse>({
path: `${ML_INTERNAL_BASE_PATH}/_inference/all`,
method: 'GET',
version: '1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import type { JobsHealthService } from './jobs_health_service';
import { jobsHealthServiceProvider } from './jobs_health_service';
import type { DatafeedsService } from '../../models/job_service/datafeeds';
import type { Logger } from '@kbn/core/server';
import type { DeepPartial } from '@kbn/utility-types';
import type { MlClient } from '../ml_client';
import type { MlJob, MlJobStats } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { AnnotationService } from '../../models/annotation_service/annotation';
import type { JobsHealthExecutorOptions } from './register_jobs_monitoring_rule_type';
import type { JobAuditMessagesService } from '../../models/job_audit_messages/job_audit_messages';
import type { DeepPartial } from '../../../common/types/common';
import type { FieldFormatsRegistryProvider } from '../../../common/types/kibana';

const MOCK_DATE_NOW = 1487076708000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { IScopedClusterClient } from '@kbn/core/server';
import { JOB_MAP_NODE_TYPES, type MapElements } from '@kbn/ml-data-frame-analytics-utils';
import { flatten } from 'lodash';
import type {
InferenceModelConfig,
InferenceInferenceEndpoint,
InferenceTaskType,
TasksTaskInfo,
TransformGetTransformTransformSummary,
Expand Down Expand Up @@ -591,19 +591,19 @@ export class ModelsProvider {
* Puts the requested Inference endpoint id into elasticsearch, triggering elasticsearch to create the inference endpoint id
* @param inferenceId - Inference Endpoint Id
* @param taskType - Inference Task type. Either sparse_embedding or text_embedding
* @param modelConfig - Model configuration based on service type
* @param inferenceConfig - Model configuration based on service type
*/
async createInferenceEndpoint(
inferenceId: string,
taskType: InferenceTaskType,
modelConfig: InferenceModelConfig
inferenceConfig: InferenceInferenceEndpoint
) {
try {
const result = await this._client.asCurrentUser.inference.putModel(
const result = await this._client.asCurrentUser.inference.put(
{
inference_id: inferenceId,
task_type: taskType,
model_config: modelConfig,
inference_config: inferenceConfig,
},
{ maxRetries: 0 }
);
Expand All @@ -613,7 +613,7 @@ export class ModelsProvider {
// Erroring out is misleading in these cases, so we return the model_id and task_type
if (error.name === 'TimeoutError') {
return {
model_id: modelConfig.service,
model_id: inferenceConfig.service,
task_type: taskType,
};
} else {
Expand Down
7 changes: 5 additions & 2 deletions x-pack/plugins/ml/server/routes/inference_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
*/
import type { CloudSetup } from '@kbn/cloud-plugin/server';
import { schema } from '@kbn/config-schema';
import type { InferenceModelConfig, InferenceTaskType } from '@elastic/elasticsearch/lib/api/types';
import type {
InferenceInferenceEndpoint,
InferenceTaskType,
} from '@elastic/elasticsearch/lib/api/types';
import type { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils';
import type { RouteInitialization } from '../types';
import { createInferenceSchema } from './schemas/inference_schema';
Expand Down Expand Up @@ -46,7 +49,7 @@ export function inferenceModelRoutes(
const body = await modelsProvider(client, mlClient, cloud).createInferenceEndpoint(
inferenceId,
taskType as InferenceTaskType,
request.body as InferenceModelConfig
request.body as InferenceInferenceEndpoint
);
const { syncSavedObjects } = syncSavedObjectsFactory(client, mlSavedObjectService);
await syncSavedObjects(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const getPingHistogram: UMElasticsearchQueryFn<
body: {
query: {
bool: {
// @ts-expect-error upgrade typescript v5.1.6
filter: [...filter, SUMMARY_FILTER, EXCLUDE_RUN_ONCE_FILTER],
},
},
Expand Down Expand Up @@ -81,7 +80,6 @@ export const getPingHistogram: UMElasticsearchQueryFn<
});

const { body: result } = await uptimeEsClient.search(params, 'getPingsOverTime');
// @ts-expect-error upgrade typescript v5.1.6
const buckets = result?.aggregations?.timeseries?.buckets ?? [];

const histogram = buckets.map((bucket: Pick<(typeof buckets)[0], 'key' | 'down' | 'up'>) => {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/rule_registry/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ const allowedFilterKeysSchema = t.union([
t.literal('range'),
t.literal('rank_feature'),
t.literal('regexp'),
t.literal('rule_query'),
t.literal('rule'),
t.literal('semantic'),
t.literal('shape'),
t.literal('simple_query_string'),
t.literal('span_containing'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
AggregateName,
AggregationsAggregate,
AggregationsMultiBucketAggregateBase,
InlineScript,
MappingRuntimeFields,
QueryDslQueryContainer,
SortCombinations,
Expand Down Expand Up @@ -826,18 +825,16 @@ export class AlertsClient {
const result = await this.esClient.updateByQuery({
index,
conflicts: 'proceed',
body: {
script: {
Comment on lines -829 to -830
Copy link
Member

Choose a reason for hiding this comment

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

Just taking advantage of this PR to remove the deprecated use of body here.

source: `if (ctx._source['${ALERT_WORKFLOW_STATUS}'] != null) {
script: {
source: `if (ctx._source['${ALERT_WORKFLOW_STATUS}'] != null) {
ctx._source['${ALERT_WORKFLOW_STATUS}'] = '${status}'
}
if (ctx._source.signal != null && ctx._source.signal.status != null) {
ctx._source.signal.status = '${status}'
}`,
lang: 'painless',
} as InlineScript,
query: fetchAndAuditResponse.authorizedQuery as Omit<QueryDslQueryContainer, 'script'>,
lang: 'painless',
},
query: fetchAndAuditResponse.authorizedQuery as Omit<QueryDslQueryContainer, 'script'>,
ignore_unavailable: true,
});
return result;
Expand Down Expand Up @@ -965,14 +962,12 @@ export class AlertsClient {
await this.esClient.updateByQuery({
index,
conflicts: 'proceed',
body: {
script: {
source: painlessScript,
lang: 'painless',
params: { caseIds },
} as InlineScript,
query: esQuery,
script: {
source: painlessScript,
lang: 'painless',
params: { caseIds },
},
query: esQuery,
ignore_unavailable: true,
});
} catch (err) {
Expand Down
Loading