mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Initial framework for data plugin. (#34350)
This commit is contained in:
parent
cce64060d0
commit
61a4b04cd6
5 changed files with 220 additions and 0 deletions
38
src/legacy/core_plugins/data/index.ts
Normal file
38
src/legacy/core_plugins/data/index.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { Legacy } from '../../../../kibana';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function DataPlugin(kibana: any) {
|
||||
const config: Legacy.PluginSpecOptions = {
|
||||
id: 'data',
|
||||
require: ['elasticsearch'],
|
||||
publicDir: resolve(__dirname, 'public'),
|
||||
config: (Joi: any) => {
|
||||
return Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
}).default();
|
||||
},
|
||||
init: (server: Legacy.Server) => ({}),
|
||||
};
|
||||
|
||||
return new kibana.Plugin(config);
|
||||
}
|
4
src/legacy/core_plugins/data/package.json
Normal file
4
src/legacy/core_plugins/data/package.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "data",
|
||||
"version": "kibana"
|
||||
}
|
49
src/legacy/core_plugins/data/public/index.ts
Normal file
49
src/legacy/core_plugins/data/public/index.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { IndexPatternsService } from './index_patterns';
|
||||
|
||||
class DataService {
|
||||
private readonly indexPatterns: IndexPatternsService;
|
||||
|
||||
constructor() {
|
||||
this.indexPatterns = new IndexPatternsService();
|
||||
}
|
||||
|
||||
public setup() {
|
||||
return {
|
||||
indexPatterns: this.indexPatterns.setup(),
|
||||
};
|
||||
}
|
||||
|
||||
public stop() {
|
||||
this.indexPatterns.stop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We temporarily export default here so that users importing from 'plugins/data'
|
||||
* will automatically receive the response value of the `setup` contract, mimicking
|
||||
* the data that will eventually be injected by the new platform.
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default new DataService().setup();
|
||||
|
||||
/** @public */
|
||||
export type DataSetup = ReturnType<DataService['setup']>;
|
20
src/legacy/core_plugins/data/public/index_patterns/index.ts
Normal file
20
src/legacy/core_plugins/data/public/index_patterns/index.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export { IndexPatternsService, IndexPatternsSetup } from './index_patterns_service';
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// @ts-ignore
|
||||
import { Field } from 'ui/index_patterns/_field.js';
|
||||
// @ts-ignore
|
||||
import { FieldList } from 'ui/index_patterns/_field_list';
|
||||
// @ts-ignore
|
||||
import { IndexPatternsFlattenHitProvider } from 'ui/index_patterns/_flatten_hit';
|
||||
// @ts-ignore
|
||||
import { getComputedFields } from 'ui/index_patterns/_get_computed_fields';
|
||||
// @ts-ignore
|
||||
import { getRoutes, IndexPatternProvider } from 'ui/index_patterns/_index_pattern';
|
||||
// @ts-ignore
|
||||
import { mockFields, mockIndexPattern } from 'ui/index_patterns/fixtures';
|
||||
// @ts-ignore
|
||||
import { CONTAINS_SPACES } from 'ui/index_patterns/index';
|
||||
// @ts-ignore
|
||||
import { ILLEGAL_CHARACTERS } from 'ui/index_patterns/index';
|
||||
// @ts-ignore
|
||||
import { INDEX_PATTERN_ILLEGAL_CHARACTERS } from 'ui/index_patterns/index';
|
||||
// @ts-ignore
|
||||
import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/index_patterns/index';
|
||||
// @ts-ignore
|
||||
import { IndexPatternsApiClientProvider } from 'ui/index_patterns/index';
|
||||
// @ts-ignore
|
||||
import { IndexPatternSelect } from 'ui/index_patterns/index';
|
||||
// @ts-ignore
|
||||
import { IndexPatternsProvider } from 'ui/index_patterns/index';
|
||||
// @ts-ignore
|
||||
import { validateIndexPattern } from 'ui/index_patterns/index';
|
||||
// @ts-ignore
|
||||
import setupRouteWithDefaultPattern from 'ui/index_patterns/route_setup/load_default';
|
||||
// @ts-ignore
|
||||
import { getFromSavedObject, isFilterable } from 'ui/index_patterns/static_utils';
|
||||
|
||||
// IndexPattern, StaticIndexPattern, StaticIndexPatternField, Field
|
||||
import * as types from 'ui/index_patterns/index.d.ts';
|
||||
|
||||
/**
|
||||
* Index Patterns Service
|
||||
*
|
||||
* The `setup` method of this service returns the public contract for
|
||||
* index patterns. Right now these APIs are simply imported from `ui/public`
|
||||
* and re-exported here. Once the index patterns code actually moves to
|
||||
* this plugin, the imports above can simply be updated to point to their
|
||||
* corresponding local directory.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export class IndexPatternsService {
|
||||
public setup() {
|
||||
return {
|
||||
getRoutes,
|
||||
IndexPatternProvider,
|
||||
IndexPatternsApiClientProvider,
|
||||
IndexPatternsFlattenHitProvider,
|
||||
IndexPatternsProvider,
|
||||
setupRouteWithDefaultPattern, // only used in kibana/management
|
||||
validateIndexPattern,
|
||||
constants: {
|
||||
ILLEGAL_CHARACTERS,
|
||||
CONTAINS_SPACES,
|
||||
INDEX_PATTERN_ILLEGAL_CHARACTERS,
|
||||
INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE,
|
||||
},
|
||||
fields: {
|
||||
Field,
|
||||
FieldList,
|
||||
getComputedFields,
|
||||
getFromSavedObject,
|
||||
isFilterable,
|
||||
},
|
||||
fixtures: {
|
||||
mockFields,
|
||||
mockIndexPattern,
|
||||
},
|
||||
types: {
|
||||
...types,
|
||||
},
|
||||
ui: {
|
||||
IndexPatternSelect,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public stop() {
|
||||
// nothing to do here yet
|
||||
}
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export type IndexPatternsSetup = ReturnType<IndexPatternsService['setup']>;
|
Loading…
Add table
Add a link
Reference in a new issue