Skip to content

Commit

Permalink
typescript fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkime committed Aug 17, 2021
1 parent d7c45e2 commit 52f9751
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 58 deletions.
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-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IndexPatternListItem](./kibana-plugin-plugins-data-public.indexpatternlistitem.md) &gt; [id](./kibana-plugin-plugins-data-public.indexpatternlistitem.id.md)

## IndexPatternListItem.id property

<b>Signature:</b>

```typescript
id: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- 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; [IndexPatternListItem](./kibana-plugin-plugins-data-public.indexpatternlistitem.md)

## IndexPatternListItem interface

<b>Signature:</b>

```typescript
export interface IndexPatternListItem
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [id](./kibana-plugin-plugins-data-public.indexpatternlistitem.id.md) | <code>string</code> | |
| [title](./kibana-plugin-plugins-data-public.indexpatternlistitem.title.md) | <code>string</code> | |
| [type](./kibana-plugin-plugins-data-public.indexpatternlistitem.type.md) | <code>string</code> | |
| [typeMeta](./kibana-plugin-plugins-data-public.indexpatternlistitem.typemeta.md) | <code>TypeMeta</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-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IndexPatternListItem](./kibana-plugin-plugins-data-public.indexpatternlistitem.md) &gt; [title](./kibana-plugin-plugins-data-public.indexpatternlistitem.title.md)

## IndexPatternListItem.title property

<b>Signature:</b>

```typescript
title: string;
```
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-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IndexPatternListItem](./kibana-plugin-plugins-data-public.indexpatternlistitem.md) &gt; [type](./kibana-plugin-plugins-data-public.indexpatternlistitem.type.md)

## IndexPatternListItem.type property

<b>Signature:</b>

```typescript
type: string;
```
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-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IndexPatternListItem](./kibana-plugin-plugins-data-public.indexpatternlistitem.md) &gt; [typeMeta](./kibana-plugin-plugins-data-public.indexpatternlistitem.typemeta.md)

## IndexPatternListItem.typeMeta property

<b>Signature:</b>

```typescript
typeMeta: TypeMeta;
```

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
| [IKibanaSearchRequest](./kibana-plugin-plugins-data-public.ikibanasearchrequest.md) | |
| [IKibanaSearchResponse](./kibana-plugin-plugins-data-public.ikibanasearchresponse.md) | |
| [IndexPatternAttributes](./kibana-plugin-plugins-data-public.indexpatternattributes.md) | Interface for an index pattern saved object |
| [IndexPatternListItem](./kibana-plugin-plugins-data-public.indexpatternlistitem.md) | |
| [IndexPatternSpec](./kibana-plugin-plugins-data-public.indexpatternspec.md) | Static index pattern format Serialized data object, representing index pattern attributes and state |
| [ISearchOptions](./kibana-plugin-plugins-data-public.isearchoptions.md) | |
| [ISearchSetup](./kibana-plugin-plugins-data-public.isearchsetup.md) | The setup contract exposed by the Search plugin exposes the search strategy extension point. |
Expand Down Expand Up @@ -156,7 +157,6 @@
| [IFieldParamType](./kibana-plugin-plugins-data-public.ifieldparamtype.md) | |
| [IFieldSubType](./kibana-plugin-plugins-data-public.ifieldsubtype.md) | |
| [IMetricAggType](./kibana-plugin-plugins-data-public.imetricaggtype.md) | |
| [IndexPatternListSavedObjectAttrs](./kibana-plugin-plugins-data-public.indexpatternlistsavedobjectattrs.md) | |
| [IndexPatternLoadExpressionFunctionDefinition](./kibana-plugin-plugins-data-public.indexpatternloadexpressionfunctiondefinition.md) | |
| [IndexPatternsContract](./kibana-plugin-plugins-data-public.indexpatternscontract.md) | |
| [IndexPatternSelectProps](./kibana-plugin-plugins-data-public.indexpatternselectprops.md) | |
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/common/index_patterns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export * from './constants';
export * from './fields';
export * from './types';
export { IndexPatternsService, IndexPatternsContract } from './index_patterns';
export type { IndexPattern, IndexPatternListSavedObjectAttrs } from './index_patterns';
export type { IndexPattern, IndexPatternListItem } from './index_patterns';
export * from './errors';
export * from './expressions';
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
FieldAttrs,
FieldSpec,
IndexPatternFieldMap,
TypeMeta,
} from '../types';
import { FieldFormatsStartCommon, FORMATS_UI_SETTINGS } from '../../../../field_formats/common/';
import { UI_SETTINGS, SavedObject } from '../../../common';
Expand All @@ -49,7 +50,12 @@ export type IndexPatternListSavedObjectAttrs = Pick<
'title' | 'type' | 'typeMeta'
>;

export type IndexPatternListItem = IndexPatternListSavedObjectAttrs & { id: string };
export interface IndexPatternListItem {
id: string;
title: string;
type: string;
typeMeta: TypeMeta;
}

