Skip to content

Commit

Permalink
Merge branch 'master' into detections-roles-users-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Nov 18, 2020
2 parents ed09038 + 938b762 commit 957db54
Show file tree
Hide file tree
Showing 277 changed files with 4,777 additions and 1,835 deletions.
10 changes: 10 additions & 0 deletions .ci/build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -euo pipefail

cd "$(dirname "${0}")"

cp /usr/local/bin/runbld ./
cp /usr/local/bin/bash_standard_lib.sh ./

docker build -t kibana-ci -f ./Dockerfile .
2 changes: 2 additions & 0 deletions .ci/packer_cache_for_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ tar -cf "$HOME/.kibana/bootstrap_cache/$branch.tar" \

echo "created $HOME/.kibana/bootstrap_cache/$branch.tar"

.ci/build_docker.sh

if [[ "$branch" != "master" ]]; then
rm --preserve-root -rf "$checkoutDir"
fi
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,8 @@ module.exports = {
'no-shadow-restricted-names': 'error',
'no-sparse-arrays': 'error',
'no-this-before-super': 'error',
'no-undef': 'error',
// rely on typescript
'no-undef': 'off',
'no-unreachable': 'error',
'no-unsafe-finally': 'error',
'no-useless-call': 'error',
Expand Down Expand Up @@ -998,7 +999,8 @@ module.exports = {
'no-shadow-restricted-names': 'error',
'no-sparse-arrays': 'error',
'no-this-before-super': 'error',
'no-undef': 'error',
// rely on typescript
'no-undef': 'off',
'no-unreachable': 'error',
'no-unsafe-finally': 'error',
'no-useless-call': 'error',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-embeddable-public](./kibana-plugin-plugins-embeddable-public.md) &gt; [Adapters](./kibana-plugin-plugins-embeddable-public.adapters.md) &gt; [data](./kibana-plugin-plugins-embeddable-public.adapters.data.md)

## Adapters.data property

<b>Signature:</b>

```typescript
data?: DataAdapter;
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ The interface that the adapters used to open an inspector have to fullfill.
```typescript
export interface Adapters
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [data](./kibana-plugin-plugins-embeddable-public.adapters.data.md) | <code>DataAdapter</code> | |
| [requests](./kibana-plugin-plugins-embeddable-public.adapters.requests.md) | <code>RequestAdapter</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-embeddable-public](./kibana-plugin-plugins-embeddable-public.md) &gt; [Adapters](./kibana-plugin-plugins-embeddable-public.adapters.md) &gt; [requests](./kibana-plugin-plugins-embeddable-public.adapters.requests.md)

## Adapters.requests property

<b>Signature:</b>

```typescript
requests?: RequestAdapter;
```
2 changes: 1 addition & 1 deletion examples/state_containers_examples/public/todo/todo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export const TodoAppPage: React.FC<{

function withDefaultState<State extends BaseState>(
stateContainer: BaseStateContainer<State>,
// eslint-disable-next-line no-shadow
// eslint-disable-next-line @typescript-eslint/no-shadow
defaultState: State
): INullableBaseStateContainer<State> {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ function useGlobalStateSyncing(
}, [query, kbnUrlStateStorage]);
}

// eslint-disable-next-line @typescript-eslint/no-shadow
function useAppStateSyncing<AppState extends QueryState>(
appStateContainer: BaseStateContainer<AppState>,
query: DataPublicPluginStart['query'],
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@
"@types/xml2js": "^0.4.5",
"@types/yauzl": "^2.9.1",
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "^3.10.0",
"@typescript-eslint/parser": "^3.10.0",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"@welldone-software/why-did-you-render": "^5.0.0",
"@yarnpkg/lockfile": "^1.1.0",
"abab": "^1.0.4",
Expand Down Expand Up @@ -644,7 +644,7 @@
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.4",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-react-perf": "^3.2.3",
"expose-loader": "^0.7.5",
"faker": "1.1.0",
Expand Down
6 changes: 5 additions & 1 deletion packages/elastic-eslint-config-kibana/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ module.exports = {
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-shadow': 'error',
// rely on typescript
'@typescript-eslint/no-undef': 'off',
'no-undef': 'off',

'@typescript-eslint/triple-slash-reference': ['error', {
path: 'never',
types: 'never',
Expand Down Expand Up @@ -218,7 +223,6 @@ module.exports = {
'no-eval': 'error',
'no-new-wrappers': 'error',
'no-script-url': 'error',
'no-shadow': 'error',
'no-throw-literal': 'error',
'no-undef-init': 'error',
'no-unsafe-finally': 'error',
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/utils/crypto/sha256.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ type BufferEncoding =
| 'binary'
| 'hex';

/* eslint-disable no-bitwise, no-shadow */
/* eslint-disable no-bitwise, @typescript-eslint/no-shadow */
export class Sha256 {
private _a: number;
private _b: number;
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/http/router/validator/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ export type RouteValidatorFullConfig<P, Q, B> = RouteValidatorConfig<P, Q, B> &
* @internal
*/
export class RouteValidator<P = {}, Q = {}, B = {}> {
public static from<P = {}, Q = {}, B = {}>(
opts: RouteValidator<P, Q, B> | RouteValidatorFullConfig<P, Q, B>
public static from<_P = {}, _Q = {}, _B = {}>(
opts: RouteValidator<_P, _Q, _B> | RouteValidatorFullConfig<_P, _Q, _B>
) {
if (opts instanceof RouteValidator) {
return opts;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/common/search/aggs/agg_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface AggTypeConfig<
aggConfigs: IAggConfigs,
aggConfig: TAggConfig,
searchSource: ISearchSource,
inspectorRequestAdapter: RequestAdapter,
inspectorRequestAdapter?: RequestAdapter,
abortSignal?: AbortSignal
) => Promise<any>;
getSerializedFormat?: (agg: TAggConfig) => SerializedFieldFormat;
Expand Down Expand Up @@ -189,7 +189,7 @@ export class AggType<
aggConfigs: IAggConfigs,
aggConfig: TAggConfig,
searchSource: ISearchSource,
inspectorRequestAdapter: RequestAdapter,
inspectorRequestAdapter?: RequestAdapter,
abortSignal?: AbortSignal
) => Promise<any>;
/**
Expand Down
42 changes: 24 additions & 18 deletions src/plugins/data/common/search/aggs/buckets/terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { noop } from 'lodash';
import { i18n } from '@kbn/i18n';
import type { RequestAdapter } from 'src/plugins/inspector/common';

import { BucketAggType, IBucketAggConfig } from './bucket_agg_type';
import { BUCKET_TYPES } from './bucket_agg_types';
Expand Down Expand Up @@ -111,27 +112,32 @@ export const getTermsBucketAgg = () =>

nestedSearchSource.setField('aggs', filterAgg);

const request = inspectorRequestAdapter.start(
i18n.translate('data.search.aggs.buckets.terms.otherBucketTitle', {
defaultMessage: 'Other bucket',
}),
{
description: i18n.translate('data.search.aggs.buckets.terms.otherBucketDescription', {
defaultMessage:
'This request counts the number of documents that fall ' +
'outside the criterion of the data buckets.',
let request: ReturnType<RequestAdapter['start']> | undefined;
if (inspectorRequestAdapter) {
request = inspectorRequestAdapter.start(
i18n.translate('data.search.aggs.buckets.terms.otherBucketTitle', {
defaultMessage: 'Other bucket',
}),
}
);
nestedSearchSource.getSearchRequestBody().then((body) => {
request.json(body);
});
request.stats(getRequestInspectorStats(nestedSearchSource));
{
description: i18n.translate('data.search.aggs.buckets.terms.otherBucketDescription', {
defaultMessage:
'This request counts the number of documents that fall ' +
'outside the criterion of the data buckets.',
}),
}
);
nestedSearchSource.getSearchRequestBody().then((body) => {
request!.json(body);
});
request.stats(getRequestInspectorStats(nestedSearchSource));
}

const response = await nestedSearchSource.fetch({ abortSignal });
request
.stats(getResponseInspectorStats(response, nestedSearchSource))
.ok({ json: response });
if (request) {
request
.stats(getResponseInspectorStats(response, nestedSearchSource))
.ok({ json: response });
}
resp = mergeOtherBucketAggResponse(aggConfigs, resp, response, aggConfig, filterAgg());
}
if (aggConfig.params.missingBucket) {
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/data/public/autocomplete/autocomplete_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { CoreSetup, PluginInitializerContext } from 'src/core/public';
import { TimefilterSetup } from '../query';
import { QuerySuggestionGetFn } from './providers/query_suggestion_provider';
import {
getEmptyValueSuggestions,
Expand Down Expand Up @@ -57,9 +58,9 @@ export class AutocompleteService {
private hasQuerySuggestions = (language: string) => this.querySuggestionProviders.has(language);

/** @public **/
public setup(core: CoreSetup) {
public setup(core: CoreSetup, { timefilter }: { timefilter: TimefilterSetup }) {
this.getValueSuggestions = this.autocompleteConfig.valueSuggestions.enabled
? setupValueSuggestionProvider(core)
? setupValueSuggestionProvider(core, { timefilter })
: getEmptyValueSuggestions;

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,10 @@
*/

import { stubIndexPattern, stubFields } from '../../stubs';
import { TimefilterSetup } from '../../query';
import { setupValueSuggestionProvider, ValueSuggestionsGetFn } from './value_suggestion_provider';
import { IUiSettingsClient, CoreSetup } from 'kibana/public';

jest.mock('../../services', () => ({
getQueryService: () => ({
timefilter: {
timefilter: {
createFilter: () => {
return {
time: 'fake',
};
},
getTime: () => {
return {
to: 'now',
from: 'now-15m',
};
},
},
},
}),
}));

describe('FieldSuggestions', () => {
let getValueSuggestions: ValueSuggestionsGetFn;
let http: any;
Expand All @@ -50,7 +31,23 @@ describe('FieldSuggestions', () => {
const uiSettings = { get: (key: string) => shouldSuggestValues } as IUiSettingsClient;
http = { fetch: jest.fn() };

getValueSuggestions = setupValueSuggestionProvider({ http, uiSettings } as CoreSetup);
getValueSuggestions = setupValueSuggestionProvider({ http, uiSettings } as CoreSetup, {
timefilter: ({
timefilter: {
createFilter: () => {
return {
time: 'fake',
};
},
getTime: () => {
return {
to: 'now',
from: 'now-15m',
};
},
},
} as unknown) as TimefilterSetup,
});
});

describe('with value suggestions disabled', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import dateMath from '@elastic/datemath';
import { memoize } from 'lodash';
import { CoreSetup } from 'src/core/public';
import { IIndexPattern, IFieldType, UI_SETTINGS, buildQueryFromFilters } from '../../../common';
import { getQueryService } from '../../services';
import { TimefilterSetup } from '../../query';

function resolver(title: string, field: IFieldType, query: string, filters: any[]) {
// Only cache results for a minute
Expand All @@ -40,8 +40,10 @@ interface ValueSuggestionsGetFnArgs {
signal?: AbortSignal;
}

const getAutocompleteTimefilter = (indexPattern: IIndexPattern) => {
const { timefilter } = getQueryService().timefilter;
const getAutocompleteTimefilter = (
{ timefilter }: TimefilterSetup,
indexPattern: IIndexPattern
) => {
const timeRange = timefilter.getTime();

// Use a rounded timerange so that memoizing works properly
Expand All @@ -54,7 +56,10 @@ const getAutocompleteTimefilter = (indexPattern: IIndexPattern) => {

export const getEmptyValueSuggestions = (() => Promise.resolve([])) as ValueSuggestionsGetFn;

export const setupValueSuggestionProvider = (core: CoreSetup): ValueSuggestionsGetFn => {
export const setupValueSuggestionProvider = (
core: CoreSetup,
{ timefilter }: { timefilter: TimefilterSetup }
): ValueSuggestionsGetFn => {
const requestSuggestions = memoize(
(index: string, field: IFieldType, query: string, filters: any = [], signal?: AbortSignal) =>
core.http.fetch(`/api/kibana/suggestions/values/${index}`, {
Expand Down Expand Up @@ -86,7 +91,9 @@ export const setupValueSuggestionProvider = (core: CoreSetup): ValueSuggestionsG
return [];
}

const timeFilter = useTimeRange ? getAutocompleteTimefilter(indexPattern) : undefined;
const timeFilter = useTimeRange
? getAutocompleteTimefilter(timefilter, indexPattern)
: undefined;
const filterQuery = timeFilter ? buildQueryFromFilters([timeFilter], indexPattern).filter : [];
const filters = [...(boolFilter ? boolFilter : []), ...filterQuery];
return await requestSuggestions(title, field, query, filters, signal);
Expand Down
11 changes: 0 additions & 11 deletions src/plugins/data/public/index_patterns/index_pattern.stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,9 @@
import sinon from 'sinon';

import { CoreSetup } from 'src/core/public';
import { FieldFormat as FieldFormatImpl } from '../../common/field_formats';
import { IFieldType, FieldSpec } from '../../common/index_patterns';
import { FieldFormatsStart } from '../field_formats';
import { IndexPattern, indexPatterns, KBN_FIELD_TYPES, fieldList } from '../';
import { getFieldFormatsRegistry } from '../test_utils';
import { setFieldFormats } from '../services';

setFieldFormats(({
getDefaultInstance: () =>
({
getConverterFor: () => (value: any) => value,
convert: (value: any) => JSON.stringify(value),
} as FieldFormatImpl),
} as unknown) as FieldFormatsStart);

export function getStubIndexPattern(
pattern: string,
Expand Down
Loading

0 comments on commit 957db54

Please sign in to comment.