Skip to content

Commit

Permalink
Merge branch 'master' into fixes-stack-testing-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jul 14, 2021
2 parents d4b52dd + dd081ba commit 417cd1b
Show file tree
Hide file tree
Showing 48 changed files with 1,156 additions and 270 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IndexPatternType](./kibana-plugin-plugins-data-public.indexpatterntype.md)

## IndexPatternType enum

<b>Signature:</b>

```typescript
export declare enum IndexPatternType
```

## Enumeration Members

| Member | Value | Description |
| --- | --- | --- |
| DEFAULT | <code>&quot;default&quot;</code> | |
| ROLLUP | <code>&quot;rollup&quot;</code> | |

Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export interface TypeMeta
| Property | Type | Description |
| --- | --- | --- |
| [aggs](./kibana-plugin-plugins-data-public.indexpatterntypemeta.aggs.md) | <code>Record&lt;string, AggregationRestrictions&gt;</code> | |
| [params](./kibana-plugin-plugins-data-public.indexpatterntypemeta.params.md) | <code>{</code><br/><code> rollup_index: string;</code><br/><code> }</code> | |

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

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IndexPatternTypeMeta](./kibana-plugin-plugins-data-public.indexpatterntypemeta.md) &gt; [params](./kibana-plugin-plugins-data-public.indexpatterntypemeta.params.md)

## IndexPatternTypeMeta.params property

<b>Signature:</b>

```typescript
params?: {
rollup_index: string;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
| --- | --- |
| [BUCKET\_TYPES](./kibana-plugin-plugins-data-public.bucket_types.md) | |
| [ES\_FIELD\_TYPES](./kibana-plugin-plugins-data-public.es_field_types.md) | \* |
| [IndexPatternType](./kibana-plugin-plugins-data-public.indexpatterntype.md) | |
| [KBN\_FIELD\_TYPES](./kibana-plugin-plugins-data-public.kbn_field_types.md) | \* |
| [METRIC\_TYPES](./kibana-plugin-plugins-data-public.metric_types.md) | |
| [QuerySuggestionTypes](./kibana-plugin-plugins-data-public.querysuggestiontypes.md) | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ export declare class Execution<Input = unknown, Output = unknown, InspectorAdapt
| [invokeChain(chainArr, input)](./kibana-plugin-plugins-expressions-public.execution.invokechain.md) | | |
| [invokeFunction(fn, input, args)](./kibana-plugin-plugins-expressions-public.execution.invokefunction.md) | | |
| [resolveArgs(fnDef, input, argAsts)](./kibana-plugin-plugins-expressions-public.execution.resolveargs.md) | | |
| [start(input)](./kibana-plugin-plugins-expressions-public.execution.start.md) | | Call this method to start execution.<!-- -->N.B. <code>input</code> is initialized to <code>null</code> rather than <code>undefined</code> for legacy reasons, because in legacy interpreter it was set to <code>null</code> by default. |
| [start(input, isSubExpression)](./kibana-plugin-plugins-expressions-public.execution.start.md) | | Call this method to start execution.<!-- -->N.B. <code>input</code> is initialized to <code>null</code> rather than <code>undefined</code> for legacy reasons, because in legacy interpreter it was set to <code>null</code> by default. |

Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ N.B. `input` is initialized to `null` rather than `undefined` for legacy reasons
<b>Signature:</b>

```typescript
start(input?: Input): Observable<ExecutionResult<Output | ExpressionValueError>>;
start(input?: Input, isSubExpression?: boolean): Observable<ExecutionResult<Output | ExpressionValueError>>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| input | <code>Input</code> | |
| isSubExpression | <code>boolean</code> | |

<b>Returns:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ export declare class Execution<Input = unknown, Output = unknown, InspectorAdapt
| [invokeChain(chainArr, input)](./kibana-plugin-plugins-expressions-server.execution.invokechain.md) | | |
| [invokeFunction(fn, input, args)](./kibana-plugin-plugins-expressions-server.execution.invokefunction.md) | | |
| [resolveArgs(fnDef, input, argAsts)](./kibana-plugin-plugins-expressions-server.execution.resolveargs.md) | | |
| [start(input)](./kibana-plugin-plugins-expressions-server.execution.start.md) | | Call this method to start execution.<!-- -->N.B. <code>input</code> is initialized to <code>null</code> rather than <code>undefined</code> for legacy reasons, because in legacy interpreter it was set to <code>null</code> by default. |
| [start(input, isSubExpression)](./kibana-plugin-plugins-expressions-server.execution.start.md) | | Call this method to start execution.<!-- -->N.B. <code>input</code> is initialized to <code>null</code> rather than <code>undefined</code> for legacy reasons, because in legacy interpreter it was set to <code>null</code> by default. |

Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ N.B. `input` is initialized to `null` rather than `undefined` for legacy reasons
<b>Signature:</b>

