Skip to content

Commit

Permalink
Merge branch 'connector-create-connector-with-api' of github.com:jedr…
Browse files Browse the repository at this point in the history
…azb/kibana into connector-create-connector-with-api
  • Loading branch information
jedrazb committed Jun 5, 2024
2 parents 67a4ea4 + 2e8b139 commit 74fd9b6
Show file tree
Hide file tree
Showing 96 changed files with 2,968 additions and 456 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ examples/field_formats_example @elastic/kibana-data-discovery
src/plugins/field_formats @elastic/kibana-data-discovery
packages/kbn-field-types @elastic/kibana-data-discovery
packages/kbn-field-utils @elastic/kibana-data-discovery
x-pack/plugins/fields_metadata @elastic/obs-ux-logs-team
x-pack/plugins/file_upload @elastic/kibana-gis
examples/files_example @elastic/appex-sharedux
src/plugins/files_management @elastic/appex-sharedux
Expand Down
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,10 @@ activities.
|The features plugin enhance Kibana with a per-feature privilege system.
|{kib-repo}blob/{branch}/x-pack/plugins/fields_metadata/README.md[fieldsMetadata]
|The @kbn/fields-metadata-plugin is designed to provide a centralized and asynchronous way to consume field metadata across Kibana. This plugin addresses the need for on-demand retrieval of field metadata from static ECS definitions and integration manifests, with the flexibility to extend to additional resolution sources in the future.
|{kib-repo}blob/{branch}/x-pack/plugins/file_upload[fileUpload]
|WARNING: Missing README.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@
"@kbn/field-formats-plugin": "link:src/plugins/field_formats",
"@kbn/field-types": "link:packages/kbn-field-types",
"@kbn/field-utils": "link:packages/kbn-field-utils",
"@kbn/fields-metadata-plugin": "link:x-pack/plugins/fields_metadata",
"@kbn/file-upload-plugin": "link:x-pack/plugins/file_upload",
"@kbn/files-example-plugin": "link:examples/files_example",
"@kbn/files-management-plugin": "link:src/plugins/files_management",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('SavedObjectsRepository Spaces Extension', () => {
const documentMigrator = createDocumentMigrator(registry);

// const currentSpace = 'foo-namespace';
const defaultOptions = { ignore: [404], maxRetries: 0, meta: true }; // These are just the hard-coded options passed in via the repo
const defaultOptions = { ignore: [404], meta: true }; // These are just the hard-coded options passed in via the repo

const instantiateRepository = () => {
const allTypes = registry.getAllTypes().map((type) => type.name);
Expand Down Expand Up @@ -283,7 +283,7 @@ describe('SavedObjectsRepository Spaces Extension', () => {
: { type: CUSTOM_INDEX_TYPE, customIndex: attributes }
),
}),
{ maxRetries: 0, meta: true }
{ meta: true }
);
});
});
Expand Down Expand Up @@ -316,7 +316,7 @@ describe('SavedObjectsRepository Spaces Extension', () => {
expect.objectContaining({
id: expect.stringMatching(regex),
}),
{ ignore: [404], maxRetries: 0, meta: true }
{ ignore: [404], meta: true }
);
});
});
Expand Down Expand Up @@ -391,7 +391,7 @@ describe('SavedObjectsRepository Spaces Extension', () => {
]),
}),
}),
{ ignore: [404], maxRetries: 0, meta: true }
{ ignore: [404], meta: true }
);
});
});
Expand Down Expand Up @@ -582,7 +582,7 @@ describe('SavedObjectsRepository Spaces Extension', () => {
]),
}),
}),
{ ignore: [404], maxRetries: 0, meta: true }
{ ignore: [404], meta: true }
);
});

Expand Down Expand Up @@ -652,7 +652,7 @@ describe('SavedObjectsRepository Spaces Extension', () => {
}),
]),
}),
{ maxRetries: 0 }
{}
);
});
});
Expand Down Expand Up @@ -717,7 +717,7 @@ describe('SavedObjectsRepository Spaces Extension', () => {
}),
]),
}),
{ maxRetries: 0 }
{}
);
});
});
Expand Down Expand Up @@ -869,7 +869,7 @@ describe('SavedObjectsRepository Spaces Extension', () => {
}),
]),
}),
{ maxRetries: 0 }
{}
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ describe('RepositoryEsClient', () => {
expect(retryCallClusterMock).toHaveBeenCalledTimes(1);
});