interface IndexPatternsServiceDeps {
uiSettings: UiSettingsCommon;
Expand Down
9 changes: 2 additions & 7 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ export const indexPatterns = {
flattenHitWrapper,
};

export {
IndexPatternsContract,
IndexPattern,
IndexPatternField,
IndexPatternListSavedObjectAttrs,
TypeMeta,
} from './index_patterns';
export { IndexPatternsContract, IndexPattern, IndexPatternField, TypeMeta } from './index_patterns';

export {
IIndexPattern,
Expand All @@ -85,6 +79,7 @@ export {
INDEX_PATTERN_SAVED_OBJECT_TYPE,
AggregationRestrictions,
IndexPatternType,
IndexPatternListItem,
} from '../common';

export { DuplicateIndexPatternError } from '../common/index_patterns/errors';
Expand Down
7 changes: 1 addition & 6 deletions src/plugins/data/public/index_patterns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ export {
} from '../../common/index_patterns/lib';
export { flattenHitWrapper, formatHitProvider, onRedirectNoIndexPattern } from './index_patterns';

export {
IndexPatternField,
IIndexPatternFieldList,
TypeMeta,
IndexPatternListSavedObjectAttrs,
} from '../../common/index_patterns';
export { IndexPatternField, IIndexPatternFieldList, TypeMeta } from '../../common/index_patterns';

export {
IndexPatternsService,
Expand Down
42 changes: 25 additions & 17 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1367,10 +1367,19 @@ export class IndexPatternField implements IFieldType {
get visualizable(): boolean;
}

// Warning: (ae-missing-release-tag) "IndexPatternListSavedObjectAttrs" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
// Warning: (ae-missing-release-tag) "IndexPatternListItem" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type IndexPatternListSavedObjectAttrs = Pick<IndexPatternAttributes, 'title' | 'type' | 'typeMeta'>;
export interface IndexPatternListItem {
// (undocumented)
id: string;
// (undocumented)
title: string;
// (undocumented)
type: string;
// (undocumented)
typeMeta: TypeMeta;
}

// Warning: (ae-forgotten-export) The symbol "name" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Input" needs to be exported by the entry point index.d.ts
Expand Down Expand Up @@ -1467,7 +1476,6 @@ export class IndexPatternsService {
getFieldsForIndexPattern: (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions | undefined) => Promise<any>;
getFieldsForWildcard: (options: GetFieldsOptions) => Promise<any>;
getIds: (refresh?: boolean) => Promise<string[]>;
// Warning: (ae-forgotten-export) The symbol "IndexPatternListItem" needs to be exported by the entry point index.d.ts
getIdsWithTitle: (refresh?: boolean) => Promise<IndexPatternListItem[]>;
getTitles: (refresh?: boolean) => Promise<string[]>;
refreshFields: (indexPattern: IndexPattern) => Promise<void>;
Expand Down Expand Up @@ -2343,20 +2351,20 @@ export interface WaitUntilNextSessionCompletesOptions {
// src/plugins/data/public/index.ts:53:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:53:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:53:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:216:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:216:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:216:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:218:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:219:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:228:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:229:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:230:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:231:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:235:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:236:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:239:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:240:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:243:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:211:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:211:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:211:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:213:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:214:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:223:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:224:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:225:1 - (ae-forgotten-export) The symbol "IpAddress" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:226:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:230:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:231:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:234:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:235:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:238:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" 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

// (No @packageDocumentation comment for this package)
Expand Down
23 changes: 9 additions & 14 deletions src/plugins/index_pattern_management/public/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { IndexPatternsContract } from 'src/plugins/data/public';
import { IFieldType, IndexPatternListSavedObjectAttrs, TypeMeta } from 'src/plugins/data/public';
import { IFieldType, IndexPattern, IndexPatternListItem } from 'src/plugins/data/public';
import { i18n } from '@kbn/i18n';

const defaultIndexPatternListName = i18n.translate(
Expand All @@ -24,7 +24,7 @@ const rollupIndexPatternListName = i18n.translate(
}
);

const isRollup = (indexPatternType: string) => {
const isRollup = (indexPatternType: string = '') => {
return indexPatternType === 'rollup';
};

Expand Down Expand Up @@ -63,7 +63,7 @@ export async function getIndexPatterns(
);
}

export const getTags = (indexPattern: IndexPatternListSavedObjectAttrs, isDefault: boolean) => {
export const getTags = (indexPattern: IndexPatternListItem | IndexPattern, isDefault: boolean) => {
const tags = [];
if (isDefault) {
tags.push({
Expand All @@ -80,24 +80,19 @@ export const getTags = (indexPattern: IndexPatternListSavedObjectAttrs, isDefaul
return tags;
};

export const areScriptedFieldsEnabled = (indexPattern: IndexPatternListSavedObjectAttrs) => {
export const areScriptedFieldsEnabled = (indexPattern: IndexPatternListItem | IndexPattern) => {
return !isRollup(indexPattern.type);
};

export const getFieldInfo = (indexPattern: IndexPatternListSavedObjectAttrs, field: IFieldType) => {
export const getFieldInfo = (
indexPattern: IndexPatternListItem | IndexPattern,
field: IFieldType
) => {
if (!isRollup(indexPattern.type)) {
return [];
}

let typeMeta: TypeMeta;

try {
typeMeta = JSON.parse(indexPattern.typeMeta);
} catch {
return [];
}

const allAggs = typeMeta?.aggs;
const allAggs = indexPattern.typeMeta?.aggs;
const fieldAggs: string[] | undefined =
allAggs && Object.keys(allAggs).filter((agg) => allAggs[agg][field.name]);

Expand Down

0 comments on commit 52f9751

Please sign in to comment.