-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial framework for data plugin. (#34350)
- Loading branch information
1 parent
cce6406
commit 61a4b04
Showing
5 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "data", | ||
"version": "kibana" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 20 additions & 0 deletions
20
src/legacy/core_plugins/data/public/index_patterns/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
109 changes: 109 additions & 0 deletions
109
src/legacy/core_plugins/data/public/index_patterns/index_patterns_service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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']>; |