```typescript
start(input?: Input): Observable<ExecutionResult<Output | ExpressionValueError>>;
start(input?: Input, isSubExpression?: boolean): Observable<ExecutionResult<Output | ExpressionValueError>>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| input | <code>Input</code> | |
| isSubExpression | <code>boolean</code> | |

<b>Returns:</b>

Expand Down
7 changes: 4 additions & 3 deletions src/core/server/core_app/bundle_routes/file_hash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const mockedCache = (): jest.Mocked<IFileHashCache> => ({
set: jest.fn(),
});

// FLAKY: https://github.com/elastic/kibana/issues/105174
describe.skip('getFileHash', () => {
describe('getFileHash', () => {
const sampleFilePath = resolve(__dirname, 'foo.js');
const fd = 42;
const stats: Stats = { ino: 42, size: 9000 } as any;
Expand Down Expand Up @@ -68,6 +67,8 @@ describe.skip('getFileHash', () => {
await getFileHash(cache, sampleFilePath, stats, fd);

expect(cache.set).toHaveBeenCalledTimes(1);
expect(cache.set).toHaveBeenCalledWith(`${sampleFilePath}-${stats.ino}`, computedHashPromise);
expect(cache.set).toHaveBeenCalledWith(`${sampleFilePath}-${stats.ino}`, expect.any(Promise));
const promiseValue = await cache.set.mock.calls[0][1];
expect(promiseValue).toEqual('computed-hash');
});
});
10 changes: 9 additions & 1 deletion src/plugins/data/common/index_patterns/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,17 @@ export type AggregationRestrictions = Record<
time_zone?: string;
}
>;

export interface TypeMeta {
aggs?: Record<string, AggregationRestrictions>;
[key: string]: any;
params?: {
rollup_index: string;
};
}

export enum IndexPatternType {
DEFAULT = 'default',
ROLLUP = 'rollup',
}

export type FieldSpecConflictDescriptions = Record<string, string[]>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ export const handleRequest = async ({
requestSearchSource.setField('filter', filters);
requestSearchSource.setField('query', query);

inspectorAdapters.requests?.reset();

const { rawResponse: response } = await requestSearchSource
.fetch$({
abortSignal,
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export {
IndexPatternLoadExpressionFunctionDefinition,
fieldList,
INDEX_PATTERN_SAVED_OBJECT_TYPE,
IndexPatternType,
} from '../common';

export { DuplicateIndexPatternError } from '../common/index_patterns/errors';
Expand Down
44 changes: 28 additions & 16 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1688,14 +1688,26 @@ export class IndexPatternsService {
updateSavedObject(indexPattern: IndexPattern, saveAttempts?: number, ignoreErrors?: boolean): Promise<void | Error>;
}

// Warning: (ae-missing-release-tag) "IndexPatternType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export enum IndexPatternType {
// (undocumented)
DEFAULT = "default",
// (undocumented)
ROLLUP = "rollup"
}

// Warning: (ae-missing-release-tag) "TypeMeta" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface IndexPatternTypeMeta {
// (undocumented)
[key: string]: any;
// (undocumented)
aggs?: Record<string, IndexPatternAggRestrictions>;
// (undocumented)
params?: {
rollup_index: string;
};
}

// Warning: (ae-missing-release-tag) "injectReferences" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
Expand Down Expand Up @@ -2766,20 +2778,20 @@ export interface WaitUntilNextSessionCompletesOptions {
// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:409:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:411:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:421:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:422:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:423:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:424:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:428:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:429:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:432:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:433:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:436:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:410:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:410:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:410:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:413:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:422:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:423:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:424:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:425:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:429:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:430:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:433:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:434:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:437:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:34:5 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/search/session/session_service.ts:62:5 - (ae-forgotten-export) The symbol "UrlGeneratorStateMapping" needs to be exported by the entry point index.d.ts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,21 @@ export const useSavedSearch = ({
).pipe(debounceTime(100));

const subscription = fetch$.subscribe((val) => {
fetchAll(val === 'reset');
try {
fetchAll(val === 'reset');
} catch (error) {
data$.next({
state: FetchStatus.ERROR,
fetchError: error,
});
}
});

return () => {
subscription.unsubscribe();
};
}, [
data$,
data.query.queryString,
filterManager,
refetch$,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,33 @@ describe('DocViewTable at Discover Doc with Fields API', () => {
},
},
},
{
name: 'city',
displayName: 'city',
type: 'keyword',
isMapped: true,
readFromDocValues: true,
searchable: true,
shortDotsEnable: false,
scripted: false,
filterable: false,
},
{
name: 'city.raw',
displayName: 'city.raw',
type: 'string',
isMapped: true,
spec: {
subType: {
multi: {
parent: 'city',
},
},
},
shortDotsEnable: false,
scripted: false,
filterable: false,
},
],
},
metaFields: ['_index', '_type', '_score', '_id'],
Expand Down Expand Up @@ -380,6 +407,7 @@ describe('DocViewTable at Discover Doc with Fields API', () => {
customer_first_name: 'Betty',
'customer_first_name.keyword': 'Betty',
'customer_first_name.nickname': 'Betsy',
'city.raw': 'Los Angeles',
},
};
const props = {
Expand Down Expand Up @@ -417,6 +445,8 @@ describe('DocViewTable at Discover Doc with Fields API', () => {
findTestSubject(component, 'tableDocViewRow-customer_first_name.nickname-multifieldBadge')
.length
).toBe(1);

expect(findTestSubject(component, 'tableDocViewRow-city.raw').length).toBe(1);
});

it('does not render multifield rows if showMultiFields flag is not set', () => {
Expand Down Expand Up @@ -449,5 +479,7 @@ describe('DocViewTable at Discover Doc with Fields API', () => {
findTestSubject(component, 'tableDocViewRow-customer_first_name.nickname-multifieldBadge')
.length
).toBe(0);

expect(findTestSubject(component, 'tableDocViewRow-city.raw').length).toBe(1);
});
});
16 changes: 14 additions & 2 deletions src/plugins/discover/public/application/components/table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import React, { useCallback, useMemo } from 'react';
import React, { useCallback, useMemo, useState } from 'react';
import { EuiInMemoryTable } from '@elastic/eui';
import { IndexPattern, IndexPatternField } from '../../../../../data/public';
import { SHOW_MULTIFIELDS } from '../../../../common';
Expand Down Expand Up @@ -60,6 +60,8 @@ export const DocViewerTable = ({
indexPattern?.fields,
]);

const [childParentFieldsMap] = useState({} as Record<string, string>);

const formattedHit = useMemo(() => indexPattern?.formatHit(hit, 'html'), [hit, indexPattern]);

const tableColumns = useMemo(() => {
Expand Down Expand Up @@ -92,11 +94,21 @@ export const DocViewerTable = ({
}

const flattened = indexPattern.flattenHit(hit);
Object.keys(flattened).forEach((key) => {
const field = mapping(key);
if (field && field.spec?.subType?.multi?.parent) {
childParentFieldsMap[field.name] = field.spec.subType.multi.parent;
}
});
const items: FieldRecord[] = Object.keys(flattened)
.filter((fieldName) => {
const fieldMapping = mapping(fieldName);
const isMultiField = !!fieldMapping?.spec?.subType?.multi;
return isMultiField ? showMultiFields : true;
if (!isMultiField) {
return true;
}
const parent = childParentFieldsMap[fieldName];
return showMultiFields || (parent && !flattened.hasOwnProperty(parent));
})
.sort((fieldA, fieldB) => {
const mappingA = mapping(fieldA);
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/expressions/common/execution/execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ describe('Execution', () => {
});
expect(execution.inspectorAdapters).toBe(inspectorAdapters);
});

test('it should reset the request adapter only on startup', async () => {
const inspectorAdapters = { requests: { reset: jest.fn() } };
await run('add val={add 5 | access "value"}', {
inspectorAdapters,
});
expect(inspectorAdapters.requests.reset).toHaveBeenCalledTimes(1);
});
});

describe('expression abortion', () => {
Expand Down
9 changes: 7 additions & 2 deletions src/plugins/expressions/common/execution/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,18 @@ export class Execution<
* because in legacy interpreter it was set to `null` by default.
*/
public start(
input: Input = null as any
input: Input = null as any,
isSubExpression?: boolean
): Observable<ExecutionResult<Output | ExpressionValueError>> {
if (this.hasStarted) throw new Error('Execution already started.');
this.hasStarted = true;
this.input = input;
this.state.transitions.start();

if (!isSubExpression) {
this.context.inspectorAdapters.requests?.reset();
}

if (isObservable<Input>(input)) {
input.subscribe(this.input$);
} else if (isPromise(input)) {
Expand Down Expand Up @@ -534,7 +539,7 @@ export class Execution<
);
this.childExecutions.push(execution);

return execution.start(input);
return execution.start(input, true);
case 'string':
case 'number':
case 'null':
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/expressions/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class Execution<Input = unknown, Output = unknown, InspectorAdapters exte
// (undocumented)
resolveArgs(fnDef: ExpressionFunction, input: unknown, argAsts: any): Observable<any>;
readonly result: Observable<ExecutionResult<Output | ExpressionValueError>>;
start(input?: Input): Observable<ExecutionResult<Output | ExpressionValueError>>;
start(input?: Input, isSubExpression?: boolean): Observable<ExecutionResult<Output | ExpressionValueError>>;
// Warning: (ae-forgotten-export) The symbol "ExecutionResult" needs to be exported by the entry point index.d.ts
readonly state: ExecutionContainer<ExecutionResult<Output | ExpressionValueError>>;
}
Expand Down
Loading

0 comments on commit 417cd1b

Please sign in to comment.