From 575f6154a1ac860ad82a220acbce37da7678e992 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 29 Dec 2020 10:40:09 +0100 Subject: [PATCH 01/18] migrate expressions to ts project refs --- src/plugins/expressions/tsconfig.json | 16 ++++++++++++++++ test/tsconfig.json | 1 + tsconfig.json | 2 ++ tsconfig.refs.json | 1 + x-pack/test/tsconfig.json | 1 + x-pack/tsconfig.json | 1 + 6 files changed, 22 insertions(+) create mode 100644 src/plugins/expressions/tsconfig.json diff --git a/src/plugins/expressions/tsconfig.json b/src/plugins/expressions/tsconfig.json new file mode 100644 index 0000000000000..c254f5d7e3bc8 --- /dev/null +++ b/src/plugins/expressions/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": ["common/**/*", "public/**/*", "server/**/*", "index.ts"], + "references": [ + { "path": "../../core/tsconfig.json" }, + { "path": "../kibana_utils/tsconfig.json" }, + { "path": "../inspector/tsconfig.json" }, + ] +} diff --git a/test/tsconfig.json b/test/tsconfig.json index df26441b0806f..0586ce529540e 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -8,6 +8,7 @@ "exclude": ["plugin_functional/plugins/**/*", "interpreter_functional/plugins/**/*"], "references": [ { "path": "../src/core/tsconfig.json" }, + { "path": "../src/plugins/expressions/tsconfig.json" }, { "path": "../src/plugins/inspector/tsconfig.json" }, { "path": "../src/plugins/kibana_react/tsconfig.json" }, { "path": "../src/plugins/kibana_usage_collection/tsconfig.json" }, diff --git a/tsconfig.json b/tsconfig.json index 02048414f678e..a6b04483504b0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ "src/**/__fixtures__/**/*", "src/core/**/*", "src/plugins/dev_tools/**/*", + "src/plugins/expressions/**/*", "src/plugins/inspector/**/*", "src/plugins/kibana_legacy/**/*", "src/plugins/kibana_react/**/*", @@ -29,6 +30,7 @@ "references": [ { "path": "./src/core/tsconfig.json" }, { "path": "./src/plugins/dev_tools/tsconfig.json" }, + { "path": "./src/plugins/expressions/tsconfig.json" }, { "path": "./src/plugins/inspector/tsconfig.json" }, { "path": "./src/plugins/kibana_legacy/tsconfig.json" }, { "path": "./src/plugins/kibana_react/tsconfig.json" }, diff --git a/tsconfig.refs.json b/tsconfig.refs.json index a99d4d57d3f0a..08d1604770e7a 100644 --- a/tsconfig.refs.json +++ b/tsconfig.refs.json @@ -3,6 +3,7 @@ "references": [ { "path": "./src/core/tsconfig.json" }, { "path": "./src/plugins/dev_tools/tsconfig.json" }, + { "path": "./src/plugins/expressions/tsconfig.json" }, { "path": "./src/plugins/inspector/tsconfig.json" }, { "path": "./src/plugins/kibana_legacy/tsconfig.json" }, { "path": "./src/plugins/kibana_react/tsconfig.json" }, diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index 3ac7026d16a17..f4b2c9617e1dd 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -9,6 +9,7 @@ "exclude": ["../typings/jest.d.ts"], "references": [ { "path": "../../src/core/tsconfig.json" }, + { "path": "../../src/plugins/expressions/tsconfig.json" }, { "path": "../../src/plugins/kibana_react/tsconfig.json" }, { "path": "../../src/plugins/kibana_usage_collection/tsconfig.json" }, { "path": "../../src/plugins/kibana_utils/tsconfig.json" }, diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 87dcc939a4eb6..74638ecfce845 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -17,6 +17,7 @@ "references": [ { "path": "../src/core/tsconfig.json" }, { "path": "../src/plugins/dev_tools/tsconfig.json" }, + { "path": "../src/plugins/expressions/tsconfig.json" }, { "path": "../src/plugins/inspector/tsconfig.json" }, { "path": "../src/plugins/kibana_legacy/tsconfig.json" }, { "path": "../src/plugins/kibana_react/tsconfig.json" }, From 60ace67426e094bfecce873f62f972c73e0856ef Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 29 Dec 2020 10:48:56 +0100 Subject: [PATCH 02/18] bfetch to ts project --- src/plugins/bfetch/tsconfig.json | 15 +++++++++++++++ test/tsconfig.json | 1 + tsconfig.json | 2 ++ tsconfig.refs.json | 1 + x-pack/test/tsconfig.json | 1 + x-pack/tsconfig.json | 1 + 6 files changed, 21 insertions(+) create mode 100644 src/plugins/bfetch/tsconfig.json diff --git a/src/plugins/bfetch/tsconfig.json b/src/plugins/bfetch/tsconfig.json new file mode 100644 index 0000000000000..173ff725d07d0 --- /dev/null +++ b/src/plugins/bfetch/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": ["common/**/*", "public/**/*", "server/**/*", "index.ts"], + "references": [ + { "path": "../../core/tsconfig.json" }, + { "path": "../kibana_utils/tsconfig.json" }, + ] +} diff --git a/test/tsconfig.json b/test/tsconfig.json index 0586ce529540e..041624ef494ff 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -8,6 +8,7 @@ "exclude": ["plugin_functional/plugins/**/*", "interpreter_functional/plugins/**/*"], "references": [ { "path": "../src/core/tsconfig.json" }, + { "path": "../src/plugins/bfetch/tsconfig.json" }, { "path": "../src/plugins/expressions/tsconfig.json" }, { "path": "../src/plugins/inspector/tsconfig.json" }, { "path": "../src/plugins/kibana_react/tsconfig.json" }, diff --git a/tsconfig.json b/tsconfig.json index a6b04483504b0..d6df15c008c31 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "src/**/__fixtures__/**/*", "src/core/**/*", + "src/plugins/bfetch/**/*", "src/plugins/dev_tools/**/*", "src/plugins/expressions/**/*", "src/plugins/inspector/**/*", @@ -29,6 +30,7 @@ ], "references": [ { "path": "./src/core/tsconfig.json" }, + { "path": "./src/plugins/bfetch/tsconfig.json" }, { "path": "./src/plugins/dev_tools/tsconfig.json" }, { "path": "./src/plugins/expressions/tsconfig.json" }, { "path": "./src/plugins/inspector/tsconfig.json" }, diff --git a/tsconfig.refs.json b/tsconfig.refs.json index 08d1604770e7a..7acd193c0853e 100644 --- a/tsconfig.refs.json +++ b/tsconfig.refs.json @@ -2,6 +2,7 @@ "include": [], "references": [ { "path": "./src/core/tsconfig.json" }, + { "path": "./src/plugins/bfetch/tsconfig.json" }, { "path": "./src/plugins/dev_tools/tsconfig.json" }, { "path": "./src/plugins/expressions/tsconfig.json" }, { "path": "./src/plugins/inspector/tsconfig.json" }, diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index f4b2c9617e1dd..8a41ea8e001f6 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -9,6 +9,7 @@ "exclude": ["../typings/jest.d.ts"], "references": [ { "path": "../../src/core/tsconfig.json" }, + { "path": "../../src/plugins/bfetch/tsconfig.json" }, { "path": "../../src/plugins/expressions/tsconfig.json" }, { "path": "../../src/plugins/kibana_react/tsconfig.json" }, { "path": "../../src/plugins/kibana_usage_collection/tsconfig.json" }, diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 74638ecfce845..8c9a6de158f3c 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -16,6 +16,7 @@ }, "references": [ { "path": "../src/core/tsconfig.json" }, + { "path": "../src/plugins/bfetch/tsconfig.json" }, { "path": "../src/plugins/dev_tools/tsconfig.json" }, { "path": "../src/plugins/expressions/tsconfig.json" }, { "path": "../src/plugins/inspector/tsconfig.json" }, From ec63c40dd3241b10e28a903648609dbf399d3349 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 29 Dec 2020 11:00:29 +0100 Subject: [PATCH 03/18] ui_actions to ts project --- src/plugins/expressions/tsconfig.json | 2 +- .../tests/execute_trigger_actions.test.ts | 1 + .../public/triggers/row_click_trigger.ts | 2 +- src/plugins/ui_actions/tsconfig.json | 17 +++++++++++++++++ test/tsconfig.json | 3 ++- tsconfig.json | 2 ++ tsconfig.refs.json | 1 + x-pack/test/tsconfig.json | 1 + x-pack/tsconfig.json | 1 + 9 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/plugins/ui_actions/tsconfig.json diff --git a/src/plugins/expressions/tsconfig.json b/src/plugins/expressions/tsconfig.json index c254f5d7e3bc8..cce71013cefa5 100644 --- a/src/plugins/expressions/tsconfig.json +++ b/src/plugins/expressions/tsconfig.json @@ -7,7 +7,7 @@ "declaration": true, "declarationMap": true }, - "include": ["common/**/*", "public/**/*", "server/**/*", "index.ts"], + "include": ["common/**/*", "public/**/*", "server/**/*", "./index.ts"], "references": [ { "path": "../../core/tsconfig.json" }, { "path": "../kibana_utils/tsconfig.json" }, diff --git a/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts b/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts index 51ba165ba730b..acd5e9adbecae 100644 --- a/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts +++ b/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts @@ -54,6 +54,7 @@ const reset = () => { uiActions = uiActionsPluginMock.createPlugin(); uiActions.setup.registerTrigger({ + // @ts-expect-error id: CONTACT_USER_TRIGGER, }); // uiActions.setup.attachAction(CONTACT_USER_TRIGGER, 'ACTION_SEND_MESSAGE'); diff --git a/src/plugins/ui_actions/public/triggers/row_click_trigger.ts b/src/plugins/ui_actions/public/triggers/row_click_trigger.ts index 0fc261b3e1fb3..d999efa7331e0 100644 --- a/src/plugins/ui_actions/public/triggers/row_click_trigger.ts +++ b/src/plugins/ui_actions/public/triggers/row_click_trigger.ts @@ -19,7 +19,7 @@ import { i18n } from '@kbn/i18n'; import { Trigger } from '.'; -import { Datatable } from '../../../expressions'; +import type { Datatable } from '../../../expressions'; export const ROW_CLICK_TRIGGER = 'ROW_CLICK_TRIGGER'; diff --git a/src/plugins/ui_actions/tsconfig.json b/src/plugins/ui_actions/tsconfig.json new file mode 100644 index 0000000000000..a871d7215cdc5 --- /dev/null +++ b/src/plugins/ui_actions/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": ["public/**/*"], + "references": [ + { "path": "../../core/tsconfig.json" }, + { "path": "../expressions/tsconfig.json" }, + { "path": "../kibana_utils/tsconfig.json" }, + { "path": "../kibana_react/tsconfig.json" }, + ] +} diff --git a/test/tsconfig.json b/test/tsconfig.json index 041624ef494ff..d5e0edb99fc09 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -17,6 +17,7 @@ { "path": "../src/plugins/newsfeed/tsconfig.json" }, { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "../src/plugins/telemetry/tsconfig.json" }, - { "path": "../src/plugins/usage_collection/tsconfig.json" } + { "path": "../src/plugins/ui_actions/tsconfig.json" }, + { "path": "../src/plugins/usage_collection/tsconfig.json" }, ] } diff --git a/tsconfig.json b/tsconfig.json index d6df15c008c31..d90cf863dc15c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,6 +20,7 @@ "src/plugins/share/**/*", "src/plugins/telemetry/**/*", "src/plugins/telemetry_collection_manager/**/*", + "src/plugins/ui_actions/**/*", "src/plugins/url_forwarding/**/*", "src/plugins/usage_collection/**/*", // In the build we actually exclude **/public/**/* from this config so that @@ -43,6 +44,7 @@ { "path": "./src/plugins/share/tsconfig.json" }, { "path": "./src/plugins/telemetry/tsconfig.json" }, { "path": "./src/plugins/telemetry_collection_manager/tsconfig.json" }, + { "path": "./src/plugins/ui_actions/tsconfig.json" }, { "path": "./src/plugins/url_forwarding/tsconfig.json" }, { "path": "./src/plugins/usage_collection/tsconfig.json" }, ] diff --git a/tsconfig.refs.json b/tsconfig.refs.json index 7acd193c0853e..8c5a96a883077 100644 --- a/tsconfig.refs.json +++ b/tsconfig.refs.json @@ -15,6 +15,7 @@ { "path": "./src/plugins/share/tsconfig.json" }, { "path": "./src/plugins/telemetry/tsconfig.json" }, { "path": "./src/plugins/telemetry_collection_manager/tsconfig.json" }, + { "path": "./src/plugins/ui_actions/tsconfig.json" }, { "path": "./src/plugins/url_forwarding/tsconfig.json" }, { "path": "./src/plugins/usage_collection/tsconfig.json" }, ] diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index 8a41ea8e001f6..269507c87b68f 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -19,6 +19,7 @@ { "path": "../../src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "../../src/plugins/telemetry/tsconfig.json" }, { "path": "../../src/plugins/usage_collection/tsconfig.json" }, + { "path": "../../src/plugins/ui_actions/tsconfig.json" }, { "path": "../plugins/global_search/tsconfig.json" }, { "path": "../plugins/licensing/tsconfig.json" }, { "path": "../plugins/telemetry_collection_xpack/tsconfig.json" } diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 8c9a6de158f3c..3a1c305f3f100 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -30,6 +30,7 @@ { "path": "../src/plugins/telemetry/tsconfig.json" }, { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "../src/plugins/url_forwarding/tsconfig.json" }, + { "path": "../src/plugins/ui_actions/tsconfig.json" }, { "path": "../src/plugins/usage_collection/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, From 63a41f55052fda93eac6497cd7090eff8b652d46 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 29 Dec 2020 13:34:08 +0100 Subject: [PATCH 04/18] move fitures to data plugins --- .../fixtures/logstash_fields.js | 85 +++ .../stubbed_saved_object_index_pattern.ts | 37 + .../index_patterns/index_pattern.test.ts | 4 +- .../index_patterns/index_patterns.test.ts | 2 +- .../tabify/fixtures/fake_hierarchical_data.ts | 632 ++++++++++++++++++ .../data/common/search/tabify/tabify.test.ts | 2 +- 6 files changed, 758 insertions(+), 4 deletions(-) create mode 100644 src/plugins/data/common/index_patterns/index_patterns/fixtures/logstash_fields.js create mode 100644 src/plugins/data/common/index_patterns/index_patterns/fixtures/stubbed_saved_object_index_pattern.ts create mode 100644 src/plugins/data/common/search/tabify/fixtures/fake_hierarchical_data.ts diff --git a/src/plugins/data/common/index_patterns/index_patterns/fixtures/logstash_fields.js b/src/plugins/data/common/index_patterns/index_patterns/fixtures/logstash_fields.js new file mode 100644 index 0000000000000..e421877724f56 --- /dev/null +++ b/src/plugins/data/common/index_patterns/index_patterns/fixtures/logstash_fields.js @@ -0,0 +1,85 @@ +/* + * 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. + */ +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { shouldReadFieldFromDocValues, castEsToKbnFieldTypeName } from '../../../../server'; + +function stubbedLogstashFields() { + return [ + // |aggregatable + // | |searchable + // name esType | | |metadata | subType + ['bytes', 'long', true, true, { count: 10 }], + ['ssl', 'boolean', true, true, { count: 20 }], + ['@timestamp', 'date', true, true, { count: 30 }], + ['time', 'date', true, true, { count: 30 }], + ['@tags', 'keyword', true, true], + ['utc_time', 'date', true, true], + ['phpmemory', 'integer', true, true], + ['ip', 'ip', true, true], + ['request_body', 'attachment', true, true], + ['point', 'geo_point', true, true], + ['area', 'geo_shape', true, true], + ['hashed', 'murmur3', false, true], + ['geo.coordinates', 'geo_point', true, true], + ['extension', 'text', true, true], + ['extension.keyword', 'keyword', true, true, {}, { multi: { parent: 'extension' } }], + ['machine.os', 'text', true, true], + ['machine.os.raw', 'keyword', true, true, {}, { multi: { parent: 'machine.os' } }], + ['geo.src', 'keyword', true, true], + ['_id', '_id', true, true], + ['_type', '_type', true, true], + ['_source', '_source', true, true], + ['non-filterable', 'text', true, false], + ['non-sortable', 'text', false, false], + ['custom_user_field', 'conflict', true, true], + ['script string', 'text', true, false, { script: "'i am a string'" }], + ['script number', 'long', true, false, { script: '1234' }], + ['script date', 'date', true, false, { script: '1234', lang: 'painless' }], + ['script murmur3', 'murmur3', true, false, { script: '1234' }], + ].map(function (row) { + const [name, esType, aggregatable, searchable, metadata = {}, subType = undefined] = row; + + const { + count = 0, + script, + lang = script ? 'expression' : undefined, + scripted = !!script, + } = metadata; + + // the conflict type is actually a kbnFieldType, we + // don't have any other way to represent it here + const type = esType === 'conflict' ? esType : castEsToKbnFieldTypeName(esType); + + return { + name, + type, + esTypes: [esType], + readFromDocValues: shouldReadFieldFromDocValues(aggregatable, esType), + aggregatable, + searchable, + count, + script, + lang, + scripted, + subType, + }; + }); +} + +export default stubbedLogstashFields; diff --git a/src/plugins/data/common/index_patterns/index_patterns/fixtures/stubbed_saved_object_index_pattern.ts b/src/plugins/data/common/index_patterns/index_patterns/fixtures/stubbed_saved_object_index_pattern.ts new file mode 100644 index 0000000000000..261e451db5452 --- /dev/null +++ b/src/plugins/data/common/index_patterns/index_patterns/fixtures/stubbed_saved_object_index_pattern.ts @@ -0,0 +1,37 @@ +/* + * 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-expect-error +import stubbedLogstashFields from './logstash_fields'; + +const mockLogstashFields = stubbedLogstashFields(); + +export function stubbedSavedObjectIndexPattern(id: string | null = null) { + return { + id, + type: 'index-pattern', + attributes: { + timeFieldName: 'timestamp', + customFormats: {}, + fields: mockLogstashFields, + title: 'title', + }, + version: '2', + }; +} diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts index 145901509d1c5..af2bbf241487c 100644 --- a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts +++ b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts @@ -23,8 +23,8 @@ import { IndexPattern } from './index_pattern'; import { DuplicateField } from '../../../../kibana_utils/common'; // @ts-expect-error -import mockLogStashFields from '../../../../../fixtures/logstash_fields'; -import { stubbedSavedObjectIndexPattern } from '../../../../../fixtures/stubbed_saved_object_index_pattern'; +import mockLogStashFields from './fixtures/logstash_fields'; +import { stubbedSavedObjectIndexPattern } from './fixtures/stubbed_saved_object_index_pattern'; import { IndexPatternField } from '../fields'; import { fieldFormatsMock } from '../../field_formats/mocks'; diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts index 3d32742c168ad..18f18ede86181 100644 --- a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts +++ b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts @@ -20,7 +20,7 @@ import { defaults } from 'lodash'; import { IndexPatternsService, IndexPattern } from '.'; import { fieldFormatsMock } from '../../field_formats/mocks'; -import { stubbedSavedObjectIndexPattern } from '../../../../../fixtures/stubbed_saved_object_index_pattern'; +import { stubbedSavedObjectIndexPattern } from './fixtures/stubbed_saved_object_index_pattern'; import { UiSettingsCommon, SavedObjectsClientCommon, SavedObject } from '../types'; const createFieldsFetcher = jest.fn().mockImplementation(() => ({ diff --git a/src/plugins/data/common/search/tabify/fixtures/fake_hierarchical_data.ts b/src/plugins/data/common/search/tabify/fixtures/fake_hierarchical_data.ts new file mode 100644 index 0000000000000..4480caae39664 --- /dev/null +++ b/src/plugins/data/common/search/tabify/fixtures/fake_hierarchical_data.ts @@ -0,0 +1,632 @@ +/* + * 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 const metricOnly = { + hits: { total: 1000, hits: [], max_score: 0 }, + aggregations: { + agg_1: { value: 412032 }, + }, +}; + +export const threeTermBuckets = { + hits: { total: 1000, hits: [], max_score: 0 }, + aggregations: { + agg_2: { + buckets: [ + { + key: 'png', + doc_count: 50, + agg_1: { value: 412032 }, + agg_3: { + buckets: [ + { + key: 'IT', + doc_count: 10, + agg_1: { value: 9299 }, + agg_4: { + buckets: [ + { key: 'win', doc_count: 4, agg_1: { value: 0 } }, + { key: 'mac', doc_count: 6, agg_1: { value: 9299 } }, + ], + }, + }, + { + key: 'US', + doc_count: 20, + agg_1: { value: 8293 }, + agg_4: { + buckets: [ + { key: 'linux', doc_count: 12, agg_1: { value: 3992 } }, + { key: 'mac', doc_count: 8, agg_1: { value: 3029 } }, + ], + }, + }, + ], + }, + }, + { + key: 'css', + doc_count: 20, + agg_1: { value: 412032 }, + agg_3: { + buckets: [ + { + key: 'MX', + doc_count: 7, + agg_1: { value: 9299 }, + agg_4: { + buckets: [ + { key: 'win', doc_count: 3, agg_1: { value: 4992 } }, + { key: 'mac', doc_count: 4, agg_1: { value: 5892 } }, + ], + }, + }, + { + key: 'US', + doc_count: 13, + agg_1: { value: 8293 }, + agg_4: { + buckets: [ + { key: 'linux', doc_count: 12, agg_1: { value: 3992 } }, + { key: 'mac', doc_count: 1, agg_1: { value: 3029 } }, + ], + }, + }, + ], + }, + }, + { + key: 'html', + doc_count: 90, + agg_1: { value: 412032 }, + agg_3: { + buckets: [ + { + key: 'CN', + doc_count: 85, + agg_1: { value: 9299 }, + agg_4: { + buckets: [ + { key: 'win', doc_count: 46, agg_1: { value: 4992 } }, + { key: 'mac', doc_count: 39, agg_1: { value: 5892 } }, + ], + }, + }, + { + key: 'FR', + doc_count: 15, + agg_1: { value: 8293 }, + agg_4: { + buckets: [ + { key: 'win', doc_count: 3, agg_1: { value: 3992 } }, + { key: 'mac', doc_count: 12, agg_1: { value: 3029 } }, + ], + }, + }, + ], + }, + }, + ], + }, + }, +}; + +export const oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative = { + hits: { total: 1000, hits: [], max_score: 0 }, + aggregations: { + agg_3: { + buckets: [ + { + key: 'png', + doc_count: 50, + agg_4: { + buckets: [ + { + key_as_string: '2014-09-28T00:00:00.000Z', + key: 1411862400000, + doc_count: 1, + agg_1: { value: 9283 }, + agg_2: { value: 1411862400000 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 23, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-09-29T00:00:00.000Z', + key: 1411948800000, + doc_count: 2, + agg_1: { value: 28349 }, + agg_2: { value: 1411948800000 }, + agg_5: { value: 203 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 39, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-09-30T00:00:00.000Z', + key: 1412035200000, + doc_count: 3, + agg_1: { value: 84330 }, + agg_2: { value: 1412035200000 }, + agg_5: { value: 200 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 329, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-10-01T00:00:00.000Z', + key: 1412121600000, + doc_count: 4, + agg_1: { value: 34992 }, + agg_2: { value: 1412121600000 }, + agg_5: { value: 103 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 22, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-10-02T00:00:00.000Z', + key: 1412208000000, + doc_count: 5, + agg_1: { value: 145432 }, + agg_2: { value: 1412208000000 }, + agg_5: { value: 153 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 93, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-10-03T00:00:00.000Z', + key: 1412294400000, + doc_count: 35, + agg_1: { value: 220943 }, + agg_2: { value: 1412294400000 }, + agg_5: { value: 239 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 72, + }, + }, + ], + }, + }, + }, + ], + }, + }, + { + key: 'css', + doc_count: 20, + agg_4: { + buckets: [ + { + key_as_string: '2014-09-28T00:00:00.000Z', + key: 1411862400000, + doc_count: 1, + agg_1: { value: 9283 }, + agg_2: { value: 1411862400000 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 75, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-09-29T00:00:00.000Z', + key: 1411948800000, + doc_count: 2, + agg_1: { value: 28349 }, + agg_2: { value: 1411948800000 }, + agg_5: { value: 10 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 11, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-09-30T00:00:00.000Z', + key: 1412035200000, + doc_count: 3, + agg_1: { value: 84330 }, + agg_2: { value: 1412035200000 }, + agg_5: { value: 24 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 238, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-10-01T00:00:00.000Z', + key: 1412121600000, + doc_count: 4, + agg_1: { value: 34992 }, + agg_2: { value: 1412121600000 }, + agg_5: { value: 49 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 343, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-10-02T00:00:00.000Z', + key: 1412208000000, + doc_count: 5, + agg_1: { value: 145432 }, + agg_2: { value: 1412208000000 }, + agg_5: { value: 100 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 837, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-10-03T00:00:00.000Z', + key: 1412294400000, + doc_count: 5, + agg_1: { value: 220943 }, + agg_2: { value: 1412294400000 }, + agg_5: { value: 23 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 302, + }, + }, + ], + }, + }, + }, + ], + }, + }, + { + key: 'html', + doc_count: 90, + agg_4: { + buckets: [ + { + key_as_string: '2014-09-28T00:00:00.000Z', + key: 1411862400000, + doc_count: 10, + agg_1: { value: 9283 }, + agg_2: { value: 1411862400000 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 30, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-09-29T00:00:00.000Z', + key: 1411948800000, + doc_count: 20, + agg_1: { value: 28349 }, + agg_2: { value: 1411948800000 }, + agg_5: { value: 1 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 43, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-09-30T00:00:00.000Z', + key: 1412035200000, + doc_count: 30, + agg_1: { value: 84330 }, + agg_2: { value: 1412035200000 }, + agg_5: { value: 5 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 88, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-10-01T00:00:00.000Z', + key: 1412121600000, + doc_count: 11, + agg_1: { value: 34992 }, + agg_2: { value: 1412121600000 }, + agg_5: { value: 10 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 91, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-10-02T00:00:00.000Z', + key: 1412208000000, + doc_count: 12, + agg_1: { value: 145432 }, + agg_2: { value: 1412208000000 }, + agg_5: { value: 43 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 534, + }, + }, + ], + }, + }, + }, + { + key_as_string: '2014-10-03T00:00:00.000Z', + key: 1412294400000, + doc_count: 7, + agg_1: { value: 220943 }, + agg_2: { value: 1412294400000 }, + agg_5: { value: 1 }, + agg_6: { + hits: { + total: 2, + hits: [ + { + fields: { + bytes: 553, + }, + }, + ], + }, + }, + }, + ], + }, + }, + ], + }, + }, +}; + +export const oneRangeBucket = { + took: 35, + timed_out: false, + _shards: { + total: 1, + successful: 1, + failed: 0, + }, + hits: { + total: 6039, + max_score: 0, + hits: [], + }, + aggregations: { + agg_2: { + buckets: { + '0.0-1000.0': { + from: 0, + from_as_string: '0.0', + to: 1000, + to_as_string: '1000.0', + doc_count: 606, + }, + '1000.0-2000.0': { + from: 1000, + from_as_string: '1000.0', + to: 2000, + to_as_string: '2000.0', + doc_count: 298, + }, + }, + }, + }, +}; + +export const oneFilterBucket = { + took: 11, + timed_out: false, + _shards: { + total: 1, + successful: 1, + failed: 0, + }, + hits: { + total: 6005, + max_score: 0, + hits: [], + }, + aggregations: { + agg_2: { + buckets: { + 'type:apache': { + doc_count: 4844, + }, + 'type:nginx': { + doc_count: 1161, + }, + }, + }, + }, +}; + +export const oneHistogramBucket = { + took: 37, + timed_out: false, + _shards: { + total: 6, + successful: 6, + failed: 0, + }, + hits: { + total: 49208, + max_score: 0, + hits: [], + }, + aggregations: { + agg_2: { + buckets: [ + { + key_as_string: '2014-09-28T00:00:00.000Z', + key: 1411862400000, + doc_count: 8247, + }, + { + key_as_string: '2014-09-29T00:00:00.000Z', + key: 1411948800000, + doc_count: 8184, + }, + { + key_as_string: '2014-09-30T00:00:00.000Z', + key: 1412035200000, + doc_count: 8269, + }, + { + key_as_string: '2014-10-01T00:00:00.000Z', + key: 1412121600000, + doc_count: 8141, + }, + { + key_as_string: '2014-10-02T00:00:00.000Z', + key: 1412208000000, + doc_count: 8148, + }, + { + key_as_string: '2014-10-03T00:00:00.000Z', + key: 1412294400000, + doc_count: 8219, + }, + ], + }, + }, +}; diff --git a/src/plugins/data/common/search/tabify/tabify.test.ts b/src/plugins/data/common/search/tabify/tabify.test.ts index 6b9d520b11436..1ee5d23230396 100644 --- a/src/plugins/data/common/search/tabify/tabify.test.ts +++ b/src/plugins/data/common/search/tabify/tabify.test.ts @@ -21,7 +21,7 @@ import { tabifyAggResponse } from './tabify'; import { IndexPattern } from '../../index_patterns/index_patterns/index_pattern'; import { AggConfigs, IAggConfig, IAggConfigs } from '../aggs'; import { mockAggTypesRegistry } from '../aggs/test_helpers'; -import { metricOnly, threeTermBuckets } from 'fixtures/fake_hierarchical_data'; +import { metricOnly, threeTermBuckets } from './fixtures/fake_hierarchical_data'; describe('tabifyAggResponse Integration', () => { const typesRegistry = mockAggTypesRegistry(); From e3eb995c2de7d34ece05d0d8df4e09948537fec7 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 29 Dec 2020 15:39:49 +0100 Subject: [PATCH 05/18] add data ts project --- .../components/data_table.tsx | 4 ++-- src/plugins/data/tsconfig.json | 21 +++++++++++++++++++ tsconfig.json | 2 ++ tsconfig.refs.json | 1 + 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/plugins/data/tsconfig.json diff --git a/src/plugins/data/public/utils/table_inspector_view/components/data_table.tsx b/src/plugins/data/public/utils/table_inspector_view/components/data_table.tsx index f842568859fc2..2e477ab38847f 100644 --- a/src/plugins/data/public/utils/table_inspector_view/components/data_table.tsx +++ b/src/plugins/data/public/utils/table_inspector_view/components/data_table.tsx @@ -112,7 +112,7 @@ export class DataTableFormat extends Component { const value = table.rows[rowIndex][column.id]; const eventData = { table, column: columnIndex, row: rowIndex, value }; - uiActions.executeTriggerActions('VALUE_CLICK_TRIGGER' as TriggerId, { + uiActions.getTrigger('VALUE_CLICK_TRIGGER').exec({ data: { data: [eventData] }, }); }} @@ -145,7 +145,7 @@ export class DataTableFormat extends Component { const value = table.rows[rowIndex][column.id]; const eventData = { table, column: columnIndex, row: rowIndex, value }; - uiActions.executeTriggerActions('VALUE_CLICK_TRIGGER' as TriggerId, { + uiActions.getTrigger('VALUE_CLICK_TRIGGER').exec({ data: { data: [eventData], negate: true }, }); }} diff --git a/src/plugins/data/tsconfig.json b/src/plugins/data/tsconfig.json new file mode 100644 index 0000000000000..81bcb3b02e100 --- /dev/null +++ b/src/plugins/data/tsconfig.json @@ -0,0 +1,21 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": ["common/**/*", "public/**/*", "server/**/*", "config.ts"], + "references": [ + { "path": "../../core/tsconfig.json" }, + { "path": "../bfetch/tsconfig.json" }, + { "path": "../ui_actions/tsconfig.json" }, + { "path": "../share/tsconfig.json" }, + { "path": "../inspector/tsconfig.json" }, + { "path": "../usage_collection/tsconfig.json" }, + { "path": "../kibana_utils/tsconfig.json" }, + { "path": "../kibana_react/tsconfig.json" }, + ] +} diff --git a/tsconfig.json b/tsconfig.json index d90cf863dc15c..29107095715b4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ "src/**/__fixtures__/**/*", "src/core/**/*", "src/plugins/bfetch/**/*", + "src/plugins/data/**/*", "src/plugins/dev_tools/**/*", "src/plugins/expressions/**/*", "src/plugins/inspector/**/*", @@ -32,6 +33,7 @@ "references": [ { "path": "./src/core/tsconfig.json" }, { "path": "./src/plugins/bfetch/tsconfig.json" }, + { "path": "./src/plugins/data/tsconfig.json" }, { "path": "./src/plugins/dev_tools/tsconfig.json" }, { "path": "./src/plugins/expressions/tsconfig.json" }, { "path": "./src/plugins/inspector/tsconfig.json" }, diff --git a/tsconfig.refs.json b/tsconfig.refs.json index 8c5a96a883077..f5caed3138957 100644 --- a/tsconfig.refs.json +++ b/tsconfig.refs.json @@ -3,6 +3,7 @@ "references": [ { "path": "./src/core/tsconfig.json" }, { "path": "./src/plugins/bfetch/tsconfig.json" }, + { "path": "./src/plugins/data/tsconfig.json" }, { "path": "./src/plugins/dev_tools/tsconfig.json" }, { "path": "./src/plugins/expressions/tsconfig.json" }, { "path": "./src/plugins/inspector/tsconfig.json" }, From 6f89403d115cdeb2547ed350e846bdd89c3843f7 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 13:41:05 +0100 Subject: [PATCH 06/18] remove outdated ts-expect-error --- .../ui_actions/public/tests/execute_trigger_actions.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts b/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts index 0a6cc6e955871..6f8a45cc2e40a 100644 --- a/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts +++ b/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts @@ -49,7 +49,6 @@ const reset = () => { uiActions = uiActionsPluginMock.createPlugin(); uiActions.setup.registerTrigger({ - // @ts-expect-error id: CONTACT_USER_TRIGGER, }); // uiActions.setup.attachAction(CONTACT_USER_TRIGGER, 'ACTION_SEND_MESSAGE'); From a37458afaa8d305c27ce48b5bec3814e8b175530 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 13:50:11 +0100 Subject: [PATCH 07/18] add data to x-pack tsconfigs --- x-pack/test/tsconfig.json | 1 + x-pack/tsconfig.json | 1 + 2 files changed, 2 insertions(+) diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index 269507c87b68f..f138dadfe3506 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -10,6 +10,7 @@ "references": [ { "path": "../../src/core/tsconfig.json" }, { "path": "../../src/plugins/bfetch/tsconfig.json" }, + { "path": "../../src/plugins/data/tsconfig.json" }, { "path": "../../src/plugins/expressions/tsconfig.json" }, { "path": "../../src/plugins/kibana_react/tsconfig.json" }, { "path": "../../src/plugins/kibana_usage_collection/tsconfig.json" }, diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 3a1c305f3f100..24fd6f96659db 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -17,6 +17,7 @@ "references": [ { "path": "../src/core/tsconfig.json" }, { "path": "../src/plugins/bfetch/tsconfig.json" }, + { "path": "../src/plugins/data/tsconfig.json" }, { "path": "../src/plugins/dev_tools/tsconfig.json" }, { "path": "../src/plugins/expressions/tsconfig.json" }, { "path": "../src/plugins/inspector/tsconfig.json" }, From 8cce1489d9b057bcc102ccc80d3c3fdd0654814c Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 13:59:42 +0100 Subject: [PATCH 08/18] navigation to ts project --- src/plugins/navigation/tsconfig.json | 16 ++++++++++++++++ test/tsconfig.json | 1 + tsconfig.json | 2 ++ tsconfig.refs.json | 1 + x-pack/test/tsconfig.json | 1 + x-pack/tsconfig.json | 1 + 6 files changed, 22 insertions(+) create mode 100644 src/plugins/navigation/tsconfig.json diff --git a/src/plugins/navigation/tsconfig.json b/src/plugins/navigation/tsconfig.json new file mode 100644 index 0000000000000..07cfe10d7d81f --- /dev/null +++ b/src/plugins/navigation/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": ["public/**/*"], + "references": [ + { "path": "../../core/tsconfig.json" }, + { "path": "../kibana_react/tsconfig.json" }, + { "path": "../data/tsconfig.json" }, + ] +} diff --git a/test/tsconfig.json b/test/tsconfig.json index d5e0edb99fc09..7051cd8da8738 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -14,6 +14,7 @@ { "path": "../src/plugins/kibana_react/tsconfig.json" }, { "path": "../src/plugins/kibana_usage_collection/tsconfig.json" }, { "path": "../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../src/plugins/navigation/tsconfig.json" }, { "path": "../src/plugins/newsfeed/tsconfig.json" }, { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "../src/plugins/telemetry/tsconfig.json" }, diff --git a/tsconfig.json b/tsconfig.json index 29107095715b4..d051c7f0a1ed7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "src/plugins/kibana_react/**/*", "src/plugins/kibana_usage_collection/**/*", "src/plugins/kibana_utils/**/*", + "src/plugins/navigation/**/*", "src/plugins/newsfeed/**/*", "src/plugins/security_oss/**/*", "src/plugins/share/**/*", @@ -41,6 +42,7 @@ { "path": "./src/plugins/kibana_react/tsconfig.json" }, { "path": "./src/plugins/kibana_usage_collection/tsconfig.json" }, { "path": "./src/plugins/kibana_utils/tsconfig.json" }, + { "path": "./src/plugins/navigation/tsconfig.json" }, { "path": "./src/plugins/newsfeed/tsconfig.json" }, { "path": "./src/plugins/security_oss/tsconfig.json" }, { "path": "./src/plugins/share/tsconfig.json" }, diff --git a/tsconfig.refs.json b/tsconfig.refs.json index f5caed3138957..0ef1f70faef97 100644 --- a/tsconfig.refs.json +++ b/tsconfig.refs.json @@ -11,6 +11,7 @@ { "path": "./src/plugins/kibana_react/tsconfig.json" }, { "path": "./src/plugins/kibana_usage_collection/tsconfig.json" }, { "path": "./src/plugins/kibana_utils/tsconfig.json" }, + { "path": "./src/plugins/navigation/tsconfig.json" }, { "path": "./src/plugins/newsfeed/tsconfig.json" }, { "path": "./src/plugins/security_oss/tsconfig.json" }, { "path": "./src/plugins/share/tsconfig.json" }, diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index f138dadfe3506..1b9337dc9d5a9 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -15,6 +15,7 @@ { "path": "../../src/plugins/kibana_react/tsconfig.json" }, { "path": "../../src/plugins/kibana_usage_collection/tsconfig.json" }, { "path": "../../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../../src/plugins/navigation/tsconfig.json" }, { "path": "../../src/plugins/newsfeed/tsconfig.json" }, { "path": "../../src/plugins/share/tsconfig.json" }, { "path": "../../src/plugins/telemetry_collection_manager/tsconfig.json" }, diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 24fd6f96659db..a778a47f43252 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -25,6 +25,7 @@ { "path": "../src/plugins/kibana_react/tsconfig.json" }, { "path": "../src/plugins/kibana_usage_collection/tsconfig.json" }, { "path": "../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../src/plugins/navigation/tsconfig.json" }, { "path": "../src/plugins/newsfeed/tsconfig.json" }, { "path": "../src/plugins/security_oss/tsconfig.json" }, { "path": "../src/plugins/share/tsconfig.json" }, From 1cde72d48b52522981e5b6b4c0033ce1c6ed8672 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 14:37:09 +0100 Subject: [PATCH 09/18] cleanup licensing tsconfig --- x-pack/plugins/licensing/tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/plugins/licensing/tsconfig.json b/x-pack/plugins/licensing/tsconfig.json index 9b8eb15dc4a9e..6118bcd81d342 100644 --- a/x-pack/plugins/licensing/tsconfig.json +++ b/x-pack/plugins/licensing/tsconfig.json @@ -10,8 +10,7 @@ "include": [ "public/**/*", "server/**/*", - "common/**/*", - "../../../typings/**/*" + "common/**/*" ], "references": [ { "path": "../../../src/core/tsconfig.json" }, From d69368662ac638a3449eb498986c8e3788ccf300 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 14:40:57 +0100 Subject: [PATCH 10/18] saved_objects to ts project --- src/plugins/saved_objects/tsconfig.json | 17 +++++++++++++++++ test/tsconfig.json | 1 + tsconfig.json | 2 ++ tsconfig.refs.json | 1 + x-pack/test/tsconfig.json | 1 + x-pack/tsconfig.json | 1 + 6 files changed, 23 insertions(+) create mode 100644 src/plugins/saved_objects/tsconfig.json diff --git a/src/plugins/saved_objects/tsconfig.json b/src/plugins/saved_objects/tsconfig.json new file mode 100644 index 0000000000000..d9045b91b9dfa --- /dev/null +++ b/src/plugins/saved_objects/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": ["common/**/*", "public/**/*", "server/**/*"], + "references": [ + { "path": "../../core/tsconfig.json" }, + { "path": "../data/tsconfig.json" }, + { "path": "../kibana_utils/tsconfig.json" }, + { "path": "../kibana_react/tsconfig.json" }, + ] +} diff --git a/test/tsconfig.json b/test/tsconfig.json index 7051cd8da8738..1ad7cf9886701 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -16,6 +16,7 @@ { "path": "../src/plugins/kibana_utils/tsconfig.json" }, { "path": "../src/plugins/navigation/tsconfig.json" }, { "path": "../src/plugins/newsfeed/tsconfig.json" }, + { "path": "../src/plugins/saved_objects/tsconfig.json" }, { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "../src/plugins/telemetry/tsconfig.json" }, { "path": "../src/plugins/ui_actions/tsconfig.json" }, diff --git a/tsconfig.json b/tsconfig.json index d051c7f0a1ed7..329cf69af5865 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,6 +18,7 @@ "src/plugins/kibana_utils/**/*", "src/plugins/navigation/**/*", "src/plugins/newsfeed/**/*", + "src/plugins/saved_objects/**/*", "src/plugins/security_oss/**/*", "src/plugins/share/**/*", "src/plugins/telemetry/**/*", @@ -44,6 +45,7 @@ { "path": "./src/plugins/kibana_utils/tsconfig.json" }, { "path": "./src/plugins/navigation/tsconfig.json" }, { "path": "./src/plugins/newsfeed/tsconfig.json" }, + { "path": "./src/plugins/saved_objects/tsconfig.json" }, { "path": "./src/plugins/security_oss/tsconfig.json" }, { "path": "./src/plugins/share/tsconfig.json" }, { "path": "./src/plugins/telemetry/tsconfig.json" }, diff --git a/tsconfig.refs.json b/tsconfig.refs.json index 0ef1f70faef97..dcb4fd5c621eb 100644 --- a/tsconfig.refs.json +++ b/tsconfig.refs.json @@ -13,6 +13,7 @@ { "path": "./src/plugins/kibana_utils/tsconfig.json" }, { "path": "./src/plugins/navigation/tsconfig.json" }, { "path": "./src/plugins/newsfeed/tsconfig.json" }, + { "path": "./src/plugins/saved_objects/tsconfig.json" }, { "path": "./src/plugins/security_oss/tsconfig.json" }, { "path": "./src/plugins/share/tsconfig.json" }, { "path": "./src/plugins/telemetry/tsconfig.json" }, diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index 1b9337dc9d5a9..908e775d51bf3 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -17,6 +17,7 @@ { "path": "../../src/plugins/kibana_utils/tsconfig.json" }, { "path": "../../src/plugins/navigation/tsconfig.json" }, { "path": "../../src/plugins/newsfeed/tsconfig.json" }, + { "path": "../../src/plugins/saved_objects/tsconfig.json" }, { "path": "../../src/plugins/share/tsconfig.json" }, { "path": "../../src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "../../src/plugins/telemetry/tsconfig.json" }, diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index a778a47f43252..22fbb23c2a382 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -27,6 +27,7 @@ { "path": "../src/plugins/kibana_utils/tsconfig.json" }, { "path": "../src/plugins/navigation/tsconfig.json" }, { "path": "../src/plugins/newsfeed/tsconfig.json" }, + { "path": "../src/plugins/saved_objects/tsconfig.json" }, { "path": "../src/plugins/security_oss/tsconfig.json" }, { "path": "../src/plugins/share/tsconfig.json" }, { "path": "../src/plugins/telemetry/tsconfig.json" }, From e9e65e7fa6f4e0361d7a1df61fb43f703bc8de4a Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 15:03:27 +0100 Subject: [PATCH 11/18] embeddable to ts project --- .../embeddables/embeddable_renderer.test.tsx | 2 +- .../lib/embeddables/embeddable_root.test.tsx | 2 +- src/plugins/embeddable/public/plugin.test.ts | 2 +- .../embeddable/public/tests/container.test.ts | 5 +- .../public/tests/explicit_input.test.ts | 5 +- .../tests/fixtures/hello_world_embeddable.tsx | 54 +++++++++++++++++++ .../hello_world_embeddable_factory.ts | 46 ++++++++++++++++ .../embeddable/public/tests/fixtures/index.ts | 21 ++++++++ src/plugins/embeddable/tsconfig.json | 23 ++++++++ test/tsconfig.json | 1 + tsconfig.json | 2 + tsconfig.refs.json | 1 + x-pack/test/tsconfig.json | 1 + x-pack/tsconfig.json | 1 + 14 files changed, 155 insertions(+), 11 deletions(-) create mode 100644 src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable.tsx create mode 100644 src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable_factory.ts create mode 100644 src/plugins/embeddable/public/tests/fixtures/index.ts create mode 100644 src/plugins/embeddable/tsconfig.json diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable_renderer.test.tsx b/src/plugins/embeddable/public/lib/embeddables/embeddable_renderer.test.tsx index bcd9d31dade26..1b18d588d8f82 100644 --- a/src/plugins/embeddable/public/lib/embeddables/embeddable_renderer.test.tsx +++ b/src/plugins/embeddable/public/lib/embeddables/embeddable_renderer.test.tsx @@ -24,7 +24,7 @@ import { HelloWorldEmbeddable, HelloWorldEmbeddableFactoryDefinition, HELLO_WORLD_EMBEDDABLE, -} from '../../../../../../examples/embeddable_examples/public/hello_world'; +} from '../../tests/fixtures'; import { EmbeddableRenderer } from './embeddable_renderer'; import { embeddablePluginMock } from '../../mocks'; diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable_root.test.tsx b/src/plugins/embeddable/public/lib/embeddables/embeddable_root.test.tsx index cb900884fde97..fa1515b27c53d 100644 --- a/src/plugins/embeddable/public/lib/embeddables/embeddable_root.test.tsx +++ b/src/plugins/embeddable/public/lib/embeddables/embeddable_root.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { HelloWorldEmbeddable } from '../../../../../../examples/embeddable_examples/public'; +import { HelloWorldEmbeddable } from '../../tests/fixtures'; import { EmbeddableRoot } from './embeddable_root'; import { mount } from 'enzyme'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/embeddable/public/plugin.test.ts b/src/plugins/embeddable/public/plugin.test.ts index 5d47463344434..757a1989d8fc7 100644 --- a/src/plugins/embeddable/public/plugin.test.ts +++ b/src/plugins/embeddable/public/plugin.test.ts @@ -20,7 +20,7 @@ import { coreMock } from '../../../core/public/mocks'; import { testPlugin } from './tests/test_plugin'; import { EmbeddableFactoryProvider } from './types'; import { defaultEmbeddableFactoryProvider } from './lib'; -import { HelloWorldEmbeddable } from '../../../../examples/embeddable_examples/public'; +import { HelloWorldEmbeddable } from './tests/fixtures'; test('can set custom embeddable factory provider', async () => { const coreSetup = coreMock.createSetup(); diff --git a/src/plugins/embeddable/public/tests/container.test.ts b/src/plugins/embeddable/public/tests/container.test.ts index bb3e35c949666..1eb5cbbd340a3 100644 --- a/src/plugins/embeddable/public/tests/container.test.ts +++ b/src/plugins/embeddable/public/tests/container.test.ts @@ -36,10 +36,7 @@ import { ERROR_EMBEDDABLE_TYPE } from '../lib/embeddables/error_embeddable'; import { FilterableEmbeddableFactory } from '../lib/test_samples/embeddables/filterable_embeddable_factory'; import { CONTACT_CARD_EMBEDDABLE } from '../lib/test_samples/embeddables/contact_card/contact_card_embeddable_factory'; import { SlowContactCardEmbeddableFactory } from '../lib/test_samples/embeddables/contact_card/slow_contact_card_embeddable_factory'; -import { - HELLO_WORLD_EMBEDDABLE, - HelloWorldEmbeddableFactoryDefinition, -} from '../../../../../examples/embeddable_examples/public'; +import { HELLO_WORLD_EMBEDDABLE, HelloWorldEmbeddableFactoryDefinition } from './fixtures'; import { HelloWorldContainer } from '../lib/test_samples/embeddables/hello_world_container'; import { ContactCardEmbeddableInput, diff --git a/src/plugins/embeddable/public/tests/explicit_input.test.ts b/src/plugins/embeddable/public/tests/explicit_input.test.ts index 531fbcee94db6..7ab50de40582b 100644 --- a/src/plugins/embeddable/public/tests/explicit_input.test.ts +++ b/src/plugins/embeddable/public/tests/explicit_input.test.ts @@ -27,10 +27,7 @@ import { import { FilterableEmbeddableFactory } from '../lib/test_samples/embeddables/filterable_embeddable_factory'; import { CONTACT_CARD_EMBEDDABLE } from '../lib/test_samples/embeddables/contact_card/contact_card_embeddable_factory'; import { SlowContactCardEmbeddableFactory } from '../lib/test_samples/embeddables/contact_card/slow_contact_card_embeddable_factory'; -import { - HELLO_WORLD_EMBEDDABLE, - HelloWorldEmbeddableFactoryDefinition, -} from '../../../../../examples/embeddable_examples/public'; +import { HELLO_WORLD_EMBEDDABLE, HelloWorldEmbeddableFactoryDefinition } from './fixtures'; import { FilterableContainer } from '../lib/test_samples/embeddables/filterable_container'; import { isErrorEmbeddable } from '../lib'; import { HelloWorldContainer } from '../lib/test_samples/embeddables/hello_world_container'; diff --git a/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable.tsx b/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable.tsx new file mode 100644 index 0000000000000..55385d4125790 --- /dev/null +++ b/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable.tsx @@ -0,0 +1,54 @@ +/* + * 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 { Embeddable, EmbeddableInput, IContainer } from '../../'; + +export const HELLO_WORLD_EMBEDDABLE = 'HELLO_WORLD_EMBEDDABLE'; + +export class HelloWorldEmbeddable extends Embeddable { + // The type of this embeddable. This will be used to find the appropriate factory + // to instantiate this kind of embeddable. + public readonly type = HELLO_WORLD_EMBEDDABLE; + + constructor(initialInput: EmbeddableInput, parent?: IContainer) { + super( + // Input state is irrelevant to this embeddable, just pass it along. + initialInput, + // Initial output state - this embeddable does not do anything with output, so just + // pass along an empty object. + {}, + // Optional parent component, this embeddable can optionally be rendered inside a container. + parent + ); + } + + /** + * Render yourself at the dom node using whatever framework you like, angular, react, or just plain + * vanilla js. + * @param node + */ + public render(node: HTMLElement) { + node.innerHTML = '
HELLO WORLD!
'; + } + + /** + * This is mostly relevant for time based embeddables which need to update data + * even if EmbeddableInput has not changed at all. + */ + public reload() {} +} diff --git a/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable_factory.ts b/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable_factory.ts new file mode 100644 index 0000000000000..8f78cc0efd9a0 --- /dev/null +++ b/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable_factory.ts @@ -0,0 +1,46 @@ +/* + * 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 { i18n } from '@kbn/i18n'; +import { IContainer, EmbeddableInput, EmbeddableFactoryDefinition, EmbeddableFactory } from '../..'; +import { HelloWorldEmbeddable, HELLO_WORLD_EMBEDDABLE } from './hello_world_embeddable'; + +export type HelloWorldEmbeddableFactory = EmbeddableFactory; +export class HelloWorldEmbeddableFactoryDefinition implements EmbeddableFactoryDefinition { + public readonly type = HELLO_WORLD_EMBEDDABLE; + + /** + * In our simple example, we let everyone have permissions to edit this. Most + * embeddables should check the UI Capabilities service to be sure of + * the right permissions. + */ + public async isEditable() { + return true; + } + + public async create(initialInput: EmbeddableInput, parent?: IContainer) { + return new HelloWorldEmbeddable(initialInput, parent); + } + + public getDisplayName() { + return i18n.translate('embeddableExamples.helloworld.displayName', { + defaultMessage: 'hello world', + }); + } +} diff --git a/src/plugins/embeddable/public/tests/fixtures/index.ts b/src/plugins/embeddable/public/tests/fixtures/index.ts new file mode 100644 index 0000000000000..f47b4f5e5b847 --- /dev/null +++ b/src/plugins/embeddable/public/tests/fixtures/index.ts @@ -0,0 +1,21 @@ +/* + * 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 * from './hello_world_embeddable'; +export * from './hello_world_embeddable_factory'; diff --git a/src/plugins/embeddable/tsconfig.json b/src/plugins/embeddable/tsconfig.json new file mode 100644 index 0000000000000..27a887500fb68 --- /dev/null +++ b/src/plugins/embeddable/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": [ + "common/**/*", + "public/**/*", + "server/**/*" + ], + "references": [ + { "path": "../../core/tsconfig.json" }, + { "path": "../inspector/tsconfig.json" }, + { "path": "../saved_objects/tsconfig.json" }, + { "path": "../kibana_utils/tsconfig.json" }, + { "path": "../kibana_react/tsconfig.json" }, + { "path": "../ui_actions/tsconfig.json" }, + ] +} diff --git a/test/tsconfig.json b/test/tsconfig.json index 1ad7cf9886701..83c456d4bb8ae 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -9,6 +9,7 @@ "references": [ { "path": "../src/core/tsconfig.json" }, { "path": "../src/plugins/bfetch/tsconfig.json" }, + { "path": "../src/plugins/embeddable/tsconfig.json" }, { "path": "../src/plugins/expressions/tsconfig.json" }, { "path": "../src/plugins/inspector/tsconfig.json" }, { "path": "../src/plugins/kibana_react/tsconfig.json" }, diff --git a/tsconfig.json b/tsconfig.json index 329cf69af5865..fd76cd2674401 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,7 @@ "src/plugins/bfetch/**/*", "src/plugins/data/**/*", "src/plugins/dev_tools/**/*", + "src/plugins/embeddable/**/*", "src/plugins/expressions/**/*", "src/plugins/inspector/**/*", "src/plugins/kibana_legacy/**/*", @@ -37,6 +38,7 @@ { "path": "./src/plugins/bfetch/tsconfig.json" }, { "path": "./src/plugins/data/tsconfig.json" }, { "path": "./src/plugins/dev_tools/tsconfig.json" }, + { "path": "./src/plugins/embeddable/tsconfig.json" }, { "path": "./src/plugins/expressions/tsconfig.json" }, { "path": "./src/plugins/inspector/tsconfig.json" }, { "path": "./src/plugins/kibana_legacy/tsconfig.json" }, diff --git a/tsconfig.refs.json b/tsconfig.refs.json index dcb4fd5c621eb..1e14c5618f543 100644 --- a/tsconfig.refs.json +++ b/tsconfig.refs.json @@ -5,6 +5,7 @@ { "path": "./src/plugins/bfetch/tsconfig.json" }, { "path": "./src/plugins/data/tsconfig.json" }, { "path": "./src/plugins/dev_tools/tsconfig.json" }, + { "path": "./src/plugins/embeddable/tsconfig.json" }, { "path": "./src/plugins/expressions/tsconfig.json" }, { "path": "./src/plugins/inspector/tsconfig.json" }, { "path": "./src/plugins/kibana_legacy/tsconfig.json" }, diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index 908e775d51bf3..cc0a9a85c0a89 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -11,6 +11,7 @@ { "path": "../../src/core/tsconfig.json" }, { "path": "../../src/plugins/bfetch/tsconfig.json" }, { "path": "../../src/plugins/data/tsconfig.json" }, + { "path": "../../src/plugins/embeddable/tsconfig.json" }, { "path": "../../src/plugins/expressions/tsconfig.json" }, { "path": "../../src/plugins/kibana_react/tsconfig.json" }, { "path": "../../src/plugins/kibana_usage_collection/tsconfig.json" }, diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 22fbb23c2a382..9ab4d75cee1c1 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -19,6 +19,7 @@ { "path": "../src/plugins/bfetch/tsconfig.json" }, { "path": "../src/plugins/data/tsconfig.json" }, { "path": "../src/plugins/dev_tools/tsconfig.json" }, + { "path": "../src/plugins/embeddable/tsconfig.json" }, { "path": "../src/plugins/expressions/tsconfig.json" }, { "path": "../src/plugins/inspector/tsconfig.json" }, { "path": "../src/plugins/kibana_legacy/tsconfig.json" }, From 9fea2ce691a5bf09ffc9fe8db2d76b202df72e04 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 15:25:09 +0100 Subject: [PATCH 12/18] ui_actions_enhanced to ts project --- .../public/can_inherit_time_range.test.ts | 4 +-- .../public/custom_time_range_action.test.ts | 2 +- .../plugins/ui_actions_enhanced/tsconfig.json | 26 +++++++++++++++++++ x-pack/test/tsconfig.json | 3 ++- x-pack/tsconfig.json | 4 ++- x-pack/tsconfig.refs.json | 1 + 6 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 x-pack/plugins/ui_actions_enhanced/tsconfig.json diff --git a/x-pack/plugins/ui_actions_enhanced/public/can_inherit_time_range.test.ts b/x-pack/plugins/ui_actions_enhanced/public/can_inherit_time_range.test.ts index 9fb3a54d5a182..b718c4ed2c240 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/can_inherit_time_range.test.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/can_inherit_time_range.test.ts @@ -4,10 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ import { canInheritTimeRange } from './can_inherit_time_range'; -/** eslint-disable */ import { HelloWorldContainer } from '../../../../src/plugins/embeddable/public/lib/test_samples'; -import { HelloWorldEmbeddable } from '../../../../examples/embeddable_examples/public'; -/** eslint-enable */ +import { HelloWorldEmbeddable } from '../../../../src/plugins/embeddable/public/tests/fixtures'; import { TimeRangeEmbeddable, TimeRangeContainer } from './test_helpers'; test('canInheritTimeRange returns false if embeddable is inside container without a time range', () => { diff --git a/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.test.ts b/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.test.ts index fde21b18f2593..cdd7a0e3a4a13 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.test.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.test.ts @@ -16,7 +16,7 @@ import { HelloWorldContainer } from '../../../../src/plugins/embeddable/public/l import { HelloWorldEmbeddable, HELLO_WORLD_EMBEDDABLE, -} from '../../../../examples/embeddable_examples/public'; +} from '../../../../src/plugins/embeddable/public/tests/fixtures'; import { nextTick } from '@kbn/test/jest'; import { ReactElement } from 'react'; diff --git a/x-pack/plugins/ui_actions_enhanced/tsconfig.json b/x-pack/plugins/ui_actions_enhanced/tsconfig.json new file mode 100644 index 0000000000000..af24c30389b8b --- /dev/null +++ b/x-pack/plugins/ui_actions_enhanced/tsconfig.json @@ -0,0 +1,26 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": [ + "public/**/*", + "server/**/*", + "common/**/*", + "../../typings/**/*" + ], + "references": [ + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../../../src/plugins/data/tsconfig.json" }, + { "path": "../../../src/plugins/embeddable/tsconfig.json" }, + { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, + { "path": "../../../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../../../src/plugins/ui_actions/tsconfig.json" }, + + { "path": "../licensing/tsconfig.json" }, + ] +} diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index cc0a9a85c0a89..f817de0c6c55f 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -26,6 +26,7 @@ { "path": "../../src/plugins/ui_actions/tsconfig.json" }, { "path": "../plugins/global_search/tsconfig.json" }, { "path": "../plugins/licensing/tsconfig.json" }, - { "path": "../plugins/telemetry_collection_xpack/tsconfig.json" } + { "path": "../plugins/telemetry_collection_xpack/tsconfig.json" }, + { "path": "../plugins/ui_actions_enhanced/tsconfig.json" }, ] } diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 9ab4d75cee1c1..75e96b1b1ba5b 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -8,6 +8,7 @@ "plugins/licensing/**/*", "plugins/security_solution/cypress/**/*", "plugins/telemetry_collection_xpack/**/*", + "plugins/ui_actions_enhanced/**/*", "test/**/*" ], "compilerOptions": { @@ -39,6 +40,7 @@ { "path": "./plugins/global_search/tsconfig.json" }, { "path": "./plugins/licensing/tsconfig.json" }, - { "path": "./plugins/telemetry_collection_xpack/tsconfig.json" } + { "path": "./plugins/telemetry_collection_xpack/tsconfig.json" }, + { "path": "./plugins/ui_actions_enhanced/tsconfig.json" } ] } diff --git a/x-pack/tsconfig.refs.json b/x-pack/tsconfig.refs.json index a4dfa15a3d8ab..37cdc6d5adf85 100644 --- a/x-pack/tsconfig.refs.json +++ b/x-pack/tsconfig.refs.json @@ -4,5 +4,6 @@ { "path": "./plugins/licensing/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, { "path": "./plugins/telemetry_collection_xpack/tsconfig.json" }, + { "path": "./plugins/ui_actions_enhanced/tsconfig.json" }, ] } From b017b13d45aab93952e73d6495e00ac6a93c5c8d Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 15:31:03 +0100 Subject: [PATCH 13/18] embeddable_enhanced to ts project --- .../plugins/embeddable_enhanced/tsconfig.json | 21 +++++++++++++++++++ x-pack/test/tsconfig.json | 1 + x-pack/tsconfig.json | 2 ++ x-pack/tsconfig.refs.json | 1 + 4 files changed, 25 insertions(+) create mode 100644 x-pack/plugins/embeddable_enhanced/tsconfig.json diff --git a/x-pack/plugins/embeddable_enhanced/tsconfig.json b/x-pack/plugins/embeddable_enhanced/tsconfig.json new file mode 100644 index 0000000000000..6e9eb69585cbc --- /dev/null +++ b/x-pack/plugins/embeddable_enhanced/tsconfig.json @@ -0,0 +1,21 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": [ + "public/**/*", + ], + "references": [ + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../../../src/plugins/embeddable/tsconfig.json" }, + { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, + { "path": "../../../src/plugins/ui_actions/tsconfig.json" }, + + { "path": "../ui_actions_enhanced/tsconfig.json" }, + ] +} diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index f817de0c6c55f..6eca5ffca6b91 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -25,6 +25,7 @@ { "path": "../../src/plugins/usage_collection/tsconfig.json" }, { "path": "../../src/plugins/ui_actions/tsconfig.json" }, { "path": "../plugins/global_search/tsconfig.json" }, + { "path": "../plugins/embeddable_enhanced/tsconfig.json" }, { "path": "../plugins/licensing/tsconfig.json" }, { "path": "../plugins/telemetry_collection_xpack/tsconfig.json" }, { "path": "../plugins/ui_actions_enhanced/tsconfig.json" }, diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 75e96b1b1ba5b..3a9ef8e570f6d 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -5,6 +5,7 @@ "plugins/apm/e2e/cypress/**/*", "plugins/apm/scripts/**/*", "plugins/global_search/**/*", + "plugins/embeddable_enhanced/**/*", "plugins/licensing/**/*", "plugins/security_solution/cypress/**/*", "plugins/telemetry_collection_xpack/**/*", @@ -39,6 +40,7 @@ { "path": "../src/plugins/usage_collection/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, + { "path": "./plugins/embeddable_enhanced/tsconfig.json" }, { "path": "./plugins/licensing/tsconfig.json" }, { "path": "./plugins/telemetry_collection_xpack/tsconfig.json" }, { "path": "./plugins/ui_actions_enhanced/tsconfig.json" } diff --git a/x-pack/tsconfig.refs.json b/x-pack/tsconfig.refs.json index 37cdc6d5adf85..f4c4faf150949 100644 --- a/x-pack/tsconfig.refs.json +++ b/x-pack/tsconfig.refs.json @@ -3,6 +3,7 @@ "references": [ { "path": "./plugins/licensing/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, + { "path": "./plugins/embeddable_enhanced/tsconfig.json" }, { "path": "./plugins/telemetry_collection_xpack/tsconfig.json" }, { "path": "./plugins/ui_actions_enhanced/tsconfig.json" }, ] From e9d7fa0077600757f3ba017a9239bc0638a431fc Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 15:54:14 +0100 Subject: [PATCH 14/18] features to ts project --- .../server/feature_privilege_iterator.js | 9 +++++++++ .../features/server/oss_features.test.ts | 3 ++- x-pack/plugins/features/server/plugin.ts | 5 ++++- x-pack/plugins/features/tsconfig.json | 19 +++++++++++++++++++ x-pack/test/tsconfig.json | 1 + x-pack/tsconfig.json | 2 ++ x-pack/tsconfig.refs.json | 1 + 7 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 x-pack/plugins/features/server/feature_privilege_iterator.js create mode 100644 x-pack/plugins/features/tsconfig.json diff --git a/x-pack/plugins/features/server/feature_privilege_iterator.js b/x-pack/plugins/features/server/feature_privilege_iterator.js new file mode 100644 index 0000000000000..b36cd9745de12 --- /dev/null +++ b/x-pack/plugins/features/server/feature_privilege_iterator.js @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +// the file created to remove TS cicular dependency between features and security pluin +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +export { featurePrivilegeIterator } from '../../security/server/authorization'; diff --git a/x-pack/plugins/features/server/oss_features.test.ts b/x-pack/plugins/features/server/oss_features.test.ts index a22e95105ba05..6b2ce6fd70c97 100644 --- a/x-pack/plugins/features/server/oss_features.test.ts +++ b/x-pack/plugins/features/server/oss_features.test.ts @@ -5,7 +5,8 @@ */ import { buildOSSFeatures } from './oss_features'; -import { featurePrivilegeIterator } from '../../security/server/authorization'; +// @ts-expect-error +import { featurePrivilegeIterator } from './feature_privilege_iterator'; import { KibanaFeature } from '.'; import { LicenseType } from '../../licensing/server'; diff --git a/x-pack/plugins/features/server/plugin.ts b/x-pack/plugins/features/server/plugin.ts index 857bba4c606d4..c3e2ad06fb85c 100644 --- a/x-pack/plugins/features/server/plugin.ts +++ b/x-pack/plugins/features/server/plugin.ts @@ -13,7 +13,6 @@ import { PluginInitializerContext, } from '../../../../src/core/server'; import { Capabilities as UICapabilities } from '../../../../src/core/server'; -import { PluginSetupContract as TimelionSetupContract } from '../../../../src/plugins/vis_type_timelion/server'; import { FeatureRegistry } from './feature_registry'; import { uiCapabilitiesForFeatures } from './ui_capabilities_for_features'; import { buildOSSFeatures } from './oss_features'; @@ -51,6 +50,10 @@ export interface PluginStartContract { getKibanaFeatures(): KibanaFeature[]; } +interface TimelionSetupContract { + uiEnabled: boolean; +} + /** * Represents Features Plugin instance that will be managed by the Kibana plugin system. */ diff --git a/x-pack/plugins/features/tsconfig.json b/x-pack/plugins/features/tsconfig.json new file mode 100644 index 0000000000000..1260af55fbff6 --- /dev/null +++ b/x-pack/plugins/features/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": [ + "common/**/*", + "public/**/*", + "server/**/*", + ], + "references": [ + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../licensing/tsconfig.json" }, + ] +} diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index 6eca5ffca6b91..d24b0630f84a8 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -25,6 +25,7 @@ { "path": "../../src/plugins/usage_collection/tsconfig.json" }, { "path": "../../src/plugins/ui_actions/tsconfig.json" }, { "path": "../plugins/global_search/tsconfig.json" }, + { "path": "../plugins/features/tsconfig.json" }, { "path": "../plugins/embeddable_enhanced/tsconfig.json" }, { "path": "../plugins/licensing/tsconfig.json" }, { "path": "../plugins/telemetry_collection_xpack/tsconfig.json" }, diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 3a9ef8e570f6d..3f7917cb47416 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -5,6 +5,7 @@ "plugins/apm/e2e/cypress/**/*", "plugins/apm/scripts/**/*", "plugins/global_search/**/*", + "plugins/features/**/*", "plugins/embeddable_enhanced/**/*", "plugins/licensing/**/*", "plugins/security_solution/cypress/**/*", @@ -40,6 +41,7 @@ { "path": "../src/plugins/usage_collection/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, + { "path": "./plugins/features/tsconfig.json" }, { "path": "./plugins/embeddable_enhanced/tsconfig.json" }, { "path": "./plugins/licensing/tsconfig.json" }, { "path": "./plugins/telemetry_collection_xpack/tsconfig.json" }, diff --git a/x-pack/tsconfig.refs.json b/x-pack/tsconfig.refs.json index f4c4faf150949..127fcd2514084 100644 --- a/x-pack/tsconfig.refs.json +++ b/x-pack/tsconfig.refs.json @@ -3,6 +3,7 @@ "references": [ { "path": "./plugins/licensing/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, + { "path": "./plugins/features/tsconfig.json" }, { "path": "./plugins/embeddable_enhanced/tsconfig.json" }, { "path": "./plugins/telemetry_collection_xpack/tsconfig.json" }, { "path": "./plugins/ui_actions_enhanced/tsconfig.json" }, From eda816b99919abd445d0fd4ad00d2ae916b598e3 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 16:32:07 +0100 Subject: [PATCH 15/18] data_enhanced to ts project refs --- x-pack/plugins/data_enhanced/tsconfig.json | 27 ++++++++++++++++++++++ x-pack/test/tsconfig.json | 2 ++ x-pack/tsconfig.json | 2 ++ x-pack/tsconfig.refs.json | 1 + 4 files changed, 32 insertions(+) create mode 100644 x-pack/plugins/data_enhanced/tsconfig.json diff --git a/x-pack/plugins/data_enhanced/tsconfig.json b/x-pack/plugins/data_enhanced/tsconfig.json new file mode 100644 index 0000000000000..e7f0d396f6d3e --- /dev/null +++ b/x-pack/plugins/data_enhanced/tsconfig.json @@ -0,0 +1,27 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true, + }, + "include": [ + "common/**/*", + "public/**/*", + "public/autocomplete/providers/kql_query_suggestion/__fixtures__/*.json", + "server/**/*", + "config.ts" + ], + "references": [ + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../../../src/plugins/bfetch/tsconfig.json" }, + { "path": "../../../src/plugins/data/tsconfig.json" }, + { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, + { "path": "../../../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, + + { "path": "../features/tsconfig.json" }, + ] +} diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index d24b0630f84a8..ccf681f128b10 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -24,6 +24,8 @@ { "path": "../../src/plugins/telemetry/tsconfig.json" }, { "path": "../../src/plugins/usage_collection/tsconfig.json" }, { "path": "../../src/plugins/ui_actions/tsconfig.json" }, + + { "path": "../plugins/data_enhanced/tsconfig.json" }, { "path": "../plugins/global_search/tsconfig.json" }, { "path": "../plugins/features/tsconfig.json" }, { "path": "../plugins/embeddable_enhanced/tsconfig.json" }, diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 3f7917cb47416..613dc9f5b361f 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -4,6 +4,7 @@ "exclude": [ "plugins/apm/e2e/cypress/**/*", "plugins/apm/scripts/**/*", + "plugins/data_enhanced/**/*", "plugins/global_search/**/*", "plugins/features/**/*", "plugins/embeddable_enhanced/**/*", @@ -40,6 +41,7 @@ { "path": "../src/plugins/ui_actions/tsconfig.json" }, { "path": "../src/plugins/usage_collection/tsconfig.json" }, + { "path": "./plugins/data_enhanced/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, { "path": "./plugins/features/tsconfig.json" }, { "path": "./plugins/embeddable_enhanced/tsconfig.json" }, diff --git a/x-pack/tsconfig.refs.json b/x-pack/tsconfig.refs.json index 127fcd2514084..0516f414963ef 100644 --- a/x-pack/tsconfig.refs.json +++ b/x-pack/tsconfig.refs.json @@ -2,6 +2,7 @@ "include": [], "references": [ { "path": "./plugins/licensing/tsconfig.json" }, + { "path": "./plugins/data_enhanced/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, { "path": "./plugins/features/tsconfig.json" }, { "path": "./plugins/embeddable_enhanced/tsconfig.json" }, From a39e6c0fbda2f1209fc538c8a7a685fc5a59ef5c Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 17:27:09 +0100 Subject: [PATCH 16/18] fix i18n check --- .../public/tests/fixtures/hello_world_embeddable_factory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable_factory.ts b/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable_factory.ts index 8f78cc0efd9a0..5c651e254e284 100644 --- a/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable_factory.ts +++ b/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable_factory.ts @@ -39,7 +39,7 @@ export class HelloWorldEmbeddableFactoryDefinition implements EmbeddableFactoryD } public getDisplayName() { - return i18n.translate('embeddableExamples.helloworld.displayName', { + return i18n.translate('embeddableApi.helloworld.displayName', { defaultMessage: 'hello world', }); } From b4f9b28c25cfae5e8cd517b9cb5e7490ed80e0c9 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Jan 2021 17:49:05 +0100 Subject: [PATCH 17/18] fix find_plugins_ready_to_migrate_to_ts_refs script --- src/dev/run_find_plugins_ready_migrate_to_ts_refs.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dev/run_find_plugins_ready_migrate_to_ts_refs.ts b/src/dev/run_find_plugins_ready_migrate_to_ts_refs.ts index 30ec0ac8ef52e..cfbef768f6874 100644 --- a/src/dev/run_find_plugins_ready_migrate_to_ts_refs.ts +++ b/src/dev/run_find_plugins_ready_migrate_to_ts_refs.ts @@ -19,6 +19,7 @@ import Path from 'path'; import Fs from 'fs'; +import JSON5 from 'json5'; import { get } from 'lodash'; import { run, KibanaPlatformPlugin } from '@kbn/dev-utils'; import { getPluginDeps, findPlugins } from './plugin_discovery'; @@ -46,7 +47,8 @@ run( id: pluginId, }); - if (deps.size === 0 && errors.size === 0) { + const allDepsMigrated = [...deps].every((p) => isMigratedToTsProjectRefs(p.directory)); + if (allDepsMigrated && errors.size === 0) { readyToMigrate.add(pluginMap.get(pluginId)!); } } @@ -82,7 +84,7 @@ function isMigratedToTsProjectRefs(dir: string): boolean { try { const path = Path.join(dir, 'tsconfig.json'); const content = Fs.readFileSync(path, { encoding: 'utf8' }); - return get(JSON.parse(content), 'compilerOptions.composite', false); + return get(JSON5.parse(content), 'compilerOptions.composite', false); } catch (e) { return false; } From 1bde8d539de7c5036f8df93ad21cd76e71d9c049 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Jan 2021 16:54:09 +0100 Subject: [PATCH 18/18] add a comment for bug ignoring json for composite projects --- x-pack/plugins/data_enhanced/tsconfig.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/data_enhanced/tsconfig.json b/x-pack/plugins/data_enhanced/tsconfig.json index e7f0d396f6d3e..28969652f23df 100644 --- a/x-pack/plugins/data_enhanced/tsconfig.json +++ b/x-pack/plugins/data_enhanced/tsconfig.json @@ -10,9 +10,10 @@ "include": [ "common/**/*", "public/**/*", - "public/autocomplete/providers/kql_query_suggestion/__fixtures__/*.json", "server/**/*", - "config.ts" + "config.ts", + // have to declare *.json explicitly due to https://github.com/microsoft/TypeScript/issues/25636 + "public/autocomplete/providers/kql_query_suggestion/__fixtures__/*.json" ], "references": [ { "path": "../../../src/core/tsconfig.json" },