Skip to content

Commit

Permalink
Update dependency @types/lodash to ^4.17.10 (main) (elastic#194739)
Browse files Browse the repository at this point in the history
  • Loading branch information
elastic-renovate-prod[bot] authored Oct 15, 2024
1 parent 68cceef commit 563910b
Show file tree
Hide file tree
Showing 71 changed files with 167 additions and 154 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@
"@types/jsonwebtoken": "^9.0.0",
"@types/license-checker": "15.0.0",
"@types/loader-utils": "^2.0.3",
"@types/lodash": "^4.14.159",
"@types/lodash": "^4.17.10",
"@types/lru-cache": "^5.1.0",
"@types/lz-string": "^1.3.34",
"@types/mapbox__vector-tile": "1.3.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/kbn-es-query/src/filters/helpers/update_filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const updateFilter = (
operator?: FilterMeta,
params?: Filter['meta']['params'],
fieldType?: string
) => {
): Filter => {
if (!field || !operator) {
return updateField(filter, field);
}
Expand All @@ -35,7 +35,7 @@ export const updateFilter = (
return updateWithIsOperator(filter, operator, params, fieldType);
};

function updateField(filter: Filter, field?: string) {
function updateField(filter: Filter, field?: string): Filter {
return {
...filter,
meta: {
Expand All @@ -48,7 +48,7 @@ function updateField(filter: Filter, field?: string) {
type: undefined,
},
query: undefined,
};
} as Filter; // need the casting because `field` shouldn't be there
}

function updateWithExistsOperator(filter: Filter, operator?: FilterMeta) {
Expand Down Expand Up @@ -104,7 +104,7 @@ function updateWithRangeOperator(
operator: FilterMeta,
rawParams: Filter['meta']['params'] | undefined,
field: string
) {
): Filter {
if (isRangeFilterParams(rawParams)) {
const { from, to } = rawParams;
const params = {
Expand Down Expand Up @@ -148,7 +148,7 @@ function updateWithRangeOperator(
},
},
};
return updatedFilter;
return updatedFilter as Filter; // need the casting because it doesn't like the types of `params.gte|lt`
}
}

Expand Down
11 changes: 4 additions & 7 deletions packages/kbn-esql-editor/src/esql_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,10 @@ export const ESQLEditor = memo(function ESQLEditor({
}, []);

const { cache: dataSourcesCache, memoizedSources } = useMemo(() => {
const fn = memoize(
(...args: [DataViewsPublicPluginStart, CoreStart]) => ({
timestamp: Date.now(),
result: getESQLSources(...args),
}),
({ esql }) => esql
);
const fn = memoize((...args: [DataViewsPublicPluginStart, CoreStart]) => ({
timestamp: Date.now(),
result: getESQLSources(...args),
}));

return { cache: fn.cache, memoizedSources: fn };
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('processVersionedRouter', () => {
{}
);

expect(Object.keys(get(baseCase, 'paths["/foo"].get.responses.200.content'))).toEqual([
expect(Object.keys(get(baseCase, 'paths["/foo"].get.responses.200.content')!)).toEqual([
'application/test+json; Elastic-Api-Version=2023-10-31',
'application/test+json; Elastic-Api-Version=2024-12-31',
]);
Expand All @@ -142,7 +142,7 @@ describe('processVersionedRouter', () => {
createOperationIdCounter(),
{ version: '2023-10-31' }
);
expect(Object.keys(get(filteredCase, 'paths["/foo"].get.responses.200.content'))).toEqual([
expect(Object.keys(get(filteredCase, 'paths["/foo"].get.responses.200.content')!)).toEqual([
'application/test+json; Elastic-Api-Version=2023-10-31',
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,11 @@ const suggestionAggSubtypes: { [key: string]: OptionsListSuggestionAggregationBu
const isNested = fieldSpec && getFieldSubtypeNested(fieldSpec);
basePath += isNested ? '.nestedSuggestions.filteredSuggestions' : '.filteredSuggestions';

const suggestions = get(rawEsResult, `${basePath}.suggestions.buckets`)?.reduce(
(acc: OptionsListSuggestions, suggestion: EsBucket) => {
acc.push({ value: suggestion.key, docCount: suggestion.doc_count });
return acc;
},
[]
);
const buckets = get(rawEsResult, `${basePath}.suggestions.buckets`, []) as EsBucket[];
const suggestions = buckets.reduce((acc: OptionsListSuggestions, suggestion: EsBucket) => {
acc.push({ value: suggestion.key, docCount: suggestion.doc_count });
return acc;
}, []);
return {
suggestions,
totalCardinality: get(rawEsResult, `${basePath}.unique_terms.value`),
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/data_views/common/data_views/data_views.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { set } from '@kbn/safer-lodash-set';
import { defaults, get } from 'lodash';
import { defaults } from 'lodash';
import { DataViewsService, DataView, DataViewLazy } from '.';
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';

Expand Down Expand Up @@ -297,7 +297,8 @@ describe('IndexPatterns', () => {
test('does cache ad-hoc data views', async () => {
const id = '1';

const createFromSpecOriginal = get(indexPatterns, 'createFromSpec');
// eslint-disable-next-line dot-notation
const createFromSpecOriginal = indexPatterns['createFromSpec'];
let mockedCreateFromSpec: jest.Mock;

set(
Expand Down Expand Up @@ -340,7 +341,8 @@ describe('IndexPatterns', () => {
test('does cache ad-hoc data views for DataViewLazy', async () => {
const id = '1';

const createFromSpecOriginal = get(indexPatterns, 'createFromSpecLazy');
// eslint-disable-next-line dot-notation
const createFromSpecOriginal = indexPatterns['createFromSpecLazy'];
let mockedCreateFromSpec: jest.Mock;

set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { debounce } from 'lodash';
import type { Cancelable } from 'lodash';
import type { DebouncedFunc } from 'lodash';
import { useCallback, useEffect, useMemo, useState } from 'react';
import useUpdateEffect from 'react-use/lib/useUpdateEffect';

Expand All @@ -22,7 +22,7 @@ export function useDebouncedValue<T>(value: T, timeout?: number): [T, boolean] {
},
[setStoredValue, setPending]
);
const setDebouncedValue = useMemo<typeof setValue & Partial<Cancelable>>(
const setDebouncedValue = useMemo<typeof setValue & Partial<DebouncedFunc<typeof setValue>>>(
() => (timeout ? debounce(setValue, timeout) : setValue),
[setValue, timeout]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class PhraseFilterManager extends FilterManager {
private getValueFromFilter(kbnFilter: Filter): any {
// bool filter - multiple phrase filters
if (_.has(kbnFilter, 'query.bool.should')) {
return _.get(kbnFilter, 'query.bool.should')
return (_.get(kbnFilter, 'query.bool.should') as PhraseFilter[])
.map((kbnQueryFilter: PhraseFilter) => {
return this.getValueFromFilter(kbnQueryFilter);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import useMount from 'react-use/lib/useMount';
import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { AggParam, IAggConfig, IFieldParamType, KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { IAggConfig, IFieldParamType, KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { DataViewField } from '@kbn/data-views-plugin/public';
import { formatListAsProse, parseCommaSeparatedList, useValidation } from './utils';
import { AggParamEditorProps } from '../agg_param_props';
Expand Down Expand Up @@ -47,7 +47,7 @@ function FieldParamEditor({
: [];

const onChange = (options: EuiComboBoxOptionOption[]) => {
const selectedOption: DataViewField = get(options, '0.target');
const selectedOption: DataViewField | undefined = get(options, '0.target');
if (!(aggParam.required && !selectedOption)) {
setValue(selectedOption);
}
Expand Down Expand Up @@ -158,9 +158,8 @@ function getFieldTypesString(agg: IAggConfig) {
}

function getFieldTypes(agg: IAggConfig) {
const param =
get(agg, 'type.params', []).find((p: AggParam) => p.name === 'field') ||
({} as IFieldParamType);
const param = (get(agg, 'type.params', []).find((p) => p.name === 'field') ||
{}) as IFieldParamType;
return parseCommaSeparatedList(param.filterFieldTypes || []);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function TimeIntervalParamEditor({
const onCustomInterval = (customValue: string) => setValue(customValue.trim());

const onChange = (opts: EuiComboBoxOptionOption[]) => {
const selectedOpt: ComboBoxOption = get(opts, '0');
const selectedOpt = get(opts, '0');
setValue(selectedOpt ? selectedOpt.key : '');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function getArgValueSuggestions() {
// index argument not provided
return;
}
const indexPatternTitle = get(indexPatternArg, 'value.text');
const indexPatternTitle = get(indexPatternArg, 'value.text', '');

return (await indexPatterns.find(indexPatternTitle, 1)).find(
(index) => index.title === indexPatternTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { Panel, Series } from '../../../../common/types';
import type { BaseMeta } from '../request_processors/types';

const getTimeSeries = <TRawResponse = unknown>(resp: TRawResponse, series: Series) =>
get(resp, `aggregations.timeseries`) || get(resp, `aggregations.${series.id}.timeseries`);
get(resp, `aggregations.timeseries`) || get(resp, [`aggregations`, series.id, `timeseries`]);

interface SplittedData<TMeta extends BaseMeta = BaseMeta> {
id: string;
Expand Down Expand Up @@ -49,7 +49,7 @@ export async function getSplits<TRawResponse = unknown, TMeta extends BaseMeta =
extractFields: Function
): Promise<Array<SplittedData<TMeta>>> {
if (!meta) {
meta = get(resp, `aggregations.${series.id}.meta`);
meta = get(resp, `aggregations.${series.id}.meta`) as TMeta | undefined;
}

const color = new Color(series.color);
Expand Down Expand Up @@ -81,7 +81,7 @@ export async function getSplits<TRawResponse = unknown, TMeta extends BaseMeta =

if (series.split_mode === 'filters' && isPlainObject(buckets)) {
return (series.split_filters || []).map((filter) => {
const bucket = get(resp, `aggregations.${series.id}.buckets.${filter.id}`);
const bucket = get(resp, [`aggregations`, series.id, `buckets`, filter.id!]); // using array path because the dotted string failed to resolve the types
bucket.id = `${series.id}${SERIES_SEPARATOR}${filter.id}`;
bucket.key = filter.id;
bucket.splitByLabel = splitByLabel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ const hasSiblingPipelineAggregation = (aggs: Record<string, unknown> = {}) =>
*/
export const normalizeQuery: TableRequestProcessorsFunction = () => {
return () => (doc) => {
const series = get(doc, 'aggs.pivot.aggs') as Array<{
aggs: Record<string, unknown>;
}>;
const series = get(doc, 'aggs.pivot.aggs');
const normalizedSeries = {};

forEach(series, (value, seriesId) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ function MetricsAxisOptions(props: ValidationVisOptionsProps<VisParams>) {
}

if (lastCustomLabels[axis.id] !== newCustomLabel && newCustomLabel !== '') {
const lastSeriesAggType = get(lastSeriesAgg, `${matchingSeries[0].id}.type`);
const lastSeriesAggField = get(lastSeriesAgg, `${matchingSeries[0].id}.field`);
const lastSeriesAggType = get(lastSeriesAgg, [matchingSeries[0].id, `type`]); // using array path vs. string because type inference was broken
const lastSeriesAggField = get(lastSeriesAgg, [matchingSeries[0].id, `field`]);
const matchingSeriesAggType = get(matchingSeries, '[0]type.name', '');
const matchingSeriesAggField = get(matchingSeries, '[0]params.field.name', '');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export const getVisualizeEmbeddableFactory: (deps: {
}
const currentVis = vis$.getValue();
if (!disableTriggers) {
const triggerId = get(
const triggerId: string = get(
VIS_EVENT_TO_TRIGGER,
event.name,
VIS_EVENT_TO_TRIGGER.filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,11 @@ export class VisualizeEmbeddable
return;
}
if (!this.input.disableTriggers) {
const triggerId = get(VIS_EVENT_TO_TRIGGER, event.name, VIS_EVENT_TO_TRIGGER.filter);
const triggerId: string = get(
VIS_EVENT_TO_TRIGGER,
event.name,
VIS_EVENT_TO_TRIGGER.filter
);
let context;

if (triggerId === VIS_EVENT_TO_TRIGGER.applyFilter) {
Expand Down
8 changes: 4 additions & 4 deletions test/api_integration/apis/kql_telemetry/kql_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export default function ({ getService }: FtrProviderContext) {
q: 'type:kql-telemetry',
})
.then((response) => {
const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry');
expect(kqlTelemetryDoc.optInCount).to.be(1);
const optInCount = get(response, 'hits.hits[0]._source.kql-telemetry.optInCount');
expect(optInCount).to.be(1);
});
});

Expand All @@ -69,8 +69,8 @@ export default function ({ getService }: FtrProviderContext) {
q: 'type:kql-telemetry',
})
.then((response) => {
const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry');
expect(kqlTelemetryDoc.optOutCount).to.be(1);
const optOutCount = get(response, 'hits.hits[0]._source.kql-telemetry.optOutCount');
expect(optOutCount).to.be(1);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import _ from 'lodash';
export class KibanaPrivilege {
constructor(public readonly id: string, public readonly actions: string[] = []) {}

public get name() {
public get name(): string {
return _.upperFirst(this.id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export const sanitizeBulkErrorResponse = (
(responseToUse.items ?? []).forEach(
(item: Partial<Record<estypes.BulkOperationType, estypes.BulkResponseItem>>) => {
for (const [_, responseItem] of Object.entries(item)) {
const reason: string = get(responseItem, 'error.reason');
const reason = get(responseItem, 'error.reason');
const redactIndex = reason ? reason.indexOf(`Preview of field's value:`) : -1;
if (redactIndex > 1) {
set(responseItem, 'error.reason', reason.substring(0, redactIndex - 1));
set(responseItem, 'error.reason', reason!.substring(0, redactIndex - 1));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class ExtendedTemplate extends PureComponent<Props> {

// TODO: this should be in a helper, it's the same code from container_style
getArgValue = (name: string, alt: string) => {
return get(this.props.argValue, `chain.0.arguments.${name}.0`, alt);
return get(this.props.argValue, `chain.0.arguments.${name}.0`, alt) as string | undefined;
};

// TODO: this should be in a helper, it's the same code from container_style
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ const PERCENT_DECIMALS_FIELD = 'percentDecimals';

export const ExtendedTemplate: FunctionComponent<Props> = ({ onValueChange, argValue }) => {
const showLabels = getFieldValue(argValue, SHOW_FIELD);
const showValues = getFieldValue(argValue, VALUES_FIELD);
const valueFormat = getFieldValue(argValue, VALUES_FORMAT_FIELD);
const percentDecimals = getFieldValue(argValue, PERCENT_DECIMALS_FIELD);
const showValues = getFieldValue(argValue, VALUES_FIELD) as boolean;
const valueFormat = getFieldValue(argValue, VALUES_FORMAT_FIELD) as string;
const percentDecimals = getFieldValue(argValue, PERCENT_DECIMALS_FIELD) as string;

const positions: EuiSelectOption[] = [
{ text: strings.getPositionDefaultLabel(), value: 'default' },
Expand Down Expand Up @@ -110,7 +110,7 @@ export const ExtendedTemplate: FunctionComponent<Props> = ({ onValueChange, argV
<EuiFormRow label={strings.getPositionLabel()} display="columnCompressed">
<EuiSelect
compressed
value={getFieldValue(argValue, POSITION_FIELD)}
value={getFieldValue(argValue, POSITION_FIELD) as string}
options={positions}
onChange={onCommonFieldChange(POSITION_FIELD)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const SimpleTemplate: FunctionComponent<Props> = ({ onValueChange, argVal
[argValue, onValueChange, showValuePath]
);

const showLabels = getFieldValue(argValue, SHOW_FIELD, false);
const showLabels = getFieldValue(argValue, SHOW_FIELD, false) as boolean;

return (
<EuiSwitch compressed checked={showLabels} onChange={onToggle} showLabel={false} label="" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getFieldValue = (
defaultValue?: unknown
) => {
if (!ast) {
return null;
return undefined;
}

return get(ast, getFieldPath(field), defaultValue);
Expand Down
Loading

0 comments on commit 563910b

Please sign in to comment.