it('sets maxRetries: 0 to delegate retry logic to retryCallCluster', async () => {
it('keeps call options unchanged', async () => {
expect(repositoryClient.bulk).toStrictEqual(expect.any(Function));
await repositoryClient.bulk({ body: [] });
expect(client.bulk).toHaveBeenCalledWith(
expect.any(Object),
expect.objectContaining({ maxRetries: 0 })
);
const options = { maxRetries: 12 };
await repositoryClient.bulk({ body: [] }, options);
expect(client.bulk).toHaveBeenCalledWith(expect.any(Object), options);
});

it('transform elasticsearch errors into saved objects errors', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ export function createRepositoryEsClient(client: ElasticsearchClient): Repositor
Object.defineProperty(acc, key, {
value: async (params?: unknown, options?: TransportRequestOptions) => {
try {
return await retryCallCluster(() =>
(client[key] as Function)(params, { maxRetries: 0, ...options })
);
return await retryCallCluster(() => (client[key] as Function)(params, options ?? {}));
} catch (e) {
// retry failures are caught here, as are 404's that aren't ignored (e.g update calls)
throw decorateEsError(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import './index.scss';
import { isFieldLensCompatible } from '@kbn/visualization-ui-components';
import React, { useCallback, useEffect } from 'react';
import React, { useCallback, useEffect, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFormRow, EuiSwitch, EuiSwitchEvent, EuiButtonGroup, EuiSpacer } from '@elastic/eui';
import {
Expand Down Expand Up @@ -87,6 +87,16 @@ const AnnotationEditorControls = ({
[currentAnnotation, onAnnotationChange]
);

const currentLineConfig = useMemo(() => {
if (isRange) {
return;
}
return {
lineStyle: currentAnnotation.lineStyle,
lineWidth: currentAnnotation.lineWidth,
};
}, [currentAnnotation, isRange]);

return (
<>
<DimensionEditorSection
Expand Down Expand Up @@ -270,10 +280,7 @@ const AnnotationEditorControls = ({
<LineStyleSettings
idPrefix={idPrefix}
setConfig={update}
currentConfig={{
lineStyle: currentAnnotation.lineStyle,
lineWidth: currentAnnotation.lineWidth,
}}
currentConfig={currentLineConfig}
/>
</>
)}
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-io-ts-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export type { IndexPattern } from './src/index_pattern_rt';
export type { NonEmptyString, NonEmptyStringBrand } from './src/non_empty_string_rt';

export { arrayToStringRt } from './src/array_to_string_rt';
export { deepExactRt } from './src/deep_exact_rt';
export { indexPatternRt } from './src/index_pattern_rt';
export { jsonRt } from './src/json_rt';
Expand Down
52 changes: 52 additions & 0 deletions packages/kbn-io-ts-utils/src/array_to_string_rt/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import * as rt from 'io-ts';
import { arrayToStringRt } from '.';
import { isRight, Either, fold } from 'fp-ts/lib/Either';
import { identity } from 'fp-ts/lib/function';

function getValueOrThrow(either: Either<unknown, any>) {
return fold(() => {
throw new Error('Cannot get right value of left');
}, identity)(either);
}

describe('arrayToStringRt', () => {
it('should validate strings', () => {
expect(isRight(arrayToStringRt.decode(''))).toBe(true);
expect(isRight(arrayToStringRt.decode('message'))).toBe(true);
expect(isRight(arrayToStringRt.decode('message,event.original'))).toBe(true);
expect(isRight(arrayToStringRt.decode({}))).toBe(false);
expect(isRight(arrayToStringRt.decode(true))).toBe(false);
});

it('should return array of strings when decoding', () => {
expect(getValueOrThrow(arrayToStringRt.decode(''))).toEqual(['']);
expect(getValueOrThrow(arrayToStringRt.decode('message'))).toEqual(['message']);
expect(getValueOrThrow(arrayToStringRt.decode('message,event.original'))).toEqual([
'message',
'event.original',
]);
});

it('should be pipable', () => {
const piped = arrayToStringRt.pipe(rt.array(rt.string));

const validInput = ['message', 'event.original'];
const invalidInput = {};

const valid = piped.decode(validInput.join(','));
const invalid = piped.decode(invalidInput);

expect(isRight(valid)).toBe(true);
expect(getValueOrThrow(valid)).toEqual(validInput);

expect(isRight(invalid)).toBe(false);
});
});
24 changes: 24 additions & 0 deletions packages/kbn-io-ts-utils/src/array_to_string_rt/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { either } from 'fp-ts/lib/Either';
import * as rt from 'io-ts';

export const arrayToStringRt = new rt.Type<unknown[], string, unknown>(
'arrayToString',
rt.array(rt.unknown).is,
(input, context) =>
either.chain(rt.string.validate(input, context), (str) => {
try {
return rt.success(str.split(','));
} catch (e) {
return rt.failure(input, context);
}
}),
(arr) => arr.join(',')
);
1 change: 1 addition & 0 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pageLoadAssetSize:
expressionXY: 45000
features: 21723
fieldFormats: 65209
fieldsMetadata: 21885
files: 22673
filesManagement: 18683
fileUpload: 25664
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import React, { useState, memo, useCallback } from 'react';
import React, { useState, memo } from 'react';
import { i18n } from '@kbn/i18n';
import {
EuiButtonGroup,
Expand Down Expand Up @@ -44,12 +44,9 @@ export const LineStyleSettings = ({
<EuiFlexItem>
<LineThicknessSlider
value={currentConfig?.lineWidth || 1}
// Without this memoization, EuiFieldNumber rerenders too often
// which somehow causes the annotation query to fall out of sync
onChange={useCallback((value) => {
onChange={(value) => {
setConfig({ lineWidth: value });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])}
}}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/console/public/lib/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ function isUrlParamsToken(token: { type: string } | null) {
}
}

/* Logs the provided arguments to the console if the `window.autocomplete_trace` flag is set to true.
* This function checks if the `autocomplete_trace` flag is enabled on the `window` object. This is
* only used when executing functional tests.
* If the flag is enabled, it logs each argument to the console.
* If an argument is an object, it is stringified before logging.
*/
const tracer = (...args: any[]) => {
// @ts-expect-error ts upgrade v4.7.4
// @ts-ignore
if (window.autocomplete_trace) {
// eslint-disable-next-line no-console
console.log.call(
Expand Down
1 change: 1 addition & 0 deletions src/plugins/unified_doc_viewer/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"browser": true,
"requiredBundles": ["kibanaUtils"],
"requiredPlugins": ["data", "discoverShared", "fieldFormats"],
"optionalPlugins": ["fieldsMetadata"]
}
}
2 changes: 2 additions & 0 deletions src/plugins/unified_doc_viewer/public/__mocks__/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks';
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
import { discoverSharedPluginMock } from '@kbn/discover-shared-plugin/public/mocks';
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';
import { fieldsMetadataPluginPublicMock } from '@kbn/fields-metadata-plugin/public/mocks';
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
import type { UnifiedDocViewerServices, UnifiedDocViewerStart } from '../types';
import { Storage } from '@kbn/kibana-utils-plugin/public';
Expand All @@ -24,6 +25,7 @@ export const mockUnifiedDocViewerServices: jest.Mocked<UnifiedDocViewerServices>
data: dataPluginMock.createStartContract(),
discoverShared: discoverSharedPluginMock.createStartContract(),
fieldFormats: fieldFormatsMock,
fieldsMetadata: fieldsMetadataPluginPublicMock.createStartContract(),
storage: new Storage(localStorage),
uiSettings: uiSettingsServiceMock.createStartContract(),
unifiedDocViewer: mockUnifiedDocViewer,
Expand Down
Loading

0 comments on commit 74fd9b6

Please sign in to comment.