From 4e6650113bc3b107bcce8f42d8743d1b0f96b6ea Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Thu, 11 Feb 2021 21:16:59 +0100 Subject: [PATCH] TS config cleanup (#90492) (#91173) * exclude all the plugins from src/plugins * move all the used fixtures to discover * remove src/fixtures alias * remove unused fixtures * cleanup x-pack/tsconfig.json * dont compile apm/scripts * fix tests * dont include infra in xpack/tsconfig.json * update list of includes # Conflicts: # src/fixtures/hits.js --- packages/kbn-test/jest-preset.js | 1 - src/dev/precommit_hook/casing_check_config.js | 1 - src/fixtures/agg_resp/date_histogram.js | 258 -------- src/fixtures/agg_resp/geohash_grid.js | 84 --- src/fixtures/agg_resp/range.js | 45 -- src/fixtures/config_upgrade_from_4.0.0.json | 25 - ..._upgrade_from_4.0.0_to_4.0.1-snapshot.json | 35 - .../config_upgrade_from_4.0.0_to_4.0.1.json | 35 - src/fixtures/fake_chart_events.js | 28 - src/fixtures/fake_hierarchical_data.ts | 621 ------------------ src/fixtures/field_mapping.js | 68 -- src/fixtures/hits.js | 42 -- src/fixtures/mapping_with_dupes.js | 46 -- src/fixtures/mock_index_patterns.js | 19 - src/fixtures/mock_state.js | 20 - src/fixtures/mock_ui_state.js | 33 - src/fixtures/search_response.js | 24 - src/fixtures/stubbed_search_source.js | 54 -- .../discover/public/__fixtures__}/fake_row.js | 0 .../public/__fixtures__}/logstash_fields.js | 3 +- .../public/__fixtures__}/real_hits.js | 0 .../stubbed_logstash_index_pattern.js | 9 +- .../stubbed_saved_object_index_pattern.ts | 2 +- .../doc_table/components/row_headers.test.js | 4 +- .../angular/doc_table/doc_table.test.js | 4 +- .../doc_table/lib/get_default_sort.test.ts | 2 +- .../angular/doc_table/lib/get_sort.test.ts | 2 +- .../lib/get_sort_for_search_source.test.ts | 2 +- .../sidebar/discover_field.test.tsx | 2 +- .../sidebar/discover_field_details.test.tsx | 2 +- .../discover_field_details_footer.test.tsx | 2 +- .../sidebar/discover_sidebar.test.tsx | 4 +- .../discover_sidebar_responsive.test.tsx | 4 +- .../sidebar/lib/field_calculator.test.ts | 4 +- .../public/__fixtures__/logstash_fields.js | 75 +++ .../stubbed_logstash_index_pattern.js | 47 ++ src/plugins/visualizations/public/vis.test.ts | 2 +- src/type_definitions/react_virtualized.d.ts | 11 - tsconfig.base.json | 3 +- tsconfig.json | 60 +- .../fleet/hooks/use_request/use_request.ts | 5 +- .../fleet/mock/fleet_start_services.tsx | 2 +- .../public/applications/fleet/mock/types.ts | 2 +- x-pack/plugins/fleet/server/mocks.ts | 14 + .../server/routes/limited_concurrency.ts | 5 +- .../routes/package_policy/handlers.test.ts | 3 +- .../server/routes/setup/handlers.test.ts | 3 +- .../fleet/server/saved_objects/index.ts | 3 +- .../server/saved_objects/security_solution.js | 11 + .../fleet/server/services/app_context.ts | 7 +- .../server/services/package_policy.test.ts | 3 +- .../fleet/server/services/package_policy.ts | 2 + .../fleet/server/services/setup.test.ts | 3 +- x-pack/plugins/fleet/tsconfig.json | 6 +- x-pack/plugins/osquery/tsconfig.json | 2 +- x-pack/tsconfig.json | 76 +-- 56 files changed, 216 insertions(+), 1614 deletions(-) delete mode 100644 src/fixtures/agg_resp/date_histogram.js delete mode 100644 src/fixtures/agg_resp/geohash_grid.js delete mode 100644 src/fixtures/agg_resp/range.js delete mode 100644 src/fixtures/config_upgrade_from_4.0.0.json delete mode 100644 src/fixtures/config_upgrade_from_4.0.0_to_4.0.1-snapshot.json delete mode 100644 src/fixtures/config_upgrade_from_4.0.0_to_4.0.1.json delete mode 100644 src/fixtures/fake_chart_events.js delete mode 100644 src/fixtures/fake_hierarchical_data.ts delete mode 100644 src/fixtures/field_mapping.js delete mode 100644 src/fixtures/hits.js delete mode 100644 src/fixtures/mapping_with_dupes.js delete mode 100644 src/fixtures/mock_index_patterns.js delete mode 100644 src/fixtures/mock_state.js delete mode 100644 src/fixtures/mock_ui_state.js delete mode 100644 src/fixtures/search_response.js delete mode 100644 src/fixtures/stubbed_search_source.js rename src/{fixtures => plugins/discover/public/__fixtures__}/fake_row.js (100%) rename src/{fixtures => plugins/discover/public/__fixtures__}/logstash_fields.js (96%) rename src/{fixtures => plugins/discover/public/__fixtures__}/real_hits.js (100%) rename src/{fixtures => plugins/discover/public/__fixtures__}/stubbed_logstash_index_pattern.js (81%) create mode 100644 src/plugins/visualizations/public/__fixtures__/logstash_fields.js create mode 100644 src/plugins/visualizations/public/__fixtures__/stubbed_logstash_index_pattern.js delete mode 100644 src/type_definitions/react_virtualized.d.ts create mode 100644 x-pack/plugins/fleet/server/saved_objects/security_solution.js diff --git a/packages/kbn-test/jest-preset.js b/packages/kbn-test/jest-preset.js index 127acd8d0beb..d6e5ea637ed7 100644 --- a/packages/kbn-test/jest-preset.js +++ b/packages/kbn-test/jest-preset.js @@ -37,7 +37,6 @@ module.exports = { '\\.ace\\.worker.js$': '/packages/kbn-test/target/jest/mocks/worker_module_mock.js', '\\.editor\\.worker.js$': '/packages/kbn-test/target/jest/mocks/worker_module_mock.js', '^(!!)?file-loader!': '/packages/kbn-test/target/jest/mocks/file_mock.js', - '^fixtures/(.*)': '/src/fixtures/$1', '^src/core/(.*)': '/src/core/$1', '^src/plugins/(.*)': '/src/plugins/$1', }, diff --git a/src/dev/precommit_hook/casing_check_config.js b/src/dev/precommit_hook/casing_check_config.js index baed8284347c..144da018c300 100644 --- a/src/dev/precommit_hook/casing_check_config.js +++ b/src/dev/precommit_hook/casing_check_config.js @@ -123,7 +123,6 @@ export const REMOVE_EXTENSION = ['packages/kbn-plugin-generator/template/**/*.ej * @type {Array} */ export const TEMPORARILY_IGNORED_PATHS = [ - 'src/fixtures/config_upgrade_from_4.0.0_to_4.0.1-snapshot.json', 'src/core/server/core_app/assets/favicons/android-chrome-192x192.png', 'src/core/server/core_app/assets/favicons/android-chrome-256x256.png', 'src/core/server/core_app/assets/favicons/android-chrome-512x512.png', diff --git a/src/fixtures/agg_resp/date_histogram.js b/src/fixtures/agg_resp/date_histogram.js deleted file mode 100644 index 29b34f1ce69d..000000000000 --- a/src/fixtures/agg_resp/date_histogram.js +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -export default { - took: 35, - timed_out: false, - _shards: { - total: 2, - successful: 2, - failed: 0, - }, - hits: { - total: 32899, - max_score: 0, - hits: [], - }, - aggregations: { - 1: { - buckets: [ - { - key_as_string: '2015-01-30T01:00:00.000Z', - key: 1422579600000, - doc_count: 18, - }, - { - key_as_string: '2015-01-30T02:00:00.000Z', - key: 1422583200000, - doc_count: 68, - }, - { - key_as_string: '2015-01-30T03:00:00.000Z', - key: 1422586800000, - doc_count: 146, - }, - { - key_as_string: '2015-01-30T04:00:00.000Z', - key: 1422590400000, - doc_count: 149, - }, - { - key_as_string: '2015-01-30T05:00:00.000Z', - key: 1422594000000, - doc_count: 363, - }, - { - key_as_string: '2015-01-30T06:00:00.000Z', - key: 1422597600000, - doc_count: 555, - }, - { - key_as_string: '2015-01-30T07:00:00.000Z', - key: 1422601200000, - doc_count: 878, - }, - { - key_as_string: '2015-01-30T08:00:00.000Z', - key: 1422604800000, - doc_count: 1133, - }, - { - key_as_string: '2015-01-30T09:00:00.000Z', - key: 1422608400000, - doc_count: 1438, - }, - { - key_as_string: '2015-01-30T10:00:00.000Z', - key: 1422612000000, - doc_count: 1719, - }, - { - key_as_string: '2015-01-30T11:00:00.000Z', - key: 1422615600000, - doc_count: 1813, - }, - { - key_as_string: '2015-01-30T12:00:00.000Z', - key: 1422619200000, - doc_count: 1790, - }, - { - key_as_string: '2015-01-30T13:00:00.000Z', - key: 1422622800000, - doc_count: 1582, - }, - { - key_as_string: '2015-01-30T14:00:00.000Z', - key: 1422626400000, - doc_count: 1439, - }, - { - key_as_string: '2015-01-30T15:00:00.000Z', - key: 1422630000000, - doc_count: 1154, - }, - { - key_as_string: '2015-01-30T16:00:00.000Z', - key: 1422633600000, - doc_count: 847, - }, - { - key_as_string: '2015-01-30T17:00:00.000Z', - key: 1422637200000, - doc_count: 588, - }, - { - key_as_string: '2015-01-30T18:00:00.000Z', - key: 1422640800000, - doc_count: 374, - }, - { - key_as_string: '2015-01-30T19:00:00.000Z', - key: 1422644400000, - doc_count: 152, - }, - { - key_as_string: '2015-01-30T20:00:00.000Z', - key: 1422648000000, - doc_count: 140, - }, - { - key_as_string: '2015-01-30T21:00:00.000Z', - key: 1422651600000, - doc_count: 73, - }, - { - key_as_string: '2015-01-30T22:00:00.000Z', - key: 1422655200000, - doc_count: 28, - }, - { - key_as_string: '2015-01-30T23:00:00.000Z', - key: 1422658800000, - doc_count: 9, - }, - { - key_as_string: '2015-01-31T00:00:00.000Z', - key: 1422662400000, - doc_count: 29, - }, - { - key_as_string: '2015-01-31T01:00:00.000Z', - key: 1422666000000, - doc_count: 38, - }, - { - key_as_string: '2015-01-31T02:00:00.000Z', - key: 1422669600000, - doc_count: 70, - }, - { - key_as_string: '2015-01-31T03:00:00.000Z', - key: 1422673200000, - doc_count: 136, - }, - { - key_as_string: '2015-01-31T04:00:00.000Z', - key: 1422676800000, - doc_count: 173, - }, - { - key_as_string: '2015-01-31T05:00:00.000Z', - key: 1422680400000, - doc_count: 370, - }, - { - key_as_string: '2015-01-31T06:00:00.000Z', - key: 1422684000000, - doc_count: 545, - }, - { - key_as_string: '2015-01-31T07:00:00.000Z', - key: 1422687600000, - doc_count: 845, - }, - { - key_as_string: '2015-01-31T08:00:00.000Z', - key: 1422691200000, - doc_count: 1070, - }, - { - key_as_string: '2015-01-31T09:00:00.000Z', - key: 1422694800000, - doc_count: 1419, - }, - { - key_as_string: '2015-01-31T10:00:00.000Z', - key: 1422698400000, - doc_count: 1725, - }, - { - key_as_string: '2015-01-31T11:00:00.000Z', - key: 1422702000000, - doc_count: 1801, - }, - { - key_as_string: '2015-01-31T12:00:00.000Z', - key: 1422705600000, - doc_count: 1823, - }, - { - key_as_string: '2015-01-31T13:00:00.000Z', - key: 1422709200000, - doc_count: 1657, - }, - { - key_as_string: '2015-01-31T14:00:00.000Z', - key: 1422712800000, - doc_count: 1454, - }, - { - key_as_string: '2015-01-31T15:00:00.000Z', - key: 1422716400000, - doc_count: 1131, - }, - { - key_as_string: '2015-01-31T16:00:00.000Z', - key: 1422720000000, - doc_count: 810, - }, - { - key_as_string: '2015-01-31T17:00:00.000Z', - key: 1422723600000, - doc_count: 583, - }, - { - key_as_string: '2015-01-31T18:00:00.000Z', - key: 1422727200000, - doc_count: 384, - }, - { - key_as_string: '2015-01-31T19:00:00.000Z', - key: 1422730800000, - doc_count: 165, - }, - { - key_as_string: '2015-01-31T20:00:00.000Z', - key: 1422734400000, - doc_count: 135, - }, - { - key_as_string: '2015-01-31T21:00:00.000Z', - key: 1422738000000, - doc_count: 72, - }, - { - key_as_string: '2015-01-31T22:00:00.000Z', - key: 1422741600000, - doc_count: 8, - }, - ], - }, - }, -}; diff --git a/src/fixtures/agg_resp/geohash_grid.js b/src/fixtures/agg_resp/geohash_grid.js deleted file mode 100644 index 4a8fb3704c9b..000000000000 --- a/src/fixtures/agg_resp/geohash_grid.js +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import _ from 'lodash'; -export default function GeoHashGridAggResponseFixture() { - // for vis: - // - // vis = new Vis(indexPattern, { - // type: 'tile_map', - // aggs:[ - // { schema: 'metric', type: 'avg', params: { field: 'bytes' } }, - // { schema: 'split', type: 'terms', params: { field: '@tags', size: 10 } }, - // { schema: 'segment', type: 'geohash_grid', params: { field: 'geo.coordinates', precision: 3 } } - // ], - // params: { - // isDesaturated: true, - // mapType: 'Scaled%20Circle%20Markers' - // }, - // }); - - const geoHashCharts = _.union( - _.range(48, 57), // 0-9 - _.range(65, 90), // A-Z - _.range(97, 122) // a-z - ); - - const tags = _.times(_.random(4, 20), function (i) { - // random number of tags - let docCount = 0; - const buckets = _.times(_.random(40, 200), function () { - return _.sampleSize(geoHashCharts, 3).join(''); - }) - .sort() - .map(function (geoHash) { - const count = _.random(1, 5000); - - docCount += count; - - return { - key: geoHash, - doc_count: count, - 1: { - value: 2048 + i, - }, - }; - }); - - return { - key: 'tag ' + (i + 1), - doc_count: docCount, - 3: { - buckets: buckets, - }, - 1: { - value: 1000 + i, - }, - }; - }); - - return { - took: 3, - timed_out: false, - _shards: { - total: 4, - successful: 4, - failed: 0, - }, - hits: { - total: 298, - max_score: 0.0, - hits: [], - }, - aggregations: { - 2: { - buckets: tags, - }, - }, - }; -} diff --git a/src/fixtures/agg_resp/range.js b/src/fixtures/agg_resp/range.js deleted file mode 100644 index ca15f535add8..000000000000 --- a/src/fixtures/agg_resp/range.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -export default { - took: 35, - timed_out: false, - _shards: { - total: 7, - successful: 7, - failed: 0, - }, - hits: { - total: 218512, - max_score: 0, - hits: [], - }, - aggregations: { - 1: { - buckets: { - '*-1024.0': { - to: 1024, - to_as_string: '1024.0', - doc_count: 20904, - }, - '1024.0-2560.0': { - from: 1024, - from_as_string: '1024.0', - to: 2560, - to_as_string: '2560.0', - doc_count: 23358, - }, - '2560.0-*': { - from: 2560, - from_as_string: '2560.0', - doc_count: 174250, - }, - }, - }, - }, -}; diff --git a/src/fixtures/config_upgrade_from_4.0.0.json b/src/fixtures/config_upgrade_from_4.0.0.json deleted file mode 100644 index 522de78648c9..000000000000 --- a/src/fixtures/config_upgrade_from_4.0.0.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "took": 1, - "timed_out": false, - "_shards": { - "total": 1, - "successful": 1, - "failed": 0 - }, - "hits": { - "total": 1, - "max_score": 1, - "hits": [ - { - "_index": ".kibana", - "_type": "config", - "_id": "4.0.0", - "_score": 1, - "_source": { - "buildNum": 5888, - "defaultIndex": "logstash-*" - } - } - ] - } -} diff --git a/src/fixtures/config_upgrade_from_4.0.0_to_4.0.1-snapshot.json b/src/fixtures/config_upgrade_from_4.0.0_to_4.0.1-snapshot.json deleted file mode 100644 index 8767232dcdc1..000000000000 --- a/src/fixtures/config_upgrade_from_4.0.0_to_4.0.1-snapshot.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "took": 1, - "timed_out": false, - "_shards": { - "total": 1, - "successful": 1, - "failed": 0 - }, - "hits": { - "total": 2, - "max_score": 1, - "hits": [ - { - "_index": ".kibana", - "_type": "config", - "_id": "4.0.1-SNAPSHOT", - "_score": 1, - "_source": { - "buildNum": 5921, - "defaultIndex": "logstash-*" - } - }, - { - "_index": ".kibana", - "_type": "config", - "_id": "4.0.0", - "_score": 1, - "_source": { - "buildNum": 5888, - "defaultIndex": "logstash-*" - } - } - ] - } -} diff --git a/src/fixtures/config_upgrade_from_4.0.0_to_4.0.1.json b/src/fixtures/config_upgrade_from_4.0.0_to_4.0.1.json deleted file mode 100644 index 57b486491b39..000000000000 --- a/src/fixtures/config_upgrade_from_4.0.0_to_4.0.1.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "took": 1, - "timed_out": false, - "_shards": { - "total": 1, - "successful": 1, - "failed": 0 - }, - "hits": { - "total": 2, - "max_score": 1, - "hits": [ - { - "_index": ".kibana", - "_type": "config", - "_id": "4.0.1", - "_score": 1, - "_source": { - "buildNum": 5921, - "defaultIndex": "logstash-*" - } - }, - { - "_index": ".kibana", - "_type": "config", - "_id": "4.0.0", - "_score": 1, - "_source": { - "buildNum": 5888, - "defaultIndex": "logstash-*" - } - } - ] - } -} diff --git a/src/fixtures/fake_chart_events.js b/src/fixtures/fake_chart_events.js deleted file mode 100644 index 71f49cb4713b..000000000000 --- a/src/fixtures/fake_chart_events.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -const results = {}; - -results.timeSeries = { - data: { - ordered: { - date: true, - interval: 600000, - max: 1414437217559, - min: 1414394017559, - }, - }, - label: 'apache', - value: 44, - point: { - label: 'apache', - x: 1414400400000, - y: 44, - y0: 0, - }, -}; diff --git a/src/fixtures/fake_hierarchical_data.ts b/src/fixtures/fake_hierarchical_data.ts deleted file mode 100644 index 2e23acfc3a80..000000000000 --- a/src/fixtures/fake_hierarchical_data.ts +++ /dev/null @@ -1,621 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -export 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/fixtures/field_mapping.js b/src/fixtures/field_mapping.js deleted file mode 100644 index 5077e361d545..000000000000 --- a/src/fixtures/field_mapping.js +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -export default { - test: { - mappings: { - testType: { - baz: { - full_name: 'baz', - mapping: { - bar: { - type: 'long', - }, - }, - }, - 'foo.bar': { - full_name: 'foo.bar', - mapping: { - bar: { - type: 'string', - }, - }, - }, - not_analyzed_field: { - full_name: 'not_analyzed_field', - mapping: { - bar: { - type: 'string', - index: 'not_analyzed', - }, - }, - }, - index_no_field: { - full_name: 'index_no_field', - mapping: { - bar: { - type: 'string', - index: 'no', - }, - }, - }, - _id: { - full_name: '_id', - mapping: { - _id: { - store: false, - index: 'no', - }, - }, - }, - _timestamp: { - full_name: '_timestamp', - mapping: { - _timestamp: { - store: true, - index: 'no', - }, - }, - }, - }, - }, - }, -}; diff --git a/src/fixtures/hits.js b/src/fixtures/hits.js deleted file mode 100644 index 6cbb080031cf..000000000000 --- a/src/fixtures/hits.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -export default function fitsFixture() { - return [ - // extension - // | machine.os - //timestamp | | bytes - //| ssl ip | | | request - [0, true, '192.168.0.1', 'php', 'Linux', 10, 'foo'], - [1, true, '192.168.0.1', 'php', 'Linux', 20, 'bar'], - [2, true, '192.168.0.1', 'php', 'Linux', 30, 'bar'], - [3, true, '192.168.0.1', 'php', 'Linux', 30, 'baz'], - [4, true, '192.168.0.1', 'php', 'Linux', 30, 'baz'], - [5, true, '192.168.0.1', 'php', 'Linux', 40.141592, 'bat'], - [6, true, '192.168.0.1', 'php', 'Linux', 40.141592, 'bat'], - [7, true, '192.168.0.1', 'php', 'Linux', 40.141592, 'bat'], - [8, true, '192.168.0.1', 'php', 'Linux', 40.141592, 'bat'], - [9, true, '192.168.0.1', 'php', 'Linux', 40.141592, 'bat'], - ].map((row, i) => { - return { - _score: 1, - _id: 1000 + i, - _type: 'test', - _index: 'test-index', - _source: { - '@timestamp': row[0], - ssl: row[1], - ip: row[2], - extension: row[3], - 'machine.os': row[4], - bytes: row[5], - request: row[6], - }, - }; - }); -} diff --git a/src/fixtures/mapping_with_dupes.js b/src/fixtures/mapping_with_dupes.js deleted file mode 100644 index 7f6da2600c9a..000000000000 --- a/src/fixtures/mapping_with_dupes.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -export default { - test: { - mappings: { - testType: { - baz: { - full_name: 'baz', - mapping: { - bar: { - type: 'long', - }, - }, - }, - 'foo.bar': { - full_name: 'foo.bar', - mapping: { - bar: { - type: 'string', - }, - }, - }, - }, - }, - }, - duplicates: { - mappings: { - testType: { - baz: { - full_name: 'baz', - mapping: { - bar: { - type: 'date', - }, - }, - }, - }, - }, - }, -}; diff --git a/src/fixtures/mock_index_patterns.js b/src/fixtures/mock_index_patterns.js deleted file mode 100644 index ce44b71613b0..000000000000 --- a/src/fixtures/mock_index_patterns.js +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import sinon from 'sinon'; -import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; - -export default function (Private) { - const indexPatterns = Private(FixturesStubbedLogstashIndexPatternProvider); - const getIndexPatternStub = sinon.stub().resolves(indexPatterns); - - return { - get: getIndexPatternStub, - }; -} diff --git a/src/fixtures/mock_state.js b/src/fixtures/mock_state.js deleted file mode 100644 index cb18dac7b767..000000000000 --- a/src/fixtures/mock_state.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import _ from 'lodash'; -import sinon from 'sinon'; - -function MockState(defaults) { - this.on = _.noop; - this.off = _.noop; - this.save = sinon.stub(); - this.replace = sinon.stub(); - _.assign(this, defaults); -} - -export default MockState; diff --git a/src/fixtures/mock_ui_state.js b/src/fixtures/mock_ui_state.js deleted file mode 100644 index fc0a18137a5f..000000000000 --- a/src/fixtures/mock_ui_state.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { set } from '@elastic/safer-lodash-set'; -import _ from 'lodash'; -let values = {}; -export default { - get: function (path, def) { - return _.get(values, path, def); - }, - set: function (path, val) { - set(values, path, val); - return val; - }, - setSilent: function (path, val) { - set(values, path, val); - return val; - }, - emit: _.noop, - on: _.noop, - off: _.noop, - clearAllKeys: function () { - values = {}; - }, - _reset: function () { - values = {}; - }, -}; diff --git a/src/fixtures/search_response.js b/src/fixtures/search_response.js deleted file mode 100644 index a84bd184990e..000000000000 --- a/src/fixtures/search_response.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import hits from 'fixtures/real_hits'; - -export default { - took: 73, - timed_out: false, - _shards: { - total: 144, - successful: 144, - failed: 0, - }, - hits: { - total: 49487, - max_score: 1.0, - hits: hits, - }, -}; diff --git a/src/fixtures/stubbed_search_source.js b/src/fixtures/stubbed_search_source.js deleted file mode 100644 index ea41e7bbe681..000000000000 --- a/src/fixtures/stubbed_search_source.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import sinon from 'sinon'; -import searchResponse from 'fixtures/search_response'; -import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; - -export default function stubSearchSource(Private, $q, Promise) { - let deferedResult = $q.defer(); - const indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); - - let onResultsCount = 0; - return { - setField: sinon.spy(), - fetch: sinon.spy(), - destroy: sinon.spy(), - getField: function (param) { - switch (param) { - case 'index': - return indexPattern; - default: - throw new Error(`Param "${param}" is not implemented in the stubbed search source`); - } - }, - crankResults: function () { - deferedResult.resolve(searchResponse); - deferedResult = $q.defer(); - }, - onResults: function () { - onResultsCount++; - - // Up to the test to resolve this manually - // For example: - // someHandler.resolve(require('fixtures/search_response')) - return deferedResult.promise; - }, - getOnResultsCount: function () { - return onResultsCount; - }, - _flatten: function () { - return Promise.resolve({ index: indexPattern, body: {} }); - }, - _requestStartHandlers: [], - onRequestStart(fn) { - this._requestStartHandlers.push(fn); - }, - requestIsStopped() {}, - }; -} diff --git a/src/fixtures/fake_row.js b/src/plugins/discover/public/__fixtures__/fake_row.js similarity index 100% rename from src/fixtures/fake_row.js rename to src/plugins/discover/public/__fixtures__/fake_row.js diff --git a/src/fixtures/logstash_fields.js b/src/plugins/discover/public/__fixtures__/logstash_fields.js similarity index 96% rename from src/fixtures/logstash_fields.js rename to src/plugins/discover/public/__fixtures__/logstash_fields.js index 6303c83d809c..a51e1555421d 100644 --- a/src/fixtures/logstash_fields.js +++ b/src/plugins/discover/public/__fixtures__/logstash_fields.js @@ -6,7 +6,8 @@ * Side Public License, v 1. */ -import { shouldReadFieldFromDocValues, castEsToKbnFieldTypeName } from '../plugins/data/server'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { shouldReadFieldFromDocValues, castEsToKbnFieldTypeName } from '../../../data/server'; function stubbedLogstashFields() { return [ diff --git a/src/fixtures/real_hits.js b/src/plugins/discover/public/__fixtures__/real_hits.js similarity index 100% rename from src/fixtures/real_hits.js rename to src/plugins/discover/public/__fixtures__/real_hits.js diff --git a/src/fixtures/stubbed_logstash_index_pattern.js b/src/plugins/discover/public/__fixtures__/stubbed_logstash_index_pattern.js similarity index 81% rename from src/fixtures/stubbed_logstash_index_pattern.js rename to src/plugins/discover/public/__fixtures__/stubbed_logstash_index_pattern.js index 3451fb5422ec..c8513176d1c9 100644 --- a/src/fixtures/stubbed_logstash_index_pattern.js +++ b/src/plugins/discover/public/__fixtures__/stubbed_logstash_index_pattern.js @@ -6,11 +6,12 @@ * Side Public License, v 1. */ -import stubbedLogstashFields from 'fixtures/logstash_fields'; +import stubbedLogstashFields from './logstash_fields'; +import { getKbnFieldType } from '../../../data/common'; -import { getKbnFieldType } from '../plugins/data/common'; -import { getStubIndexPattern } from '../plugins/data/public/test_utils'; -import { uiSettingsServiceMock } from '../core/public/ui_settings/ui_settings_service.mock'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getStubIndexPattern } from '../../../data/public/test_utils'; +import { uiSettingsServiceMock } from '../../../../core/public/mocks'; const uiSettingSetupMock = uiSettingsServiceMock.createSetupContract(); uiSettingSetupMock.get.mockImplementation((item, defaultValue) => { diff --git a/src/plugins/discover/public/__mocks__/stubbed_saved_object_index_pattern.ts b/src/plugins/discover/public/__mocks__/stubbed_saved_object_index_pattern.ts index b8ce93c45e54..a0c0b1f2c816 100644 --- a/src/plugins/discover/public/__mocks__/stubbed_saved_object_index_pattern.ts +++ b/src/plugins/discover/public/__mocks__/stubbed_saved_object_index_pattern.ts @@ -7,7 +7,7 @@ */ // @ts-expect-error -import stubbedLogstashFields from '../../../../fixtures/logstash_fields'; +import stubbedLogstashFields from '../__fixtures__/logstash_fields'; const mockLogstashFields = stubbedLogstashFields(); diff --git a/src/plugins/discover/public/application/angular/doc_table/components/row_headers.test.js b/src/plugins/discover/public/application/angular/doc_table/components/row_headers.test.js index 33772f730912..1824110c85b1 100644 --- a/src/plugins/discover/public/application/angular/doc_table/components/row_headers.test.js +++ b/src/plugins/discover/public/application/angular/doc_table/components/row_headers.test.js @@ -12,9 +12,9 @@ import 'angular-sanitize'; import 'angular-route'; import _ from 'lodash'; import sinon from 'sinon'; -import { getFakeRow } from 'fixtures/fake_row'; +import { getFakeRow } from '../../../../__fixtures__/fake_row'; import $ from 'jquery'; -import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; +import FixturesStubbedLogstashIndexPatternProvider from '../../../../__fixtures__/stubbed_logstash_index_pattern'; import { setScopedHistory, setServices, setDocViewsRegistry } from '../../../../kibana_services'; import { coreMock } from '../../../../../../../core/public/mocks'; import { dataPluginMock } from '../../../../../../data/public/mocks'; diff --git a/src/plugins/discover/public/application/angular/doc_table/doc_table.test.js b/src/plugins/discover/public/application/angular/doc_table/doc_table.test.js index cec8d72fbe77..1765bae07eed 100644 --- a/src/plugins/discover/public/application/angular/doc_table/doc_table.test.js +++ b/src/plugins/discover/public/application/angular/doc_table/doc_table.test.js @@ -12,8 +12,8 @@ import 'angular-mocks'; import 'angular-sanitize'; import 'angular-route'; import { createBrowserHistory } from 'history'; -import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; -import hits from 'fixtures/real_hits'; +import FixturesStubbedLogstashIndexPatternProvider from '../../../__fixtures__/stubbed_logstash_index_pattern'; +import hits from '../../../__fixtures__/real_hits'; import { coreMock } from '../../../../../../core/public/mocks'; import { dataPluginMock } from '../../../../../data/public/mocks'; import { navigationPluginMock } from '../../../../../navigation/public/mocks'; diff --git a/src/plugins/discover/public/application/angular/doc_table/lib/get_default_sort.test.ts b/src/plugins/discover/public/application/angular/doc_table/lib/get_default_sort.test.ts index 899c3cc2d413..c73656435fb5 100644 --- a/src/plugins/discover/public/application/angular/doc_table/lib/get_default_sort.test.ts +++ b/src/plugins/discover/public/application/angular/doc_table/lib/get_default_sort.test.ts @@ -8,7 +8,7 @@ import { getDefaultSort } from './get_default_sort'; // @ts-ignore -import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; +import FixturesStubbedLogstashIndexPatternProvider from '../../../../__fixtures__/stubbed_logstash_index_pattern'; import { IndexPattern } from '../../../../kibana_services'; describe('getDefaultSort function', function () { diff --git a/src/plugins/discover/public/application/angular/doc_table/lib/get_sort.test.ts b/src/plugins/discover/public/application/angular/doc_table/lib/get_sort.test.ts index cf8fa67e5456..bd28987b4fdb 100644 --- a/src/plugins/discover/public/application/angular/doc_table/lib/get_sort.test.ts +++ b/src/plugins/discover/public/application/angular/doc_table/lib/get_sort.test.ts @@ -8,7 +8,7 @@ import { getSort, getSortArray } from './get_sort'; // @ts-ignore -import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; +import FixturesStubbedLogstashIndexPatternProvider from '../../../../__fixtures__/stubbed_logstash_index_pattern'; import { IndexPattern } from '../../../../kibana_services'; describe('docTable', function () { diff --git a/src/plugins/discover/public/application/angular/doc_table/lib/get_sort_for_search_source.test.ts b/src/plugins/discover/public/application/angular/doc_table/lib/get_sort_for_search_source.test.ts index 1d965a176b99..f0a13557af9f 100644 --- a/src/plugins/discover/public/application/angular/doc_table/lib/get_sort_for_search_source.test.ts +++ b/src/plugins/discover/public/application/angular/doc_table/lib/get_sort_for_search_source.test.ts @@ -8,7 +8,7 @@ import { getSortForSearchSource } from './get_sort_for_search_source'; // @ts-ignore -import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; +import FixturesStubbedLogstashIndexPatternProvider from '../../../../__fixtures__/stubbed_logstash_index_pattern'; import { IndexPattern } from '../../../../kibana_services'; import { SortOrder } from '../components/table_header/helpers'; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field.test.tsx index baec882fc624..c16dab618b28 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { findTestSubject } from '@elastic/eui/lib/test'; // @ts-ignore -import stubbedLogstashFields from 'fixtures/logstash_fields'; +import stubbedLogstashFields from '../../../__fixtures__/logstash_fields'; import { mountWithIntl } from '@kbn/test/jest'; import { DiscoverField } from './discover_field'; import { coreMock } from '../../../../../../core/public/mocks'; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_details.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field_details.test.tsx index 29bd4ce5b2b7..0113213f70c8 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field_details.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_details.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { findTestSubject } from '@elastic/eui/lib/test'; // @ts-ignore -import stubbedLogstashFields from 'fixtures/logstash_fields'; +import stubbedLogstashFields from '../../../__fixtures__/logstash_fields'; import { mountWithIntl } from '@kbn/test/jest'; import { DiscoverFieldDetails } from './discover_field_details'; import { coreMock } from '../../../../../../core/public/mocks'; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_details_footer.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field_details_footer.test.tsx index a82c3d740e7e..07baeddf034e 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field_details_footer.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_details_footer.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { findTestSubject } from '@elastic/eui/lib/test'; // @ts-ignore -import stubbedLogstashFields from 'fixtures/logstash_fields'; +import stubbedLogstashFields from '../../../__fixtures__/logstash_fields'; import { mountWithIntl } from '@kbn/test/jest'; import { coreMock } from '../../../../../../core/public/mocks'; import { IndexPatternField } from '../../../../../data/public'; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx index 0ff70585af14..947972ce1cfc 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx @@ -10,9 +10,9 @@ import { each, cloneDeep } from 'lodash'; import { ReactWrapper } from 'enzyme'; import { findTestSubject } from '@elastic/eui/lib/test'; // @ts-ignore -import realHits from 'fixtures/real_hits.js'; +import realHits from '../../../__fixtures__/real_hits.js'; // @ts-ignore -import stubbedLogstashFields from 'fixtures/logstash_fields'; +import stubbedLogstashFields from '../../../__fixtures__/logstash_fields'; import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { DiscoverSidebarProps } from './discover_sidebar'; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx index 02ab5abade7f..7b12ab5f9bcd 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx @@ -10,9 +10,9 @@ import { each, cloneDeep } from 'lodash'; import { ReactWrapper } from 'enzyme'; import { findTestSubject } from '@elastic/eui/lib/test'; // @ts-ignore -import realHits from 'fixtures/real_hits.js'; +import realHits from '../../../__fixtures__/real_hits.js'; // @ts-ignore -import stubbedLogstashFields from 'fixtures/logstash_fields'; +import stubbedLogstashFields from '../../../__fixtures__/logstash_fields'; import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { coreMock } from '../../../../../../core/public/mocks'; diff --git a/src/plugins/discover/public/application/components/sidebar/lib/field_calculator.test.ts b/src/plugins/discover/public/application/components/sidebar/lib/field_calculator.test.ts index 94464c309251..faa31dde1bb8 100644 --- a/src/plugins/discover/public/application/components/sidebar/lib/field_calculator.test.ts +++ b/src/plugins/discover/public/application/components/sidebar/lib/field_calculator.test.ts @@ -8,9 +8,9 @@ import _ from 'lodash'; // @ts-ignore -import realHits from 'fixtures/real_hits.js'; +import realHits from '../../../../__fixtures__/real_hits.js'; // @ts-ignore -import stubbedLogstashFields from 'fixtures/logstash_fields'; +import stubbedLogstashFields from '../../../../__fixtures__/logstash_fields'; import { coreMock } from '../../../../../../../core/public/mocks'; import { IndexPattern } from '../../../../../../data/public'; import { getStubIndexPattern } from '../../../../../../data/public/test_utils'; diff --git a/src/plugins/visualizations/public/__fixtures__/logstash_fields.js b/src/plugins/visualizations/public/__fixtures__/logstash_fields.js new file mode 100644 index 000000000000..a51e1555421d --- /dev/null +++ b/src/plugins/visualizations/public/__fixtures__/logstash_fields.js @@ -0,0 +1,75 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { shouldReadFieldFromDocValues, castEsToKbnFieldTypeName } from '../../../data/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/visualizations/public/__fixtures__/stubbed_logstash_index_pattern.js b/src/plugins/visualizations/public/__fixtures__/stubbed_logstash_index_pattern.js new file mode 100644 index 000000000000..c8513176d1c9 --- /dev/null +++ b/src/plugins/visualizations/public/__fixtures__/stubbed_logstash_index_pattern.js @@ -0,0 +1,47 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import stubbedLogstashFields from './logstash_fields'; +import { getKbnFieldType } from '../../../data/common'; + +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getStubIndexPattern } from '../../../data/public/test_utils'; +import { uiSettingsServiceMock } from '../../../../core/public/mocks'; + +const uiSettingSetupMock = uiSettingsServiceMock.createSetupContract(); +uiSettingSetupMock.get.mockImplementation((item, defaultValue) => { + return defaultValue; +}); + +export default function stubbedLogstashIndexPatternService() { + const mockLogstashFields = stubbedLogstashFields(); + + const fields = mockLogstashFields.map(function (field) { + const kbnType = getKbnFieldType(field.type); + + if (!kbnType || kbnType.name === 'unknown') { + throw new TypeError(`unknown type ${field.type}`); + } + + return { + ...field, + sortable: 'sortable' in field ? !!field.sortable : kbnType.sortable, + filterable: 'filterable' in field ? !!field.filterable : kbnType.filterable, + displayName: field.name, + }; + }); + + const indexPattern = getStubIndexPattern('logstash-*', (cfg) => cfg, 'time', fields, { + uiSettings: uiSettingSetupMock, + }); + + indexPattern.id = 'logstash-*'; + indexPattern.isTimeNanosBased = () => false; + + return indexPattern; +} diff --git a/src/plugins/visualizations/public/vis.test.ts b/src/plugins/visualizations/public/vis.test.ts index b90e5effeb8a..45c5bb6b979c 100644 --- a/src/plugins/visualizations/public/vis.test.ts +++ b/src/plugins/visualizations/public/vis.test.ts @@ -26,7 +26,7 @@ jest.mock('./services', () => { // eslint-disable-next-line const { SearchSource } = require('../../data/common/search/search_source'); // eslint-disable-next-line - const fixturesStubbedLogstashIndexPatternProvider = require('../../../fixtures/stubbed_logstash_index_pattern'); + const fixturesStubbedLogstashIndexPatternProvider = require('./__fixtures__/stubbed_logstash_index_pattern'); const visType = new BaseVisType({ name: 'pie', title: 'pie', diff --git a/src/type_definitions/react_virtualized.d.ts b/src/type_definitions/react_virtualized.d.ts deleted file mode 100644 index d78a159b7156..000000000000 --- a/src/type_definitions/react_virtualized.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -declare module 'react-virtualized' { - export type ListProps = any; -} diff --git a/tsconfig.base.json b/tsconfig.base.json index f8e07911e71c..c63d43b4cb6a 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -5,8 +5,7 @@ // Allows for importing from `kibana` package for the exported types. "kibana": ["./kibana"], "kibana/public": ["src/core/public"], - "kibana/server": ["src/core/server"], - "fixtures/*": ["src/fixtures/*"] + "kibana/server": ["src/core/server"] }, // Support .tsx files and transform JSX into calls to React.createElement "jsx": "react", diff --git a/tsconfig.json b/tsconfig.json index f6e0fbc8d9e9..48feac3efe47 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,65 +7,7 @@ "exclude": [ "src/**/__fixtures__/**/*", "src/core/**/*", - "src/plugins/telemetry_management_section/**/*", - "src/plugins/advanced_settings/**/*", - "src/plugins/apm_oss/**/*", - "src/plugins/bfetch/**/*", - "src/plugins/charts/**/*", - "src/plugins/console/**/*", - "src/plugins/dashboard/**/*", - "src/plugins/discover/**/*", - "src/plugins/data/**/*", - "src/plugins/dev_tools/**/*", - "src/plugins/embeddable/**/*", - "src/plugins/es_ui_shared/**/*", - "src/plugins/expressions/**/*", - "src/plugins/home/**/*", - "src/plugins/input_control_vis/**/*", - "src/plugins/inspector/**/*", - "src/plugins/kibana_legacy/**/*", - "src/plugins/kibana_overview/**/*", - "src/plugins/kibana_react/**/*", - "src/plugins/kibana_usage_collection/**/*", - "src/plugins/kibana_utils/**/*", - "src/plugins/legacy_export/**/*", - "src/plugins/management/**/*", - "src/plugins/maps_legacy/**/*", - "src/plugins/navigation/**/*", - "src/plugins/newsfeed/**/*", - "src/plugins/region_map/**/*", - "src/plugins/saved_objects/**/*", - "src/plugins/saved_objects_management/**/*", - "src/plugins/saved_objects_tagging_oss/**/*", - "src/plugins/security_oss/**/*", - "src/plugins/share/**/*", - "src/plugins/spaces_oss/**/*", - "src/plugins/telemetry/**/*", - "src/plugins/telemetry_collection_manager/**/*", - "src/plugins/tile_map/**/*", - "src/plugins/timelion/**/*", - "src/plugins/ui_actions/**/*", - "src/plugins/url_forwarding/**/*", - "src/plugins/usage_collection/**/*", - "src/plugins/presentation_util/**/*", - "src/plugins/vis_default_editor/**/*", - "src/plugins/vis_type_markdown/**/*", - "src/plugins/vis_type_metric/**/*", - "src/plugins/vis_type_table/**/*", - "src/plugins/vis_type_tagcloud/**/*", - "src/plugins/vis_type_timelion/**/*", - "src/plugins/vis_type_timeseries/**/*", - "src/plugins/vis_type_vislib/**/*", - "src/plugins/vis_type_vega/**/*", - "src/plugins/vis_type_xy/**/*", - "src/plugins/visualizations/**/*", - "src/plugins/visualize/**/*", - "src/plugins/index_pattern_management/**/*", - // In the build we actually exclude **/public/**/* from this config so that - // we can run the TSC on both this and the .browser version of this config - // file, but if we did it during development IDEs would not be able to find - // the tsconfig.json file for public files correctly. - // "src/**/public/**/*" + "src/plugins/**/*" ], "references": [ { "path": "./src/core/tsconfig.json" }, diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/use_request.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/use_request.ts index 33c993ffdad4..4c4433c2b4f8 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/use_request.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/use_request.ts @@ -19,7 +19,10 @@ let httpClient: HttpSetup; export type UseRequestConfig = _UseRequestConfig; -interface RequestError extends Error { +/** + * @internal + */ +export interface RequestError extends Error { statusCode?: number; } diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/fleet_start_services.tsx b/x-pack/plugins/fleet/public/applications/fleet/mock/fleet_start_services.tsx index 72e6601a023e..d219384f66ce 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/mock/fleet_start_services.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/mock/fleet_start_services.tsx @@ -7,10 +7,10 @@ import React from 'react'; import { I18nProvider } from '@kbn/i18n/react'; +import { MockedKeys } from '@kbn/utility-types/jest'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { createStartDepsMock } from './plugin_dependencies'; import { IStorage, Storage } from '../../../../../../../src/plugins/kibana_utils/public'; -import { MockedKeys } from '../../../../../../../packages/kbn-utility-types/jest/index'; import { setHttpClient } from '../hooks/use_request'; import { MockedFleetStartServices } from './types'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/types.ts b/x-pack/plugins/fleet/public/applications/fleet/mock/types.ts index 9e0adf75c0a3..0a55fa43bf18 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/mock/types.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/mock/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { MockedKeys } from '../../../../../../../packages/kbn-utility-types/jest/index'; +import { MockedKeys } from '@kbn/utility-types/jest'; import { FleetSetupDeps, FleetStart, FleetStartDeps, FleetStartServices } from '../../../plugin'; export type MockedFleetStartServices = MockedKeys; diff --git a/x-pack/plugins/fleet/server/mocks.ts b/x-pack/plugins/fleet/server/mocks.ts index 92159c1ced7c..c650995c809c 100644 --- a/x-pack/plugins/fleet/server/mocks.ts +++ b/x-pack/plugins/fleet/server/mocks.ts @@ -10,6 +10,9 @@ import { loggingSystemMock, savedObjectsServiceMock, } from 'src/core/server/mocks'; +import { coreMock } from '../../../../src/core/server/mocks'; +import { licensingMock } from '../../../plugins/licensing/server/mocks'; + import { FleetAppContext } from './plugin'; import { encryptedSavedObjectsMock } from '../../encrypted_saved_objects/server/mocks'; import { securityMock } from '../../security/server/mocks'; @@ -29,6 +32,17 @@ export const createAppContextStartContractMock = (): FleetAppContext => { }; }; +function createCoreRequestHandlerContextMock() { + return { + core: coreMock.createRequestHandlerContext(), + licensing: licensingMock.createRequestHandlerContext(), + }; +} + +export const xpackMocks = { + createRequestHandlerContext: createCoreRequestHandlerContextMock, +}; + export const createPackagePolicyServiceMock = () => { return { compilePackagePolicyInputs: jest.fn(), diff --git a/x-pack/plugins/fleet/server/routes/limited_concurrency.ts b/x-pack/plugins/fleet/server/routes/limited_concurrency.ts index 45af0a3b7eaa..92195ae08681 100644 --- a/x-pack/plugins/fleet/server/routes/limited_concurrency.ts +++ b/x-pack/plugins/fleet/server/routes/limited_concurrency.ts @@ -5,11 +5,12 @@ * 2.0. */ -import { +import type { CoreSetup, KibanaRequest, LifecycleResponseFactory, OnPreAuthToolkit, + OnPreAuthHandler, } from 'kibana/server'; import { LIMITED_CONCURRENCY_ROUTE_TAG } from '../../common'; import { FleetConfigType } from '../index'; @@ -48,7 +49,7 @@ export function createLimitedPreAuthHandler({ }: { isMatch: (request: KibanaRequest) => boolean; maxCounter: IMaxCounter; -}) { +}): OnPreAuthHandler { return function preAuthHandler( request: KibanaRequest, response: LifecycleResponseFactory, diff --git a/x-pack/plugins/fleet/server/routes/package_policy/handlers.test.ts b/x-pack/plugins/fleet/server/routes/package_policy/handlers.test.ts index df99f2fba7ed..2b44975cc3b4 100644 --- a/x-pack/plugins/fleet/server/routes/package_policy/handlers.test.ts +++ b/x-pack/plugins/fleet/server/routes/package_policy/handlers.test.ts @@ -9,9 +9,8 @@ import { httpServerMock, httpServiceMock } from 'src/core/server/mocks'; import { IRouter, KibanaRequest, RequestHandler, RouteConfig } from 'kibana/server'; import { registerRoutes } from './index'; import { PACKAGE_POLICY_API_ROUTES } from '../../../common/constants'; -import { xpackMocks } from '../../../../../mocks'; import { appContextService } from '../../services'; -import { createAppContextStartContractMock } from '../../mocks'; +import { createAppContextStartContractMock, xpackMocks } from '../../mocks'; import { PackagePolicyServiceInterface, ExternalCallback } from '../..'; import { CreatePackagePolicyRequestSchema } from '../../types/rest_spec'; import { packagePolicyService } from '../../services'; diff --git a/x-pack/plugins/fleet/server/routes/setup/handlers.test.ts b/x-pack/plugins/fleet/server/routes/setup/handlers.test.ts index af9596849fd7..946f17ad8129 100644 --- a/x-pack/plugins/fleet/server/routes/setup/handlers.test.ts +++ b/x-pack/plugins/fleet/server/routes/setup/handlers.test.ts @@ -5,11 +5,10 @@ * 2.0. */ -import { xpackMocks } from '../../../../../../x-pack/mocks'; import { httpServerMock } from 'src/core/server/mocks'; import { PostIngestSetupResponse } from '../../../common'; import { RegistryError } from '../../errors'; -import { createAppContextStartContractMock } from '../../mocks'; +import { createAppContextStartContractMock, xpackMocks } from '../../mocks'; import { FleetSetupHandler } from './handlers'; import { appContextService } from '../../services/app_context'; import { setupIngestManager } from '../../services/setup'; diff --git a/x-pack/plugins/fleet/server/saved_objects/index.ts b/x-pack/plugins/fleet/server/saved_objects/index.ts index d50db8d9809f..f2eb8be5c030 100644 --- a/x-pack/plugins/fleet/server/saved_objects/index.ts +++ b/x-pack/plugins/fleet/server/saved_objects/index.ts @@ -10,7 +10,8 @@ import { EncryptedSavedObjectsPluginSetup } from '../../../encrypted_saved_objec import { migratePackagePolicyToV7110, migratePackagePolicyToV7120, -} from '../../../security_solution/common'; + // @ts-expect-error +} from './security_solution'; import { OUTPUT_SAVED_OBJECT_TYPE, AGENT_POLICY_SAVED_OBJECT_TYPE, diff --git a/x-pack/plugins/fleet/server/saved_objects/security_solution.js b/x-pack/plugins/fleet/server/saved_objects/security_solution.js new file mode 100644 index 000000000000..63f70ba783c0 --- /dev/null +++ b/x-pack/plugins/fleet/server/saved_objects/security_solution.js @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { + migratePackagePolicyToV7110, + migratePackagePolicyToV7120, +} from '../../../security_solution/common'; diff --git a/x-pack/plugins/fleet/server/services/app_context.ts b/x-pack/plugins/fleet/server/services/app_context.ts index f63282f8ed7c..02e4fceea54f 100644 --- a/x-pack/plugins/fleet/server/services/app_context.ts +++ b/x-pack/plugins/fleet/server/services/app_context.ts @@ -7,6 +7,8 @@ import { BehaviorSubject, Observable } from 'rxjs'; import { first } from 'rxjs/operators'; +import { kibanaPackageJSON } from '@kbn/utils'; + import { ElasticsearchClient, SavedObjectsServiceStart, @@ -18,7 +20,6 @@ import { EncryptedSavedObjectsClient, EncryptedSavedObjectsPluginSetup, } from '../../../encrypted_saved_objects/server'; -import packageJSON from '../../../../../package.json'; import { SecurityPluginStart } from '../../../security/server'; import { FleetConfigType } from '../../common'; import { ExternalCallback, ExternalCallbacksStorage, FleetAppContext } from '../plugin'; @@ -33,8 +34,8 @@ class AppContextService { private configSubject$?: BehaviorSubject; private savedObjects: SavedObjectsServiceStart | undefined; private isProductionMode: FleetAppContext['isProductionMode'] = false; - private kibanaVersion: FleetAppContext['kibanaVersion'] = packageJSON.version; - private kibanaBranch: FleetAppContext['kibanaBranch'] = packageJSON.branch; + private kibanaVersion: FleetAppContext['kibanaVersion'] = kibanaPackageJSON.version; + private kibanaBranch: FleetAppContext['kibanaBranch'] = kibanaPackageJSON.branch; private cloud?: CloudSetup; private logger: Logger | undefined; private httpSetup?: HttpServiceSetup; diff --git a/x-pack/plugins/fleet/server/services/package_policy.test.ts b/x-pack/plugins/fleet/server/services/package_policy.test.ts index 1f2666dc14d1..604592a0a8d8 100644 --- a/x-pack/plugins/fleet/server/services/package_policy.test.ts +++ b/x-pack/plugins/fleet/server/services/package_policy.test.ts @@ -12,10 +12,9 @@ import { PackageInfo, PackagePolicySOAttributes } from '../types'; import { SavedObjectsUpdateResponse } from 'src/core/server'; import { httpServerMock } from 'src/core/server/mocks'; import { KibanaRequest } from 'kibana/server'; -import { xpackMocks } from '../../../../mocks'; import { ExternalCallback } from '..'; import { appContextService } from './app_context'; -import { createAppContextStartContractMock } from '../mocks'; +import { createAppContextStartContractMock, xpackMocks } from '../mocks'; async function mockedGetAssetsData(_a: any, _b: any, dataset: string) { if (dataset === 'dataset1') { diff --git a/x-pack/plugins/fleet/server/services/package_policy.ts b/x-pack/plugins/fleet/server/services/package_policy.ts index 8d1ac90f3ec1..a882ceb0037f 100644 --- a/x-pack/plugins/fleet/server/services/package_policy.ts +++ b/x-pack/plugins/fleet/server/services/package_policy.ts @@ -565,3 +565,5 @@ async function _compilePackageStream( export type PackagePolicyServiceInterface = PackagePolicyService; export const packagePolicyService = new PackagePolicyService(); + +export type { PackagePolicyService }; diff --git a/x-pack/plugins/fleet/server/services/setup.test.ts b/x-pack/plugins/fleet/server/services/setup.test.ts index a4df30b97a44..479f28fa0a1e 100644 --- a/x-pack/plugins/fleet/server/services/setup.test.ts +++ b/x-pack/plugins/fleet/server/services/setup.test.ts @@ -5,8 +5,7 @@ * 2.0. */ -import { xpackMocks } from '../../../../../x-pack/mocks'; -import { createAppContextStartContractMock } from '../mocks'; +import { createAppContextStartContractMock, xpackMocks } from '../mocks'; import { appContextService } from './app_context'; import { setupIngestManager } from './setup'; diff --git a/x-pack/plugins/fleet/tsconfig.json b/x-pack/plugins/fleet/tsconfig.json index 3a37b1441042..152fb2e132f6 100644 --- a/x-pack/plugins/fleet/tsconfig.json +++ b/x-pack/plugins/fleet/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "composite": true, "outDir": "./target/types", @@ -12,7 +12,9 @@ "common/**/*", "public/**/*", "server/**/*", - "scripts/**/*" + "scripts/**/*", + "package.json", + "../../typings/**/*" ], "references": [ { "path": "../../../src/core/tsconfig.json" }, diff --git a/x-pack/plugins/osquery/tsconfig.json b/x-pack/plugins/osquery/tsconfig.json index 616783376258..407830d6a6c2 100644 --- a/x-pack/plugins/osquery/tsconfig.json +++ b/x-pack/plugins/osquery/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "composite": true, "outDir": "./target/types", diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 6b874f625384..2c475083b589 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -1,69 +1,24 @@ { "extends": "../tsconfig.base.json", - "include": ["mocks.ts", "typings/**/*", "plugins/**/*", "tasks/**/*"], + "include": [ + "mocks.ts", + "typings/**/*", + "tasks/**/*", + "plugins/apm/**/*", + "plugins/case/**/*", + "plugins/lists/**/*", + "plugins/logstash/**/*", + "plugins/monitoring/**/*", + "plugins/security_solution/**/*", + "plugins/xpack_legacy/**/*", + "plugins/drilldowns/url_drilldown/**/*" + ], "exclude": [ - "plugins/actions/**/*", - "plugins/alerts/**/*", + "test/**/*", "plugins/apm/e2e/cypress/**/*", "plugins/apm/ftr_e2e/**/*", "plugins/apm/scripts/**/*", - "plugins/banners/**/*", - "plugins/canvas/**/*", - "plugins/console_extensions/**/*", - "plugins/code/**/*", - "plugins/data_enhanced/**/*", - "plugins/discover_enhanced/**/*", - "plugins/dashboard_mode/**/*", - "plugins/dashboard_enhanced/**/*", - "plugins/fleet/**/*", - "plugins/global_search/**/*", - "plugins/global_search_providers/**/*", - "plugins/graph/**/*", - "plugins/features/**/*", - "plugins/file_upload/**/*", - "plugins/embeddable_enhanced/**/*", - "plugins/event_log/**/*", - "plugins/enterprise_search/**/*", - "plugins/infra/**/*", - "plugins/licensing/**/*", - "plugins/lens/**/*", - "plugins/maps/**/*", - "plugins/maps_legacy_licensing/**/*", - "plugins/ml/**/*", - "plugins/observability/**/*", - "plugins/osquery/**/*", - "plugins/reporting/**/*", - "plugins/searchprofiler/**/*", - "plugins/security_solution/cypress/**/*", - "plugins/task_manager/**/*", - "plugins/telemetry_collection_xpack/**/*", - "plugins/transform/**/*", - "plugins/translations/**/*", - "plugins/triggers_actions_ui/**/*", - "plugins/ui_actions_enhanced/**/*", - "plugins/spaces/**/*", - "plugins/security/**/*", - "plugins/stack_alerts/**/*", - "plugins/encrypted_saved_objects/**/*", - "plugins/beats_management/**/*", - "plugins/cloud/**/*", - "plugins/saved_objects_tagging/**/*", - "plugins/global_search_bar/**/*", - "plugins/ingest_pipelines/**/*", - "plugins/license_management/**/*", - "plugins/snapshot_restore/**/*", - "plugins/painless_lab/**/*", - "plugins/watcher/**/*", - "plugins/runtime_fields/**/*", - "plugins/index_management/**/*", - "plugins/grokdebugger/**/*", - "plugins/upgrade_assistant/**/*", - "plugins/rollup/**/*", - "plugins/remote_clusters/**/*", - "plugins/cross_cluster_replication/**/*", - "plugins/index_lifecycle_management/**/*", - "plugins/uptime/**/*", - "test/**/*" + "plugins/security_solution/cypress/**/*" ], "compilerOptions": { // overhead is too significant @@ -121,6 +76,7 @@ { "path": "./plugins/event_log/tsconfig.json" }, { "path": "./plugins/features/tsconfig.json" }, { "path": "./plugins/file_upload/tsconfig.json" }, + { "path": "./plugins/fleet/tsconfig.json" }, { "path": "./plugins/global_search_bar/tsconfig.json" }, { "path": "./plugins/global_search_providers/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" },