mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[data views] Move data views api from data plugin and into its own (#113497)
* initial pass at moving data views into own plugin * require expressions plugin, fix META_FIELDS reference * bundle limits and localization * fix integration test * update plugin list and jest config * type fixes * search fixes * fix localization * fix mocks * fix mocks * fix stub * type fixes * fix import on test file * path fixes * remove shorted dotted from data plugin * more todo removal * eslint fixes * eslint fix * simplify data views server plugin * simplify data views server plugin * simplify data views server plugin * fix imports on api routes * fix imports on api routes * update plugin list * ts fixes * ts fixes * add deprecation notice * fix circular dependency and api integration test * fix circular dependency and api integration test * rename types for better clarity * path fixes * jest.config and tsconfig cleanup Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
28702ff1c6
commit
bbb2e96dd5
169 changed files with 996 additions and 497 deletions
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -62,6 +62,7 @@
|
|||
/packages/kbn-interpreter/ @elastic/kibana-app-services
|
||||
/src/plugins/bfetch/ @elastic/kibana-app-services
|
||||
/src/plugins/data/ @elastic/kibana-app-services
|
||||
/src/plugins/data-views/ @elastic/kibana-app-services
|
||||
/src/plugins/embeddable/ @elastic/kibana-app-services
|
||||
/src/plugins/expressions/ @elastic/kibana-app-services
|
||||
/src/plugins/field_formats/ @elastic/kibana-app-services
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"bfetch": "src/plugins/bfetch",
|
||||
"dashboard": "src/plugins/dashboard",
|
||||
"data": "src/plugins/data",
|
||||
"dataViews": "src/plugins/data_views",
|
||||
"embeddableApi": "src/plugins/embeddable",
|
||||
"embeddableExamples": "examples/embeddable_examples",
|
||||
"fieldFormats": "src/plugins/field_formats",
|
||||
|
|
|
@ -57,6 +57,12 @@ as uiSettings within the code.
|
|||
|The data plugin provides common data access services, such as search and query, for solutions and application developers.
|
||||
|
||||
|
||||
|{kib-repo}blob/{branch}/src/plugins/data_views/README.mdx[dataViews]
|
||||
|The data views API provides a consistent method of structuring and formatting documents
|
||||
and field lists across the various Kibana apps. Its typically used in conjunction with
|
||||
<DocLink id="kibDevTutorialDataSearchAndSessions" section="high-level-search" text="SearchSource" /> for composing queries.
|
||||
|
||||
|
||||
|{kib-repo}blob/{branch}/src/plugins/dev_tools/README.md[devTools]
|
||||
|The ui/registry/dev_tools is removed in favor of the devTools plugin which exposes a register method in the setup contract.
|
||||
Registering app works mostly the same as registering apps in core.application.register.
|
||||
|
|
|
@ -116,3 +116,4 @@ pageLoadAssetSize:
|
|||
expressions: 239290
|
||||
securitySolution: 231753
|
||||
customIntegrations: 28810
|
||||
dataViews: 42000
|
||||
|
|
|
@ -49,15 +49,6 @@ This is helpful when you want to provide a user with options, for example when c
|
|||
|
||||
```
|
||||
|
||||
## Data Views
|
||||
|
||||
The data views API provides a consistent method of structuring and formatting documents
|
||||
and field lists across the various Kibana apps. Its typically used in conjunction with
|
||||
<DocLink id="kibDevTutorialDataSearchAndSessions" section="high-level-search" text="SearchSource" /> for composing queries.
|
||||
|
||||
*Note: Kibana index patterns are currently being renamed to data views. There will be some naming inconsistencies until the transition is complete.*
|
||||
|
||||
|
||||
## Query
|
||||
|
||||
The query service is responsible for managing the configuration of a search query (`QueryState`): filters, time range, query string, and settings such as the auto refresh behavior and saved queries.
|
||||
|
|
|
@ -9,15 +9,6 @@
|
|||
export const DEFAULT_QUERY_LANGUAGE = 'kuery';
|
||||
export const KIBANA_USER_QUERY_LANGUAGE_KEY = 'kibana.userQueryLanguage';
|
||||
|
||||
/** @public **/
|
||||
export const DATA_VIEW_SAVED_OBJECT_TYPE = 'index-pattern';
|
||||
|
||||
/**
|
||||
* @deprecated Use DATA_VIEW_SAVED_OBJECT_TYPE. All index pattern interfaces were renamed.
|
||||
*/
|
||||
|
||||
export const INDEX_PATTERN_SAVED_OBJECT_TYPE = DATA_VIEW_SAVED_OBJECT_TYPE;
|
||||
|
||||
export type ValueSuggestionsMethod = 'terms_enum' | 'terms_agg';
|
||||
|
||||
export const UI_SETTINGS = {
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export * from './constants';
|
||||
export * from './fields';
|
||||
export * from './types';
|
||||
export {
|
||||
IndexPatternsService,
|
||||
IndexPatternsContract,
|
||||
DataViewsService,
|
||||
DataViewsContract,
|
||||
} from './data_views';
|
||||
// todo was trying to export this as type but wasn't working
|
||||
export { IndexPattern, IndexPatternListItem, DataView, DataViewListItem } from './data_views';
|
||||
export * from './errors';
|
||||
export * from './expressions';
|
|
@ -11,18 +11,68 @@
|
|||
|
||||
export * from './constants';
|
||||
export * from './es_query';
|
||||
export * from './data_views';
|
||||
export * from './kbn_field_types';
|
||||
export * from './query';
|
||||
export * from './search';
|
||||
export * from './types';
|
||||
export * from './utils';
|
||||
export * from './exports';
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated Use data plugin interface instead
|
||||
* @removeBy 8.1
|
||||
*/
|
||||
|
||||
export { IndexPatternAttributes } from './types';
|
||||
export type {
|
||||
IFieldType,
|
||||
IIndexPatternFieldList,
|
||||
FieldFormatMap,
|
||||
RuntimeType,
|
||||
RuntimeField,
|
||||
IIndexPattern,
|
||||
DataViewAttributes,
|
||||
IndexPatternAttributes,
|
||||
FieldAttrs,
|
||||
FieldAttrSet,
|
||||
OnNotification,
|
||||
OnError,
|
||||
UiSettingsCommon,
|
||||
SavedObjectsClientCommonFindArgs,
|
||||
SavedObjectsClientCommon,
|
||||
GetFieldsOptions,
|
||||
GetFieldsOptionsTimePattern,
|
||||
IDataViewsApiClient,
|
||||
IIndexPatternsApiClient,
|
||||
SavedObject,
|
||||
AggregationRestrictions,
|
||||
TypeMeta,
|
||||
FieldSpecConflictDescriptions,
|
||||
FieldSpecExportFmt,
|
||||
FieldSpec,
|
||||
DataViewFieldMap,
|
||||
IndexPatternFieldMap,
|
||||
DataViewSpec,
|
||||
IndexPatternSpec,
|
||||
SourceFilter,
|
||||
IndexPatternExpressionType,
|
||||
IndexPatternLoadStartDependencies,
|
||||
IndexPatternLoadExpressionFunctionDefinition,
|
||||
} from '../../data_views/common';
|
||||
export {
|
||||
RUNTIME_FIELD_TYPES,
|
||||
FLEET_ASSETS_TO_IGNORE,
|
||||
META_FIELDS,
|
||||
DATA_VIEW_SAVED_OBJECT_TYPE,
|
||||
INDEX_PATTERN_SAVED_OBJECT_TYPE,
|
||||
isFilterable,
|
||||
isNestedField,
|
||||
fieldList,
|
||||
DataViewField,
|
||||
IndexPatternField,
|
||||
DataViewType,
|
||||
IndexPatternType,
|
||||
IndexPatternsService,
|
||||
IndexPatternsContract,
|
||||
DataViewsService,
|
||||
DataViewsContract,
|
||||
IndexPattern,
|
||||
IndexPatternListItem,
|
||||
DataView,
|
||||
DataViewListItem,
|
||||
DuplicateDataViewError,
|
||||
DataViewSavedObjectConflictError,
|
||||
getIndexPatternLoadMeta,
|
||||
} from '../../data_views/common';
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export * from './data_views/fields/fields.mocks';
|
||||
export * from '../../data_views/common/fields/fields.mocks';
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
import { BaseParamType } from './base';
|
||||
import { propFilter } from '../utils';
|
||||
import { KBN_FIELD_TYPES } from '../../../kbn_field_types/types';
|
||||
import { isNestedField, IndexPatternField } from '../../../data_views/fields';
|
||||
import { isNestedField, IndexPatternField } from '../../../../../data_views/common';
|
||||
|
||||
const filterByType = propFilter('type');
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import { Observable } from 'rxjs';
|
|||
import type { Datatable, ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
|
||||
import { buildExpressionFunction } from '../../../../../../plugins/expressions/common';
|
||||
|
||||
import { IndexPatternExpressionType } from '../../../data_views/expressions';
|
||||
import { IndexPatternExpressionType } from '../../../../../data_views/common/expressions';
|
||||
import { IndexPatternsContract } from '../../..';
|
||||
|
||||
import { AggsStart, AggExpressionType, aggCountFnName } from '../../aggs';
|
||||
|
|
|
@ -10,7 +10,7 @@ import { SavedObjectReference } from 'src/core/types';
|
|||
import { Filter } from '@kbn/es-query';
|
||||
import { SearchSourceFields } from './types';
|
||||
|
||||
import { INDEX_PATTERN_SAVED_OBJECT_TYPE } from '../../constants';
|
||||
import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../../../../data/common';
|
||||
|
||||
export const extractReferences = (
|
||||
state: SearchSourceFields
|
||||
|
@ -22,7 +22,7 @@ export const extractReferences = (
|
|||
const refName = 'kibanaSavedObjectMeta.searchSourceJSON.index';
|
||||
references.push({
|
||||
name: refName,
|
||||
type: INDEX_PATTERN_SAVED_OBJECT_TYPE,
|
||||
type: DATA_VIEW_SAVED_OBJECT_TYPE,
|
||||
id: indexId,
|
||||
});
|
||||
searchSourceFields = {
|
||||
|
@ -42,7 +42,7 @@ export const extractReferences = (
|
|||
const refName = `kibanaSavedObjectMeta.searchSourceJSON.filter[${i}].meta.index`;
|
||||
references.push({
|
||||
name: refName,
|
||||
type: INDEX_PATTERN_SAVED_OBJECT_TYPE,
|
||||
type: DATA_VIEW_SAVED_OBJECT_TYPE,
|
||||
id: filterRow.meta.index,
|
||||
});
|
||||
return {
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export * from './data_views/field.stub';
|
||||
export * from './data_views/data_view.stub';
|
||||
export * from '../../data_views/common/field.stub';
|
||||
export * from '../../data_views/common/data_view.stub';
|
||||
export * from './es_query/stubs';
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
export * from './query/types';
|
||||
export * from './kbn_field_types/types';
|
||||
export * from './data_views/types';
|
||||
|
||||
/**
|
||||
* If a service is being shared on both the client and the server, and
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
"version": "kibana",
|
||||
"server": true,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["bfetch", "expressions", "uiActions", "share", "inspector", "fieldFormats"],
|
||||
"serviceFolders": ["search", "data_views", "query", "autocomplete", "ui"],
|
||||
"requiredPlugins": ["bfetch", "expressions", "uiActions", "share", "inspector", "fieldFormats", "dataViews"],
|
||||
"serviceFolders": ["search", "query", "autocomplete", "ui"],
|
||||
"optionalPlugins": ["usageCollection"],
|
||||
"extraPublicDirs": ["common"],
|
||||
"requiredBundles": ["kibanaUtils", "kibanaReact", "inspector"],
|
||||
|
|
|
@ -6,25 +6,4 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export {
|
||||
ILLEGAL_CHARACTERS_KEY,
|
||||
CONTAINS_SPACES_KEY,
|
||||
ILLEGAL_CHARACTERS_VISIBLE,
|
||||
ILLEGAL_CHARACTERS,
|
||||
validateDataView,
|
||||
} from '../../common/data_views/lib';
|
||||
export { flattenHitWrapper, formatHitProvider, onRedirectNoIndexPattern } from './data_views';
|
||||
|
||||
export { IndexPatternField, IIndexPatternFieldList, TypeMeta } from '../../common/data_views';
|
||||
|
||||
export {
|
||||
IndexPatternsService,
|
||||
IndexPatternsContract,
|
||||
IndexPattern,
|
||||
DataViewsApiClient,
|
||||
DataViewsService,
|
||||
DataViewsContract,
|
||||
DataView,
|
||||
} from './data_views';
|
||||
export { UiSettingsPublicToCommon } from './ui_settings_wrapper';
|
||||
export { SavedObjectsClientPublicToCommon } from './saved_objects_client_wrapper';
|
||||
export * from '../../../data_views/public';
|
||||
|
|
|
@ -83,14 +83,12 @@ export {
|
|||
IndexPatternLoadExpressionFunctionDefinition,
|
||||
fieldList,
|
||||
GetFieldsOptions,
|
||||
INDEX_PATTERN_SAVED_OBJECT_TYPE,
|
||||
AggregationRestrictions,
|
||||
IndexPatternType,
|
||||
IndexPatternListItem,
|
||||
DuplicateDataViewError,
|
||||
} from '../common';
|
||||
|
||||
export { DuplicateDataViewError } from '../common/data_views/errors';
|
||||
|
||||
/*
|
||||
* Autocomplete query suggestions:
|
||||
*/
|
||||
|
|
|
@ -21,12 +21,6 @@ import { AutocompleteService } from './autocomplete';
|
|||
import { SearchService } from './search/search_service';
|
||||
import { QueryService } from './query';
|
||||
import { createIndexPatternSelect } from './ui/index_pattern_select';
|
||||
import {
|
||||
DataViewsService,
|
||||
onRedirectNoIndexPattern,
|
||||
DataViewsApiClient,
|
||||
UiSettingsPublicToCommon,
|
||||
} from './data_views';
|
||||
import {
|
||||
setIndexPatterns,
|
||||
setNotifications,
|
||||
|
@ -44,8 +38,6 @@ import {
|
|||
createSelectRangeAction,
|
||||
} from './actions';
|
||||
import { APPLY_FILTER_TRIGGER, applyFilterTrigger } from './triggers';
|
||||
import { SavedObjectsClientPublicToCommon } from './data_views';
|
||||
import { getIndexPatternLoad } from './data_views/expressions';
|
||||
import { UsageCollectionSetup } from '../../usage_collection/public';
|
||||
import { getTableViewDescription } from './utils/table_inspector_view';
|
||||
import { NowProvider, NowProviderInternalContract } from './now_provider';
|
||||
|
@ -89,8 +81,6 @@ export class DataPublicPlugin
|
|||
): DataPublicPluginSetup {
|
||||
const startServices = createStartServicesGetter(core.getStartServices);
|
||||
|
||||
expressions.registerFunction(getIndexPatternLoad({ getStartServices: core.getStartServices }));
|
||||
|
||||
this.usageCollection = usageCollection;
|
||||
|
||||
const searchService = this.searchService.setup(core, {
|
||||
|
@ -138,29 +128,13 @@ export class DataPublicPlugin
|
|||
|
||||
public start(
|
||||
core: CoreStart,
|
||||
{ uiActions, fieldFormats }: DataStartDependencies
|
||||
{ uiActions, fieldFormats, dataViews }: DataStartDependencies
|
||||
): DataPublicPluginStart {
|
||||
const { uiSettings, http, notifications, savedObjects, overlays, application } = core;
|
||||
const { uiSettings, notifications, savedObjects, overlays } = core;
|
||||
setNotifications(notifications);
|
||||
setOverlays(overlays);
|
||||
setUiSettings(uiSettings);
|
||||
|
||||
const indexPatterns = new DataViewsService({
|
||||
uiSettings: new UiSettingsPublicToCommon(uiSettings),
|
||||
savedObjectsClient: new SavedObjectsClientPublicToCommon(savedObjects.client),
|
||||
apiClient: new DataViewsApiClient(http),
|
||||
fieldFormats,
|
||||
onNotification: (toastInputFields) => {
|
||||
notifications.toasts.add(toastInputFields);
|
||||
},
|
||||
onError: notifications.toasts.addError.bind(notifications.toasts),
|
||||
onRedirectNoIndexPattern: onRedirectNoIndexPattern(
|
||||
application.capabilities,
|
||||
application.navigateToApp,
|
||||
overlays
|
||||
),
|
||||
});
|
||||
setIndexPatterns(indexPatterns);
|
||||
setIndexPatterns(dataViews);
|
||||
|
||||
const query = this.queryService.start({
|
||||
storage: this.storage,
|
||||
|
@ -168,7 +142,7 @@ export class DataPublicPlugin
|
|||
uiSettings,
|
||||
});
|
||||
|
||||
const search = this.searchService.start(core, { fieldFormats, indexPatterns });
|
||||
const search = this.searchService.start(core, { fieldFormats, indexPatterns: dataViews });
|
||||
setSearchService(search);
|
||||
|
||||
uiActions.addTriggerAction(
|
||||
|
@ -197,8 +171,8 @@ export class DataPublicPlugin
|
|||
},
|
||||
autocomplete: this.autocomplete.start(),
|
||||
fieldFormats,
|
||||
indexPatterns,
|
||||
dataViews: indexPatterns,
|
||||
indexPatterns: dataViews,
|
||||
dataViews,
|
||||
query,
|
||||
search,
|
||||
nowProvider: this.nowProvider,
|
||||
|
@ -214,7 +188,7 @@ export class DataPublicPlugin
|
|||
return {
|
||||
...dataServices,
|
||||
ui: {
|
||||
IndexPatternSelect: createIndexPatternSelect(indexPatterns),
|
||||
IndexPatternSelect: createIndexPatternSelect(dataViews),
|
||||
SearchBar,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
*/
|
||||
|
||||
export * from '../common/stubs';
|
||||
export { createStubDataView } from './data_views/data_views/data_view.stub';
|
||||
// eslint-disable-next-line
|
||||
export { createStubDataView } from '../../data_views/public/data_views/data_view.stub';
|
||||
|
|
|
@ -11,6 +11,7 @@ import { CoreStart } from 'src/core/public';
|
|||
import { BfetchPublicSetup } from 'src/plugins/bfetch/public';
|
||||
import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
|
||||
import { ExpressionsSetup } from 'src/plugins/expressions/public';
|
||||
import { DataViewsPublicPluginStart } from 'src/plugins/data_views/public';
|
||||
import { UiActionsSetup, UiActionsStart } from 'src/plugins/ui_actions/public';
|
||||
import { FieldFormatsSetup, FieldFormatsStart } from 'src/plugins/field_formats/public';
|
||||
import { AutocompleteSetup, AutocompleteStart } from './autocomplete';
|
||||
|
@ -35,6 +36,7 @@ export interface DataSetupDependencies {
|
|||
export interface DataStartDependencies {
|
||||
uiActions: UiActionsStart;
|
||||
fieldFormats: FieldFormatsStart;
|
||||
dataViews: DataViewsPublicPluginStart;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,12 +6,4 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export * from './utils';
|
||||
export {
|
||||
IndexPatternsFetcher,
|
||||
FieldDescriptor,
|
||||
shouldReadFieldFromDocValues,
|
||||
mergeCapabilitiesWithFields,
|
||||
getCapabilitiesForRollupIndices,
|
||||
} from './fetcher';
|
||||
export { IndexPatternsServiceProvider, IndexPatternsServiceStart } from './index_patterns_service';
|
||||
export * from '../../../data_views/server';
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* 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 {
|
||||
CoreSetup,
|
||||
CoreStart,
|
||||
Plugin,
|
||||
Logger,
|
||||
SavedObjectsClientContract,
|
||||
ElasticsearchClient,
|
||||
UiSettingsServiceStart,
|
||||
} from 'kibana/server';
|
||||
import { ExpressionsServerSetup } from 'src/plugins/expressions/server';
|
||||
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
|
||||
import { DataPluginStart } from '../plugin';
|
||||
import { registerRoutes } from './routes';
|
||||
import { indexPatternSavedObjectType } from '../saved_objects';
|
||||
import { capabilitiesProvider } from './capabilities_provider';
|
||||
import { IndexPatternsCommonService } from '../';
|
||||
import { FieldFormatsStart } from '../../../field_formats/server';
|
||||
import { getIndexPatternLoad } from './expressions';
|
||||
import { UiSettingsServerToCommon } from './ui_settings_wrapper';
|
||||
import { IndexPatternsApiServer } from './index_patterns_api_client';
|
||||
import { SavedObjectsClientServerToCommon } from './saved_objects_client_wrapper';
|
||||
import { registerIndexPatternsUsageCollector } from './register_index_pattern_usage_collection';
|
||||
import { createScriptedFieldsDeprecationsConfig } from './deprecations';
|
||||
|
||||
export interface IndexPatternsServiceStart {
|
||||
indexPatternsServiceFactory: (
|
||||
savedObjectsClient: SavedObjectsClientContract,
|
||||
elasticsearchClient: ElasticsearchClient
|
||||
) => Promise<IndexPatternsCommonService>;
|
||||
}
|
||||
|
||||
export interface IndexPatternsServiceSetupDeps {
|
||||
expressions: ExpressionsServerSetup;
|
||||
logger: Logger;
|
||||
usageCollection?: UsageCollectionSetup;
|
||||
}
|
||||
|
||||
export interface IndexPatternsServiceStartDeps {
|
||||
fieldFormats: FieldFormatsStart;
|
||||
logger: Logger;
|
||||
}
|
||||
|
||||
export const indexPatternsServiceFactory =
|
||||
({
|
||||
logger,
|
||||
uiSettings,
|
||||
fieldFormats,
|
||||
}: {
|
||||
logger: Logger;
|
||||
uiSettings: UiSettingsServiceStart;
|
||||
fieldFormats: FieldFormatsStart;
|
||||
}) =>
|
||||
async (
|
||||
savedObjectsClient: SavedObjectsClientContract,
|
||||
elasticsearchClient: ElasticsearchClient
|
||||
) => {
|
||||
const uiSettingsClient = uiSettings.asScopedToClient(savedObjectsClient);
|
||||
const formats = await fieldFormats.fieldFormatServiceFactory(uiSettingsClient);
|
||||
|
||||
return new IndexPatternsCommonService({
|
||||
uiSettings: new UiSettingsServerToCommon(uiSettingsClient),
|
||||
savedObjectsClient: new SavedObjectsClientServerToCommon(savedObjectsClient),
|
||||
apiClient: new IndexPatternsApiServer(elasticsearchClient, savedObjectsClient),
|
||||
fieldFormats: formats,
|
||||
onError: (error) => {
|
||||
logger.error(error);
|
||||
},
|
||||
onNotification: ({ title, text }) => {
|
||||
logger.warn(`${title}${text ? ` : ${text}` : ''}`);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export class IndexPatternsServiceProvider implements Plugin<void, IndexPatternsServiceStart> {
|
||||
public setup(
|
||||
core: CoreSetup<IndexPatternsServiceStartDeps, DataPluginStart>,
|
||||
{ expressions, usageCollection }: IndexPatternsServiceSetupDeps
|
||||
) {
|
||||
core.savedObjects.registerType(indexPatternSavedObjectType);
|
||||
core.capabilities.registerProvider(capabilitiesProvider);
|
||||
|
||||
registerRoutes(core.http, core.getStartServices);
|
||||
|
||||
expressions.registerFunction(getIndexPatternLoad({ getStartServices: core.getStartServices }));
|
||||
registerIndexPatternsUsageCollector(core.getStartServices, usageCollection);
|
||||
core.deprecations.registerDeprecations(createScriptedFieldsDeprecationsConfig(core));
|
||||
}
|
||||
|
||||
public start(core: CoreStart, { fieldFormats, logger }: IndexPatternsServiceStartDeps) {
|
||||
const { uiSettings } = core;
|
||||
|
||||
return {
|
||||
indexPatternsServiceFactory: indexPatternsServiceFactory({
|
||||
logger,
|
||||
uiSettings,
|
||||
fieldFormats,
|
||||
}),
|
||||
};
|
||||
}
|
||||
}
|
|
@ -6,8 +6,4 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export function createIndexPatternsStartMock() {
|
||||
return {
|
||||
indexPatternsServiceFactory: jest.fn().mockResolvedValue({ get: jest.fn() }),
|
||||
};
|
||||
}
|
||||
export * from '../../../data_views/server/mocks';
|
||||
|
|
|
@ -30,7 +30,7 @@ export const exporters = {
|
|||
* Field Formats:
|
||||
*/
|
||||
|
||||
export { INDEX_PATTERN_SAVED_OBJECT_TYPE } from '../common';
|
||||
export { DATA_VIEW_SAVED_OBJECT_TYPE } from '../common';
|
||||
|
||||
/*
|
||||
* Index patterns:
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
import { CoreSetup, CoreStart, Logger, Plugin, PluginInitializerContext } from 'src/core/server';
|
||||
import { ExpressionsServerSetup } from 'src/plugins/expressions/server';
|
||||
import { BfetchServerSetup } from 'src/plugins/bfetch/server';
|
||||
import { PluginStart as DataViewsServerPluginStart } from 'src/plugins/data_views/server';
|
||||
import { ConfigSchema } from '../config';
|
||||
import { IndexPatternsServiceProvider, IndexPatternsServiceStart } from './data_views';
|
||||
import { ISearchSetup, ISearchStart, SearchEnhancements } from './search';
|
||||
import { SearchService } from './search/search_service';
|
||||
import { QueryService } from './query/query_service';
|
||||
|
@ -43,7 +43,7 @@ export interface DataPluginStart {
|
|||
* @deprecated - use "fieldFormats" plugin directly instead
|
||||
*/
|
||||
fieldFormats: FieldFormatsStart;
|
||||
indexPatterns: IndexPatternsServiceStart;
|
||||
indexPatterns: DataViewsServerPluginStart;
|
||||
}
|
||||
|
||||
export interface DataPluginSetupDependencies {
|
||||
|
@ -56,6 +56,7 @@ export interface DataPluginSetupDependencies {
|
|||
export interface DataPluginStartDependencies {
|
||||
fieldFormats: FieldFormatsStart;
|
||||
logger: Logger;
|
||||
dataViews: DataViewsServerPluginStart;
|
||||
}
|
||||
|
||||
export class DataServerPlugin
|
||||
|
@ -71,7 +72,6 @@ export class DataServerPlugin
|
|||
private readonly scriptsService: ScriptsService;
|
||||
private readonly kqlTelemetryService: KqlTelemetryService;
|
||||
private readonly autocompleteService: AutocompleteService;
|
||||
private readonly indexPatterns = new IndexPatternsServiceProvider();
|
||||
private readonly queryService = new QueryService();
|
||||
private readonly logger: Logger;
|
||||
|
||||
|
@ -91,11 +91,6 @@ export class DataServerPlugin
|
|||
this.queryService.setup(core);
|
||||
this.autocompleteService.setup(core);
|
||||
this.kqlTelemetryService.setup(core, { usageCollection });
|
||||
this.indexPatterns.setup(core, {
|
||||
expressions,
|
||||
logger: this.logger.get('indexPatterns'),
|
||||
usageCollection,
|
||||
});
|
||||
|
||||
core.uiSettings.register(getUiSettings());
|
||||
|
||||
|
@ -114,16 +109,11 @@ export class DataServerPlugin
|
|||
};
|
||||
}
|
||||
|
||||
public start(core: CoreStart, { fieldFormats }: DataPluginStartDependencies) {
|
||||
const indexPatterns = this.indexPatterns.start(core, {
|
||||
fieldFormats,
|
||||
logger: this.logger.get('indexPatterns'),
|
||||
});
|
||||
|
||||
public start(core: CoreStart, { fieldFormats, dataViews }: DataPluginStartDependencies) {
|
||||
return {
|
||||
fieldFormats,
|
||||
indexPatterns,
|
||||
search: this.searchService.start(core, { fieldFormats, indexPatterns }),
|
||||
indexPatterns: dataViews,
|
||||
search: this.searchService.start(core, { fieldFormats, indexPatterns: dataViews }),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,5 @@
|
|||
*/
|
||||
|
||||
export { querySavedObjectType } from './query';
|
||||
export { indexPatternSavedObjectType } from './index_patterns';
|
||||
export { kqlTelemetry } from './kql_telemetry';
|
||||
export { searchTelemetry } from './search_telemetry';
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
{ "path": "../usage_collection/tsconfig.json" },
|
||||
{ "path": "../kibana_utils/tsconfig.json" },
|
||||
{ "path": "../kibana_react/tsconfig.json" },
|
||||
{ "path": "../field_formats/tsconfig.json" }
|
||||
{ "path": "../field_formats/tsconfig.json" },
|
||||
{ "path": "../data_views/tsconfig.json" }
|
||||
]
|
||||
}
|
||||
|
|
19
src/plugins/data_views/README.mdx
Normal file
19
src/plugins/data_views/README.mdx
Normal file
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
id: kibDataPlugin
|
||||
slug: /kibana-dev-docs/services/data-plugin
|
||||
title: Data services
|
||||
image: https://source.unsplash.com/400x175/?Search
|
||||
summary: The data plugin contains services for searching, querying and filtering.
|
||||
date: 2020-12-02
|
||||
tags: ['kibana', 'dev', 'contributor', 'api docs']
|
||||
---
|
||||
|
||||
# Data Views
|
||||
|
||||
The data views API provides a consistent method of structuring and formatting documents
|
||||
and field lists across the various Kibana apps. Its typically used in conjunction with
|
||||
<DocLink id="kibDevTutorialDataSearchAndSessions" section="high-level-search" text="SearchSource" /> for composing queries.
|
||||
|
||||
*Note: Kibana index patterns are currently being renamed to data views. There will be some naming inconsistencies until the transition is complete.*
|
||||
|
||||
|
|
@ -29,3 +29,14 @@ export const FLEET_ASSETS_TO_IGNORE = {
|
|||
METRICS_DATA_STREAM_TO_IGNORE: 'metrics-elastic_agent', // ignore ds created by Fleet server itself
|
||||
METRICS_ENDPOINT_INDEX_TO_IGNORE: 'metrics-endpoint.metadata_current_default', // ignore index created by Fleet endpoint package installed by default in Cloud
|
||||
};
|
||||
|
||||
export const META_FIELDS = 'metaFields';
|
||||
|
||||
/** @public **/
|
||||
export const DATA_VIEW_SAVED_OBJECT_TYPE = 'index-pattern';
|
||||
|
||||
/**
|
||||
* @deprecated Use DATA_VIEW_SAVED_OBJECT_TYPE. All index pattern interfaces were renamed.
|
||||
*/
|
||||
|
||||
export const INDEX_PATTERN_SAVED_OBJECT_TYPE = DATA_VIEW_SAVED_OBJECT_TYPE;
|
|
@ -12,8 +12,8 @@ export {
|
|||
createStubDataView,
|
||||
createStubDataView as createStubIndexPattern,
|
||||
} from './data_views/data_view.stub';
|
||||
import { SavedObject } from '../../../../core/types';
|
||||
import { DataViewAttributes } from '../types';
|
||||
import { SavedObject } from '../../../core/types';
|
||||
import { DataViewAttributes } from './types';
|
||||
|
||||
export const stubDataView = createStubDataView({
|
||||
spec: {
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
import { DataView } from './data_view';
|
||||
import { DataViewSpec } from '../types';
|
||||
import { FieldFormatsStartCommon } from '../../../../field_formats/common';
|
||||
import { fieldFormatsMock } from '../../../../field_formats/common/mocks';
|
||||
import { FieldFormatsStartCommon } from '../../../field_formats/common';
|
||||
import { fieldFormatsMock } from '../../../field_formats/common/mocks';
|
||||
|
||||
/**
|
||||
* Create a custom stub index pattern. Use it in your unit tests where an {@link DataView} expected.
|
|
@ -10,12 +10,12 @@ import { map, last } from 'lodash';
|
|||
|
||||
import { IndexPattern } from './data_view';
|
||||
|
||||
import { DuplicateField } from '../../../../kibana_utils/common';
|
||||
import { DuplicateField } from '../../../kibana_utils/common';
|
||||
|
||||
import { IndexPatternField } from '../fields';
|
||||
|
||||
import { fieldFormatsMock } from '../../../../field_formats/common/mocks';
|
||||
import { FieldFormat } from '../../../../field_formats/common';
|
||||
import { fieldFormatsMock } from '../../../field_formats/common/mocks';
|
||||
import { FieldFormat } from '../../../field_formats/common';
|
||||
import { RuntimeField } from '../types';
|
||||
import { stubLogstashFields } from '../field.stub';
|
||||
import { stubbedSavedObjectIndexPattern } from '../data_view.stub';
|
|
@ -9,19 +9,19 @@
|
|||
/* eslint-disable max-classes-per-file */
|
||||
|
||||
import _, { each, reject } from 'lodash';
|
||||
import { castEsToKbnFieldTypeName } from '@kbn/field-types';
|
||||
import { castEsToKbnFieldTypeName, ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
import { FieldAttrs, FieldAttrSet, DataViewAttributes } from '../..';
|
||||
import { FieldAttrs, FieldAttrSet, DataViewAttributes } from '..';
|
||||
import type { RuntimeField } from '../types';
|
||||
import { DuplicateField } from '../../../../kibana_utils/common';
|
||||
import { DuplicateField } from '../../../kibana_utils/common';
|
||||
|
||||
import { ES_FIELD_TYPES, KBN_FIELD_TYPES, IIndexPattern, IFieldType } from '../../../common';
|
||||
import { IIndexPattern, IFieldType } from '../../common';
|
||||
import { DataViewField, IIndexPatternFieldList, fieldList } from '../fields';
|
||||
import { formatHitProvider } from './format_hit';
|
||||
import { flattenHitWrapper } from './flatten_hit';
|
||||
import { FieldFormatsStartCommon, FieldFormat } from '../../../../field_formats/common';
|
||||
import { FieldFormatsStartCommon, FieldFormat } from '../../../field_formats/common';
|
||||
import { DataViewSpec, TypeMeta, SourceFilter, DataViewFieldMap } from '../types';
|
||||
import { SerializedFieldFormat } from '../../../../expressions/common';
|
||||
import { SerializedFieldFormat } from '../../../expressions/common';
|
||||
|
||||
interface DataViewDeps {
|
||||
spec?: DataViewSpec;
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { defaults } from 'lodash';
|
||||
import { DataViewsService, DataView } from '.';
|
||||
import { fieldFormatsMock } from '../../../../field_formats/common/mocks';
|
||||
import { fieldFormatsMock } from '../../../field_formats/common/mocks';
|
||||
|
||||
import { UiSettingsCommon, SavedObjectsClientCommon, SavedObject } from '../types';
|
||||
import { stubbedSavedObjectIndexPattern } from '../data_view.stub';
|
|
@ -11,7 +11,7 @@
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { PublicMethodsOf } from '@kbn/utility-types';
|
||||
import { castEsToKbnFieldTypeName } from '@kbn/field-types';
|
||||
import { DATA_VIEW_SAVED_OBJECT_TYPE, SavedObjectsClientCommon } from '../..';
|
||||
import { DATA_VIEW_SAVED_OBJECT_TYPE, SavedObjectsClientCommon } from '..';
|
||||
|
||||
import { createDataViewCache } from '.';
|
||||
import type { RuntimeField } from '../types';
|
||||
|
@ -30,9 +30,9 @@ import {
|
|||
DataViewFieldMap,
|
||||
TypeMeta,
|
||||
} from '../types';
|
||||
import { FieldFormatsStartCommon, FORMATS_UI_SETTINGS } from '../../../../field_formats/common/';
|
||||
import { UI_SETTINGS, SavedObject } from '../../../common';
|
||||
import { SavedObjectNotFound } from '../../../../kibana_utils/common';
|
||||
import { FieldFormatsStartCommon, FORMATS_UI_SETTINGS } from '../../../field_formats/common/';
|
||||
import { META_FIELDS, SavedObject } from '../../common';
|
||||
import { SavedObjectNotFound } from '../../../kibana_utils/common';
|
||||
import { DataViewMissingIndices } from '../lib';
|
||||
import { findByTitle } from '../utils';
|
||||
import { DuplicateDataViewError } from '../errors';
|
||||
|
@ -244,7 +244,7 @@ export class DataViewsService {
|
|||
* @returns FieldSpec[]
|
||||
*/
|
||||
getFieldsForWildcard = async (options: GetFieldsOptions) => {
|
||||
const metaFields = await this.config.get(UI_SETTINGS.META_FIELDS);
|
||||
const metaFields = await this.config.get(META_FIELDS);
|
||||
return this.apiClient.getFieldsForWildcard({
|
||||
pattern: options.pattern,
|
||||
metaFields,
|
||||
|
@ -290,7 +290,7 @@ export class DataViewsService {
|
|||
}
|
||||
|
||||
this.onError(err, {
|
||||
title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', {
|
||||
title: i18n.translate('dataViews.fetchFieldErrorTitle', {
|
||||
defaultMessage: 'Error fetching fields for index pattern {title} (ID: {id})',
|
||||
values: { id: indexPattern.id, title: indexPattern.title },
|
||||
}),
|
||||
|
@ -336,7 +336,7 @@ export class DataViewsService {
|
|||
}
|
||||
|
||||
this.onError(err, {
|
||||
title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', {
|
||||
title: i18n.translate('dataViews.fetchFieldErrorTitle', {
|
||||
defaultMessage: 'Error fetching fields for index pattern {title} (ID: {id})',
|
||||
values: { id, title },
|
||||
}),
|
||||
|
@ -445,7 +445,7 @@ export class DataViewsService {
|
|||
spec.title as string,
|
||||
{
|
||||
pattern: title as string,
|
||||
metaFields: await this.config.get(UI_SETTINGS.META_FIELDS),
|
||||
metaFields: await this.config.get(META_FIELDS),
|
||||
type,
|
||||
rollupIndex: typeMeta?.params?.rollup_index,
|
||||
allowNoIndex: spec.allowNoIndex,
|
||||
|
@ -478,7 +478,7 @@ export class DataViewsService {
|
|||
});
|
||||
} else {
|
||||
this.onError(err, {
|
||||
title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', {
|
||||
title: i18n.translate('dataViews.fetchFieldErrorTitle', {
|
||||
defaultMessage: 'Error fetching fields for index pattern {title} (ID: {id})',
|
||||
values: { id: savedObject.id, title },
|
||||
}),
|
||||
|
@ -520,7 +520,7 @@ export class DataViewsService {
|
|||
*/
|
||||
async create(spec: DataViewSpec, skipFetchFields = false): Promise<DataView> {
|
||||
const shortDotsEnable = await this.config.get(FORMATS_UI_SETTINGS.SHORT_DOTS_ENABLE);
|
||||
const metaFields = await this.config.get(UI_SETTINGS.META_FIELDS);
|
||||
const metaFields = await this.config.get(META_FIELDS);
|
||||
|
||||
const indexPattern = new DataView({
|
||||
spec,
|
||||
|
@ -648,7 +648,7 @@ export class DataViewsService {
|
|||
if (ignoreErrors) {
|
||||
return;
|
||||
}
|
||||
const title = i18n.translate('data.indexPatterns.unableWriteLabel', {
|
||||
const title = i18n.translate('dataViews.unableWriteLabel', {
|
||||
defaultMessage:
|
||||
'Unable to write index pattern! Refresh the page to get the most up to date changes for this index pattern.',
|
||||
});
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { DataView } from './data_view';
|
||||
|
||||
import { fieldFormatsMock } from '../../../../field_formats/common/mocks';
|
||||
import { fieldFormatsMock } from '../../../field_formats/common/mocks';
|
||||
import { flattenHitWrapper } from './flatten_hit';
|
||||
import { stubbedSavedObjectIndexPattern } from '../data_view.stub';
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
import { DataView } from './data_view';
|
||||
import { FieldFormatsContentType } from '../../../../field_formats/common';
|
||||
import { FieldFormatsContentType } from '../../../field_formats/common';
|
||||
|
||||
const formattedCache = new WeakMap();
|
||||
const partialFormattedCache = new WeakMap();
|
|
@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
|
||||
import { DataViewsContract } from '../data_views';
|
||||
import { DataViewSpec } from '..';
|
||||
import { SavedObjectReference } from '../../../../../core/types';
|
||||
import { SavedObjectReference } from '../../../../core/types';
|
||||
|
||||
const name = 'indexPatternLoad';
|
||||
const type = 'index_pattern';
|
||||
|
@ -46,14 +46,14 @@ export const getIndexPatternLoadMeta = (): Omit<
|
|||
name,
|
||||
type,
|
||||
inputTypes: ['null'],
|
||||
help: i18n.translate('data.functions.indexPatternLoad.help', {
|
||||
help: i18n.translate('dataViews.indexPatternLoad.help', {
|
||||
defaultMessage: 'Loads an index pattern',
|
||||
}),
|
||||
args: {
|
||||
id: {
|
||||
types: ['string'],
|
||||
required: true,
|
||||
help: i18n.translate('data.functions.indexPatternLoad.id.help', {
|
||||
help: i18n.translate('dataViews.functions.indexPatternLoad.id.help', {
|
||||
defaultMessage: 'index pattern id to load',
|
||||
}),
|
||||
},
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
import { IndexPatternField } from './data_view_field';
|
||||
import { IndexPattern } from '..';
|
||||
import { KBN_FIELD_TYPES } from '../../../common';
|
||||
import { KBN_FIELD_TYPES } from '@kbn/field-types';
|
||||
import { FieldSpec, RuntimeField } from '../types';
|
||||
import { FieldFormat } from '../../../../field_formats/common';
|
||||
import { FieldFormat } from '../../../field_formats/common';
|
||||
|
||||
describe('Field', function () {
|
||||
function flatten(obj: Record<string, any>) {
|
|
@ -9,11 +9,11 @@
|
|||
/* eslint-disable max-classes-per-file */
|
||||
|
||||
import { KbnFieldType, getKbnFieldType, castEsToKbnFieldTypeName } from '@kbn/field-types';
|
||||
import { KBN_FIELD_TYPES } from '@kbn/field-types';
|
||||
import type { RuntimeField } from '../types';
|
||||
import { KBN_FIELD_TYPES } from '../../kbn_field_types/types';
|
||||
import type { IFieldType } from './types';
|
||||
import { FieldSpec, DataView } from '../..';
|
||||
import { shortenDottedString } from '../../utils';
|
||||
import { FieldSpec, DataView } from '..';
|
||||
import { shortenDottedString } from './utils';
|
||||
|
||||
/** @public */
|
||||
export class DataViewField implements IFieldType {
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
import { DataViewFieldBase } from '@kbn/es-query';
|
||||
import { FieldSpec, DataView } from '../..';
|
||||
import { FieldSpec, DataView } from '..';
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link IndexPatternField}
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { shortenDottedString } from './shorten_dotted_string';
|
||||
import { shortenDottedString } from './utils';
|
||||
|
||||
describe('shortenDottedString', () => {
|
||||
test('should convert a dot.notated.string into a short string', () => {
|
|
@ -22,3 +22,15 @@ export function isFilterable(field: IFieldType): boolean {
|
|||
export function isNestedField(field: IFieldType): boolean {
|
||||
return !!field.subType?.nested;
|
||||
}
|
||||
|
||||
const DOT_PREFIX_RE = /(.).+?\./g;
|
||||
|
||||
/**
|
||||
* Convert a dot.notated.string into a short
|
||||
* version (d.n.string)
|
||||
*
|
||||
* @return {any}
|
||||
*/
|
||||
export function shortenDottedString(input: any) {
|
||||
return typeof input !== 'string' ? input : input.replace(DOT_PREFIX_RE, '$1.');
|
||||
}
|
62
src/plugins/data_views/common/index.ts
Normal file
62
src/plugins/data_views/common/index.ts
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export {
|
||||
RUNTIME_FIELD_TYPES,
|
||||
FLEET_ASSETS_TO_IGNORE,
|
||||
META_FIELDS,
|
||||
DATA_VIEW_SAVED_OBJECT_TYPE,
|
||||
INDEX_PATTERN_SAVED_OBJECT_TYPE,
|
||||
} from './constants';
|
||||
export type { IFieldType, IIndexPatternFieldList } from './fields';
|
||||
export { isFilterable, isNestedField, fieldList, DataViewField, IndexPatternField } from './fields';
|
||||
export type {
|
||||
FieldFormatMap,
|
||||
RuntimeType,
|
||||
RuntimeField,
|
||||
IIndexPattern,
|
||||
DataViewAttributes,
|
||||
IndexPatternAttributes,
|
||||
FieldAttrs,
|
||||
FieldAttrSet,
|
||||
OnNotification,
|
||||
OnError,
|
||||
UiSettingsCommon,
|
||||
SavedObjectsClientCommonFindArgs,
|
||||
SavedObjectsClientCommon,
|
||||
GetFieldsOptions,
|
||||
GetFieldsOptionsTimePattern,
|
||||
IDataViewsApiClient,
|
||||
IIndexPatternsApiClient,
|
||||
SavedObject,
|
||||
AggregationRestrictions,
|
||||
TypeMeta,
|
||||
FieldSpecConflictDescriptions,
|
||||
FieldSpecExportFmt,
|
||||
FieldSpec,
|
||||
DataViewFieldMap,
|
||||
IndexPatternFieldMap,
|
||||
DataViewSpec,
|
||||
IndexPatternSpec,
|
||||
SourceFilter,
|
||||
} from './types';
|
||||
export { DataViewType, IndexPatternType } from './types';
|
||||
export {
|
||||
IndexPatternsService,
|
||||
IndexPatternsContract,
|
||||
DataViewsService,
|
||||
DataViewsContract,
|
||||
} from './data_views';
|
||||
export { IndexPattern, IndexPatternListItem, DataView, DataViewListItem } from './data_views';
|
||||
export { DuplicateDataViewError, DataViewSavedObjectConflictError } from './errors';
|
||||
export type {
|
||||
IndexPatternExpressionType,
|
||||
IndexPatternLoadStartDependencies,
|
||||
IndexPatternLoadExpressionFunctionDefinition,
|
||||
} from './expressions';
|
||||
export { getIndexPatternLoadMeta } from './expressions';
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
/* eslint-disable */
|
||||
|
||||
import { KbnError } from '../../../../kibana_utils/common/';
|
||||
import { KbnError } from '../../../kibana_utils/common';
|
||||
|
||||
/**
|
||||
* Tried to call a method that relies on SearchSource having an indexPattern assigned
|
|
@ -6,8 +6,8 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { SavedObjectsClientContract } from '../../../../../core/public';
|
||||
import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../../constants';
|
||||
import { SavedObjectsClientContract } from '../../../../core/public';
|
||||
import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../constants';
|
||||
import { DataViewAttributes } from '../types';
|
||||
|
||||
export async function getTitle(
|
10
src/plugins/data_views/common/stubs.ts
Normal file
10
src/plugins/data_views/common/stubs.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export * from './field.stub';
|
||||
export * from './data_views/data_view.stub';
|
|
@ -10,11 +10,12 @@ import type { DataViewFieldBase, IFieldSubType, DataViewBase } from '@kbn/es-que
|
|||
import { ToastInputFields, ErrorToastOptions } from 'src/core/public/notifications';
|
||||
// eslint-disable-next-line
|
||||
import type { SavedObject } from 'src/core/server';
|
||||
import { KBN_FIELD_TYPES } from '@kbn/field-types';
|
||||
import { IFieldType } from './fields';
|
||||
import { RUNTIME_FIELD_TYPES } from './constants';
|
||||
import { SerializedFieldFormat } from '../../../expressions/common';
|
||||
import { KBN_FIELD_TYPES, DataViewField } from '..';
|
||||
import { FieldFormat } from '../../../field_formats/common';
|
||||
import { SerializedFieldFormat } from '../../expressions/common';
|
||||
import { DataViewField } from './fields';
|
||||
import { FieldFormat } from '../../field_formats/common';
|
||||
|
||||
export type FieldFormatMap = Record<string, SerializedFieldFormat>;
|
||||
|
|
@ -7,9 +7,9 @@
|
|||
*/
|
||||
|
||||
import type { IndexPatternSavedObjectAttrs } from './data_views';
|
||||
import type { SavedObjectsClientCommon } from '../types';
|
||||
import type { SavedObjectsClientCommon } from './types';
|
||||
|
||||
import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../constants';
|
||||
import { DATA_VIEW_SAVED_OBJECT_TYPE } from './constants';
|
||||
|
||||
/**
|
||||
* Returns an object matching a given title
|
16
src/plugins/data_views/jest.config.js
Normal file
16
src/plugins/data_views/jest.config.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/src/plugins/data_views'],
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/data_views',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: ['<rootDir>/src/plugins/data_views/{common,public,server}/**/*.{ts,tsx}'],
|
||||
};
|
15
src/plugins/data_views/kibana.json
Normal file
15
src/plugins/data_views/kibana.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"id": "dataViews",
|
||||
"version": "kibana",
|
||||
"server": true,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["fieldFormats","expressions"],
|
||||
"optionalPlugins": ["usageCollection"],
|
||||
"extraPublicDirs": ["common"],
|
||||
"requiredBundles": ["kibanaUtils","kibanaReact"],
|
||||
"owner": {
|
||||
"name": "App Services",
|
||||
"githubTeam": "kibana-app-services"
|
||||
},
|
||||
"description": "Data services are useful for searching and querying data from Elasticsearch. Helpful utilities include: a re-usable react query bar, KQL autocomplete, async search, Data Views (Index Patterns) and field formatters."
|
||||
}
|
|
@ -7,11 +7,11 @@
|
|||
*/
|
||||
|
||||
import { CoreSetup } from 'kibana/public';
|
||||
import { FieldFormatsStartCommon } from '../../../../field_formats/common';
|
||||
import { getFieldFormatsRegistry } from '../../../../field_formats/public/mocks';
|
||||
import * as commonStubs from '../../../common/stubs';
|
||||
import { DataView, DataViewSpec } from '../../../common';
|
||||
import { coreMock } from '../../../../../core/public/mocks';
|
||||
import { FieldFormatsStartCommon } from '../../../field_formats/common';
|
||||
import { getFieldFormatsRegistry } from '../../../field_formats/public/mocks';
|
||||
import * as commonStubs from '../../common/stubs';
|
||||
import { DataView, DataViewSpec } from '../../common';
|
||||
import { coreMock } from '../../../../core/public/mocks';
|
||||
/**
|
||||
* Create a custom stub index pattern. Use it in your unit tests where an {@link DataView} expected.
|
||||
* @param spec - Serialized index pattern object
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { setup } from '../../../../../core/test_helpers/http_test_setup';
|
||||
import { setup } from '../../../../core/test_helpers/http_test_setup';
|
||||
|
||||
export const { http } = setup((injectedMetadata) => {
|
||||
injectedMetadata.getBasePath.mockReturnValue('/hola/daro/');
|
|
@ -7,12 +7,8 @@
|
|||
*/
|
||||
|
||||
import { HttpSetup } from 'src/core/public';
|
||||
import { DataViewMissingIndices } from '../../../common/data_views/lib';
|
||||
import {
|
||||
GetFieldsOptions,
|
||||
IDataViewsApiClient,
|
||||
GetFieldsOptionsTimePattern,
|
||||
} from '../../../common/data_views/types';
|
||||
import { DataViewMissingIndices } from '../../common/lib';
|
||||
import { GetFieldsOptions, IDataViewsApiClient, GetFieldsOptionsTimePattern } from '../../common';
|
||||
|
||||
const API_BASE_URL: string = `/api/index_patterns/`;
|
||||
|
|
@ -6,6 +6,6 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export * from '../../../common/data_views/data_views';
|
||||
export * from '../../common/data_views';
|
||||
export * from './redirect_no_index_pattern';
|
||||
export * from './data_views_api_client';
|
|
@ -10,7 +10,7 @@ import { EuiCallOut } from '@elastic/eui';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import React from 'react';
|
||||
import { CoreStart } from 'kibana/public';
|
||||
import { toMountPoint } from '../../../../kibana_react/public';
|
||||
import { toMountPoint } from '../../../kibana_react/public';
|
||||
|
||||
let bannerId: string;
|
||||
|
||||
|
@ -29,13 +29,10 @@ export const onRedirectNoIndexPattern =
|
|||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
const bannerMessage = i18n.translate(
|
||||
'data.indexPatterns.ensureDefaultIndexPattern.bannerLabel',
|
||||
{
|
||||
defaultMessage:
|
||||
'To visualize and explore data in Kibana, you must create an index pattern to retrieve data from Elasticsearch.',
|
||||
}
|
||||
);
|
||||
const bannerMessage = i18n.translate('dataViews.ensureDefaultIndexPattern.bannerLabel', {
|
||||
defaultMessage:
|
||||
'To visualize and explore data in Kibana, you must create an index pattern to retrieve data from Elasticsearch.',
|
||||
});
|
||||
|
||||
// Avoid being hostile to new users who don't have an index pattern setup yet
|
||||
// give them a friendly info message instead of a terse error message
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternLoadStartDependencies } from '../../../common/data_views/expressions';
|
||||
import { IndexPatternLoadStartDependencies } from '../../common/expressions';
|
||||
import { getFunctionDefinition } from './load_index_pattern';
|
||||
|
||||
describe('indexPattern expression function', () => {
|
|
@ -11,8 +11,8 @@ import {
|
|||
getIndexPatternLoadMeta,
|
||||
IndexPatternLoadExpressionFunctionDefinition,
|
||||
IndexPatternLoadStartDependencies,
|
||||
} from '../../../common/data_views/expressions';
|
||||
import { DataPublicPluginStart, DataStartDependencies } from '../../types';
|
||||
} from '../../common/expressions';
|
||||
import { DataViewsPublicPluginStart, DataViewsPublicStartDependencies } from '../types';
|
||||
|
||||
/**
|
||||
* Returns the expression function definition. Any stateful dependencies are accessed
|
||||
|
@ -60,11 +60,14 @@ export function getFunctionDefinition({
|
|||
export function getIndexPatternLoad({
|
||||
getStartServices,
|
||||
}: {
|
||||
getStartServices: StartServicesAccessor<DataStartDependencies, DataPublicPluginStart>;
|
||||
getStartServices: StartServicesAccessor<
|
||||
DataViewsPublicStartDependencies,
|
||||
DataViewsPublicPluginStart
|
||||
>;
|
||||
}) {
|
||||
return getFunctionDefinition({
|
||||
getStartDependencies: async () => {
|
||||
const [, , { indexPatterns }] = await getStartServices();
|
||||
const [, , indexPatterns] = await getStartServices();
|
||||
return { indexPatterns };
|
||||
},
|
||||
});
|
45
src/plugins/data_views/public/index.ts
Normal file
45
src/plugins/data_views/public/index.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export {
|
||||
ILLEGAL_CHARACTERS_KEY,
|
||||
CONTAINS_SPACES_KEY,
|
||||
ILLEGAL_CHARACTERS_VISIBLE,
|
||||
ILLEGAL_CHARACTERS,
|
||||
validateDataView,
|
||||
} from '../common/lib';
|
||||
export { flattenHitWrapper, formatHitProvider, onRedirectNoIndexPattern } from './data_views';
|
||||
|
||||
export { IndexPatternField, IIndexPatternFieldList, TypeMeta } from '../common';
|
||||
|
||||
export {
|
||||
IndexPatternsService,
|
||||
IndexPatternsContract,
|
||||
IndexPattern,
|
||||
DataViewsApiClient,
|
||||
DataViewsService,
|
||||
DataViewsContract,
|
||||
DataView,
|
||||
} from './data_views';
|
||||
export { UiSettingsPublicToCommon } from './ui_settings_wrapper';
|
||||
export { SavedObjectsClientPublicToCommon } from './saved_objects_client_wrapper';
|
||||
|
||||
/*
|
||||
* Plugin setup
|
||||
*/
|
||||
|
||||
import { DataViewsPublicPlugin } from './plugin';
|
||||
|
||||
export function plugin() {
|
||||
return new DataViewsPublicPlugin();
|
||||
}
|
||||
|
||||
export type { DataViewsPublicPluginSetup, DataViewsPublicPluginStart } from './types';
|
||||
|
||||
// Export plugin after all other imports
|
||||
export type { DataViewsPublicPlugin as DataPlugin };
|
68
src/plugins/data_views/public/plugin.ts
Normal file
68
src/plugins/data_views/public/plugin.ts
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* 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 { CoreSetup, CoreStart, Plugin } from 'src/core/public';
|
||||
import { getIndexPatternLoad } from './expressions';
|
||||
import {
|
||||
DataViewsPublicPluginSetup,
|
||||
DataViewsPublicPluginStart,
|
||||
DataViewsPublicSetupDependencies,
|
||||
DataViewsPublicStartDependencies,
|
||||
} from './types';
|
||||
|
||||
import {
|
||||
DataViewsService,
|
||||
onRedirectNoIndexPattern,
|
||||
DataViewsApiClient,
|
||||
UiSettingsPublicToCommon,
|
||||
SavedObjectsClientPublicToCommon,
|
||||
} from '.';
|
||||
|
||||
export class DataViewsPublicPlugin
|
||||
implements
|
||||
Plugin<
|
||||
DataViewsPublicPluginSetup,
|
||||
DataViewsPublicPluginStart,
|
||||
DataViewsPublicSetupDependencies,
|
||||
DataViewsPublicStartDependencies
|
||||
>
|
||||
{
|
||||
public setup(
|
||||
core: CoreSetup<DataViewsPublicStartDependencies, DataViewsPublicPluginStart>,
|
||||
{ expressions }: DataViewsPublicSetupDependencies
|
||||
): DataViewsPublicPluginSetup {
|
||||
expressions.registerFunction(getIndexPatternLoad({ getStartServices: core.getStartServices }));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
public start(
|
||||
core: CoreStart,
|
||||
{ fieldFormats }: DataViewsPublicStartDependencies
|
||||
): DataViewsPublicPluginStart {
|
||||
const { uiSettings, http, notifications, savedObjects, overlays, application } = core;
|
||||
|
||||
return new DataViewsService({
|
||||
uiSettings: new UiSettingsPublicToCommon(uiSettings),
|
||||
savedObjectsClient: new SavedObjectsClientPublicToCommon(savedObjects.client),
|
||||
apiClient: new DataViewsApiClient(http),
|
||||
fieldFormats,
|
||||
onNotification: (toastInputFields) => {
|
||||
notifications.toasts.add(toastInputFields);
|
||||
},
|
||||
onError: notifications.toasts.addError.bind(notifications.toasts),
|
||||
onRedirectNoIndexPattern: onRedirectNoIndexPattern(
|
||||
application.capabilities,
|
||||
application.navigateToApp,
|
||||
overlays
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
public stop() {}
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
import { SavedObjectsClientPublicToCommon } from './saved_objects_client_wrapper';
|
||||
import { savedObjectsServiceMock } from 'src/core/public/mocks';
|
||||
|
||||
import { DataViewSavedObjectConflictError } from '../../common/data_views';
|
||||
import { DataViewSavedObjectConflictError } from '../common';
|
||||
|
||||
describe('SavedObjectsClientPublicToCommon', () => {
|
||||
const soClient = savedObjectsServiceMock.createStartContract().client;
|
|
@ -13,7 +13,7 @@ import {
|
|||
SavedObjectsClientCommonFindArgs,
|
||||
SavedObject,
|
||||
DataViewSavedObjectConflictError,
|
||||
} from '../../common/data_views';
|
||||
} from '../common';
|
||||
|
||||
type SOClient = Pick<SavedObjectsClient, 'find' | 'resolve' | 'update' | 'create' | 'delete'>;
|
||||
|
32
src/plugins/data_views/public/types.ts
Normal file
32
src/plugins/data_views/public/types.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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 { ExpressionsSetup } from 'src/plugins/expressions/public';
|
||||
import { FieldFormatsSetup, FieldFormatsStart } from 'src/plugins/field_formats/public';
|
||||
import { PublicMethodsOf } from '@kbn/utility-types';
|
||||
import { DataViewsService } from './data_views';
|
||||
|
||||
export interface DataViewsPublicSetupDependencies {
|
||||
expressions: ExpressionsSetup;
|
||||
fieldFormats: FieldFormatsSetup;
|
||||
}
|
||||
|
||||
export interface DataViewsPublicStartDependencies {
|
||||
fieldFormats: FieldFormatsStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data plugin public Setup contract
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface DataViewsPublicPluginSetup {}
|
||||
|
||||
/**
|
||||
* Data plugin public Start contract
|
||||
*/
|
||||
export type DataViewsPublicPluginStart = PublicMethodsOf<DataViewsService>;
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { IUiSettingsClient, PublicUiSettingsParams, UserProvidedValues } from 'src/core/public';
|
||||
import { UiSettingsCommon } from '../../common';
|
||||
import { UiSettingsCommon } from '../common';
|
||||
|
||||
export class UiSettingsPublicToCommon implements UiSettingsCommon {
|
||||
private uiSettings: IUiSettingsClient;
|
50
src/plugins/data_views/server/data_views_service_factory.ts
Normal file
50
src/plugins/data_views/server/data_views_service_factory.ts
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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 {
|
||||
Logger,
|
||||
SavedObjectsClientContract,
|
||||
ElasticsearchClient,
|
||||
UiSettingsServiceStart,
|
||||
} from 'kibana/server';
|
||||
import { DataViewsService } from '../common';
|
||||
import { FieldFormatsStart } from '../../field_formats/server';
|
||||
import { UiSettingsServerToCommon } from './ui_settings_wrapper';
|
||||
import { IndexPatternsApiServer } from './index_patterns_api_client';
|
||||
import { SavedObjectsClientServerToCommon } from './saved_objects_client_wrapper';
|
||||
|
||||
export const dataViewsServiceFactory =
|
||||
({
|
||||
logger,
|
||||
uiSettings,
|
||||
fieldFormats,
|
||||
}: {
|
||||
logger: Logger;
|
||||
uiSettings: UiSettingsServiceStart;
|
||||
fieldFormats: FieldFormatsStart;
|
||||
}) =>
|
||||
async (
|
||||
savedObjectsClient: SavedObjectsClientContract,
|
||||
elasticsearchClient: ElasticsearchClient
|
||||
) => {
|
||||
const uiSettingsClient = uiSettings.asScopedToClient(savedObjectsClient);
|
||||
const formats = await fieldFormats.fieldFormatServiceFactory(uiSettingsClient);
|
||||
|
||||
return new DataViewsService({
|
||||
uiSettings: new UiSettingsServerToCommon(uiSettingsClient),
|
||||
savedObjectsClient: new SavedObjectsClientServerToCommon(savedObjectsClient),
|
||||
apiClient: new IndexPatternsApiServer(elasticsearchClient, savedObjectsClient),
|
||||
fieldFormats: formats,
|
||||
onError: (error) => {
|
||||
logger.error(error);
|
||||
},
|
||||
onNotification: ({ title, text }) => {
|
||||
logger.warn(`${title}${text ? ` : ${text}` : ''}`);
|
||||
},
|
||||
});
|
||||
};
|
|
@ -13,7 +13,7 @@ import {
|
|||
RegisterDeprecationsConfig,
|
||||
} from 'kibana/server';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { IndexPatternAttributes } from '../../../common';
|
||||
import { IndexPatternAttributes } from '../../common';
|
||||
|
||||
type IndexPatternAttributesWithFields = Pick<IndexPatternAttributes, 'title' | 'fields'>;
|
||||
|
||||
|
@ -41,10 +41,10 @@ export const createScriptedFieldsDeprecationsConfig: (
|
|||
|
||||
return [
|
||||
{
|
||||
title: i18n.translate('data.deprecations.scriptedFieldsTitle', {
|
||||
title: i18n.translate('dataViews.deprecations.scriptedFieldsTitle', {
|
||||
defaultMessage: 'Found index patterns using scripted fields',
|
||||
}),
|
||||
message: i18n.translate('data.deprecations.scriptedFieldsMessage', {
|
||||
message: i18n.translate('dataViews.deprecations.scriptedFieldsMessage', {
|
||||
defaultMessage: `You have {numberOfIndexPatternsWithScriptedFields} index patterns ({titlesPreview}...) that use scripted fields. Scripted fields are deprecated and will be removed in future. Use runtime fields instead.`,
|
||||
values: {
|
||||
titlesPreview: indexPatternTitles.slice(0, PREVIEW_LIMIT).join('; '),
|
||||
|
@ -56,10 +56,10 @@ export const createScriptedFieldsDeprecationsConfig: (
|
|||
level: 'warning', // warning because it is not set in stone WHEN we remove scripted fields, hence this deprecation is not a blocker for 8.0 upgrade
|
||||
correctiveActions: {
|
||||
manualSteps: [
|
||||
i18n.translate('data.deprecations.scriptedFields.manualStepOneMessage', {
|
||||
i18n.translate('dataViews.deprecations.scriptedFields.manualStepOneMessage', {
|
||||
defaultMessage: 'Navigate to Stack Management > Kibana > Index Patterns.',
|
||||
}),
|
||||
i18n.translate('data.deprecations.scriptedFields.manualStepTwoMessage', {
|
||||
i18n.translate('dataViews.deprecations.scriptedFields.manualStepTwoMessage', {
|
||||
defaultMessage:
|
||||
'Update {numberOfIndexPatternsWithScriptedFields} index patterns that have scripted fields to use runtime fields instead. In most cases, to migrate existing scripts, you will need to change "return <value>;" to "emit(<value>);". Index patterns with at least one scripted field: {allTitles}',
|
||||
values: {
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternLoadStartDependencies } from '../../../common/data_views/expressions';
|
||||
import { IndexPatternLoadStartDependencies } from '../../common/expressions';
|
||||
import { getFunctionDefinition } from './load_index_pattern';
|
||||
|
||||
describe('indexPattern expression function', () => {
|
|
@ -13,8 +13,8 @@ import {
|
|||
getIndexPatternLoadMeta,
|
||||
IndexPatternLoadExpressionFunctionDefinition,
|
||||
IndexPatternLoadStartDependencies,
|
||||
} from '../../../common/data_views/expressions';
|
||||
import { DataPluginStartDependencies, DataPluginStart } from '../../plugin';
|
||||
} from '../../common/expressions';
|
||||
import { DataViewsServerPluginStartDependencies, DataViewsServerPluginStart } from '../types';
|
||||
|
||||
/**
|
||||
* Returns the expression function definition. Any stateful dependencies are accessed
|
||||
|
@ -39,7 +39,7 @@ export function getFunctionDefinition({
|
|||
const kibanaRequest = getKibanaRequest ? getKibanaRequest() : null;
|
||||
if (!kibanaRequest) {
|
||||
throw new Error(
|
||||
i18n.translate('data.indexPatterns.indexPatternLoad.error.kibanaRequest', {
|
||||
i18n.translate('dataViews.indexPatternLoad.error.kibanaRequest', {
|
||||
defaultMessage:
|
||||
'A KibanaRequest is required to execute this search on the server. ' +
|
||||
'Please provide a request object to the expression execution params.',
|
||||
|
@ -73,13 +73,17 @@ export function getFunctionDefinition({
|
|||
export function getIndexPatternLoad({
|
||||
getStartServices,
|
||||
}: {
|
||||
getStartServices: StartServicesAccessor<DataPluginStartDependencies, DataPluginStart>;
|
||||
getStartServices: StartServicesAccessor<
|
||||
DataViewsServerPluginStartDependencies,
|
||||
DataViewsServerPluginStart
|
||||
>;
|
||||
}) {
|
||||
return getFunctionDefinition({
|
||||
getStartDependencies: async (request: KibanaRequest) => {
|
||||
const [{ elasticsearch, savedObjects }, , { indexPatterns }] = await getStartServices();
|
||||
const [{ elasticsearch, savedObjects }, , { indexPatternsServiceFactory }] =
|
||||
await getStartServices();
|
||||
return {
|
||||
indexPatterns: await indexPatterns.indexPatternsServiceFactory(
|
||||
indexPatterns: await indexPatternsServiceFactory(
|
||||
savedObjects.getScopedClient(request),
|
||||
elasticsearch.client.asScoped(request).asCurrentUser
|
||||
),
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"error" : {
|
||||
"root_cause" : [
|
||||
{
|
||||
"type" : "index_not_found_exception",
|
||||
"reason" : "no such index [poop]",
|
||||
"resource.type" : "index_or_alias",
|
||||
"resource.id" : "poop",
|
||||
"index_uuid" : "_na_",
|
||||
"index" : "poop"
|
||||
}
|
||||
],
|
||||
"type" : "index_not_found_exception",
|
||||
"reason" : "no such index [poop]",
|
||||
"resource.type" : "index_or_alias",
|
||||
"resource.id" : "poop",
|
||||
"index_uuid" : "_na_",
|
||||
"index" : "poop"
|
||||
},
|
||||
"status" : 404
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { IndexPatternsFetcher } from '.';
|
||||
import { ElasticsearchClient } from 'kibana/server';
|
||||
import * as indexNotFoundException from '../../../common/search/test_data/index_not_found_exception.json';
|
||||
import * as indexNotFoundException from './index_not_found_exception.json';
|
||||
|
||||
describe('Index Pattern Fetcher - server', () => {
|
||||
let indexPatterns: IndexPatternsFetcher;
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue