diff --git a/.buildkite/scripts/lifecycle/pre_command.sh b/.buildkite/scripts/lifecycle/pre_command.sh index cae6a07708d4..7016cf41d79e 100755 --- a/.buildkite/scripts/lifecycle/pre_command.sh +++ b/.buildkite/scripts/lifecycle/pre_command.sh @@ -9,7 +9,7 @@ export BUILDKITE_TOKEN echo '--- Install buildkite dependencies' cd '.buildkite' -retry 5 15 yarn install +retry 5 15 yarn install --production --pure-lockfile cd - node .buildkite/scripts/lifecycle/print_agent_links.js || true diff --git a/.buildkite/yarn.lock b/.buildkite/yarn.lock new file mode 100644 index 000000000000..0b92d21c87e2 --- /dev/null +++ b/.buildkite/yarn.lock @@ -0,0 +1,208 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@octokit/auth-token@^2.4.4": + version "2.4.4" + resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.4.tgz#ee31c69b01d0378c12fd3ffe406030f3d94d3b56" + integrity sha512-LNfGu3Ro9uFAYh10MUZVaT7X2CnNm2C8IDQmabx+3DygYIQjs9FwzFAHN/0t6mu5HEPhxcb1XOuxdpY82vCg2Q== + dependencies: + "@octokit/types" "^6.0.0" + +"@octokit/core@^3.5.1": + version "3.5.1" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.5.1.tgz#8601ceeb1ec0e1b1b8217b960a413ed8e947809b" + integrity sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw== + dependencies: + "@octokit/auth-token" "^2.4.4" + "@octokit/graphql" "^4.5.8" + "@octokit/request" "^5.6.0" + "@octokit/request-error" "^2.0.5" + "@octokit/types" "^6.0.3" + before-after-hook "^2.2.0" + universal-user-agent "^6.0.0" + +"@octokit/endpoint@^6.0.1": + version "6.0.6" + resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.6.tgz#4f09f2b468976b444742a1d5069f6fa45826d999" + integrity sha512-7Cc8olaCoL/mtquB7j/HTbPM+sY6Ebr4k2X2y4JoXpVKQ7r5xB4iGQE0IoO58wIPsUk4AzoT65AMEpymSbWTgQ== + dependencies: + "@octokit/types" "^5.0.0" + is-plain-object "^5.0.0" + universal-user-agent "^6.0.0" + +"@octokit/graphql@^4.5.8": + version "4.5.8" + resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.5.8.tgz#d42373633c3015d0eafce64a8ce196be167fdd9b" + integrity sha512-WnCtNXWOrupfPJgXe+vSmprZJUr0VIu14G58PMlkWGj3cH+KLZEfKMmbUQ6C3Wwx6fdhzVW1CD5RTnBdUHxhhA== + dependencies: + "@octokit/request" "^5.3.0" + "@octokit/types" "^6.0.0" + universal-user-agent "^6.0.0" + +"@octokit/openapi-types@^11.2.0": + version "11.2.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-11.2.0.tgz#b38d7fc3736d52a1e96b230c1ccd4a58a2f400a6" + integrity sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA== + +"@octokit/openapi-types@^2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-2.2.0.tgz#123e0438a0bc718ccdac3b5a2e69b3dd00daa85b" + integrity sha512-274lNUDonw10kT8wHg8fCcUc1ZjZHbWv0/TbAwb0ojhBQqZYc1cQ/4yqTVTtPMDeZ//g7xVEYe/s3vURkRghPg== + +"@octokit/plugin-paginate-rest@^2.16.8": + version "2.17.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.17.0.tgz#32e9c7cab2a374421d3d0de239102287d791bce7" + integrity sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw== + dependencies: + "@octokit/types" "^6.34.0" + +"@octokit/plugin-request-log@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz#5e50ed7083a613816b1e4a28aeec5fb7f1462e85" + integrity sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA== + +"@octokit/plugin-rest-endpoint-methods@^5.12.0": + version "5.13.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.13.0.tgz#8c46109021a3412233f6f50d28786f8e552427ba" + integrity sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA== + dependencies: + "@octokit/types" "^6.34.0" + deprecation "^2.3.1" + +"@octokit/request-error@^2.0.0": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.0.2.tgz#0e76b83f5d8fdda1db99027ea5f617c2e6ba9ed0" + integrity sha512-2BrmnvVSV1MXQvEkrb9zwzP0wXFNbPJij922kYBTLIlIafukrGOb+ABBT2+c6wZiuyWDH1K1zmjGQ0toN/wMWw== + dependencies: + "@octokit/types" "^5.0.1" + deprecation "^2.0.0" + once "^1.4.0" + +"@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677" + integrity sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg== + dependencies: + "@octokit/types" "^6.0.3" + deprecation "^2.0.0" + once "^1.4.0" + +"@octokit/request@^5.3.0": + version "5.4.12" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.12.tgz#b04826fa934670c56b135a81447be2c1723a2ffc" + integrity sha512-MvWYdxengUWTGFpfpefBBpVmmEYfkwMoxonIB3sUGp5rhdgwjXL1ejo6JbgzG/QD9B/NYt/9cJX1pxXeSIUCkg== + dependencies: + "@octokit/endpoint" "^6.0.1" + "@octokit/request-error" "^2.0.0" + "@octokit/types" "^6.0.3" + deprecation "^2.0.0" + is-plain-object "^5.0.0" + node-fetch "^2.6.1" + once "^1.4.0" + universal-user-agent "^6.0.0" + +"@octokit/request@^5.6.0": + version "5.6.2" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.2.tgz#1aa74d5da7b9e04ac60ef232edd9a7438dcf32d8" + integrity sha512-je66CvSEVf0jCpRISxkUcCa0UkxmFs6eGDRSbfJtAVwbLH5ceqF+YEyC8lj8ystKyZTy8adWr0qmkY52EfOeLA== + dependencies: + "@octokit/endpoint" "^6.0.1" + "@octokit/request-error" "^2.1.0" + "@octokit/types" "^6.16.1" + is-plain-object "^5.0.0" + node-fetch "^2.6.1" + universal-user-agent "^6.0.0" + +"@octokit/rest@^18.10.0": + version "18.12.0" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.12.0.tgz#f06bc4952fc87130308d810ca9d00e79f6988881" + integrity sha512-gDPiOHlyGavxr72y0guQEhLsemgVjwRePayJ+FcKc2SJqKUbxbkvf5kAZEWA/MKvsfYlQAMVzNJE3ezQcxMJ2Q== + dependencies: + "@octokit/core" "^3.5.1" + "@octokit/plugin-paginate-rest" "^2.16.8" + "@octokit/plugin-request-log" "^1.0.4" + "@octokit/plugin-rest-endpoint-methods" "^5.12.0" + +"@octokit/types@^5.0.0", "@octokit/types@^5.0.1": + version "5.5.0" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-5.5.0.tgz#e5f06e8db21246ca102aa28444cdb13ae17a139b" + integrity sha512-UZ1pErDue6bZNjYOotCNveTXArOMZQFG6hKJfOnGnulVCMcVVi7YIIuuR4WfBhjo7zgpmzn/BkPDnUXtNx+PcQ== + dependencies: + "@types/node" ">= 8" + +"@octokit/types@^6.0.0", "@octokit/types@^6.0.3": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.2.1.tgz#7f881fe44475ab1825776a4a59ca1ae082ed1043" + integrity sha512-jHs9OECOiZxuEzxMZcXmqrEO8GYraHF+UzNVH2ACYh8e/Y7YoT+hUf9ldvVd6zIvWv4p3NdxbQ0xx3ku5BnSiA== + dependencies: + "@octokit/openapi-types" "^2.2.0" + "@types/node" ">= 8" + +"@octokit/types@^6.16.1", "@octokit/types@^6.34.0": + version "6.34.0" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.34.0.tgz#c6021333334d1ecfb5d370a8798162ddf1ae8218" + integrity sha512-s1zLBjWhdEI2zwaoSgyOFoKSl109CUcVBCc7biPJ3aAf6LGLU6szDvi31JPU7bxfla2lqfhjbbg/5DdFNxOwHw== + dependencies: + "@octokit/openapi-types" "^11.2.0" + +"@types/node@>= 8": + version "16.10.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.10.2.tgz#5764ca9aa94470adb4e1185fe2e9f19458992b2e" + integrity sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ== + +axios@^0.21.4: + version "0.21.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" + integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== + dependencies: + follow-redirects "^1.14.0" + +before-after-hook@^2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.2.tgz#a6e8ca41028d90ee2c24222f201c90956091613e" + integrity sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ== + +deprecation@^2.0.0, deprecation@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" + integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== + +follow-redirects@^1.14.0: + version "1.14.4" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379" + integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g== + +is-plain-object@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== + +kibana-buildkite-library@elastic/kibana-buildkite-library: + version "1.0.0" + resolved "https://codeload.github.com/elastic/kibana-buildkite-library/tar.gz/ee34f75c00712b639124cbef60f68132fa662643" + dependencies: + "@octokit/rest" "^18.10.0" + axios "^0.21.4" + +node-fetch@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" + integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== + +once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + dependencies: + wrappy "1" + +universal-user-agent@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" + integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w== + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= diff --git a/docs/management/advanced-options.asciidoc b/docs/management/advanced-options.asciidoc index 7e7ff1137794..db48b33c712a 100644 --- a/docs/management/advanced-options.asciidoc +++ b/docs/management/advanced-options.asciidoc @@ -387,7 +387,7 @@ A custom image to use in the footer of the PDF. ==== Rollup [horizontal] -[[rollups-enabledataviews]]`rollups:enableDataViews`:: +[[rollups-enableindexpatterns]]`rollups:enableIndexPatterns`:: Enables the creation of data views that capture rollup indices, which in turn enables visualizations based on rollup data. Refresh the page to apply the changes. diff --git a/docs/management/images/management-create-rollup-bar-chart.png b/docs/management/images/management-create-rollup-bar-chart.png index 68ba4344c0ec..cf7b83c53261 100644 Binary files a/docs/management/images/management-create-rollup-bar-chart.png and b/docs/management/images/management-create-rollup-bar-chart.png differ diff --git a/docs/management/rollups/create_and_manage_rollups.asciidoc b/docs/management/rollups/create_and_manage_rollups.asciidoc index bdfd3f65b3c8..998aa5f7d39c 100644 --- a/docs/management/rollups/create_and_manage_rollups.asciidoc +++ b/docs/management/rollups/create_and_manage_rollups.asciidoc @@ -4,10 +4,10 @@ experimental::[] -A rollup job is a periodic task that aggregates data from indices specified -by a data view, and then rolls it into a new index. Rollup indices are a good way to -compactly store months or years of historical -data for use in visualizations and reports. +A rollup job is a periodic task that aggregates data from indices specified by +an index pattern, and then rolls it into a new index. Rollup indices are a good +way to compactly store months or years of historical data for use in +visualizations and reports. To get started, open the main menu, then click *Stack Management > Rollup Jobs*. @@ -15,7 +15,8 @@ To get started, open the main menu, then click *Stack Management > Rollup Jobs*. image::images/management_rollup_list.png[][List of currently active rollup jobs] Before using this feature, you should be familiar with how rollups work. -{ref}/xpack-rollup.html[Rolling up historical data] is a good source for more detailed information. +{ref}/xpack-rollup.html[Rolling up historical data] is a good source for more +detailed information. [float] === Required permissions @@ -33,10 +34,10 @@ the process. You fill in the name, data flow, and how often you want to roll up the data. Then you define a date histogram aggregation for the rollup job and optionally define terms, histogram, and metrics aggregations. -When defining the data view, you must enter a name that is different than -the output rollup index. Otherwise, the job -will attempt to capture the data in the rollup index. For example, if your data view is `metricbeat-*`, -you can name your rollup index `rollup-metricbeat`, but not `metricbeat-rollup`. +When defining the index pattern, you must enter a name that is different than +the output rollup index. Otherwise, the job will attempt to capture the data in +the rollup index. For example, if your index pattern is `metricbeat-*`, you can +name your rollup index `rollup-metricbeat`, but not `metricbeat-rollup`. [role="screenshot"] image::images/management_create_rollup_job.png[][Wizard that walks you through creation of a rollup job] @@ -53,11 +54,12 @@ You must first stop a rollup job before deleting it. [role="screenshot"] image::images/management_rollup_job_details.png[][Rollup job details] -You can’t change a rollup job after you’ve created it. To select additional fields -or redefine terms, you must delete the existing job, and then create a new one -with the updated specifications. Be sure to use a different name for the new rollup -job—reusing the same name can lead to problems with mismatched job configurations. -You can read more at {ref}/rollup-job-config.html[rollup job configuration]. +You can’t change a rollup job after you’ve created it. To select additional +fields or redefine terms, you must delete the existing job, and then create a +new one with the updated specifications. Be sure to use a different name for the +new rollup job—reusing the same name can lead to problems with mismatched +job configurations. Refer to {ref}/rollup-job-config.html[rollup job +configuration]. [float] [[rollup-data-tutorial]] @@ -66,10 +68,10 @@ You can read more at {ref}/rollup-job-config.html[rollup job configuration]. This example creates a rollup job to capture log data from sample web logs. Before you start, <>. -In this example, you want data that is older than 7 days in the target data view `kibana_sample_data_logs` -to roll up into the `rollup_logstash` index. You’ll bucket the -rolled up data on an hourly basis, using 60m for the time bucket configuration. -This allows for more granular queries, such as 2h and 12h. +In this example, you want data that is older than 7 days in the +`kibana_sample_data_logs` index to roll up into the `rollup_logstash` index. +You’ll bucket the rolled up data on an hourly basis, using `60m` for the time +bucket configuration. For this example, the job will perform the rollup every minute. However, you'd typically roll up less frequently in production. @@ -85,7 +87,7 @@ As you walk through the *Create rollup job* UI, enter the data: |Name |`logs_job` -|Data view +|Index pattern |`kibana_sample_data_logs` |Rollup index name @@ -129,9 +131,10 @@ the key information to retain in the rolled up data: where visitors are from (ge what operating system they are using (machine.os.keyword), and how much data is being sent (bytes). -You can now use the rolled up data for analysis at a fraction of the storage cost -of the original index. The original data can live side by side with the new -rollup index, or you can remove or archive it using <>. +You can now use the rolled up data for analysis at a fraction of the storage +cost of the original index. The original data can live side by side with the new +rollup index, or you can remove or archive it using +{ref}/index-lifecycle-management.html[{ilm} ({ilm-init})]. [float] ==== Visualize the rolled up data @@ -146,9 +149,9 @@ Most visualizations support rolled up data, with the exception of Timelion and V . Enter *rollup_logstash,kibana_sample_logs* as your *Data View* and `@timestamp` as the *Time Filter field name*. + -The notation for a combination data view with both raw and rolled up data -is `rollup_logstash,kibana_sample_data_logs`. In this data view, `rollup_logstash` -matches the rolled up data view and `kibana_sample_data_logs` matches the data view for raw data. +The notation for a combination data view with both raw and rolled up data is +`rollup_logstash,kibana_sample_data_logs`. In this data view, `rollup_logstash` +matches the rollup index and `kibana_sample_data_logs` matches the raw data. . Open the main menu, click *Dashboard*, then *Create dashboard*. diff --git a/docs/setup/upgrade.asciidoc b/docs/setup/upgrade.asciidoc index 29f21b850c13..9a949ffa01b6 100644 --- a/docs/setup/upgrade.asciidoc +++ b/docs/setup/upgrade.asciidoc @@ -72,7 +72,7 @@ For a comprehensive overview of the upgrade process, refer to {es} can read indices created in the previous major version. Before you upgrade to 7.0.0, you must reindex or delete any indices created in 5.x or earlier. For more information, refer to -{stack-ref}/upgrading-elastic-stack.html#oss-stack-upgrade[Upgrading the Elastic Stack]. +{stack-ref}/upgrading-elastic-stack.html[Upgrading the Elastic Stack]. When your reindex is complete, follow the <> instructions. diff --git a/package.json b/package.json index b00d8c6d2cac..c15bb092f17d 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "@elastic/apm-rum": "^5.9.1", "@elastic/apm-rum-react": "^1.3.1", "@elastic/apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace", - "@elastic/charts": "39.0.1", + "@elastic/charts": "39.0.2", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.35", "@elastic/ems-client": "8.0.0", @@ -415,15 +415,15 @@ "@babel/eslint-parser": "^7.16.3", "@babel/eslint-plugin": "^7.14.5", "@babel/generator": "^7.16.0", - "@babel/parser": "^7.16.3", + "@babel/parser": "^7.16.4", "@babel/plugin-proposal-class-properties": "^7.16.0", "@babel/plugin-proposal-export-namespace-from": "^7.16.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0", "@babel/plugin-proposal-object-rest-spread": "^7.16.0", "@babel/plugin-proposal-optional-chaining": "^7.16.0", "@babel/plugin-proposal-private-methods": "^7.16.0", - "@babel/plugin-transform-runtime": "^7.16.0", - "@babel/preset-env": "^7.16.0", + "@babel/plugin-transform-runtime": "^7.16.4", + "@babel/preset-env": "^7.16.4", "@babel/preset-react": "^7.16.0", "@babel/preset-typescript": "^7.16.0", "@babel/register": "^7.16.0", diff --git a/packages/kbn-apm-config-loader/src/index.ts b/packages/kbn-apm-config-loader/src/index.ts index b16f6dcfd418..381eb895b7ee 100644 --- a/packages/kbn-apm-config-loader/src/index.ts +++ b/packages/kbn-apm-config-loader/src/index.ts @@ -8,4 +8,5 @@ export { getConfiguration } from './config_loader'; export { initApm } from './init_apm'; +export { shouldInstrumentClient } from './rum_agent_configuration'; export type { ApmConfiguration } from './config'; diff --git a/packages/kbn-apm-config-loader/src/rum_agent_configuration.test.ts b/packages/kbn-apm-config-loader/src/rum_agent_configuration.test.ts new file mode 100644 index 000000000000..be4619578b5a --- /dev/null +++ b/packages/kbn-apm-config-loader/src/rum_agent_configuration.test.ts @@ -0,0 +1,27 @@ +/* + * 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 { shouldInstrumentClient } from './rum_agent_configuration'; +describe('shouldInstrumentClient', () => { + it('returns false if apm is disabled', () => { + expect(shouldInstrumentClient({ active: false })).toBe(false); + }); + + it('returns false if apm is enabled with contextPropagationOnly: true', () => { + expect(shouldInstrumentClient({ active: true, contextPropagationOnly: true })).toBe(false); + }); + + it('returns false if apm is enabled with disableSend: true', () => { + expect(shouldInstrumentClient({ active: true, disableSend: true })).toBe(false); + }); + + it('returns true if apm is enabled', () => { + expect(shouldInstrumentClient({ active: true })).toBe(true); + expect(shouldInstrumentClient({ active: true, contextPropagationOnly: false })).toBe(true); + expect(shouldInstrumentClient({ active: true, disableSend: false })).toBe(true); + }); +}); diff --git a/packages/kbn-apm-config-loader/src/rum_agent_configuration.ts b/packages/kbn-apm-config-loader/src/rum_agent_configuration.ts new file mode 100644 index 000000000000..5a73c95e2113 --- /dev/null +++ b/packages/kbn-apm-config-loader/src/rum_agent_configuration.ts @@ -0,0 +1,14 @@ +/* + * 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 type { AgentConfigOptions } from 'elastic-apm-node'; + +export function shouldInstrumentClient(config?: AgentConfigOptions): boolean { + return Boolean( + config?.active === true && config.contextPropagationOnly !== true && config.disableSend !== true + ); +} diff --git a/packages/kbn-es-query/src/filters/build_filters/query_string_filter.ts b/packages/kbn-es-query/src/filters/build_filters/query_string_filter.ts index a18347c77cfc..69f10efd97d6 100644 --- a/packages/kbn-es-query/src/filters/build_filters/query_string_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/query_string_filter.ts @@ -16,6 +16,7 @@ export type QueryStringFilter = Filter & { query?: { query_string?: { query: string; + fields?: string[]; }; }; }; diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js b/packages/kbn-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js index c6693245da28..7610ca912869 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js +++ b/packages/kbn-test/src/functional_test_runner/lib/mocha/decorate_mocha_ui.js @@ -57,7 +57,7 @@ export function decorateMochaUi(log, lifecycle, context, { isDockerGroup, rootTa } argumentsList[1] = function () { - before(async () => { + before('beforeTestSuite.trigger', async () => { await lifecycle.beforeTestSuite.trigger(this); }); @@ -87,7 +87,7 @@ export function decorateMochaUi(log, lifecycle, context, { isDockerGroup, rootTa provider.call(this); - after(async () => { + after('afterTestSuite.trigger', async () => { await lifecycle.afterTestSuite.trigger(this); }); }; diff --git a/renovate.json b/renovate.json index 21df347cf038..82005e82299b 100644 --- a/renovate.json +++ b/renovate.json @@ -18,7 +18,8 @@ "packageRules": [ { "matchPackagePatterns": [".*"], - "enabled": false + "enabled": false, + "prCreation": "not-pending" }, { "groupName": "@elastic/charts", @@ -60,7 +61,8 @@ "reviewers": ["team:kibana-operations"], "matchBaseBranches": ["main"], "labels": ["Team:Operations", "release_note:skip"], - "enabled": true + "enabled": true, + "stabilityDays": 7 }, { "groupName": "polyfills", @@ -70,7 +72,8 @@ "reviewers": ["team:kibana-operations"], "matchBaseBranches": ["main"], "labels": ["Team:Operations", "release_note:skip"], - "enabled": true + "enabled": true, + "stabilityDays": 7 }, { "groupName": "vega related modules", diff --git a/src/cli_setup/cli_setup.ts b/src/cli_setup/cli_setup.ts index a23a0a9f25c1..715a74b60673 100644 --- a/src/cli_setup/cli_setup.ts +++ b/src/cli_setup/cli_setup.ts @@ -33,7 +33,7 @@ program .description( 'This command walks you through all required steps to securely connect Kibana with Elasticsearch' ) - .option('-t, --token ', 'Elasticsearch enrollment token') + .option('-t, --enrollment-token ', 'Elasticsearch enrollment token') .option('-s, --silent', 'Prevent all logging'); program.parse(process.argv); @@ -82,9 +82,9 @@ async function initCommand() { } catch (error) { if (!options.silent) { spinner.fail( - `${chalk.bold('Unable to enroll with Elasticsearch:')} ${chalk.red( - `${getDetailedErrorMessage(error)}` - )}` + `${chalk.bold( + 'Unable to connect to Elasticsearch with the provided enrollment token:' + )} ${chalk.red(`${getDetailedErrorMessage(error)}`)}` ); } logger.error(''); diff --git a/src/core/public/doc_links/doc_links_service.ts b/src/core/public/doc_links/doc_links_service.ts index a9330ce499ca..6b6ceeddee68 100644 --- a/src/core/public/doc_links/doc_links_service.ts +++ b/src/core/public/doc_links/doc_links_service.ts @@ -156,7 +156,7 @@ export class DocLinksService { luceneExpressions: `${ELASTICSEARCH_DOCS}modules-scripting-expression.html`, }, indexPatterns: { - introduction: `${KIBANA_DOCS}index-patterns.html`, + introduction: `${KIBANA_DOCS}data-views.html`, fieldFormattersNumber: `${KIBANA_DOCS}numeral.html`, fieldFormattersString: `${KIBANA_DOCS}field-formatters-string.html`, runtimeFields: `${KIBANA_DOCS}managing-data-views.html#runtime-fields`, diff --git a/src/core/server/http_resources/get_apm_config.test.mocks.ts b/src/core/server/http_resources/get_apm_config.test.mocks.ts index 8c3fa180a04f..03d1a2575ba5 100644 --- a/src/core/server/http_resources/get_apm_config.test.mocks.ts +++ b/src/core/server/http_resources/get_apm_config.test.mocks.ts @@ -7,8 +7,10 @@ */ export const getConfigurationMock = jest.fn(); +export const shouldInstrumentClientMock = jest.fn(() => true); jest.doMock('@kbn/apm-config-loader', () => ({ getConfiguration: getConfigurationMock, + shouldInstrumentClient: shouldInstrumentClientMock, })); export const agentMock = {} as Record; diff --git a/src/core/server/http_resources/get_apm_config.test.ts b/src/core/server/http_resources/get_apm_config.test.ts index bd867375f46d..9552a91da97b 100644 --- a/src/core/server/http_resources/get_apm_config.test.ts +++ b/src/core/server/http_resources/get_apm_config.test.ts @@ -6,7 +6,11 @@ * Side Public License, v 1. */ -import { getConfigurationMock, agentMock } from './get_apm_config.test.mocks'; +import { + getConfigurationMock, + agentMock, + shouldInstrumentClientMock, +} from './get_apm_config.test.mocks'; import { getApmConfig } from './get_apm_config'; const defaultApmConfig = { @@ -17,6 +21,7 @@ const defaultApmConfig = { describe('getApmConfig', () => { beforeEach(() => { getConfigurationMock.mockReturnValue(defaultApmConfig); + shouldInstrumentClientMock.mockReturnValue(true); }); afterEach(() => { @@ -25,12 +30,7 @@ describe('getApmConfig', () => { }); it('returns null if apm is disabled', () => { - getConfigurationMock.mockReturnValue({ - active: false, - }); - expect(getApmConfig('/path')).toBeNull(); - - getConfigurationMock.mockReturnValue(undefined); + shouldInstrumentClientMock.mockReturnValue(false); expect(getApmConfig('/path')).toBeNull(); }); diff --git a/src/core/server/http_resources/get_apm_config.ts b/src/core/server/http_resources/get_apm_config.ts index 6ea172b162d2..3e7be65f9665 100644 --- a/src/core/server/http_resources/get_apm_config.ts +++ b/src/core/server/http_resources/get_apm_config.ts @@ -7,11 +7,11 @@ */ import agent from 'elastic-apm-node'; -import { getConfiguration } from '@kbn/apm-config-loader'; +import { getConfiguration, shouldInstrumentClient } from '@kbn/apm-config-loader'; export const getApmConfig = (requestPath: string) => { const baseConfig = getConfiguration('kibana-frontend'); - if (!baseConfig?.active) { + if (!shouldInstrumentClient(baseConfig)) { return null; } diff --git a/src/plugins/console/server/lib/spec_definitions/json/overrides/logstash.put_pipeline.json b/src/plugins/console/server/lib/spec_definitions/json/overrides/logstash.put_pipeline.json new file mode 100644 index 000000000000..224def4d5bf1 --- /dev/null +++ b/src/plugins/console/server/lib/spec_definitions/json/overrides/logstash.put_pipeline.json @@ -0,0 +1,66 @@ +{ + "logstash.put_pipeline": { + "data_autocomplete_rules": { + "__template": { + "last_modified": "", + "pipeline": "", + "pipeline_metadata": {}, + "pipeline_settings": {}, + "username": "" + }, + "last_modified": "", + "pipeline_metadata": {}, + "username": "", + "pipeline": "", + "pipeline_settings": { + "pipeline.id": "main", + "pipeline.workers": 0, + "pipeline.batch.size": 125, + "pipeline.batch.delay": 50, + "pipeline.unsafe_shutdown": false, + "pipeline.plugin_classloaders": false, + "pipeline.ordered": "auto", + "pipeline.ecs_compatibility": "disabled", + "pipeline.separate_logs": false, + "queue.type": "memory", + "queue.page_capacity": "64mb", + "queue.max_events": 0, + "queue.max_bytes": "1024mb", + "queue.checkpoint.acks": 1024, + "queue.checkpoint.writes": 1024, + "queue.checkpoint.retry": false, + "queue.max_bytes.number": 0, + "queue.max_bytes.units": "", + "queue.drain": false, + "api.enabled": true, + "api.environment": "production", + "api.http.host": "127.0.0.1", + "api.http.port": "9600-9700", + "api.ssl.enabled": false, + "api.ssl.keystore.path": "", + "api.ssl.keystore.password": "", + "api.auth.type": "none", + "api.auth.basic.username": "", + "api.auth.basic.password": "", + "log.level": "info", + "log.format": "plain", + "path.logs": "LOGSTASH_HOME/logs", + "path.plugins": "PATH/logstash/TYPE/NAME.rb", + "path.queue": "path.data/queue", + "path.data": "LOGSTASH_HOME/data", + "path.config": "/usr/share/logstash/pipeline", + "path.dead_letter_queue": "path.data/dead_letter_queue", + "dead_letter_queue.max_bytes": "1024mb", + "dead_letter_queue.enable": false, + "config.support_escapes": false, + "config.debug": false, + "config.reload.interval": "3s", + "config.reload.automatic": false, + "config.test_and_exit": false, + "config.string": "", + "node.name": "" + }, + "description": "" + } + } +} \ No newline at end of file diff --git a/src/plugins/interactive_setup/public/cluster_configuration_form.tsx b/src/plugins/interactive_setup/public/cluster_configuration_form.tsx index 967a069df383..7b6733999d87 100644 --- a/src/plugins/interactive_setup/public/cluster_configuration_form.tsx +++ b/src/plugins/interactive_setup/public/cluster_configuration_form.tsx @@ -258,9 +258,9 @@ export const ClusterConfigurationForm: FunctionComponent { - const intermediateCa = certificateChain[Math.min(1, certificateChain.length - 1)]; + const rootCa = certificateChain[certificateChain.length - 1]; form.setTouched('caCert'); - form.setValue('caCert', form.values.caCert ? '' : intermediateCa.raw); + form.setValue('caCert', form.values.caCert ? '' : rootCa.raw); }} > diff --git a/src/plugins/management/public/application.tsx b/src/plugins/management/public/application.tsx index 8e3e7da41c39..3e2c4f7c04e4 100644 --- a/src/plugins/management/public/application.tsx +++ b/src/plugins/management/public/application.tsx @@ -13,11 +13,16 @@ import { AppMountParameters } from 'kibana/public'; import { ManagementApp, ManagementAppDependencies } from './components/management_app'; export const renderApp = async ( - { history, appBasePath, element }: AppMountParameters, + { history, appBasePath, element, theme$ }: AppMountParameters, dependencies: ManagementAppDependencies ) => { ReactDOM.render( - , + , element ); diff --git a/src/plugins/management/public/components/management_app/management_app.tsx b/src/plugins/management/public/components/management_app/management_app.tsx index 23d0a2908374..ac9739cc5457 100644 --- a/src/plugins/management/public/components/management_app/management_app.tsx +++ b/src/plugins/management/public/components/management_app/management_app.tsx @@ -25,6 +25,7 @@ import { SectionsServiceStart } from '../../types'; interface ManagementAppProps { appBasePath: string; history: AppMountParameters['history']; + theme$: AppMountParameters['theme$']; dependencies: ManagementAppDependencies; } @@ -34,7 +35,7 @@ export interface ManagementAppDependencies { setBreadcrumbs: (newBreadcrumbs: ChromeBreadcrumb[]) => void; } -export const ManagementApp = ({ dependencies, history }: ManagementAppProps) => { +export const ManagementApp = ({ dependencies, history, theme$ }: ManagementAppProps) => { const { setBreadcrumbs } = dependencies; const [selectedId, setSelectedId] = useState(''); const [sections, setSections] = useState(); @@ -93,6 +94,7 @@ export const ManagementApp = ({ dependencies, history }: ManagementAppProps) => > void; onAppMounted: (id: string) => void; @@ -23,7 +24,14 @@ interface ManagementRouterProps { } export const ManagementRouter = memo( - ({ dependencies, history, setBreadcrumbs, onAppMounted, sections }: ManagementRouterProps) => ( + ({ + dependencies, + history, + setBreadcrumbs, + onAppMounted, + sections, + theme$, + }: ManagementRouterProps) => ( {sections.map((section) => @@ -38,6 +46,7 @@ export const ManagementRouter = memo( setBreadcrumbs={setBreadcrumbs} onAppMounted={onAppMounted} history={history} + theme$={theme$} /> )} /> diff --git a/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx index 72bfe609c141..57de84ec5aec 100644 --- a/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx +++ b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx @@ -19,6 +19,7 @@ interface ManagementSectionWrapperProps { setBreadcrumbs: (crumbs?: ChromeBreadcrumb[], history?: ScopedHistory) => void; onAppMounted: (id: string) => void; history: AppMountParameters['history']; + theme$: AppMountParameters['theme$']; } export class ManagementAppWrapper extends Component { @@ -26,7 +27,7 @@ export class ManagementAppWrapper extends Component(); componentDidMount() { - const { setBreadcrumbs, app, onAppMounted, history } = this.props; + const { setBreadcrumbs, app, onAppMounted, history, theme$ } = this.props; const { mount, basePath } = app; const appHistory = history.createSubHistory(app.basePath); @@ -35,6 +36,7 @@ export class ManagementAppWrapper extends Component setBreadcrumbs(crumbs, appHistory), element: this.mountElementRef.current!, history: appHistory, + theme$, }); onAppMounted(app.id); diff --git a/src/plugins/management/public/types.ts b/src/plugins/management/public/types.ts index 6a165c812b47..87b336928db9 100644 --- a/src/plugins/management/public/types.ts +++ b/src/plugins/management/public/types.ts @@ -6,10 +6,11 @@ * Side Public License, v 1. */ +import { Observable } from 'rxjs'; import { ScopedHistory, Capabilities } from 'kibana/public'; import type { LocatorPublic } from 'src/plugins/share/common'; import { ManagementSection, RegisterManagementSectionArgs } from './utils'; -import { ChromeBreadcrumb } from '../../../core/public/'; +import { ChromeBreadcrumb, CoreTheme } from '../../../core/public/'; import type { ManagementAppLocatorParams } from '../common/locator'; export interface ManagementSetup { @@ -63,6 +64,7 @@ export interface ManagementAppMountParams { element: HTMLElement; // element the section should render into setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void; history: ScopedHistory; + theme$: Observable; } export interface CreateManagementItemArgs { diff --git a/src/plugins/vis_types/timeseries/public/application/components/splits/filter.js b/src/plugins/vis_types/timeseries/public/application/components/splits/filter.js index 6324fff859d4..a53dc291fb6f 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/splits/filter.js +++ b/src/plugins/vis_types/timeseries/public/application/components/splits/filter.js @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import { createSelectHandler } from '../lib/create_select_handler'; import { GroupBySelect } from './group_by_select'; import PropTypes from 'prop-types'; import React from 'react'; @@ -15,12 +14,16 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { getDefaultQueryLanguage } from '../lib/get_default_query_language'; import { QueryBarWrapper } from '../query_bar_wrapper'; +const RESET_STATE = { + filter: undefined, +}; + export const SplitByFilter = (props) => { const { onChange, uiRestrictions, indexPattern } = props; const defaults = { filter: { language: getDefaultQueryLanguage(), query: '' } }; const model = { ...defaults, ...props.model }; const htmlId = htmlIdGenerator(); - const handleSelectChange = createSelectHandler(onChange); + return ( @@ -35,7 +38,12 @@ export const SplitByFilter = (props) => { > { + onChange({ + split_mode: newSplitMode, + ...RESET_STATE, + }); + }} uiRestrictions={uiRestrictions} /> diff --git a/src/plugins/vis_types/timeseries/public/application/components/splits/filters.js b/src/plugins/vis_types/timeseries/public/application/components/splits/filters.js index 8c91d057ae34..edb1ce592793 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/splits/filters.js +++ b/src/plugins/vis_types/timeseries/public/application/components/splits/filters.js @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import { createSelectHandler } from '../lib/create_select_handler'; import { GroupBySelect } from './group_by_select'; import { FilterItems } from './filter_items'; import PropTypes from 'prop-types'; @@ -14,10 +13,13 @@ import React from 'react'; import { htmlIdGenerator, EuiFlexGroup, EuiFlexItem, EuiFormRow } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; +const RESET_STATE = { + split_filters: undefined, +}; + export const SplitByFilters = (props) => { const { onChange, model, uiRestrictions, indexPattern } = props; const htmlId = htmlIdGenerator(); - const handleSelectChange = createSelectHandler(onChange); return (
@@ -33,7 +35,12 @@ export const SplitByFilters = (props) => { > { + onChange({ + split_mode: newSplitMode, + ...RESET_STATE, + }); + }} uiRestrictions={uiRestrictions} /> diff --git a/src/plugins/vis_types/timeseries/public/application/components/splits/terms.js b/src/plugins/vis_types/timeseries/public/application/components/splits/terms.js index b32af037533f..8a85c9826e93 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/splits/terms.js +++ b/src/plugins/vis_types/timeseries/public/application/components/splits/terms.js @@ -30,6 +30,14 @@ import { STACKED_OPTIONS } from '../../visualizations/constants'; import { getIndexPatternKey } from '../../../../common/index_patterns_utils'; const DEFAULTS = { terms_direction: 'desc', terms_size: 10, terms_order_by: '_count' }; +const RESET_STATE = { + terms_field: undefined, + terms_include: undefined, + terms_exclude: undefined, + terms_direction: undefined, + terms_size: undefined, + terms_order_by: undefined, +}; export const SplitByTermsUI = ({ onChange, @@ -106,7 +114,12 @@ export const SplitByTermsUI = ({ > { + onChange({ + split_mode: newSplitMode, + ...RESET_STATE, + }); + }} uiRestrictions={uiRestrictions} /> diff --git a/test/functional/services/remote/webdriver.ts b/test/functional/services/remote/webdriver.ts index 82a9f9b7d3f2..9ae848d95473 100644 --- a/test/functional/services/remote/webdriver.ts +++ b/test/functional/services/remote/webdriver.ts @@ -10,7 +10,7 @@ import { resolve } from 'path'; import Fs from 'fs'; import * as Rx from 'rxjs'; -import { mergeMap, map, takeUntil, catchError } from 'rxjs/operators'; +import { mergeMap, map, takeUntil, catchError, ignoreElements } from 'rxjs/operators'; import { Lifecycle } from '@kbn/test'; import { ToolingLog } from '@kbn/dev-utils'; import chromeDriver from 'chromedriver'; @@ -53,6 +53,8 @@ const chromiumUserPrefs = { }, }; +const sleep$ = (ms: number) => Rx.timer(ms).pipe(ignoreElements()); + /** * Best we can tell WebDriver locks up sometimes when we send too many * commands at once, sometimes... It causes random lockups where we never @@ -331,6 +333,7 @@ export async function initWebDriver( edgePaths = await installDriver(); } + let attempt = 1; return await Rx.race( Rx.timer(2 * MINUTE).pipe( map(() => { @@ -355,8 +358,14 @@ export async function initWebDriver( catchError((error, resubscribe) => { log.warning('Failure while creating webdriver instance'); log.warning(error); - log.warning('...retrying...'); - return resubscribe; + + if (attempt > 5) { + throw new Error('out of retry attempts'); + } + + attempt += 1; + log.warning('...retrying in 15 seconds...'); + return Rx.concat(sleep$(15000), resubscribe); }) ) ).toPromise(); diff --git a/test/interactive_setup_api_integration/fixtures/README.md b/test/interactive_setup_api_integration/fixtures/README.md index 5a7238bbba75..e25903019010 100644 --- a/test/interactive_setup_api_integration/fixtures/README.md +++ b/test/interactive_setup_api_integration/fixtures/README.md @@ -6,27 +6,86 @@ The Elasticsearch HTTP layer keystore is supposed to mimic the PKCS12 keystore t - A PrivateKeyEntry for the CA's key and certificate - A TrustedCertificateEntry for the CA's certificate +__IMPORTANT:__ CA keystore (ca.p12) is not checked in intentionally, talk to @elastic/kibana-security if you need it to sign new certificates. + ```bash -$ES_HOME/bin/elasticsearch-certutil cert \ - --out $KIBANA_HOME/test/interactive_setup_api_integration/fixtures/elasticsearch.p12 \ - --ca $KIBANA_HOME/packages/kbn-dev-utils/certs/ca.p12 --ca-pass "castorepass" --pass "storepass" \ - --dns=localhost --dns=localhost.localdomain --dns=localhost4 --dns=localhost4.localdomain4 \ +ROOT_CA_PATH='packages/kbn-dev-utils/certs/ca.p12' +ROOT_CA_NAME='root' +INTERMEDIATE_CA_NAME='intermediate' +INSTANCE_NAME='elasticsearch' + +# Create intermediate CA +bin/elasticsearch-certutil ca --ca-dn "CN=Elastic Intermediate CA" -days 18250 --out $INTERMEDIATE_CA_NAME.p12 --pass castorepass + +# Create instance certificate +bin/elasticsearch-certutil cert \ + --ca $INTERMEDIATE_CA_NAME.p12 --ca-pass castorepass --name $INSTANCE_NAME \ + --dns=localhost --dns=localhost.localdomain \ + --dns=localhost4 --dns=localhost4.localdomain4 \ --dns=localhost6 --dns=localhost6.localdomain6 \ - --ip=127.0.0.1 --ip=0:0:0:0:0:0:0:1 -``` + --ip=127.0.0.1 --ip=0:0:0:0:0:0:0:1 \ + -days 18250 --out $INSTANCE_NAME.p12 --pass storepass -Change the alias of the TrustedCertificateEntry so that it won't clash with the CA PrivateKeyEntry -```bash +# Convert P12 keystores to PEM files +openssl pkcs12 -in $ROOT_CA_PATH -out $ROOT_CA_NAME.crt -nokeys -passin pass:castorepass -passout pass: +openssl pkcs12 -in $ROOT_CA_PATH -nocerts -passin pass:castorepass -passout pass:keypass | openssl rsa -passin pass:keypass -out $ROOT_CA_NAME.key + +openssl pkcs12 -in $INTERMEDIATE_CA_NAME.p12 -out $INTERMEDIATE_CA_NAME.crt -nokeys -passin pass:castorepass -passout pass: +openssl pkcs12 -in $INTERMEDIATE_CA_NAME.p12 -nocerts -passin pass:castorepass -passout pass:keypass | openssl rsa -passin pass:keypass -out $INTERMEDIATE_CA_NAME.key + +openssl pkcs12 -in $INSTANCE_NAME.p12 -out $INSTANCE_NAME.crt -clcerts -passin pass:storepass -passout pass: +openssl pkcs12 -in $INSTANCE_NAME.p12 -nocerts -passin pass:storepass -passout pass:keypass | openssl rsa -passin pass:keypass -out $INSTANCE_NAME.key + +# Re-sign intermediate CA +mkdir -p ./tmp +openssl x509 -x509toreq -in $INTERMEDIATE_CA_NAME.crt -signkey $INTERMEDIATE_CA_NAME.key -out ./tmp/$INTERMEDIATE_CA_NAME.csr +dd if=/dev/urandom of=./tmp/rand bs=256 count=1 +touch ./tmp/index.txt +echo "01" > ./tmp/serial +cp /System/Library/OpenSSL/openssl.cnf ./tmp/ +echo " +[ tmpcnf ] +dir = ./ +certs = ./ +new_certs_dir = ./tmp +crl_dir = ./tmp/crl +database = ./tmp/index.txt +unique_subject = no +certificate = ./$ROOT_CA_NAME.crt +serial = ./tmp/serial +crlnumber = ./tmp/crlnumber +crl = ./tmp/crl.pem +private_key = ./$ROOT_CA_NAME.key +RANDFILE = ./tmp/rand +x509_extensions = v3_ca +name_opt = ca_default +cert_opt = ca_default +default_days = 18250 +default_crl_days= 30 +default_md = sha256 +preserve = no +policy = policy_anything +" >> ./tmp/openssl.cnf + +openssl ca -batch -config ./tmp/openssl.cnf -name tmpcnf -in ./tmp/$INTERMEDIATE_CA_NAME.csr -out $INTERMEDIATE_CA_NAME.crt + +# Convert PEM files back to P12 keystores +cat $INTERMEDIATE_CA_NAME.key $INTERMEDIATE_CA_NAME.crt $ROOT_CA_NAME.crt | openssl pkcs12 -export -name $INTERMEDIATE_CA_NAME -passout pass:castorepass -out $INTERMEDIATE_CA_NAME.p12 +cat $INSTANCE_NAME.key $INSTANCE_NAME.crt $ROOT_CA_NAME.crt $INTERMEDIATE_CA_NAME.crt | openssl pkcs12 -export -name $INSTANCE_NAME -passout pass:storepass -out $INSTANCE_NAME.p12 + +# Verify contents of keystores +openssl pkcs12 -info -in $INTERMEDIATE_CA_NAME.p12 -passin pass:"castorepass" -nodes +openssl pkcs12 -info -in $INSTANCE_NAME.p12 -passin pass:"storepass" -nodes + +# Change the alias of the TrustedCertificateEntry so that it won't clash with the CA PrivateKeyEntry keytool -changealias -alias ca -destalias cacert -keystore \ - $KIBANA_HOME/test/interactive_setup_api_integration/fixtures/elasticsearch.p12 \ + $INSTANCE_NAME.p12 \ -deststorepass "storepass" -``` -Import the CA PrivateKeyEntry -```bash +# Import the CA PrivateKeyEntry keytool -importkeystore \ - -srckeystore $KIBANA_HOME/packages/kbn-dev-utils/certs/ca.p12 \ + -srckeystore $ROOT_CA_PATH \ -srcstorepass "castorepass" \ - -destkeystore $KIBANA_HOME/test/interactive_setup_api_integration/fixtures/elasticsearch.p12 \ + -destkeystore $INSTANCE_NAME.p12 \ -deststorepass "storepass" ``` diff --git a/test/interactive_setup_api_integration/fixtures/elasticsearch.p12 b/test/interactive_setup_api_integration/fixtures/elasticsearch.p12 index 964932d8ffe5..62cecb487804 100644 Binary files a/test/interactive_setup_api_integration/fixtures/elasticsearch.p12 and b/test/interactive_setup_api_integration/fixtures/elasticsearch.p12 differ diff --git a/x-pack/plugins/alerting/server/rules_client/rules_client.ts b/x-pack/plugins/alerting/server/rules_client/rules_client.ts index e10af37e0936..37e9bcbfa3a8 100644 --- a/x-pack/plugins/alerting/server/rules_client/rules_client.ts +++ b/x-pack/plugins/alerting/server/rules_client/rules_client.ts @@ -450,8 +450,10 @@ export class RulesClient { public async resolve({ id, + includeLegacyId, }: { id: string; + includeLegacyId?: boolean; }): Promise> { const { saved_object: result, ...resolveResponse } = await this.unsecuredSavedObjectsClient.resolve('alert', id); @@ -483,7 +485,8 @@ export class RulesClient { result.id, result.attributes.alertTypeId, result.attributes, - result.references + result.references, + includeLegacyId ); return { diff --git a/x-pack/plugins/alerting/server/rules_client/tests/resolve.test.ts b/x-pack/plugins/alerting/server/rules_client/tests/resolve.test.ts index 537d890217cf..8102dcedbd78 100644 --- a/x-pack/plugins/alerting/server/rules_client/tests/resolve.test.ts +++ b/x-pack/plugins/alerting/server/rules_client/tests/resolve.test.ts @@ -125,6 +125,80 @@ describe('resolve()', () => { `); }); + test('calls saved objects client with id and includeLegacyId params', async () => { + const rulesClient = new RulesClient(rulesClientParams); + unsecuredSavedObjectsClient.resolve.mockResolvedValueOnce({ + saved_object: { + id: '1', + type: 'alert', + attributes: { + legacyId: 'some-legacy-id', + alertTypeId: '123', + schedule: { interval: '10s' }, + params: { + bar: true, + }, + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), + actions: [ + { + group: 'default', + actionRef: 'action_0', + params: { + foo: true, + }, + }, + ], + notifyWhen: 'onActiveAlert', + }, + references: [ + { + name: 'action_0', + type: 'action', + id: '1', + }, + ], + }, + outcome: 'aliasMatch', + alias_target_id: '2', + }); + const result = await rulesClient.resolve({ id: '1', includeLegacyId: true }); + expect(result).toMatchInlineSnapshot(` + Object { + "actions": Array [ + Object { + "group": "default", + "id": "1", + "params": Object { + "foo": true, + }, + }, + ], + "alertTypeId": "123", + "alias_target_id": "2", + "createdAt": 2019-02-12T21:01:22.479Z, + "id": "1", + "legacyId": "some-legacy-id", + "notifyWhen": "onActiveAlert", + "outcome": "aliasMatch", + "params": Object { + "bar": true, + }, + "schedule": Object { + "interval": "10s", + }, + "updatedAt": 2019-02-12T21:01:22.479Z, + } + `); + expect(unsecuredSavedObjectsClient.resolve).toHaveBeenCalledTimes(1); + expect(unsecuredSavedObjectsClient.resolve.mock.calls[0]).toMatchInlineSnapshot(` + Array [ + "alert", + "1", + ] + `); + }); + test('should call useSavedObjectReferences.injectReferences if defined for rule type', async () => { const injectReferencesFn = jest.fn().mockReturnValue({ bar: true, diff --git a/x-pack/plugins/apm/server/deprecations/index.ts b/x-pack/plugins/apm/server/deprecations/index.ts index 39e282e76d9a..92955fa0c6d0 100644 --- a/x-pack/plugins/apm/server/deprecations/index.ts +++ b/x-pack/plugins/apm/server/deprecations/index.ts @@ -9,7 +9,7 @@ import { GetDeprecationsContext, DeprecationsDetails } from 'src/core/server'; import { i18n } from '@kbn/i18n'; import { isEmpty } from 'lodash'; import { CloudSetup } from '../../../cloud/server'; -import { getCloudAgentPolicy } from '../lib/fleet/get_cloud_apm_package_policy'; +import { getCloudAgentPolicy } from '../routes/fleet/get_cloud_apm_package_policy'; import { APMRouteHandlerResources } from '../'; export function getDeprecations({ diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts index 9b5820767690..8aee60357ba7 100644 --- a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts @@ -12,7 +12,7 @@ import { ESSearchRequest, ESSearchResponse, } from '../../../../../../../src/core/types/elasticsearch'; -import { ApmIndicesConfig } from '../../settings/apm_indices/get_apm_indices'; +import { ApmIndicesConfig } from '../../../routes/settings/apm_indices/get_apm_indices'; import { tasks } from './tasks'; import { APMDataTelemetry } from '../types'; diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.test.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.test.ts index 1e697ebdcae0..b69aa1e6e019 100644 --- a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.test.ts +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ApmIndicesConfig } from '../../settings/apm_indices/get_apm_indices'; +import { ApmIndicesConfig } from '../../../routes/settings/apm_indices/get_apm_indices'; import { tasks } from './tasks'; import { SERVICE_NAME, diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts index 88ef1203bae9..bdbb1fe1dbcd 100644 --- a/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts @@ -24,7 +24,7 @@ import { APM_TELEMETRY_SAVED_OBJECT_TYPE, } from '../../../common/apm_saved_object_constants'; import { getInternalSavedObjectsClient } from '../helpers/get_internal_saved_objects_client'; -import { getApmIndices } from '../settings/apm_indices/get_apm_indices'; +import { getApmIndices } from '../../routes/settings/apm_indices/get_apm_indices'; import { collectDataTelemetry, CollectTelemetryParams, diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts index a45d314c3371..6c9a0cb45e27 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts @@ -26,7 +26,7 @@ import { APMError } from '../../../../../typings/es_schemas/ui/apm_error'; import { Metric } from '../../../../../typings/es_schemas/ui/metric'; import { Span } from '../../../../../typings/es_schemas/ui/span'; import { Transaction } from '../../../../../typings/es_schemas/ui/transaction'; -import { ApmIndicesConfig } from '../../../settings/apm_indices/get_apm_indices'; +import { ApmIndicesConfig } from '../../../../routes/settings/apm_indices/get_apm_indices'; import { callAsyncWithDebug, getDebugBody, diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/unpack_processor_events.test.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/unpack_processor_events.test.ts index 5ef3786e9bde..d3f0fca0bb25 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/unpack_processor_events.test.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/unpack_processor_events.test.ts @@ -6,7 +6,7 @@ */ import { APMEventESSearchRequest } from '.'; -import { ApmIndicesConfig } from '../../../settings/apm_indices/get_apm_indices'; +import { ApmIndicesConfig } from '../../../../routes/settings/apm_indices/get_apm_indices'; import { unpackProcessorEvents } from './unpack_processor_events'; describe('unpackProcessorEvents', () => { diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/unpack_processor_events.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/unpack_processor_events.ts index 582fe0374c5c..e62720e9fbd0 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/unpack_processor_events.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/unpack_processor_events.ts @@ -13,7 +13,7 @@ import { ESFilter, } from '../../../../../../../../src/core/types/elasticsearch'; import { APMEventESSearchRequest, APMEventESTermsEnumRequest } from '.'; -import { ApmIndicesConfig } from '../../../settings/apm_indices/get_apm_indices'; +import { ApmIndicesConfig } from '../../../../routes/settings/apm_indices/get_apm_indices'; const processorEventIndexMap = { [ProcessorEvent.transaction]: 'transaction', diff --git a/x-pack/plugins/apm/server/lib/helpers/setup_request.test.ts b/x-pack/plugins/apm/server/lib/helpers/setup_request.test.ts index 7b3201095106..ffcbe01b7f04 100644 --- a/x-pack/plugins/apm/server/lib/helpers/setup_request.test.ts +++ b/x-pack/plugins/apm/server/lib/helpers/setup_request.test.ts @@ -10,10 +10,10 @@ import { APMConfig } from '../..'; import { APMRouteHandlerResources } from '../../routes/typings'; import { ProcessorEvent } from '../../../common/processor_event'; import { PROCESSOR_EVENT } from '../../../common/elasticsearch_fieldnames'; -import { getApmIndices } from '../settings/apm_indices/get_apm_indices'; +import { getApmIndices } from '../../routes/settings/apm_indices/get_apm_indices'; import { PromiseReturnType } from '../../../../observability/typings/common'; -jest.mock('../settings/apm_indices/get_apm_indices', () => ({ +jest.mock('../../routes/settings/apm_indices/get_apm_indices', () => ({ getApmIndices: async () => ({ sourcemap: 'apm-*', @@ -26,7 +26,7 @@ jest.mock('../settings/apm_indices/get_apm_indices', () => ({ } as PromiseReturnType), })); -jest.mock('../data_view/get_dynamic_data_view', () => ({ +jest.mock('../../routes/data_view/get_dynamic_data_view', () => ({ getDynamicDataView: async () => { return; }, diff --git a/x-pack/plugins/apm/server/lib/helpers/setup_request.ts b/x-pack/plugins/apm/server/lib/helpers/setup_request.ts index a0d908c68d84..85fb94dd765b 100644 --- a/x-pack/plugins/apm/server/lib/helpers/setup_request.ts +++ b/x-pack/plugins/apm/server/lib/helpers/setup_request.ts @@ -13,7 +13,7 @@ import { APMRouteHandlerResources } from '../../routes/typings'; import { ApmIndicesConfig, getApmIndices, -} from '../settings/apm_indices/get_apm_indices'; +} from '../../routes/settings/apm_indices/get_apm_indices'; import { APMEventClient, createApmEventClient, diff --git a/x-pack/plugins/apm/server/plugin.ts b/x-pack/plugins/apm/server/plugin.ts index b273fc867e5a..9ece2c507847 100644 --- a/x-pack/plugins/apm/server/plugin.ts +++ b/x-pack/plugins/apm/server/plugin.ts @@ -20,14 +20,14 @@ import { Dataset } from '../../rule_registry/server'; import { APMConfig, APM_SERVER_FEATURE_ID } from '.'; import { UI_SETTINGS } from '../../../../src/plugins/data/common'; import { APM_FEATURE, registerFeaturesUsage } from './feature'; -import { registerApmAlerts } from './lib/alerts/register_apm_alerts'; -import { registerFleetPolicyCallbacks } from './lib/fleet/register_fleet_policy_callbacks'; +import { registerApmAlerts } from './routes/alerts/register_apm_alerts'; +import { registerFleetPolicyCallbacks } from './routes/fleet/register_fleet_policy_callbacks'; import { createApmTelemetry } from './lib/apm_telemetry'; import { createApmEventClient } from './lib/helpers/create_es_client/create_apm_event_client'; import { getInternalSavedObjectsClient } from './lib/helpers/get_internal_saved_objects_client'; -import { createApmAgentConfigurationIndex } from './lib/settings/agent_configuration/create_agent_config_index'; -import { getApmIndices } from './lib/settings/apm_indices/get_apm_indices'; -import { createApmCustomLinkIndex } from './lib/settings/custom_link/create_custom_link_index'; +import { createApmAgentConfigurationIndex } from './routes/settings/agent_configuration/create_agent_config_index'; +import { getApmIndices } from './routes/settings/apm_indices/get_apm_indices'; +import { createApmCustomLinkIndex } from './routes/settings/custom_link/create_custom_link_index'; import { apmIndices, apmTelemetry, apmServerSettings } from './saved_objects'; import type { ApmPluginRequestHandlerContext, diff --git a/x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts b/x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts index 6265ee71c27e..e3e98cc3c177 100644 --- a/x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts +++ b/x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SetupUX } from '../routes/rum_client'; +import { SetupUX } from '../routes/rum_client/route'; import { AGENT_NAME, TRANSACTION_TYPE, @@ -14,7 +14,7 @@ import { import { rangeQuery } from '../../../observability/server'; import { ProcessorEvent } from '../../common/processor_event'; import { TRANSACTION_PAGE_LOAD } from '../../common/transaction_types'; -import { getEsFilter } from '../lib/rum_client/ui_filters/get_es_filter'; +import { getEsFilter } from '../routes/rum_client/ui_filters/get_es_filter'; export function getRumPageLoadTransactionsProjection({ setup, diff --git a/x-pack/plugins/apm/server/lib/alerts/action_variables.ts b/x-pack/plugins/apm/server/routes/alerts/action_variables.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/alerts/action_variables.ts rename to x-pack/plugins/apm/server/routes/alerts/action_variables.ts diff --git a/x-pack/plugins/apm/server/lib/alerts/alerting_es_client.ts b/x-pack/plugins/apm/server/routes/alerts/alerting_es_client.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/alerts/alerting_es_client.ts rename to x-pack/plugins/apm/server/routes/alerts/alerting_es_client.ts diff --git a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_duration.ts b/x-pack/plugins/apm/server/routes/alerts/chart_preview/get_transaction_duration.ts similarity index 94% rename from x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_duration.ts rename to x-pack/plugins/apm/server/routes/alerts/chart_preview/get_transaction_duration.ts index 693502d7629e..0338f78a0a89 100644 --- a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_duration.ts +++ b/x-pack/plugins/apm/server/routes/alerts/chart_preview/get_transaction_duration.ts @@ -12,14 +12,14 @@ import { TRANSACTION_TYPE, } from '../../../../common/elasticsearch_fieldnames'; import { environmentQuery } from '../../../../common/utils/environment_query'; -import { AlertParams } from '../../../routes/alerts/chart_preview'; +import { AlertParams } from '../route'; import { getSearchAggregatedTransactions, getDocumentTypeFilterForTransactions, getTransactionDurationFieldForTransactions, getProcessorEventForTransactions, -} from '../../helpers/transactions'; -import { Setup } from '../../helpers/setup_request'; +} from '../../../lib/helpers/transactions'; +import { Setup } from '../../../lib/helpers/setup_request'; export async function getTransactionDurationChartPreview({ alertParams, diff --git a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_count.ts b/x-pack/plugins/apm/server/routes/alerts/chart_preview/get_transaction_error_count.ts similarity index 93% rename from x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_count.ts rename to x-pack/plugins/apm/server/routes/alerts/chart_preview/get_transaction_error_count.ts index 0e1fa74199f6..708acd6d7f8e 100644 --- a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_count.ts +++ b/x-pack/plugins/apm/server/routes/alerts/chart_preview/get_transaction_error_count.ts @@ -7,10 +7,10 @@ import { SERVICE_NAME } from '../../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../../common/processor_event'; -import { AlertParams } from '../../../routes/alerts/chart_preview'; +import { AlertParams } from '../route'; import { rangeQuery, termQuery } from '../../../../../observability/server'; import { environmentQuery } from '../../../../common/utils/environment_query'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; export async function getTransactionErrorCountChartPreview({ setup, diff --git a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_rate.ts b/x-pack/plugins/apm/server/routes/alerts/chart_preview/get_transaction_error_rate.ts similarity index 91% rename from x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_rate.ts rename to x-pack/plugins/apm/server/routes/alerts/chart_preview/get_transaction_error_rate.ts index e2bfaf29f83c..cf3380c105ac 100644 --- a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_rate.ts +++ b/x-pack/plugins/apm/server/routes/alerts/chart_preview/get_transaction_error_rate.ts @@ -11,17 +11,17 @@ import { TRANSACTION_TYPE, } from '../../../../common/elasticsearch_fieldnames'; import { environmentQuery } from '../../../../common/utils/environment_query'; -import { AlertParams } from '../../../routes/alerts/chart_preview'; +import { AlertParams } from '../route'; import { getSearchAggregatedTransactions, getDocumentTypeFilterForTransactions, getProcessorEventForTransactions, -} from '../../helpers/transactions'; -import { Setup } from '../../helpers/setup_request'; +} from '../../../lib/helpers/transactions'; +import { Setup } from '../../../lib/helpers/setup_request'; import { calculateFailedTransactionRate, getOutcomeAggregation, -} from '../../helpers/transaction_error_rate'; +} from '../../../lib/helpers/transaction_error_rate'; export async function getTransactionErrorRateChartPreview({ setup, diff --git a/x-pack/plugins/apm/server/lib/alerts/register_apm_alerts.ts b/x-pack/plugins/apm/server/routes/alerts/register_apm_alerts.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/alerts/register_apm_alerts.ts rename to x-pack/plugins/apm/server/routes/alerts/register_apm_alerts.ts diff --git a/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.test.ts b/x-pack/plugins/apm/server/routes/alerts/register_error_count_alert_type.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.test.ts rename to x-pack/plugins/apm/server/routes/alerts/register_error_count_alert_type.test.ts diff --git a/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts b/x-pack/plugins/apm/server/routes/alerts/register_error_count_alert_type.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts rename to x-pack/plugins/apm/server/routes/alerts/register_error_count_alert_type.ts index 723f52cb1eed..2dacb5ca1e89 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts +++ b/x-pack/plugins/apm/server/routes/alerts/register_error_count_alert_type.ts @@ -31,7 +31,7 @@ import { } from '../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../common/processor_event'; import { environmentQuery } from '../../../common/utils/environment_query'; -import { getApmIndices } from '../settings/apm_indices/get_apm_indices'; +import { getApmIndices } from '../../routes/settings/apm_indices/get_apm_indices'; import { apmActionVariables } from './action_variables'; import { alertingEsClient } from './alerting_es_client'; import { RegisterRuleDependencies } from './register_apm_alerts'; diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.test.ts b/x-pack/plugins/apm/server/routes/alerts/register_transaction_duration_alert_type.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.test.ts rename to x-pack/plugins/apm/server/routes/alerts/register_transaction_duration_alert_type.test.ts diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts b/x-pack/plugins/apm/server/routes/alerts/register_transaction_duration_alert_type.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts rename to x-pack/plugins/apm/server/routes/alerts/register_transaction_duration_alert_type.ts index 4e68ca6b5224..1e39b02655ad 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts +++ b/x-pack/plugins/apm/server/routes/alerts/register_transaction_duration_alert_type.ts @@ -37,8 +37,8 @@ import { getDurationFormatter } from '../../../common/utils/formatters'; import { getDocumentTypeFilterForTransactions, getTransactionDurationFieldForTransactions, -} from '../helpers/transactions'; -import { getApmIndices } from '../settings/apm_indices/get_apm_indices'; +} from '../../lib/helpers/transactions'; +import { getApmIndices } from '../../routes/settings/apm_indices/get_apm_indices'; import { apmActionVariables } from './action_variables'; import { alertingEsClient } from './alerting_es_client'; import { RegisterRuleDependencies } from './register_apm_alerts'; diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.test.ts b/x-pack/plugins/apm/server/routes/alerts/register_transaction_duration_anomaly_alert_type.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.test.ts rename to x-pack/plugins/apm/server/routes/alerts/register_transaction_duration_anomaly_alert_type.test.ts diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts b/x-pack/plugins/apm/server/routes/alerts/register_transaction_duration_anomaly_alert_type.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts rename to x-pack/plugins/apm/server/routes/alerts/register_transaction_duration_anomaly_alert_type.ts diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.test.ts b/x-pack/plugins/apm/server/routes/alerts/register_transaction_error_rate_alert_type.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.test.ts rename to x-pack/plugins/apm/server/routes/alerts/register_transaction_error_rate_alert_type.test.ts diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts b/x-pack/plugins/apm/server/routes/alerts/register_transaction_error_rate_alert_type.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts rename to x-pack/plugins/apm/server/routes/alerts/register_transaction_error_rate_alert_type.ts index cf5b45d90122..f196b718968d 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts +++ b/x-pack/plugins/apm/server/routes/alerts/register_transaction_error_rate_alert_type.ts @@ -35,12 +35,12 @@ import { EventOutcome } from '../../../common/event_outcome'; import { ProcessorEvent } from '../../../common/processor_event'; import { asDecimalOrInteger } from '../../../common/utils/formatters'; import { environmentQuery } from '../../../common/utils/environment_query'; -import { getApmIndices } from '../settings/apm_indices/get_apm_indices'; +import { getApmIndices } from '../../routes/settings/apm_indices/get_apm_indices'; import { apmActionVariables } from './action_variables'; import { alertingEsClient } from './alerting_es_client'; import { RegisterRuleDependencies } from './register_apm_alerts'; import { SearchAggregatedTransactionSetting } from '../../../common/aggregated_transactions'; -import { getDocumentTypeFilterForTransactions } from '../helpers/transactions'; +import { getDocumentTypeFilterForTransactions } from '../../lib/helpers/transactions'; import { asPercent } from '../../../../observability/common/utils/formatters'; import { termQuery } from '../../../../observability/server'; diff --git a/x-pack/plugins/apm/server/routes/alerts/chart_preview.ts b/x-pack/plugins/apm/server/routes/alerts/route.ts similarity index 89% rename from x-pack/plugins/apm/server/routes/alerts/chart_preview.ts rename to x-pack/plugins/apm/server/routes/alerts/route.ts index cae35c7f06a8..49baeda8d3a4 100644 --- a/x-pack/plugins/apm/server/routes/alerts/chart_preview.ts +++ b/x-pack/plugins/apm/server/routes/alerts/route.ts @@ -6,9 +6,9 @@ */ import * as t from 'io-ts'; -import { getTransactionDurationChartPreview } from '../../lib/alerts/chart_preview/get_transaction_duration'; -import { getTransactionErrorCountChartPreview } from '../../lib/alerts/chart_preview/get_transaction_error_count'; -import { getTransactionErrorRateChartPreview } from '../../lib/alerts/chart_preview/get_transaction_error_rate'; +import { getTransactionDurationChartPreview } from './chart_preview/get_transaction_duration'; +import { getTransactionErrorCountChartPreview } from './chart_preview/get_transaction_error_count'; +import { getTransactionErrorRateChartPreview } from './chart_preview/get_transaction_error_rate'; import { setupRequest } from '../../lib/helpers/setup_request'; import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; diff --git a/x-pack/plugins/apm/server/lib/alerts/test_utils/index.ts b/x-pack/plugins/apm/server/routes/alerts/test_utils/index.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/alerts/test_utils/index.ts rename to x-pack/plugins/apm/server/routes/alerts/test_utils/index.ts diff --git a/x-pack/plugins/apm/server/routes/apm_routes/get_global_apm_server_route_repository.ts b/x-pack/plugins/apm/server/routes/apm_routes/get_global_apm_server_route_repository.ts index fa8bc1e54ebf..ee4c9d1c8cfa 100644 --- a/x-pack/plugins/apm/server/routes/apm_routes/get_global_apm_server_route_repository.ts +++ b/x-pack/plugins/apm/server/routes/apm_routes/get_global_apm_server_route_repository.ts @@ -10,33 +10,33 @@ import type { EndpointOf, } from '@kbn/server-route-repository'; import { PickByValue } from 'utility-types'; -import { correlationsRouteRepository } from '../correlations'; -import { alertsChartPreviewRouteRepository } from '../alerts/chart_preview'; +import { correlationsRouteRepository } from '../correlations/route'; +import { alertsChartPreviewRouteRepository } from '../alerts/route'; import { backendsRouteRepository } from '../backends/route'; import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; -import { environmentsRouteRepository } from '../environments'; -import { errorsRouteRepository } from '../errors'; -import { apmFleetRouteRepository } from '../fleet'; -import { dataViewRouteRepository } from '../data_view'; -import { latencyDistributionRouteRepository } from '../latency_distribution'; -import { metricsRouteRepository } from '../metrics'; -import { observabilityOverviewRouteRepository } from '../observability_overview'; -import { rumRouteRepository } from '../rum_client'; -import { fallbackToTransactionsRouteRepository } from '../fallback_to_transactions'; -import { serviceRouteRepository } from '../services'; -import { serviceMapRouteRepository } from '../service_map'; -import { serviceNodeRouteRepository } from '../service_nodes'; -import { agentConfigurationRouteRepository } from '../settings/agent_configuration'; -import { anomalyDetectionRouteRepository } from '../settings/anomaly_detection'; -import { apmIndicesRouteRepository } from '../settings/apm_indices'; -import { customLinkRouteRepository } from '../settings/custom_link'; -import { sourceMapsRouteRepository } from '../source_maps'; -import { traceRouteRepository } from '../traces'; -import { transactionRouteRepository } from '../transactions'; +import { environmentsRouteRepository } from '../environments/route'; +import { errorsRouteRepository } from '../errors/route'; +import { apmFleetRouteRepository } from '../fleet/route'; +import { dataViewRouteRepository } from '../data_view/route'; +import { latencyDistributionRouteRepository } from '../latency_distribution/route'; +import { metricsRouteRepository } from '../metrics/route'; +import { observabilityOverviewRouteRepository } from '../observability_overview/route'; +import { rumRouteRepository } from '../rum_client/route'; +import { fallbackToTransactionsRouteRepository } from '../fallback_to_transactions/route'; +import { serviceRouteRepository } from '../services/route'; +import { serviceMapRouteRepository } from '../service_map/route'; +import { serviceNodeRouteRepository } from '../service_nodes/route'; +import { agentConfigurationRouteRepository } from '../settings/agent_configuration/route'; +import { anomalyDetectionRouteRepository } from '../settings/anomaly_detection/route'; +import { apmIndicesRouteRepository } from '../settings/apm_indices/route'; +import { customLinkRouteRepository } from '../settings/custom_link/route'; +import { sourceMapsRouteRepository } from '../source_maps/route'; +import { traceRouteRepository } from '../traces/route'; +import { transactionRouteRepository } from '../transactions/route'; import { APMRouteHandlerResources } from '../typings'; import { historicalDataRouteRepository } from '../historical_data'; -import { eventMetadataRouteRepository } from '../event_metadata'; -import { suggestionsRouteRepository } from '../suggestions'; +import { eventMetadataRouteRepository } from '../event_metadata/route'; +import { suggestionsRouteRepository } from '../suggestions/route'; const getTypedGlobalApmServerRouteRepository = () => { const repository = createApmServerRouteRepository() diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/field_stats/get_boolean_field_stats.ts b/x-pack/plugins/apm/server/routes/correlations/queries/field_stats/get_boolean_field_stats.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/field_stats/get_boolean_field_stats.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/field_stats/get_boolean_field_stats.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/field_stats/get_field_stats.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/field_stats/get_field_stats.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/field_stats/get_field_stats.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/field_stats/get_field_stats.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/field_stats/get_fields_stats.ts b/x-pack/plugins/apm/server/routes/correlations/queries/field_stats/get_fields_stats.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/field_stats/get_fields_stats.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/field_stats/get_fields_stats.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/field_stats/get_keyword_field_stats.ts b/x-pack/plugins/apm/server/routes/correlations/queries/field_stats/get_keyword_field_stats.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/field_stats/get_keyword_field_stats.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/field_stats/get_keyword_field_stats.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/field_stats/get_numeric_field_stats.ts b/x-pack/plugins/apm/server/routes/correlations/queries/field_stats/get_numeric_field_stats.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/field_stats/get_numeric_field_stats.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/field_stats/get_numeric_field_stats.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/get_filters.ts b/x-pack/plugins/apm/server/routes/correlations/queries/get_filters.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/get_filters.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/get_filters.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/get_query_with_params.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/get_query_with_params.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/get_query_with_params.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/get_query_with_params.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/get_query_with_params.ts b/x-pack/plugins/apm/server/routes/correlations/queries/get_query_with_params.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/get_query_with_params.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/get_query_with_params.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/get_request_base.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/get_request_base.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/get_request_base.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/get_request_base.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/get_request_base.ts b/x-pack/plugins/apm/server/routes/correlations/queries/get_request_base.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/get_request_base.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/get_request_base.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/index.ts b/x-pack/plugins/apm/server/routes/correlations/queries/index.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/index.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/index.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_correlation.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_correlation.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_correlation.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_correlation.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_correlation.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_correlation.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_correlation.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_correlation.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_correlation_with_histogram.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_correlation_with_histogram.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_correlation_with_histogram.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_correlation_with_histogram.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_correlation_with_histogram.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_correlation_with_histogram.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_correlation_with_histogram.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_correlation_with_histogram.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_failure_correlation.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_failure_correlation.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_failure_correlation.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_failure_correlation.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_field_candidates.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_field_candidates.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_field_candidates.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_field_candidates.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_field_candidates.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_field_candidates.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_field_candidates.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_field_candidates.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_field_value_pairs.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_field_value_pairs.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_field_value_pairs.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_field_value_pairs.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_field_value_pairs.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_field_value_pairs.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_field_value_pairs.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_field_value_pairs.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_fractions.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_fractions.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_fractions.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_fractions.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_fractions.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_fractions.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_fractions.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_fractions.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_histogram.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_histogram.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_histogram.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_histogram.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_histogram.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_histogram.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_histogram.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_histogram.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_histogram_range_steps.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_histogram_range_steps.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_histogram_range_steps.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_histogram_range_steps.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_histogram_range_steps.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_histogram_range_steps.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_histogram_range_steps.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_histogram_range_steps.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_p_values.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_p_values.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_p_values.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_p_values.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_percentiles.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_percentiles.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_percentiles.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_percentiles.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_percentiles.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_percentiles.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_percentiles.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_percentiles.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_ranges.test.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_ranges.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_ranges.test.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_ranges.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_ranges.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_ranges.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_ranges.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_ranges.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/queries/query_significant_correlations.ts b/x-pack/plugins/apm/server/routes/correlations/queries/query_significant_correlations.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/queries/query_significant_correlations.ts rename to x-pack/plugins/apm/server/routes/correlations/queries/query_significant_correlations.ts diff --git a/x-pack/plugins/apm/server/routes/correlations.ts b/x-pack/plugins/apm/server/routes/correlations/route.ts similarity index 92% rename from x-pack/plugins/apm/server/routes/correlations.ts rename to x-pack/plugins/apm/server/routes/correlations/route.ts index f6ca064b4385..b02a6fbc6b7a 100644 --- a/x-pack/plugins/apm/server/routes/correlations.ts +++ b/x-pack/plugins/apm/server/routes/correlations/route.ts @@ -11,22 +11,22 @@ import Boom from '@hapi/boom'; import { i18n } from '@kbn/i18n'; import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt'; -import { isActivePlatinumLicense } from '../../common/license_check'; +import { isActivePlatinumLicense } from '../../../common/license_check'; -import { setupRequest } from '../lib/helpers/setup_request'; +import { setupRequest } from '../../lib/helpers/setup_request'; import { fetchPValues, fetchSignificantCorrelations, fetchTransactionDurationFieldCandidates, fetchTransactionDurationFieldValuePairs, -} from '../lib/correlations/queries'; -import { fetchFieldsStats } from '../lib/correlations/queries/field_stats/get_fields_stats'; +} from './queries'; +import { fetchFieldsStats } from './queries/field_stats/get_fields_stats'; -import { withApmSpan } from '../utils/with_apm_span'; +import { withApmSpan } from '../../utils/with_apm_span'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { environmentRt, kueryRt, rangeRt } from './default_api_types'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { environmentRt, kueryRt, rangeRt } from '../default_api_types'; const INVALID_LICENSE = i18n.translate('xpack.apm.correlations.license.text', { defaultMessage: diff --git a/x-pack/plugins/apm/server/lib/correlations/utils/compute_expectations_and_ranges.test.ts b/x-pack/plugins/apm/server/routes/correlations/utils/compute_expectations_and_ranges.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/utils/compute_expectations_and_ranges.test.ts rename to x-pack/plugins/apm/server/routes/correlations/utils/compute_expectations_and_ranges.test.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/utils/compute_expectations_and_ranges.ts b/x-pack/plugins/apm/server/routes/correlations/utils/compute_expectations_and_ranges.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/utils/compute_expectations_and_ranges.ts rename to x-pack/plugins/apm/server/routes/correlations/utils/compute_expectations_and_ranges.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/utils/field_stats_utils.ts b/x-pack/plugins/apm/server/routes/correlations/utils/field_stats_utils.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/utils/field_stats_utils.ts rename to x-pack/plugins/apm/server/routes/correlations/utils/field_stats_utils.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/utils/index.ts b/x-pack/plugins/apm/server/routes/correlations/utils/index.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/utils/index.ts rename to x-pack/plugins/apm/server/routes/correlations/utils/index.ts diff --git a/x-pack/plugins/apm/server/lib/correlations/utils/split_all_settled_promises.ts b/x-pack/plugins/apm/server/routes/correlations/utils/split_all_settled_promises.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/correlations/utils/split_all_settled_promises.ts rename to x-pack/plugins/apm/server/routes/correlations/utils/split_all_settled_promises.ts diff --git a/x-pack/plugins/apm/server/lib/data_view/create_static_data_view.test.ts b/x-pack/plugins/apm/server/routes/data_view/create_static_data_view.test.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/data_view/create_static_data_view.test.ts rename to x-pack/plugins/apm/server/routes/data_view/create_static_data_view.test.ts index 77b9f0ffd4ad..7d345b5e3bec 100644 --- a/x-pack/plugins/apm/server/lib/data_view/create_static_data_view.test.ts +++ b/x-pack/plugins/apm/server/routes/data_view/create_static_data_view.test.ts @@ -6,9 +6,9 @@ */ import { createStaticDataView } from './create_static_data_view'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import * as HistoricalAgentData from '../../routes/historical_data/has_historical_agent_data'; -import { InternalSavedObjectsClient } from '../helpers/get_internal_saved_objects_client'; +import { InternalSavedObjectsClient } from '../../lib/helpers/get_internal_saved_objects_client'; import { APMConfig } from '../..'; function getMockSavedObjectsClient(existingDataViewTitle: string) { diff --git a/x-pack/plugins/apm/server/lib/data_view/create_static_data_view.ts b/x-pack/plugins/apm/server/routes/data_view/create_static_data_view.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/data_view/create_static_data_view.ts rename to x-pack/plugins/apm/server/routes/data_view/create_static_data_view.ts index 521d290b9ca2..13639d2efcbf 100644 --- a/x-pack/plugins/apm/server/lib/data_view/create_static_data_view.ts +++ b/x-pack/plugins/apm/server/routes/data_view/create_static_data_view.ts @@ -9,9 +9,9 @@ import { SavedObjectsErrorHelpers } from '../../../../../../src/core/server'; import { APM_STATIC_INDEX_PATTERN_ID } from '../../../common/index_pattern_constants'; import apmDataView from '../../tutorial/index_pattern.json'; import { hasHistoricalAgentData } from '../../routes/historical_data/has_historical_agent_data'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { APMRouteHandlerResources } from '../../routes/typings'; -import { InternalSavedObjectsClient } from '../helpers/get_internal_saved_objects_client.js'; +import { InternalSavedObjectsClient } from '../../lib/helpers/get_internal_saved_objects_client.js'; import { withApmSpan } from '../../utils/with_apm_span'; import { getApmDataViewTitle } from './get_apm_data_view_title'; diff --git a/x-pack/plugins/apm/server/lib/data_view/get_apm_data_view_title.test.ts b/x-pack/plugins/apm/server/routes/data_view/get_apm_data_view_title.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/data_view/get_apm_data_view_title.test.ts rename to x-pack/plugins/apm/server/routes/data_view/get_apm_data_view_title.test.ts diff --git a/x-pack/plugins/apm/server/lib/data_view/get_apm_data_view_title.ts b/x-pack/plugins/apm/server/routes/data_view/get_apm_data_view_title.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/data_view/get_apm_data_view_title.ts rename to x-pack/plugins/apm/server/routes/data_view/get_apm_data_view_title.ts diff --git a/x-pack/plugins/apm/server/lib/data_view/get_dynamic_data_view.ts b/x-pack/plugins/apm/server/routes/data_view/get_dynamic_data_view.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/data_view/get_dynamic_data_view.ts rename to x-pack/plugins/apm/server/routes/data_view/get_dynamic_data_view.ts diff --git a/x-pack/plugins/apm/server/routes/data_view.ts b/x-pack/plugins/apm/server/routes/data_view/route.ts similarity index 78% rename from x-pack/plugins/apm/server/routes/data_view.ts rename to x-pack/plugins/apm/server/routes/data_view/route.ts index 3590ef9db9bd..4e1c0ca050a0 100644 --- a/x-pack/plugins/apm/server/routes/data_view.ts +++ b/x-pack/plugins/apm/server/routes/data_view/route.ts @@ -5,11 +5,11 @@ * 2.0. */ -import { createStaticDataView } from '../lib/data_view/create_static_data_view'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { getDynamicDataView } from '../lib/data_view/get_dynamic_data_view'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; +import { createStaticDataView } from './create_static_data_view'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { getDynamicDataView } from './get_dynamic_data_view'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; const staticDataViewRoute = createApmServerRoute({ endpoint: 'POST /internal/apm/data_view/static', diff --git a/x-pack/plugins/apm/server/lib/environments/__snapshots__/get_all_environments.test.ts.snap b/x-pack/plugins/apm/server/routes/environments/__snapshots__/get_all_environments.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/environments/__snapshots__/get_all_environments.test.ts.snap rename to x-pack/plugins/apm/server/routes/environments/__snapshots__/get_all_environments.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/environments/__snapshots__/get_environments.test.ts.snap b/x-pack/plugins/apm/server/routes/environments/__snapshots__/get_environments.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/environments/__snapshots__/get_environments.test.ts.snap rename to x-pack/plugins/apm/server/routes/environments/__snapshots__/get_environments.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/environments/get_all_environments.test.ts b/x-pack/plugins/apm/server/routes/environments/get_all_environments.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/environments/get_all_environments.test.ts rename to x-pack/plugins/apm/server/routes/environments/get_all_environments.test.ts diff --git a/x-pack/plugins/apm/server/lib/environments/get_all_environments.ts b/x-pack/plugins/apm/server/routes/environments/get_all_environments.ts similarity index 93% rename from x-pack/plugins/apm/server/lib/environments/get_all_environments.ts rename to x-pack/plugins/apm/server/routes/environments/get_all_environments.ts index 7bdb21b9fda7..f479fd185b88 100644 --- a/x-pack/plugins/apm/server/lib/environments/get_all_environments.ts +++ b/x-pack/plugins/apm/server/routes/environments/get_all_environments.ts @@ -7,13 +7,13 @@ import { termQuery } from '../../../../observability/server'; import { ProcessorEvent } from '../../../common/processor_event'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { SERVICE_NAME, SERVICE_ENVIRONMENT, } from '../../../common/elasticsearch_fieldnames'; import { ENVIRONMENT_NOT_DEFINED } from '../../../common/environment_filter_values'; -import { getProcessorEventForTransactions } from '../helpers/transactions'; +import { getProcessorEventForTransactions } from '../../lib/helpers/transactions'; /** * This is used for getting *all* environments, and does not filter by range. diff --git a/x-pack/plugins/apm/server/lib/environments/get_environments.test.ts b/x-pack/plugins/apm/server/routes/environments/get_environments.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/environments/get_environments.test.ts rename to x-pack/plugins/apm/server/routes/environments/get_environments.test.ts diff --git a/x-pack/plugins/apm/server/lib/environments/get_environments.ts b/x-pack/plugins/apm/server/routes/environments/get_environments.ts similarity index 93% rename from x-pack/plugins/apm/server/lib/environments/get_environments.ts rename to x-pack/plugins/apm/server/routes/environments/get_environments.ts index cd5caab6d258..34ac9cb18d79 100644 --- a/x-pack/plugins/apm/server/lib/environments/get_environments.ts +++ b/x-pack/plugins/apm/server/routes/environments/get_environments.ts @@ -12,8 +12,8 @@ import { import { ENVIRONMENT_NOT_DEFINED } from '../../../common/environment_filter_values'; import { ProcessorEvent } from '../../../common/processor_event'; import { rangeQuery, termQuery } from '../../../../observability/server'; -import { getProcessorEventForTransactions } from '../helpers/transactions'; -import { Setup } from '../helpers/setup_request'; +import { getProcessorEventForTransactions } from '../../lib/helpers/transactions'; +import { Setup } from '../../lib/helpers/setup_request'; /** * This is used for getting the list of environments for the environments selector, diff --git a/x-pack/plugins/apm/server/routes/environments.ts b/x-pack/plugins/apm/server/routes/environments/route.ts similarity index 72% rename from x-pack/plugins/apm/server/routes/environments.ts rename to x-pack/plugins/apm/server/routes/environments/route.ts index 38328a63a411..6c980187cd33 100644 --- a/x-pack/plugins/apm/server/routes/environments.ts +++ b/x-pack/plugins/apm/server/routes/environments/route.ts @@ -6,13 +6,13 @@ */ import * as t from 'io-ts'; -import { maxSuggestions } from '../../../observability/common'; -import { getSearchAggregatedTransactions } from '../lib/helpers/transactions'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { getEnvironments } from '../lib/environments/get_environments'; -import { rangeRt } from './default_api_types'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; +import { maxSuggestions } from '../../../../observability/common'; +import { getSearchAggregatedTransactions } from '../../lib/helpers/transactions'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { getEnvironments } from './get_environments'; +import { rangeRt } from '../default_api_types'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; const environmentsRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/environments', diff --git a/x-pack/plugins/apm/server/lib/errors/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/routes/errors/__snapshots__/queries.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/errors/__snapshots__/queries.test.ts.snap rename to x-pack/plugins/apm/server/routes/errors/__snapshots__/queries.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/__snapshots__/get_buckets.test.ts.snap b/x-pack/plugins/apm/server/routes/errors/distribution/__snapshots__/get_buckets.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/errors/distribution/__snapshots__/get_buckets.test.ts.snap rename to x-pack/plugins/apm/server/routes/errors/distribution/__snapshots__/get_buckets.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/routes/errors/distribution/__snapshots__/queries.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/errors/distribution/__snapshots__/queries.test.ts.snap rename to x-pack/plugins/apm/server/routes/errors/distribution/__snapshots__/queries.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.test.ts b/x-pack/plugins/apm/server/routes/errors/distribution/get_buckets.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.test.ts rename to x-pack/plugins/apm/server/routes/errors/distribution/get_buckets.test.ts diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts b/x-pack/plugins/apm/server/routes/errors/distribution/get_buckets.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts rename to x-pack/plugins/apm/server/routes/errors/distribution/get_buckets.ts index 625089e99d36..dd2dd3bc9ff3 100644 --- a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts +++ b/x-pack/plugins/apm/server/routes/errors/distribution/get_buckets.ts @@ -16,7 +16,7 @@ import { termQuery, } from '../../../../../observability/server'; import { environmentQuery } from '../../../../common/utils/environment_query'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; export async function getBuckets({ environment, diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts b/x-pack/plugins/apm/server/routes/errors/distribution/get_distribution.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts rename to x-pack/plugins/apm/server/routes/errors/distribution/get_distribution.ts index 7d5cbe9f9558..9e7221b7cd93 100644 --- a/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts +++ b/x-pack/plugins/apm/server/routes/errors/distribution/get_distribution.ts @@ -6,7 +6,7 @@ */ import { offsetPreviousPeriodCoordinates } from '../../../../common/utils/offset_previous_period_coordinate'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { BUCKET_TARGET_COUNT } from '../../transactions/constants'; import { getBuckets } from './get_buckets'; diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/queries.test.ts b/x-pack/plugins/apm/server/routes/errors/distribution/queries.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/errors/distribution/queries.test.ts rename to x-pack/plugins/apm/server/routes/errors/distribution/queries.test.ts diff --git a/x-pack/plugins/apm/server/lib/errors/get_error_group_sample.ts b/x-pack/plugins/apm/server/routes/errors/get_error_group_sample.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/errors/get_error_group_sample.ts rename to x-pack/plugins/apm/server/routes/errors/get_error_group_sample.ts index 35c3ce999a9f..2c5073fb5dc6 100644 --- a/x-pack/plugins/apm/server/lib/errors/get_error_group_sample.ts +++ b/x-pack/plugins/apm/server/routes/errors/get_error_group_sample.ts @@ -14,7 +14,7 @@ import { import { ProcessorEvent } from '../../../common/processor_event'; import { rangeQuery, kqlQuery } from '../../../../observability/server'; import { environmentQuery } from '../../../common/utils/environment_query'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { getTransaction } from '../transactions/get_transaction'; export async function getErrorGroupSample({ diff --git a/x-pack/plugins/apm/server/lib/errors/get_error_groups.ts b/x-pack/plugins/apm/server/routes/errors/get_error_groups.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/errors/get_error_groups.ts rename to x-pack/plugins/apm/server/routes/errors/get_error_groups.ts index 4d4c935d20e7..b26f3f4e7b4f 100644 --- a/x-pack/plugins/apm/server/lib/errors/get_error_groups.ts +++ b/x-pack/plugins/apm/server/routes/errors/get_error_groups.ts @@ -18,8 +18,8 @@ import { ERROR_LOG_MESSAGE, SERVICE_NAME, } from '../../../common/elasticsearch_fieldnames'; -import { getErrorName } from '../helpers/get_error_name'; -import { Setup } from '../helpers/setup_request'; +import { getErrorName } from '../../lib/helpers/get_error_name'; +import { Setup } from '../../lib/helpers/setup_request'; export async function getErrorGroups({ environment, diff --git a/x-pack/plugins/apm/server/lib/errors/queries.test.ts b/x-pack/plugins/apm/server/routes/errors/queries.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/errors/queries.test.ts rename to x-pack/plugins/apm/server/routes/errors/queries.test.ts diff --git a/x-pack/plugins/apm/server/routes/errors.ts b/x-pack/plugins/apm/server/routes/errors/route.ts similarity index 86% rename from x-pack/plugins/apm/server/routes/errors.ts rename to x-pack/plugins/apm/server/routes/errors/route.ts index 02df03f10808..602fed89be93 100644 --- a/x-pack/plugins/apm/server/routes/errors.ts +++ b/x-pack/plugins/apm/server/routes/errors/route.ts @@ -6,18 +6,18 @@ */ import * as t from 'io-ts'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { getErrorDistribution } from '../lib/errors/distribution/get_distribution'; -import { getErrorGroupSample } from '../lib/errors/get_error_group_sample'; -import { getErrorGroups } from '../lib/errors/get_error_groups'; -import { setupRequest } from '../lib/helpers/setup_request'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { getErrorDistribution } from './distribution/get_distribution'; +import { getErrorGroupSample } from './get_error_group_sample'; +import { getErrorGroups } from './get_error_groups'; +import { setupRequest } from '../../lib/helpers/setup_request'; import { environmentRt, kueryRt, rangeRt, comparisonRangeRt, -} from './default_api_types'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; +} from '../default_api_types'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; const errorsRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/services/{serviceName}/errors', diff --git a/x-pack/plugins/apm/server/lib/event_metadata/get_event_metadata.ts b/x-pack/plugins/apm/server/routes/event_metadata/get_event_metadata.ts similarity index 93% rename from x-pack/plugins/apm/server/lib/event_metadata/get_event_metadata.ts rename to x-pack/plugins/apm/server/routes/event_metadata/get_event_metadata.ts index b9e0dee52a42..006c87a3dac2 100644 --- a/x-pack/plugins/apm/server/lib/event_metadata/get_event_metadata.ts +++ b/x-pack/plugins/apm/server/routes/event_metadata/get_event_metadata.ts @@ -12,7 +12,7 @@ import { TRANSACTION_ID, } from '../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../common/processor_event'; -import type { APMEventClient } from '../helpers/create_es_client/create_apm_event_client'; +import type { APMEventClient } from '../../lib/helpers/create_es_client/create_apm_event_client'; export async function getEventMetadata({ apmEventClient, diff --git a/x-pack/plugins/apm/server/routes/event_metadata.ts b/x-pack/plugins/apm/server/routes/event_metadata/route.ts similarity index 72% rename from x-pack/plugins/apm/server/routes/event_metadata.ts rename to x-pack/plugins/apm/server/routes/event_metadata/route.ts index 3a40e445007e..3140372aa69d 100644 --- a/x-pack/plugins/apm/server/routes/event_metadata.ts +++ b/x-pack/plugins/apm/server/routes/event_metadata/route.ts @@ -6,11 +6,11 @@ */ import * as t from 'io-ts'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { getEventMetadata } from '../lib/event_metadata/get_event_metadata'; -import { processorEventRt } from '../../common/processor_event'; -import { setupRequest } from '../lib/helpers/setup_request'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { getEventMetadata } from './get_event_metadata'; +import { processorEventRt } from '../../../common/processor_event'; +import { setupRequest } from '../../lib/helpers/setup_request'; const eventMetadataRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/event_metadata/{processorEvent}/{id}', diff --git a/x-pack/plugins/apm/server/routes/fallback_to_transactions.ts b/x-pack/plugins/apm/server/routes/fallback_to_transactions/route.ts similarity index 70% rename from x-pack/plugins/apm/server/routes/fallback_to_transactions.ts rename to x-pack/plugins/apm/server/routes/fallback_to_transactions/route.ts index 53e3ebae0d4f..77b5aeeac6ee 100644 --- a/x-pack/plugins/apm/server/routes/fallback_to_transactions.ts +++ b/x-pack/plugins/apm/server/routes/fallback_to_transactions/route.ts @@ -6,11 +6,11 @@ */ import * as t from 'io-ts'; -import { getIsUsingTransactionEvents } from '../lib/helpers/transactions/get_is_using_transaction_events'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { kueryRt, rangeRt } from './default_api_types'; +import { getIsUsingTransactionEvents } from '../../lib/helpers/transactions/get_is_using_transaction_events'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { kueryRt, rangeRt } from '../default_api_types'; const fallbackToTransactionsRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/fallback_to_transactions', diff --git a/x-pack/plugins/apm/server/lib/fleet/create_cloud_apm_package_policy.ts b/x-pack/plugins/apm/server/routes/fleet/create_cloud_apm_package_policy.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/fleet/create_cloud_apm_package_policy.ts rename to x-pack/plugins/apm/server/routes/fleet/create_cloud_apm_package_policy.ts index 6726865c6c3a..a3c7bfd079a4 100644 --- a/x-pack/plugins/apm/server/lib/fleet/create_cloud_apm_package_policy.ts +++ b/x-pack/plugins/apm/server/routes/fleet/create_cloud_apm_package_policy.ts @@ -20,7 +20,7 @@ import { APMPluginStartDependencies, } from '../../types'; import { getApmPackagePolicyDefinition } from './get_apm_package_policy_definition'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { mergePackagePolicyWithApm } from './merge_package_policy_with_apm'; export async function createCloudApmPackgePolicy({ diff --git a/x-pack/plugins/apm/server/lib/fleet/get_agents.ts b/x-pack/plugins/apm/server/routes/fleet/get_agents.ts similarity index 89% rename from x-pack/plugins/apm/server/lib/fleet/get_agents.ts rename to x-pack/plugins/apm/server/routes/fleet/get_agents.ts index 86a6294e96b0..bcfe42428dbe 100644 --- a/x-pack/plugins/apm/server/lib/fleet/get_agents.ts +++ b/x-pack/plugins/apm/server/routes/fleet/get_agents.ts @@ -11,7 +11,7 @@ import { SavedObjectsClientContract, } from 'kibana/server'; import { APMPluginStartDependencies } from '../../types'; -import { getInternalSavedObjectsClient } from '../helpers/get_internal_saved_objects_client'; +import { getInternalSavedObjectsClient } from '../../lib/helpers/get_internal_saved_objects_client'; export async function getFleetAgents({ policyIds, diff --git a/x-pack/plugins/apm/server/lib/fleet/get_apm_package_policies.ts b/x-pack/plugins/apm/server/routes/fleet/get_apm_package_policies.ts similarity index 89% rename from x-pack/plugins/apm/server/lib/fleet/get_apm_package_policies.ts rename to x-pack/plugins/apm/server/routes/fleet/get_apm_package_policies.ts index 5128339368f4..89ab9df051f7 100644 --- a/x-pack/plugins/apm/server/lib/fleet/get_apm_package_policies.ts +++ b/x-pack/plugins/apm/server/routes/fleet/get_apm_package_policies.ts @@ -11,7 +11,7 @@ import { SavedObjectsClientContract, } from 'kibana/server'; import { APMPluginStartDependencies } from '../../types'; -import { getInternalSavedObjectsClient } from '../helpers/get_internal_saved_objects_client'; +import { getInternalSavedObjectsClient } from '../../lib/helpers/get_internal_saved_objects_client'; export async function getApmPackgePolicies({ core, diff --git a/x-pack/plugins/apm/server/lib/fleet/get_apm_package_policy_definition.test.ts b/x-pack/plugins/apm/server/routes/fleet/get_apm_package_policy_definition.test.ts similarity index 94% rename from x-pack/plugins/apm/server/lib/fleet/get_apm_package_policy_definition.test.ts rename to x-pack/plugins/apm/server/routes/fleet/get_apm_package_policy_definition.test.ts index 3940fa60a38f..805099d87e1c 100644 --- a/x-pack/plugins/apm/server/lib/fleet/get_apm_package_policy_definition.test.ts +++ b/x-pack/plugins/apm/server/routes/fleet/get_apm_package_policy_definition.test.ts @@ -10,6 +10,7 @@ import { preprocessLegacyFields } from './get_apm_package_policy_definition'; const apmServerSchema = { 'apm-server.host': '0.0.0.0:8200', 'apm-server.secret_token': 'asdfkjhasdf', + 'apm-server.api_key.enabled': true, 'apm-server.read_timeout': 3600, 'apm-server.rum.event_rate.limit': 100, 'apm-server.rum.event_rate.lru_size': 100, @@ -29,6 +30,7 @@ describe('get_apm_package_policy_definition', () => { "apm-server.auth.anonymous.allow_service": "opbeans-test", "apm-server.auth.anonymous.rate_limit.event_limit": 100, "apm-server.auth.anonymous.rate_limit.ip_limit": 100, + "apm-server.auth.api_key.enabled": true, "apm-server.auth.secret_token": "asdfkjhasdf", "apm-server.host": "0.0.0.0:8200", "apm-server.read_timeout": 3600, diff --git a/x-pack/plugins/apm/server/lib/fleet/get_apm_package_policy_definition.ts b/x-pack/plugins/apm/server/routes/fleet/get_apm_package_policy_definition.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/fleet/get_apm_package_policy_definition.ts rename to x-pack/plugins/apm/server/routes/fleet/get_apm_package_policy_definition.ts index df922dd18fe4..9e1889fbe1ed 100644 --- a/x-pack/plugins/apm/server/lib/fleet/get_apm_package_policy_definition.ts +++ b/x-pack/plugins/apm/server/routes/fleet/get_apm_package_policy_definition.ts @@ -68,6 +68,10 @@ export function preprocessLegacyFields({ key: 'apm-server.auth.secret_token', legacyKey: 'apm-server.secret_token', }, + { + key: 'apm-server.auth.api_key.enabled', + legacyKey: 'apm-server.api_key.enabled', + }, ].forEach(({ key, legacyKey }) => { if (!copyOfApmServerSchema[key]) { copyOfApmServerSchema[key] = copyOfApmServerSchema[legacyKey]; diff --git a/x-pack/plugins/apm/server/lib/fleet/get_cloud_apm_package_policy.ts b/x-pack/plugins/apm/server/routes/fleet/get_cloud_apm_package_policy.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/fleet/get_cloud_apm_package_policy.ts rename to x-pack/plugins/apm/server/routes/fleet/get_cloud_apm_package_policy.ts diff --git a/x-pack/plugins/apm/server/lib/fleet/get_unsupported_apm_server_schema.test.ts b/x-pack/plugins/apm/server/routes/fleet/get_unsupported_apm_server_schema.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/fleet/get_unsupported_apm_server_schema.test.ts rename to x-pack/plugins/apm/server/routes/fleet/get_unsupported_apm_server_schema.test.ts diff --git a/x-pack/plugins/apm/server/lib/fleet/get_unsupported_apm_server_schema.ts b/x-pack/plugins/apm/server/routes/fleet/get_unsupported_apm_server_schema.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/fleet/get_unsupported_apm_server_schema.ts rename to x-pack/plugins/apm/server/routes/fleet/get_unsupported_apm_server_schema.ts diff --git a/x-pack/plugins/apm/server/lib/fleet/is_superuser.ts b/x-pack/plugins/apm/server/routes/fleet/is_superuser.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/fleet/is_superuser.ts rename to x-pack/plugins/apm/server/routes/fleet/is_superuser.ts diff --git a/x-pack/plugins/apm/server/lib/fleet/merge_package_policy_with_apm.ts b/x-pack/plugins/apm/server/routes/fleet/merge_package_policy_with_apm.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/fleet/merge_package_policy_with_apm.ts rename to x-pack/plugins/apm/server/routes/fleet/merge_package_policy_with_apm.ts index fd3e3db700fd..5442185decde 100644 --- a/x-pack/plugins/apm/server/lib/fleet/merge_package_policy_with_apm.ts +++ b/x-pack/plugins/apm/server/routes/fleet/merge_package_policy_with_apm.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { APMPluginStartDependencies } from '../../types'; import { listConfigurations } from '../settings/agent_configuration/list_configurations'; import { diff --git a/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts b/x-pack/plugins/apm/server/routes/fleet/register_fleet_policy_callbacks.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts rename to x-pack/plugins/apm/server/routes/fleet/register_fleet_policy_callbacks.ts index 6fcd0433e2e8..06e55c7fdcca 100644 --- a/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts +++ b/x-pack/plugins/apm/server/routes/fleet/register_fleet_policy_callbacks.ts @@ -17,7 +17,7 @@ import { import { AgentConfiguration } from '../../../common/agent_configuration/configuration_types'; import { AGENT_NAME } from '../../../common/elasticsearch_fieldnames'; import { APMPluginStartDependencies } from '../../types'; -import { setupRequest } from '../helpers/setup_request'; +import { setupRequest } from '../../lib/helpers/setup_request'; import { mergePackagePolicyWithApm } from './merge_package_policy_with_apm'; export async function registerFleetPolicyCallbacks({ diff --git a/x-pack/plugins/apm/server/routes/fleet.ts b/x-pack/plugins/apm/server/routes/fleet/route.ts similarity index 89% rename from x-pack/plugins/apm/server/routes/fleet.ts rename to x-pack/plugins/apm/server/routes/fleet/route.ts index a6e0cb09d894..e9e7f2254bcf 100644 --- a/x-pack/plugins/apm/server/routes/fleet.ts +++ b/x-pack/plugins/apm/server/routes/fleet/route.ts @@ -12,20 +12,20 @@ import { keyBy } from 'lodash'; import { APM_SERVER_SCHEMA_SAVED_OBJECT_ID, APM_SERVER_SCHEMA_SAVED_OBJECT_TYPE, -} from '../../common/apm_saved_object_constants'; -import { createCloudApmPackgePolicy } from '../lib/fleet/create_cloud_apm_package_policy'; -import { getFleetAgents } from '../lib/fleet/get_agents'; -import { getApmPackgePolicies } from '../lib/fleet/get_apm_package_policies'; +} from '../../../common/apm_saved_object_constants'; +import { createCloudApmPackgePolicy } from './create_cloud_apm_package_policy'; +import { getFleetAgents } from './get_agents'; +import { getApmPackgePolicies } from './get_apm_package_policies'; import { getApmPackagePolicy, getCloudAgentPolicy, -} from '../lib/fleet/get_cloud_apm_package_policy'; -import { getUnsupportedApmServerSchema } from '../lib/fleet/get_unsupported_apm_server_schema'; -import { isSuperuser } from '../lib/fleet/is_superuser'; -import { getInternalSavedObjectsClient } from '../lib/helpers/get_internal_saved_objects_client'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; +} from './get_cloud_apm_package_policy'; +import { getUnsupportedApmServerSchema } from './get_unsupported_apm_server_schema'; +import { isSuperuser } from './is_superuser'; +import { getInternalSavedObjectsClient } from '../../lib/helpers/get_internal_saved_objects_client'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; const hasFleetDataRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/fleet/has_data', diff --git a/x-pack/plugins/apm/server/lib/fleet/source_maps.test.ts b/x-pack/plugins/apm/server/routes/fleet/source_maps.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/fleet/source_maps.test.ts rename to x-pack/plugins/apm/server/routes/fleet/source_maps.test.ts diff --git a/x-pack/plugins/apm/server/lib/fleet/source_maps.ts b/x-pack/plugins/apm/server/routes/fleet/source_maps.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/fleet/source_maps.ts rename to x-pack/plugins/apm/server/routes/fleet/source_maps.ts index 8c11f80f2119..1d70076a828d 100644 --- a/x-pack/plugins/apm/server/lib/fleet/source_maps.ts +++ b/x-pack/plugins/apm/server/routes/fleet/source_maps.ts @@ -13,7 +13,7 @@ import { import { promisify } from 'util'; import { unzip } from 'zlib'; import { Artifact } from '../../../../fleet/server'; -import { SourceMap } from '../../routes/source_maps'; +import { SourceMap } from '../source_maps/route'; import { APMPluginStartDependencies } from '../../types'; import { getApmPackgePolicies } from './get_apm_package_policies'; import { APM_SERVER, PackagePolicy } from './register_fleet_policy_callbacks'; diff --git a/x-pack/plugins/apm/server/lib/fleet/sync_agent_configs_to_apm_package_policies.ts b/x-pack/plugins/apm/server/routes/fleet/sync_agent_configs_to_apm_package_policies.ts similarity index 90% rename from x-pack/plugins/apm/server/lib/fleet/sync_agent_configs_to_apm_package_policies.ts rename to x-pack/plugins/apm/server/routes/fleet/sync_agent_configs_to_apm_package_policies.ts index 5f3a3f74598a..c3660eee0afa 100644 --- a/x-pack/plugins/apm/server/lib/fleet/sync_agent_configs_to_apm_package_policies.ts +++ b/x-pack/plugins/apm/server/routes/fleet/sync_agent_configs_to_apm_package_policies.ts @@ -10,10 +10,10 @@ import { CoreStart, SavedObjectsClientContract, } from 'kibana/server'; -import { TelemetryUsageCounter } from '../../routes/typings'; +import { TelemetryUsageCounter } from '../typings'; import { APMPluginStartDependencies } from '../../types'; -import { getInternalSavedObjectsClient } from '../helpers/get_internal_saved_objects_client'; -import { Setup } from '../helpers/setup_request'; +import { getInternalSavedObjectsClient } from '../../lib/helpers/get_internal_saved_objects_client'; +import { Setup } from '../../lib/helpers/setup_request'; import { listConfigurations } from '../settings/agent_configuration/list_configurations'; import { getApmPackgePolicies } from './get_apm_package_policies'; import { getPackagePolicyWithAgentConfigurations } from './register_fleet_policy_callbacks'; diff --git a/x-pack/plugins/apm/server/lib/latency/get_overall_latency_distribution.ts b/x-pack/plugins/apm/server/routes/latency_distribution/get_overall_latency_distribution.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/latency/get_overall_latency_distribution.ts rename to x-pack/plugins/apm/server/routes/latency_distribution/get_overall_latency_distribution.ts diff --git a/x-pack/plugins/apm/server/lib/latency/get_percentile_threshold_value.ts b/x-pack/plugins/apm/server/routes/latency_distribution/get_percentile_threshold_value.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/latency/get_percentile_threshold_value.ts rename to x-pack/plugins/apm/server/routes/latency_distribution/get_percentile_threshold_value.ts diff --git a/x-pack/plugins/apm/server/routes/latency_distribution.ts b/x-pack/plugins/apm/server/routes/latency_distribution/route.ts similarity index 80% rename from x-pack/plugins/apm/server/routes/latency_distribution.ts rename to x-pack/plugins/apm/server/routes/latency_distribution/route.ts index 826898784835..f30e98dd8c7b 100644 --- a/x-pack/plugins/apm/server/routes/latency_distribution.ts +++ b/x-pack/plugins/apm/server/routes/latency_distribution/route.ts @@ -7,11 +7,11 @@ import * as t from 'io-ts'; import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt'; -import { getOverallLatencyDistribution } from '../lib/latency/get_overall_latency_distribution'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { environmentRt, kueryRt, rangeRt } from './default_api_types'; +import { getOverallLatencyDistribution } from './get_overall_latency_distribution'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { environmentRt, kueryRt, rangeRt } from '../default_api_types'; const latencyOverallDistributionRoute = createApmServerRoute({ endpoint: 'POST /internal/apm/latency/overall_distribution', diff --git a/x-pack/plugins/apm/server/lib/latency/types.ts b/x-pack/plugins/apm/server/routes/latency_distribution/types.ts similarity index 92% rename from x-pack/plugins/apm/server/lib/latency/types.ts rename to x-pack/plugins/apm/server/routes/latency_distribution/types.ts index 17c036f44f08..d2eb9cde0bf3 100644 --- a/x-pack/plugins/apm/server/lib/latency/types.ts +++ b/x-pack/plugins/apm/server/routes/latency_distribution/types.ts @@ -10,7 +10,7 @@ import type { CorrelationsClientParams, } from '../../../common/correlations/types'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; export interface OverallLatencyDistributionOptions extends CorrelationsClientParams { diff --git a/x-pack/plugins/apm/server/lib/metrics/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/routes/metrics/__snapshots__/queries.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/metrics/__snapshots__/queries.test.ts.snap rename to x-pack/plugins/apm/server/routes/metrics/__snapshots__/queries.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/default.ts b/x-pack/plugins/apm/server/routes/metrics/by_agent/default.ts similarity index 92% rename from x-pack/plugins/apm/server/lib/metrics/by_agent/default.ts rename to x-pack/plugins/apm/server/routes/metrics/by_agent/default.ts index 54e10bd8adde..b4e95d5217da 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/default.ts +++ b/x-pack/plugins/apm/server/routes/metrics/by_agent/default.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { getCPUChartData } from './shared/cpu'; import { getMemoryChartData } from './shared/memory'; diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.test.ts b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.test.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.test.ts rename to x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.test.ts index c22c326473e2..8b3fcbfe5ce8 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.test.ts +++ b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.test.ts @@ -9,7 +9,7 @@ import { METRIC_JAVA_GC_COUNT, METRIC_JAVA_GC_TIME, } from '../../../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../../../helpers/setup_request'; +import { Setup } from '../../../../../lib/helpers/setup_request'; import { ChartBase } from '../../../types'; import { fetchAndTransformGcMetrics } from './fetch_and_transform_gc_metrics'; diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts rename to x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts index 2d4cf2f70ab5..790fcf572074 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts +++ b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts @@ -8,8 +8,8 @@ import { sum, round } from 'lodash'; import { euiLightVars as theme } from '@kbn/ui-shared-deps-src/theme'; import { isFiniteNumber } from '../../../../../../common/utils/is_finite_number'; -import { Setup } from '../../../../helpers/setup_request'; -import { getMetricsDateHistogramParams } from '../../../../helpers/metrics'; +import { Setup } from '../../../../../lib/helpers/setup_request'; +import { getMetricsDateHistogramParams } from '../../../../../lib/helpers/metrics'; import { ChartBase } from '../../../types'; import { @@ -19,7 +19,7 @@ import { METRIC_JAVA_GC_TIME, SERVICE_NAME, } from '../../../../../../common/elasticsearch_fieldnames'; -import { getBucketSize } from '../../../../helpers/get_bucket_size'; +import { getBucketSize } from '../../../../../lib/helpers/get_bucket_size'; import { getVizColorForIndex } from '../../../../../../common/viz_colors'; import { JAVA_AGENT_NAMES } from '../../../../../../common/agent_name'; import { diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_rate_chart.ts b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/get_gc_rate_chart.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_rate_chart.ts rename to x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/get_gc_rate_chart.ts index 22dcb3e0f08f..a22f7df91561 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_rate_chart.ts +++ b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/get_gc_rate_chart.ts @@ -8,7 +8,7 @@ import { euiLightVars as theme } from '@kbn/ui-shared-deps-src/theme'; import { i18n } from '@kbn/i18n'; import { METRIC_JAVA_GC_COUNT } from '../../../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../../../helpers/setup_request'; +import { Setup } from '../../../../../lib/helpers/setup_request'; import { fetchAndTransformGcMetrics } from './fetch_and_transform_gc_metrics'; import { ChartBase } from '../../../types'; diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_time_chart.ts b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/get_gc_time_chart.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_time_chart.ts rename to x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/get_gc_time_chart.ts index 4b85ad94f649..596d871b916f 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_time_chart.ts +++ b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/gc/get_gc_time_chart.ts @@ -8,7 +8,7 @@ import { euiLightVars as theme } from '@kbn/ui-shared-deps-src/theme'; import { i18n } from '@kbn/i18n'; import { METRIC_JAVA_GC_TIME } from '../../../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../../../helpers/setup_request'; +import { Setup } from '../../../../../lib/helpers/setup_request'; import { fetchAndTransformGcMetrics } from './fetch_and_transform_gc_metrics'; import { ChartBase } from '../../../types'; diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/heap_memory/index.ts b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/heap_memory/index.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/metrics/by_agent/java/heap_memory/index.ts rename to x-pack/plugins/apm/server/routes/metrics/by_agent/java/heap_memory/index.ts index a872a3af76d7..cde28e77e38c 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/heap_memory/index.ts +++ b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/heap_memory/index.ts @@ -13,7 +13,7 @@ import { METRIC_JAVA_HEAP_MEMORY_USED, AGENT_NAME, } from '../../../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../../../helpers/setup_request'; +import { Setup } from '../../../../../lib/helpers/setup_request'; import { fetchAndTransformMetrics } from '../../../fetch_and_transform_metrics'; import { ChartBase } from '../../../types'; import { JAVA_AGENT_NAMES } from '../../../../../../common/agent_name'; diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/index.ts b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/index.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/metrics/by_agent/java/index.ts rename to x-pack/plugins/apm/server/routes/metrics/by_agent/java/index.ts index 9039bb19ebb7..5250884ed5e4 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/index.ts +++ b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/index.ts @@ -7,7 +7,7 @@ import { withApmSpan } from '../../../../utils/with_apm_span'; import { getHeapMemoryChart } from './heap_memory'; -import { Setup } from '../../../helpers/setup_request'; +import { Setup } from '../../../../lib/helpers/setup_request'; import { getNonHeapMemoryChart } from './non_heap_memory'; import { getThreadCountChart } from './thread_count'; import { getCPUChartData } from '../shared/cpu'; diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/non_heap_memory/index.ts b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/non_heap_memory/index.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/metrics/by_agent/java/non_heap_memory/index.ts rename to x-pack/plugins/apm/server/routes/metrics/by_agent/java/non_heap_memory/index.ts index 9fa758cb4dbd..ffcce74ee676 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/non_heap_memory/index.ts +++ b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/non_heap_memory/index.ts @@ -13,7 +13,7 @@ import { METRIC_JAVA_NON_HEAP_MEMORY_USED, AGENT_NAME, } from '../../../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../../../helpers/setup_request'; +import { Setup } from '../../../../../lib/helpers/setup_request'; import { ChartBase } from '../../../types'; import { fetchAndTransformMetrics } from '../../../fetch_and_transform_metrics'; import { JAVA_AGENT_NAMES } from '../../../../../../common/agent_name'; diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/thread_count/index.ts b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/thread_count/index.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/metrics/by_agent/java/thread_count/index.ts rename to x-pack/plugins/apm/server/routes/metrics/by_agent/java/thread_count/index.ts index 306666d27cd1..699812ffc846 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/thread_count/index.ts +++ b/x-pack/plugins/apm/server/routes/metrics/by_agent/java/thread_count/index.ts @@ -11,7 +11,7 @@ import { METRIC_JAVA_THREAD_COUNT, AGENT_NAME, } from '../../../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../../../helpers/setup_request'; +import { Setup } from '../../../../../lib/helpers/setup_request'; import { ChartBase } from '../../../types'; import { fetchAndTransformMetrics } from '../../../fetch_and_transform_metrics'; import { JAVA_AGENT_NAMES } from '../../../../../../common/agent_name'; diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/cpu/index.ts b/x-pack/plugins/apm/server/routes/metrics/by_agent/shared/cpu/index.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/metrics/by_agent/shared/cpu/index.ts rename to x-pack/plugins/apm/server/routes/metrics/by_agent/shared/cpu/index.ts index 0911081b2032..95c39d4bd55c 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/cpu/index.ts +++ b/x-pack/plugins/apm/server/routes/metrics/by_agent/shared/cpu/index.ts @@ -11,7 +11,7 @@ import { METRIC_SYSTEM_CPU_PERCENT, METRIC_PROCESS_CPU_PERCENT, } from '../../../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../../../helpers/setup_request'; +import { Setup } from '../../../../../lib/helpers/setup_request'; import { ChartBase } from '../../../types'; import { fetchAndTransformMetrics } from '../../../fetch_and_transform_metrics'; diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/memory/index.ts b/x-pack/plugins/apm/server/routes/metrics/by_agent/shared/memory/index.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/metrics/by_agent/shared/memory/index.ts rename to x-pack/plugins/apm/server/routes/metrics/by_agent/shared/memory/index.ts index 828ee2826047..d0e84211ef45 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/memory/index.ts +++ b/x-pack/plugins/apm/server/routes/metrics/by_agent/shared/memory/index.ts @@ -13,7 +13,7 @@ import { METRIC_SYSTEM_FREE_MEMORY, METRIC_SYSTEM_TOTAL_MEMORY, } from '../../../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../../../helpers/setup_request'; +import { Setup } from '../../../../../lib/helpers/setup_request'; import { fetchAndTransformMetrics } from '../../../fetch_and_transform_metrics'; import { ChartBase } from '../../../types'; diff --git a/x-pack/plugins/apm/server/lib/metrics/fetch_and_transform_metrics.ts b/x-pack/plugins/apm/server/routes/metrics/fetch_and_transform_metrics.ts similarity index 94% rename from x-pack/plugins/apm/server/lib/metrics/fetch_and_transform_metrics.ts rename to x-pack/plugins/apm/server/routes/metrics/fetch_and_transform_metrics.ts index 0a24179ed9fc..e607ae08e0b2 100644 --- a/x-pack/plugins/apm/server/lib/metrics/fetch_and_transform_metrics.ts +++ b/x-pack/plugins/apm/server/routes/metrics/fetch_and_transform_metrics.ts @@ -10,8 +10,9 @@ import { euiLightVars as theme } from '@kbn/ui-shared-deps-src/theme'; import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import { getVizColorForIndex } from '../../../common/viz_colors'; import { AggregationOptionsByType } from '../../../../../../src/core/types/elasticsearch'; -import { getMetricsDateHistogramParams } from '../helpers/metrics'; -import { Setup } from '../helpers/setup_request'; +import { APMEventESSearchRequest } from '../../lib/helpers/create_es_client/create_apm_event_client'; +import { getMetricsDateHistogramParams } from '../../lib/helpers/metrics'; +import { Setup } from '../../lib/helpers/setup_request'; import { ChartBase } from './types'; import { environmentQuery, @@ -20,7 +21,6 @@ import { import { kqlQuery, rangeQuery } from '../../../../observability/server'; import { ProcessorEvent } from '../../../common/processor_event'; import { SERVICE_NAME } from '../../../common/elasticsearch_fieldnames'; -import { APMEventESSearchRequest } from '../helpers/create_es_client/create_apm_event_client'; import { PromiseReturnType } from '../../../../observability/typings/common'; type MetricsAggregationMap = Unionize<{ diff --git a/x-pack/plugins/apm/server/lib/metrics/get_metrics_chart_data_by_agent.ts b/x-pack/plugins/apm/server/routes/metrics/get_metrics_chart_data_by_agent.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/metrics/get_metrics_chart_data_by_agent.ts rename to x-pack/plugins/apm/server/routes/metrics/get_metrics_chart_data_by_agent.ts index 611bb8196032..c6927417687d 100644 --- a/x-pack/plugins/apm/server/lib/metrics/get_metrics_chart_data_by_agent.ts +++ b/x-pack/plugins/apm/server/routes/metrics/get_metrics_chart_data_by_agent.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { getJavaMetricsCharts } from './by_agent/java'; import { getDefaultMetricsCharts } from './by_agent/default'; import { isJavaAgentName } from '../../../common/agent_name'; diff --git a/x-pack/plugins/apm/server/lib/metrics/queries.test.ts b/x-pack/plugins/apm/server/routes/metrics/queries.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/metrics/queries.test.ts rename to x-pack/plugins/apm/server/routes/metrics/queries.test.ts diff --git a/x-pack/plugins/apm/server/routes/metrics.ts b/x-pack/plugins/apm/server/routes/metrics/route.ts similarity index 76% rename from x-pack/plugins/apm/server/routes/metrics.ts rename to x-pack/plugins/apm/server/routes/metrics/route.ts index 36a504859797..4e15188827e9 100644 --- a/x-pack/plugins/apm/server/routes/metrics.ts +++ b/x-pack/plugins/apm/server/routes/metrics/route.ts @@ -6,11 +6,11 @@ */ import * as t from 'io-ts'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { getMetricsChartDataByAgent } from '../lib/metrics/get_metrics_chart_data_by_agent'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { environmentRt, kueryRt, rangeRt } from './default_api_types'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { getMetricsChartDataByAgent } from './get_metrics_chart_data_by_agent'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { environmentRt, kueryRt, rangeRt } from '../default_api_types'; const metricsChartsRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/services/{serviceName}/metrics/charts', diff --git a/x-pack/plugins/apm/server/lib/metrics/types.ts b/x-pack/plugins/apm/server/routes/metrics/types.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/metrics/types.ts rename to x-pack/plugins/apm/server/routes/metrics/types.ts diff --git a/x-pack/plugins/apm/server/lib/observability_overview/get_service_count.ts b/x-pack/plugins/apm/server/routes/observability_overview/get_service_count.ts similarity index 90% rename from x-pack/plugins/apm/server/lib/observability_overview/get_service_count.ts rename to x-pack/plugins/apm/server/routes/observability_overview/get_service_count.ts index 3eb11f668115..74b70e5fa7d6 100644 --- a/x-pack/plugins/apm/server/lib/observability_overview/get_service_count.ts +++ b/x-pack/plugins/apm/server/routes/observability_overview/get_service_count.ts @@ -8,8 +8,8 @@ import { ProcessorEvent } from '../../../common/processor_event'; import { rangeQuery } from '../../../../observability/server'; import { SERVICE_NAME } from '../../../common/elasticsearch_fieldnames'; -import { Setup } from '../helpers/setup_request'; -import { getProcessorEventForTransactions } from '../helpers/transactions'; +import { Setup } from '../../lib/helpers/setup_request'; +import { getProcessorEventForTransactions } from '../../lib/helpers/transactions'; export async function getServiceCount({ setup, diff --git a/x-pack/plugins/apm/server/lib/observability_overview/get_transactions_per_minute.ts b/x-pack/plugins/apm/server/routes/observability_overview/get_transactions_per_minute.ts similarity index 93% rename from x-pack/plugins/apm/server/lib/observability_overview/get_transactions_per_minute.ts rename to x-pack/plugins/apm/server/routes/observability_overview/get_transactions_per_minute.ts index de4d6dec4e1f..83e51d7d638f 100644 --- a/x-pack/plugins/apm/server/lib/observability_overview/get_transactions_per_minute.ts +++ b/x-pack/plugins/apm/server/routes/observability_overview/get_transactions_per_minute.ts @@ -11,12 +11,12 @@ import { } from '../../../common/transaction_types'; import { TRANSACTION_TYPE } from '../../../common/elasticsearch_fieldnames'; import { rangeQuery } from '../../../../observability/server'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { getDocumentTypeFilterForTransactions, getProcessorEventForTransactions, -} from '../helpers/transactions'; -import { calculateThroughputWithRange } from '../helpers/calculate_throughput'; +} from '../../lib/helpers/transactions'; +import { calculateThroughputWithRange } from '../../lib/helpers/calculate_throughput'; export async function getTransactionsPerMinute({ setup, diff --git a/x-pack/plugins/apm/server/lib/observability_overview/has_data.ts b/x-pack/plugins/apm/server/routes/observability_overview/has_data.ts similarity index 94% rename from x-pack/plugins/apm/server/lib/observability_overview/has_data.ts rename to x-pack/plugins/apm/server/routes/observability_overview/has_data.ts index f09b67ec98df..9f98af055e69 100644 --- a/x-pack/plugins/apm/server/lib/observability_overview/has_data.ts +++ b/x-pack/plugins/apm/server/routes/observability_overview/has_data.ts @@ -6,7 +6,7 @@ */ import { ProcessorEvent } from '../../../common/processor_event'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; export async function getHasData({ setup }: { setup: Setup }) { const { apmEventClient } = setup; diff --git a/x-pack/plugins/apm/server/routes/observability_overview.ts b/x-pack/plugins/apm/server/routes/observability_overview/route.ts similarity index 74% rename from x-pack/plugins/apm/server/routes/observability_overview.ts rename to x-pack/plugins/apm/server/routes/observability_overview/route.ts index 2df3212d8da7..c99586638c3d 100644 --- a/x-pack/plugins/apm/server/routes/observability_overview.ts +++ b/x-pack/plugins/apm/server/routes/observability_overview/route.ts @@ -7,15 +7,15 @@ import * as t from 'io-ts'; import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { getServiceCount } from '../lib/observability_overview/get_service_count'; -import { getTransactionsPerMinute } from '../lib/observability_overview/get_transactions_per_minute'; -import { getHasData } from '../lib/observability_overview/has_data'; -import { rangeRt } from './default_api_types'; -import { getSearchAggregatedTransactions } from '../lib/helpers/transactions'; -import { withApmSpan } from '../utils/with_apm_span'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { getServiceCount } from './get_service_count'; +import { getTransactionsPerMinute } from './get_transactions_per_minute'; +import { getHasData } from './has_data'; +import { rangeRt } from '../default_api_types'; +import { getSearchAggregatedTransactions } from '../../lib/helpers/transactions'; +import { withApmSpan } from '../../utils/with_apm_span'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; const observabilityOverviewHasDataRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/observability_overview/has_data', diff --git a/x-pack/plugins/apm/server/lib/rum_client/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/routes/rum_client/__snapshots__/queries.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/rum_client/__snapshots__/queries.test.ts.snap rename to x-pack/plugins/apm/server/routes/rum_client/__snapshots__/queries.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_client_metrics.ts b/x-pack/plugins/apm/server/routes/rum_client/get_client_metrics.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/rum_client/get_client_metrics.ts rename to x-pack/plugins/apm/server/routes/rum_client/get_client_metrics.ts index 206fc134a0c8..40352db9f18a 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_client_metrics.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/get_client_metrics.ts @@ -7,7 +7,7 @@ import { getRumPageLoadTransactionsProjection } from '../../projections/rum_page_load_transactions'; import { mergeProjection } from '../../projections/util/merge_projection'; -import { SetupUX } from '../../routes/rum_client'; +import { SetupUX } from './route'; import { TRANSACTION_TIME_TO_FIRST_BYTE, TRANSACTION_DURATION, diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_js_errors.ts b/x-pack/plugins/apm/server/routes/rum_client/get_js_errors.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/rum_client/get_js_errors.ts rename to x-pack/plugins/apm/server/routes/rum_client/get_js_errors.ts index dca575b42cf0..a0f7c0940b81 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_js_errors.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/get_js_errors.ts @@ -6,7 +6,7 @@ */ import { mergeProjection } from '../../projections/util/merge_projection'; -import { SetupUX } from '../../routes/rum_client'; +import { SetupUX } from './route'; import { getRumErrorsProjection } from '../../projections/rum_page_load_transactions'; import { ERROR_EXC_MESSAGE, diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_long_task_metrics.ts b/x-pack/plugins/apm/server/routes/rum_client/get_long_task_metrics.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/rum_client/get_long_task_metrics.ts rename to x-pack/plugins/apm/server/routes/rum_client/get_long_task_metrics.ts index d5cc78e2f306..29ef955e19aa 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_long_task_metrics.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/get_long_task_metrics.ts @@ -7,7 +7,7 @@ import { getRumPageLoadTransactionsProjection } from '../../projections/rum_page_load_transactions'; import { mergeProjection } from '../../projections/util/merge_projection'; -import { SetupUX } from '../../routes/rum_client'; +import { SetupUX } from './route'; const LONG_TASK_SUM_FIELD = 'transaction.experience.longtask.sum'; const LONG_TASK_COUNT_FIELD = 'transaction.experience.longtask.count'; diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_page_load_distribution.ts b/x-pack/plugins/apm/server/routes/rum_client/get_page_load_distribution.ts similarity index 99% rename from x-pack/plugins/apm/server/lib/rum_client/get_page_load_distribution.ts rename to x-pack/plugins/apm/server/routes/rum_client/get_page_load_distribution.ts index e551b4a34746..27c8c4668ce9 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_page_load_distribution.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/get_page_load_distribution.ts @@ -8,7 +8,7 @@ import { TRANSACTION_DURATION } from '../../../common/elasticsearch_fieldnames'; import { getRumPageLoadTransactionsProjection } from '../../projections/rum_page_load_transactions'; import { mergeProjection } from '../../projections/util/merge_projection'; -import { SetupUX } from '../../routes/rum_client'; +import { SetupUX } from './route'; export const MICRO_TO_SEC = 1000000; diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_page_view_trends.ts b/x-pack/plugins/apm/server/routes/rum_client/get_page_view_trends.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/rum_client/get_page_view_trends.ts rename to x-pack/plugins/apm/server/routes/rum_client/get_page_view_trends.ts index 87766aae4327..6bcc7f66d1df 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_page_view_trends.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/get_page_view_trends.ts @@ -7,7 +7,7 @@ import { getRumPageLoadTransactionsProjection } from '../../projections/rum_page_load_transactions'; import { mergeProjection } from '../../projections/util/merge_projection'; -import { SetupUX } from '../../routes/rum_client'; +import { SetupUX } from './route'; import { BreakdownItem } from '../../../typings/ui_filters'; export async function getPageViewTrends({ diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_pl_dist_breakdown.ts b/x-pack/plugins/apm/server/routes/rum_client/get_pl_dist_breakdown.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/rum_client/get_pl_dist_breakdown.ts rename to x-pack/plugins/apm/server/routes/rum_client/get_pl_dist_breakdown.ts index 298f2a3b7ddf..d6a67b57fa98 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_pl_dist_breakdown.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/get_pl_dist_breakdown.ts @@ -8,7 +8,7 @@ import { getRumPageLoadTransactionsProjection } from '../../projections/rum_page_load_transactions'; import { ProcessorEvent } from '../../../common/processor_event'; import { mergeProjection } from '../../projections/util/merge_projection'; -import { SetupUX } from '../../routes/rum_client'; +import { SetupUX } from './route'; import { CLIENT_GEO_COUNTRY_ISO_CODE, USER_AGENT_DEVICE, diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_rum_services.ts b/x-pack/plugins/apm/server/routes/rum_client/get_rum_services.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/rum_client/get_rum_services.ts rename to x-pack/plugins/apm/server/routes/rum_client/get_rum_services.ts index 1929f7e3ed99..e62b54f00d21 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_rum_services.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/get_rum_services.ts @@ -5,7 +5,7 @@ * 2.0. */ import { SERVICE_NAME } from '../../../common/elasticsearch_fieldnames'; -import { SetupUX } from '../../routes/rum_client'; +import { SetupUX } from './route'; import { getRumPageLoadTransactionsProjection } from '../../projections/rum_page_load_transactions'; import { mergeProjection } from '../../projections/util/merge_projection'; diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_url_search.ts b/x-pack/plugins/apm/server/routes/rum_client/get_url_search.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/rum_client/get_url_search.ts rename to x-pack/plugins/apm/server/routes/rum_client/get_url_search.ts index 515df78f87bd..0ffb836402f6 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_url_search.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/get_url_search.ts @@ -6,7 +6,7 @@ */ import { mergeProjection } from '../../projections/util/merge_projection'; -import { SetupUX } from '../../routes/rum_client'; +import { SetupUX } from './route'; import { getRumPageLoadTransactionsProjection } from '../../projections/rum_page_load_transactions'; import { TRANSACTION_DURATION, diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_visitor_breakdown.ts b/x-pack/plugins/apm/server/routes/rum_client/get_visitor_breakdown.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/rum_client/get_visitor_breakdown.ts rename to x-pack/plugins/apm/server/routes/rum_client/get_visitor_breakdown.ts index ed0a4e90a4cb..d7447889db84 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_visitor_breakdown.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/get_visitor_breakdown.ts @@ -7,7 +7,7 @@ import { getRumPageLoadTransactionsProjection } from '../../projections/rum_page_load_transactions'; import { mergeProjection } from '../../projections/util/merge_projection'; -import { SetupUX } from '../../routes/rum_client'; +import { SetupUX } from './route'; import { USER_AGENT_NAME, USER_AGENT_OS, diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_web_core_vitals.ts b/x-pack/plugins/apm/server/routes/rum_client/get_web_core_vitals.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/rum_client/get_web_core_vitals.ts rename to x-pack/plugins/apm/server/routes/rum_client/get_web_core_vitals.ts index 6dfa3abe117d..6a3b3a1c7b1c 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_web_core_vitals.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/get_web_core_vitals.ts @@ -7,7 +7,7 @@ import { getRumPageLoadTransactionsProjection } from '../../projections/rum_page_load_transactions'; import { mergeProjection } from '../../projections/util/merge_projection'; -import { SetupUX } from '../../routes/rum_client'; +import { SetupUX } from './route'; import { CLS_FIELD, FCP_FIELD, diff --git a/x-pack/plugins/apm/server/lib/rum_client/has_rum_data.ts b/x-pack/plugins/apm/server/routes/rum_client/has_rum_data.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/rum_client/has_rum_data.ts rename to x-pack/plugins/apm/server/routes/rum_client/has_rum_data.ts index ba35ac5c5c89..6cb3bc069e07 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/has_rum_data.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/has_rum_data.ts @@ -6,7 +6,7 @@ */ import moment from 'moment'; -import { SetupUX } from '../../routes/rum_client'; +import { SetupUX } from './route'; import { SERVICE_NAME, TRANSACTION_TYPE, diff --git a/x-pack/plugins/apm/server/lib/rum_client/queries.test.ts b/x-pack/plugins/apm/server/routes/rum_client/queries.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/rum_client/queries.test.ts rename to x-pack/plugins/apm/server/routes/rum_client/queries.test.ts diff --git a/x-pack/plugins/apm/server/routes/rum_client.ts b/x-pack/plugins/apm/server/routes/rum_client/route.ts similarity index 87% rename from x-pack/plugins/apm/server/routes/rum_client.ts rename to x-pack/plugins/apm/server/routes/rum_client/route.ts index e84a281a7ce1..482dcc0799ed 100644 --- a/x-pack/plugins/apm/server/routes/rum_client.ts +++ b/x-pack/plugins/apm/server/routes/rum_client/route.ts @@ -7,23 +7,23 @@ import * as t from 'io-ts'; import { Logger } from 'kibana/server'; import { isoToEpochRt } from '@kbn/io-ts-utils/iso_to_epoch_rt'; -import { setupRequest, Setup } from '../lib/helpers/setup_request'; -import { getClientMetrics } from '../lib/rum_client/get_client_metrics'; -import { getJSErrors } from '../lib/rum_client/get_js_errors'; -import { getLongTaskMetrics } from '../lib/rum_client/get_long_task_metrics'; -import { getPageLoadDistribution } from '../lib/rum_client/get_page_load_distribution'; -import { getPageViewTrends } from '../lib/rum_client/get_page_view_trends'; -import { getPageLoadDistBreakdown } from '../lib/rum_client/get_pl_dist_breakdown'; -import { getRumServices } from '../lib/rum_client/get_rum_services'; -import { getUrlSearch } from '../lib/rum_client/get_url_search'; -import { getVisitorBreakdown } from '../lib/rum_client/get_visitor_breakdown'; -import { getWebCoreVitals } from '../lib/rum_client/get_web_core_vitals'; -import { hasRumData } from '../lib/rum_client/has_rum_data'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { rangeRt } from './default_api_types'; -import { UxUIFilters } from '../../typings/ui_filters'; -import { APMRouteHandlerResources } from '../routes/typings'; +import { setupRequest, Setup } from '../../lib/helpers/setup_request'; +import { getClientMetrics } from './get_client_metrics'; +import { getJSErrors } from './get_js_errors'; +import { getLongTaskMetrics } from './get_long_task_metrics'; +import { getPageLoadDistribution } from './get_page_load_distribution'; +import { getPageViewTrends } from './get_page_view_trends'; +import { getPageLoadDistBreakdown } from './get_pl_dist_breakdown'; +import { getRumServices } from './get_rum_services'; +import { getUrlSearch } from './get_url_search'; +import { getVisitorBreakdown } from './get_visitor_breakdown'; +import { getWebCoreVitals } from './get_web_core_vitals'; +import { hasRumData } from './has_rum_data'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { rangeRt } from '../default_api_types'; +import { UxUIFilters } from '../../../typings/ui_filters'; +import { APMRouteHandlerResources } from '../typings'; export type SetupUX = Setup & { uiFilters: UxUIFilters; diff --git a/x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.test.ts b/x-pack/plugins/apm/server/routes/rum_client/ui_filters/get_es_filter.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.test.ts rename to x-pack/plugins/apm/server/routes/rum_client/ui_filters/get_es_filter.test.ts diff --git a/x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.ts b/x-pack/plugins/apm/server/routes/rum_client/ui_filters/get_es_filter.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.ts rename to x-pack/plugins/apm/server/routes/rum_client/ui_filters/get_es_filter.ts diff --git a/x-pack/plugins/apm/server/lib/service_map/fetch_service_paths_from_trace_ids.ts b/x-pack/plugins/apm/server/routes/service_map/fetch_service_paths_from_trace_ids.ts similarity index 99% rename from x-pack/plugins/apm/server/lib/service_map/fetch_service_paths_from_trace_ids.ts rename to x-pack/plugins/apm/server/routes/service_map/fetch_service_paths_from_trace_ids.ts index 2f725b61942c..b3bd4d151018 100644 --- a/x-pack/plugins/apm/server/lib/service_map/fetch_service_paths_from_trace_ids.ts +++ b/x-pack/plugins/apm/server/routes/service_map/fetch_service_paths_from_trace_ids.ts @@ -13,7 +13,7 @@ import { ExternalConnectionNode, ServiceConnectionNode, } from '../../../common/service_map'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; export async function fetchServicePathsFromTraceIds( setup: Setup, diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts b/x-pack/plugins/apm/server/routes/service_map/get_service_anomalies.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts rename to x-pack/plugins/apm/server/routes/service_map/get_service_anomalies.ts index 2aa2f5c6eead..65c022b7175d 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts +++ b/x-pack/plugins/apm/server/routes/service_map/get_service_anomalies.ts @@ -20,8 +20,8 @@ import { } from '../../../common/transaction_types'; import { rangeQuery } from '../../../../observability/server'; import { withApmSpan } from '../../utils/with_apm_span'; -import { getMlJobsWithAPMGroup } from '../anomaly_detection/get_ml_jobs_with_apm_group'; -import { Setup } from '../helpers/setup_request'; +import { getMlJobsWithAPMGroup } from '../../lib/anomaly_detection/get_ml_jobs_with_apm_group'; +import { Setup } from '../../lib/helpers/setup_request'; import { apmMlAnomalyQuery } from '../../../common/anomaly_detection/apm_ml_anomaly_query'; import { ApmMlDetectorIndex } from '../../../common/anomaly_detection/apm_ml_detectors'; diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_map.ts b/x-pack/plugins/apm/server/routes/service_map/get_service_map.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/service_map/get_service_map.ts rename to x-pack/plugins/apm/server/routes/service_map/get_service_map.ts index 9f94bdd9275c..d7eb101f77e3 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_map.ts +++ b/x-pack/plugins/apm/server/routes/service_map/get_service_map.ts @@ -17,7 +17,7 @@ import { } from '../../../common/elasticsearch_fieldnames'; import { environmentQuery } from '../../../common/utils/environment_query'; import { withApmSpan } from '../../utils/with_apm_span'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { DEFAULT_ANOMALIES, getServiceAnomalies, @@ -26,7 +26,7 @@ import { getServiceMapFromTraceIds } from './get_service_map_from_trace_ids'; import { getTraceSampleIds } from './get_trace_sample_ids'; import { transformServiceMapResponses } from './transform_service_map_responses'; import { ENVIRONMENT_ALL } from '../../../common/environment_filter_values'; -import { getProcessorEventForTransactions } from '../helpers/transactions'; +import { getProcessorEventForTransactions } from '../../lib/helpers/transactions'; export interface IEnvOptions { setup: Setup; diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_map_backend_node_info.ts b/x-pack/plugins/apm/server/routes/service_map/get_service_map_backend_node_info.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/service_map/get_service_map_backend_node_info.ts rename to x-pack/plugins/apm/server/routes/service_map/get_service_map_backend_node_info.ts index c8242731e756..3866bac88ef4 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_map_backend_node_info.ts +++ b/x-pack/plugins/apm/server/routes/service_map/get_service_map_backend_node_info.ts @@ -16,8 +16,8 @@ import { EventOutcome } from '../../../common/event_outcome'; import { ProcessorEvent } from '../../../common/processor_event'; import { environmentQuery } from '../../../common/utils/environment_query'; import { withApmSpan } from '../../utils/with_apm_span'; -import { calculateThroughput } from '../helpers/calculate_throughput'; -import { Setup } from '../helpers/setup_request'; +import { calculateThroughput } from '../../lib/helpers/calculate_throughput'; +import { Setup } from '../../lib/helpers/setup_request'; interface Options { setup: Setup; diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_map_from_trace_ids.test.ts b/x-pack/plugins/apm/server/routes/service_map/get_service_map_from_trace_ids.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/service_map/get_service_map_from_trace_ids.test.ts rename to x-pack/plugins/apm/server/routes/service_map/get_service_map_from_trace_ids.test.ts diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_map_from_trace_ids.ts b/x-pack/plugins/apm/server/routes/service_map/get_service_map_from_trace_ids.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/service_map/get_service_map_from_trace_ids.ts rename to x-pack/plugins/apm/server/routes/service_map/get_service_map_from_trace_ids.ts index e77e127aebb4..6a61a514881b 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_map_from_trace_ids.ts +++ b/x-pack/plugins/apm/server/routes/service_map/get_service_map_from_trace_ids.ts @@ -7,7 +7,7 @@ import { find, uniqBy } from 'lodash'; import { Connection, ConnectionNode } from '../../../common/service_map'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { fetchServicePathsFromTraceIds } from './fetch_service_paths_from_trace_ids'; export function getConnections({ diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.test.ts b/x-pack/plugins/apm/server/routes/service_map/get_service_map_service_node_info.test.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.test.ts rename to x-pack/plugins/apm/server/routes/service_map/get_service_map_service_node_info.test.ts index e064d97bb7ae..9f65481d0748 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.test.ts +++ b/x-pack/plugins/apm/server/routes/service_map/get_service_map_service_node_info.test.ts @@ -6,8 +6,8 @@ */ import { getServiceMapServiceNodeInfo } from './get_service_map_service_node_info'; -import { Setup } from '../helpers/setup_request'; -import * as getErrorRateModule from '../transaction_groups/get_error_rate'; +import { Setup } from '../../lib/helpers/setup_request'; +import * as getErrorRateModule from '../../lib/transaction_groups/get_error_rate'; import { ENVIRONMENT_ALL } from '../../../common/environment_filter_values'; describe('getServiceMapServiceNodeInfo', () => { diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.ts b/x-pack/plugins/apm/server/routes/service_map/get_service_map_service_node_info.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.ts rename to x-pack/plugins/apm/server/routes/service_map/get_service_map_service_node_info.ts index 2f089adf70c1..d6eb7729effa 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.ts +++ b/x-pack/plugins/apm/server/routes/service_map/get_service_map_service_node_info.ts @@ -26,13 +26,13 @@ import { getDocumentTypeFilterForTransactions, getTransactionDurationFieldForTransactions, getProcessorEventForTransactions, -} from '../helpers/transactions'; -import { Setup } from '../helpers/setup_request'; +} from '../../lib/helpers/transactions'; +import { Setup } from '../../lib/helpers/setup_request'; import { percentCgroupMemoryUsedScript, percentSystemMemoryUsedScript, } from '../metrics/by_agent/shared/memory'; -import { getErrorRate } from '../transaction_groups/get_error_rate'; +import { getErrorRate } from '../../lib/transaction_groups/get_error_rate'; interface Options { setup: Setup; diff --git a/x-pack/plugins/apm/server/lib/service_map/get_trace_sample_ids.ts b/x-pack/plugins/apm/server/routes/service_map/get_trace_sample_ids.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/service_map/get_trace_sample_ids.ts rename to x-pack/plugins/apm/server/routes/service_map/get_trace_sample_ids.ts index 7e16e69498e7..af24953833a2 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_trace_sample_ids.ts +++ b/x-pack/plugins/apm/server/routes/service_map/get_trace_sample_ids.ts @@ -18,7 +18,7 @@ import { ProcessorEvent } from '../../../common/processor_event'; import { SERVICE_MAP_TIMEOUT_ERROR } from '../../../common/service_map'; import { rangeQuery } from '../../../../observability/server'; import { environmentQuery } from '../../../common/utils/environment_query'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; const MAX_TRACES_TO_INSPECT = 1000; diff --git a/x-pack/plugins/apm/server/lib/service_map/group_resource_nodes.test.ts b/x-pack/plugins/apm/server/routes/service_map/group_resource_nodes.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/service_map/group_resource_nodes.test.ts rename to x-pack/plugins/apm/server/routes/service_map/group_resource_nodes.test.ts diff --git a/x-pack/plugins/apm/server/lib/service_map/group_resource_nodes.ts b/x-pack/plugins/apm/server/routes/service_map/group_resource_nodes.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/service_map/group_resource_nodes.ts rename to x-pack/plugins/apm/server/routes/service_map/group_resource_nodes.ts diff --git a/x-pack/plugins/apm/server/lib/service_map/mock_responses/group_resource_nodes_grouped.json b/x-pack/plugins/apm/server/routes/service_map/mock_responses/group_resource_nodes_grouped.json similarity index 100% rename from x-pack/plugins/apm/server/lib/service_map/mock_responses/group_resource_nodes_grouped.json rename to x-pack/plugins/apm/server/routes/service_map/mock_responses/group_resource_nodes_grouped.json diff --git a/x-pack/plugins/apm/server/lib/service_map/mock_responses/group_resource_nodes_pregrouped.json b/x-pack/plugins/apm/server/routes/service_map/mock_responses/group_resource_nodes_pregrouped.json similarity index 100% rename from x-pack/plugins/apm/server/lib/service_map/mock_responses/group_resource_nodes_pregrouped.json rename to x-pack/plugins/apm/server/routes/service_map/mock_responses/group_resource_nodes_pregrouped.json diff --git a/x-pack/plugins/apm/server/routes/service_map.ts b/x-pack/plugins/apm/server/routes/service_map/route.ts similarity index 81% rename from x-pack/plugins/apm/server/routes/service_map.ts rename to x-pack/plugins/apm/server/routes/service_map/route.ts index e75b4ec832d8..97d0c01ed6a4 100644 --- a/x-pack/plugins/apm/server/routes/service_map.ts +++ b/x-pack/plugins/apm/server/routes/service_map/route.ts @@ -7,17 +7,17 @@ import Boom from '@hapi/boom'; import * as t from 'io-ts'; -import { isActivePlatinumLicense } from '../../common/license_check'; -import { invalidLicenseMessage } from '../../common/service_map'; -import { notifyFeatureUsage } from '../feature'; -import { getSearchAggregatedTransactions } from '../lib/helpers/transactions'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { getServiceMap } from '../lib/service_map/get_service_map'; -import { getServiceMapBackendNodeInfo } from '../lib/service_map/get_service_map_backend_node_info'; -import { getServiceMapServiceNodeInfo } from '../lib/service_map/get_service_map_service_node_info'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { environmentRt, rangeRt } from './default_api_types'; +import { isActivePlatinumLicense } from '../../../common/license_check'; +import { invalidLicenseMessage } from '../../../common/service_map'; +import { notifyFeatureUsage } from '../../feature'; +import { getSearchAggregatedTransactions } from '../../lib/helpers/transactions'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { getServiceMap } from './get_service_map'; +import { getServiceMapBackendNodeInfo } from './get_service_map_backend_node_info'; +import { getServiceMapServiceNodeInfo } from './get_service_map_service_node_info'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { environmentRt, rangeRt } from '../default_api_types'; const serviceMapRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/service-map', diff --git a/x-pack/plugins/apm/server/lib/service_map/transform_service_map_responses.test.ts b/x-pack/plugins/apm/server/routes/service_map/transform_service_map_responses.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/service_map/transform_service_map_responses.test.ts rename to x-pack/plugins/apm/server/routes/service_map/transform_service_map_responses.test.ts diff --git a/x-pack/plugins/apm/server/lib/service_map/transform_service_map_responses.ts b/x-pack/plugins/apm/server/routes/service_map/transform_service_map_responses.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/service_map/transform_service_map_responses.ts rename to x-pack/plugins/apm/server/routes/service_map/transform_service_map_responses.ts diff --git a/x-pack/plugins/apm/server/lib/service_nodes/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/routes/service_nodes/__snapshots__/queries.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/service_nodes/__snapshots__/queries.test.ts.snap rename to x-pack/plugins/apm/server/routes/service_nodes/__snapshots__/queries.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/service_nodes/index.ts b/x-pack/plugins/apm/server/routes/service_nodes/get_service_nodes.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/service_nodes/index.ts rename to x-pack/plugins/apm/server/routes/service_nodes/get_service_nodes.ts index 541fbb79c9e5..ebd56cb9768c 100644 --- a/x-pack/plugins/apm/server/lib/service_nodes/index.ts +++ b/x-pack/plugins/apm/server/routes/service_nodes/get_service_nodes.ts @@ -21,7 +21,7 @@ import { import { ProcessorEvent } from '../../../common/processor_event'; import { kqlQuery, rangeQuery } from '../../../../observability/server'; import { environmentQuery } from '../../../common/utils/environment_query'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; const getServiceNodes = async ({ kuery, diff --git a/x-pack/plugins/apm/server/lib/service_nodes/queries.test.ts b/x-pack/plugins/apm/server/routes/service_nodes/queries.test.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/service_nodes/queries.test.ts rename to x-pack/plugins/apm/server/routes/service_nodes/queries.test.ts index f8bc3879d579..470be6142aae 100644 --- a/x-pack/plugins/apm/server/lib/service_nodes/queries.test.ts +++ b/x-pack/plugins/apm/server/routes/service_nodes/queries.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { getServiceNodes } from './'; +import { getServiceNodes } from './get_service_nodes'; import { SearchParamsMock, inspectSearchParams, diff --git a/x-pack/plugins/apm/server/routes/service_nodes.ts b/x-pack/plugins/apm/server/routes/service_nodes/route.ts similarity index 72% rename from x-pack/plugins/apm/server/routes/service_nodes.ts rename to x-pack/plugins/apm/server/routes/service_nodes/route.ts index 61d58bfa3cf3..027a907dd265 100644 --- a/x-pack/plugins/apm/server/routes/service_nodes.ts +++ b/x-pack/plugins/apm/server/routes/service_nodes/route.ts @@ -6,12 +6,12 @@ */ import * as t from 'io-ts'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { getServiceNodes } from '../lib/service_nodes'; -import { rangeRt, kueryRt } from './default_api_types'; -import { environmentRt } from '../../common/environment_rt'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { getServiceNodes } from './get_service_nodes'; +import { rangeRt, kueryRt } from '../default_api_types'; +import { environmentRt } from '../../../common/environment_rt'; const serviceNodesRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/services/{serviceName}/serviceNodes', diff --git a/x-pack/plugins/apm/server/lib/services/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/routes/services/__snapshots__/queries.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/services/__snapshots__/queries.test.ts.snap rename to x-pack/plugins/apm/server/routes/services/__snapshots__/queries.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/services/annotations/__fixtures__/multiple_versions.json b/x-pack/plugins/apm/server/routes/services/annotations/__fixtures__/multiple_versions.json similarity index 100% rename from x-pack/plugins/apm/server/lib/services/annotations/__fixtures__/multiple_versions.json rename to x-pack/plugins/apm/server/routes/services/annotations/__fixtures__/multiple_versions.json diff --git a/x-pack/plugins/apm/server/lib/services/annotations/__fixtures__/no_versions.json b/x-pack/plugins/apm/server/routes/services/annotations/__fixtures__/no_versions.json similarity index 100% rename from x-pack/plugins/apm/server/lib/services/annotations/__fixtures__/no_versions.json rename to x-pack/plugins/apm/server/routes/services/annotations/__fixtures__/no_versions.json diff --git a/x-pack/plugins/apm/server/lib/services/annotations/__fixtures__/one_version.json b/x-pack/plugins/apm/server/routes/services/annotations/__fixtures__/one_version.json similarity index 100% rename from x-pack/plugins/apm/server/lib/services/annotations/__fixtures__/one_version.json rename to x-pack/plugins/apm/server/routes/services/annotations/__fixtures__/one_version.json diff --git a/x-pack/plugins/apm/server/lib/services/annotations/__fixtures__/versions_first_seen.json b/x-pack/plugins/apm/server/routes/services/annotations/__fixtures__/versions_first_seen.json similarity index 100% rename from x-pack/plugins/apm/server/lib/services/annotations/__fixtures__/versions_first_seen.json rename to x-pack/plugins/apm/server/routes/services/annotations/__fixtures__/versions_first_seen.json diff --git a/x-pack/plugins/apm/server/lib/services/annotations/get_derived_service_annotations.ts b/x-pack/plugins/apm/server/routes/services/annotations/get_derived_service_annotations.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/services/annotations/get_derived_service_annotations.ts rename to x-pack/plugins/apm/server/routes/services/annotations/get_derived_service_annotations.ts index 22b37e33a26e..523775de170e 100644 --- a/x-pack/plugins/apm/server/lib/services/annotations/get_derived_service_annotations.ts +++ b/x-pack/plugins/apm/server/routes/services/annotations/get_derived_service_annotations.ts @@ -17,8 +17,8 @@ import { environmentQuery } from '../../../../common/utils/environment_query'; import { getDocumentTypeFilterForTransactions, getProcessorEventForTransactions, -} from '../../helpers/transactions'; -import { Setup } from '../../helpers/setup_request'; +} from '../../../lib/helpers/transactions'; +import { Setup } from '../../../lib/helpers/setup_request'; export async function getDerivedServiceAnnotations({ setup, diff --git a/x-pack/plugins/apm/server/lib/services/annotations/get_stored_annotations.ts b/x-pack/plugins/apm/server/routes/services/annotations/get_stored_annotations.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/services/annotations/get_stored_annotations.ts rename to x-pack/plugins/apm/server/routes/services/annotations/get_stored_annotations.ts diff --git a/x-pack/plugins/apm/server/lib/services/annotations/index.test.ts b/x-pack/plugins/apm/server/routes/services/annotations/index.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/services/annotations/index.test.ts rename to x-pack/plugins/apm/server/routes/services/annotations/index.test.ts diff --git a/x-pack/plugins/apm/server/lib/services/annotations/index.ts b/x-pack/plugins/apm/server/routes/services/annotations/index.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/services/annotations/index.ts rename to x-pack/plugins/apm/server/routes/services/annotations/index.ts index 677530522f6c..488a4ce6e4c2 100644 --- a/x-pack/plugins/apm/server/lib/services/annotations/index.ts +++ b/x-pack/plugins/apm/server/routes/services/annotations/index.ts @@ -8,7 +8,7 @@ import { ElasticsearchClient, Logger } from 'kibana/server'; import { ScopedAnnotationsClient } from '../../../../../observability/server'; import { getDerivedServiceAnnotations } from './get_derived_service_annotations'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { getStoredAnnotations } from './get_stored_annotations'; export async function getServiceAnnotations({ diff --git a/x-pack/plugins/apm/server/lib/services/get_service_agent.ts b/x-pack/plugins/apm/server/routes/services/get_service_agent.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/services/get_service_agent.ts rename to x-pack/plugins/apm/server/routes/services/get_service_agent.ts index dc3fee20fdf6..8117729eb9b5 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_agent.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_agent.ts @@ -12,7 +12,7 @@ import { SERVICE_RUNTIME_NAME, } from '../../../common/elasticsearch_fieldnames'; import { rangeQuery } from '../../../../observability/server'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; interface ServiceAgent { agent?: { diff --git a/x-pack/plugins/apm/server/lib/services/get_service_alerts.ts b/x-pack/plugins/apm/server/routes/services/get_service_alerts.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/services/get_service_alerts.ts rename to x-pack/plugins/apm/server/routes/services/get_service_alerts.ts diff --git a/x-pack/plugins/apm/server/lib/services/get_service_dependencies.ts b/x-pack/plugins/apm/server/routes/services/get_service_dependencies.ts similarity index 77% rename from x-pack/plugins/apm/server/lib/services/get_service_dependencies.ts rename to x-pack/plugins/apm/server/routes/services/get_service_dependencies.ts index d4472d495230..cf60502e9861 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_dependencies.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_dependencies.ts @@ -7,9 +7,9 @@ import { SERVICE_NAME } from '../../../common/elasticsearch_fieldnames'; import { environmentQuery } from '../../../common/utils/environment_query'; -import { getConnectionStats } from '../connections/get_connection_stats'; -import { getConnectionStatsItemsWithRelativeImpact } from '../connections/get_connection_stats/get_connection_stats_items_with_relative_impact'; -import { Setup } from '../helpers/setup_request'; +import { getConnectionStats } from '../../lib/connections/get_connection_stats'; +import { getConnectionStatsItemsWithRelativeImpact } from '../../lib/connections/get_connection_stats/get_connection_stats_items_with_relative_impact'; +import { Setup } from '../../lib/helpers/setup_request'; export async function getServiceDependencies({ setup, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_dependencies_breakdown.ts b/x-pack/plugins/apm/server/routes/services/get_service_dependencies_breakdown.ts similarity index 90% rename from x-pack/plugins/apm/server/lib/services/get_service_dependencies_breakdown.ts rename to x-pack/plugins/apm/server/routes/services/get_service_dependencies_breakdown.ts index c0e1af40d98d..a0b8eb1768d6 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_dependencies_breakdown.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_dependencies_breakdown.ts @@ -9,8 +9,8 @@ import { getNodeName } from '../../../common/connections'; import { kqlQuery } from '../../../../observability/server'; import { SERVICE_NAME } from '../../../common/elasticsearch_fieldnames'; import { environmentQuery } from '../../../common/utils/environment_query'; -import { Setup } from '../helpers/setup_request'; -import { getConnectionStats } from '../connections/get_connection_stats'; +import { Setup } from '../../lib/helpers/setup_request'; +import { getConnectionStats } from '../../lib/connections/get_connection_stats'; export async function getServiceDependenciesBreakdown({ setup, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_detailed_statistics.ts b/x-pack/plugins/apm/server/routes/services/get_service_error_groups/get_service_error_group_detailed_statistics.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_detailed_statistics.ts rename to x-pack/plugins/apm/server/routes/services/get_service_error_groups/get_service_error_group_detailed_statistics.ts index 9a0b6155fe84..17c538d0fd7e 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_detailed_statistics.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_error_groups/get_service_error_group_detailed_statistics.ts @@ -15,8 +15,8 @@ import { import { ProcessorEvent } from '../../../../common/processor_event'; import { rangeQuery, kqlQuery } from '../../../../../observability/server'; import { environmentQuery } from '../../../../common/utils/environment_query'; -import { getBucketSize } from '../../helpers/get_bucket_size'; -import { Setup } from '../../helpers/setup_request'; +import { getBucketSize } from '../../../lib/helpers/get_bucket_size'; +import { Setup } from '../../../lib/helpers/setup_request'; export async function getServiceErrorGroupDetailedStatistics({ kuery, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_main_statistics.ts b/x-pack/plugins/apm/server/routes/services/get_service_error_groups/get_service_error_group_main_statistics.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_main_statistics.ts rename to x-pack/plugins/apm/server/routes/services/get_service_error_groups/get_service_error_group_main_statistics.ts index 1a25b18f81aa..8d174abb1bed 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_main_statistics.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_error_groups/get_service_error_group_main_statistics.ts @@ -15,8 +15,8 @@ import { } from '../../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../../common/processor_event'; import { environmentQuery } from '../../../../common/utils/environment_query'; -import { getErrorName } from '../../helpers/get_error_name'; -import { Setup } from '../../helpers/setup_request'; +import { getErrorName } from '../../../lib/helpers/get_error_name'; +import { Setup } from '../../../lib/helpers/setup_request'; export async function getServiceErrorGroupMainStatistics({ kuery, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/index.ts b/x-pack/plugins/apm/server/routes/services/get_service_error_groups/index.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/services/get_service_error_groups/index.ts rename to x-pack/plugins/apm/server/routes/services/get_service_error_groups/index.ts index 83cb38da6e0a..1a853231bb09 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/index.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_error_groups/index.ts @@ -19,9 +19,9 @@ import { import { ProcessorEvent } from '../../../../common/processor_event'; import { environmentQuery } from '../../../../common/utils/environment_query'; import { withApmSpan } from '../../../utils/with_apm_span'; -import { getBucketSize } from '../../helpers/get_bucket_size'; -import { getErrorName } from '../../helpers/get_error_name'; -import { Setup } from '../../helpers/setup_request'; +import { getBucketSize } from '../../../lib/helpers/get_bucket_size'; +import { getErrorName } from '../../../lib/helpers/get_error_name'; +import { Setup } from '../../../lib/helpers/setup_request'; export type ServiceErrorGroupItem = ValuesType< PromiseReturnType diff --git a/x-pack/plugins/apm/server/lib/services/get_service_infrastructure.ts b/x-pack/plugins/apm/server/routes/services/get_service_infrastructure.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/services/get_service_infrastructure.ts rename to x-pack/plugins/apm/server/routes/services/get_service_infrastructure.ts index 09946187b90a..cda0beb6b2d7 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_infrastructure.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_infrastructure.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { rangeQuery, kqlQuery } from '../../../../observability/server'; import { environmentQuery } from '../../../common/utils/environment_query'; import { ProcessorEvent } from '../../../common/processor_event'; diff --git a/x-pack/plugins/apm/server/lib/services/get_service_instance_metadata_details.ts b/x-pack/plugins/apm/server/routes/services/get_service_instance_metadata_details.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/services/get_service_instance_metadata_details.ts rename to x-pack/plugins/apm/server/routes/services/get_service_instance_metadata_details.ts index d349ca3ce039..957d655b98e5 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_instance_metadata_details.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_instance_metadata_details.ts @@ -12,12 +12,12 @@ import { SERVICE_NODE_NAME, } from '../../../common/elasticsearch_fieldnames'; import { rangeQuery } from '../../../../observability/server'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { maybe } from '../../../common/utils/maybe'; import { getDocumentTypeFilterForTransactions, getProcessorEventForTransactions, -} from '../helpers/transactions'; +} from '../../lib/helpers/transactions'; export async function getServiceInstanceMetadataDetails({ serviceName, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_instances/detailed_statistics.ts b/x-pack/plugins/apm/server/routes/services/get_service_instances/detailed_statistics.ts similarity index 98% rename from x-pack/plugins/apm/server/lib/services/get_service_instances/detailed_statistics.ts rename to x-pack/plugins/apm/server/routes/services/get_service_instances/detailed_statistics.ts index fd6f0f6d03c6..10393e343477 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_instances/detailed_statistics.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_instances/detailed_statistics.ts @@ -11,7 +11,7 @@ import { Coordinate } from '../../../../typings/timeseries'; import { LatencyAggregationType } from '../../../../common/latency_aggregation_types'; import { joinByKey } from '../../../../common/utils/join_by_key'; import { withApmSpan } from '../../../utils/with_apm_span'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { getServiceInstancesSystemMetricStatistics } from './get_service_instances_system_metric_statistics'; import { getServiceInstancesTransactionStatistics } from './get_service_instances_transaction_statistics'; diff --git a/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instances_system_metric_statistics.ts b/x-pack/plugins/apm/server/routes/services/get_service_instances/get_service_instances_system_metric_statistics.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instances_system_metric_statistics.ts rename to x-pack/plugins/apm/server/routes/services/get_service_instances/get_service_instances_system_metric_statistics.ts index 61e89ed8ca5e..11fcbd8ce656 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instances_system_metric_statistics.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_instances/get_service_instances_system_metric_statistics.ts @@ -19,8 +19,8 @@ import { SERVICE_NODE_NAME_MISSING } from '../../../../common/service_nodes'; import { Coordinate } from '../../../../typings/timeseries'; import { kqlQuery, rangeQuery } from '../../../../../observability/server'; import { environmentQuery } from '../../../../common/utils/environment_query'; -import { getBucketSize } from '../../helpers/get_bucket_size'; -import { Setup } from '../../helpers/setup_request'; +import { getBucketSize } from '../../../lib/helpers/get_bucket_size'; +import { Setup } from '../../../lib/helpers/setup_request'; import { percentCgroupMemoryUsedScript, percentSystemMemoryUsedScript, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instances_transaction_statistics.ts b/x-pack/plugins/apm/server/routes/services/get_service_instances/get_service_instances_transaction_statistics.ts similarity index 94% rename from x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instances_transaction_statistics.ts rename to x-pack/plugins/apm/server/routes/services/get_service_instances/get_service_instances_transaction_statistics.ts index b0f64036a184..166e8d61142e 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instances_transaction_statistics.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_instances/get_service_instances_transaction_statistics.ts @@ -20,14 +20,14 @@ import { getDocumentTypeFilterForTransactions, getTransactionDurationFieldForTransactions, getProcessorEventForTransactions, -} from '../../helpers/transactions'; -import { calculateThroughput } from '../../helpers/calculate_throughput'; -import { getBucketSizeForAggregatedTransactions } from '../../helpers/get_bucket_size_for_aggregated_transactions'; +} from '../../../lib/helpers/transactions'; +import { calculateThroughput } from '../../../lib/helpers/calculate_throughput'; +import { getBucketSizeForAggregatedTransactions } from '../../../lib/helpers/get_bucket_size_for_aggregated_transactions'; import { getLatencyAggregation, getLatencyValue, -} from '../../helpers/latency_aggregation_type'; -import { Setup } from '../../helpers/setup_request'; +} from '../../../lib/helpers/latency_aggregation_type'; +import { Setup } from '../../../lib/helpers/setup_request'; interface ServiceInstanceTransactionPrimaryStatistics { serviceNodeName: string; diff --git a/x-pack/plugins/apm/server/lib/services/get_service_instances/main_statistics.ts b/x-pack/plugins/apm/server/routes/services/get_service_instances/main_statistics.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/services/get_service_instances/main_statistics.ts rename to x-pack/plugins/apm/server/routes/services/get_service_instances/main_statistics.ts index ea34693bceb3..a064c71496de 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_instances/main_statistics.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_instances/main_statistics.ts @@ -8,7 +8,7 @@ import { LatencyAggregationType } from '../../../../common/latency_aggregation_types'; import { joinByKey } from '../../../../common/utils/join_by_key'; import { withApmSpan } from '../../../utils/with_apm_span'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { getServiceInstancesSystemMetricStatistics } from './get_service_instances_system_metric_statistics'; import { getServiceInstancesTransactionStatistics } from './get_service_instances_transaction_statistics'; diff --git a/x-pack/plugins/apm/server/lib/services/get_service_metadata_details.ts b/x-pack/plugins/apm/server/routes/services/get_service_metadata_details.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/services/get_service_metadata_details.ts rename to x-pack/plugins/apm/server/routes/services/get_service_metadata_details.ts index e2852a51b0c0..b7ce68a0de57 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_metadata_details.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_metadata_details.ts @@ -22,8 +22,8 @@ import { import { ContainerType } from '../../../common/service_metadata'; import { rangeQuery } from '../../../../observability/server'; import { TransactionRaw } from '../../../typings/es_schemas/raw/transaction_raw'; -import { getProcessorEventForTransactions } from '../helpers/transactions'; -import { Setup } from '../helpers/setup_request'; +import { getProcessorEventForTransactions } from '../../lib/helpers/transactions'; +import { Setup } from '../../lib/helpers/setup_request'; import { should } from './get_service_metadata_icons'; type ServiceMetadataDetailsRaw = Pick< diff --git a/x-pack/plugins/apm/server/lib/services/get_service_metadata_icons.ts b/x-pack/plugins/apm/server/routes/services/get_service_metadata_icons.ts similarity index 94% rename from x-pack/plugins/apm/server/lib/services/get_service_metadata_icons.ts rename to x-pack/plugins/apm/server/routes/services/get_service_metadata_icons.ts index 2c93a298cb13..ca97e9d58f06 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_metadata_icons.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_metadata_icons.ts @@ -18,8 +18,8 @@ import { import { ContainerType } from '../../../common/service_metadata'; import { rangeQuery } from '../../../../observability/server'; import { TransactionRaw } from '../../../typings/es_schemas/raw/transaction_raw'; -import { getProcessorEventForTransactions } from '../helpers/transactions'; -import { Setup } from '../helpers/setup_request'; +import { getProcessorEventForTransactions } from '../../lib/helpers/transactions'; +import { Setup } from '../../lib/helpers/setup_request'; type ServiceMetadataIconsRaw = Pick< TransactionRaw, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_node_metadata.ts b/x-pack/plugins/apm/server/routes/services/get_service_node_metadata.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/services/get_service_node_metadata.ts rename to x-pack/plugins/apm/server/routes/services/get_service_node_metadata.ts index ab0fa9152991..89e0e42e9591 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_node_metadata.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_node_metadata.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { HOST_NAME, CONTAINER_ID, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_transaction_group_detailed_statistics.ts b/x-pack/plugins/apm/server/routes/services/get_service_transaction_group_detailed_statistics.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/services/get_service_transaction_group_detailed_statistics.ts rename to x-pack/plugins/apm/server/routes/services/get_service_transaction_group_detailed_statistics.ts index 35256e6a7ecd..70f77c26fdbf 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_transaction_group_detailed_statistics.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_transaction_group_detailed_statistics.ts @@ -22,14 +22,14 @@ import { getDocumentTypeFilterForTransactions, getTransactionDurationFieldForTransactions, getProcessorEventForTransactions, -} from '../helpers/transactions'; -import { getBucketSizeForAggregatedTransactions } from '../helpers/get_bucket_size_for_aggregated_transactions'; +} from '../../lib/helpers/transactions'; +import { getBucketSizeForAggregatedTransactions } from '../../lib/helpers/get_bucket_size_for_aggregated_transactions'; import { getLatencyAggregation, getLatencyValue, -} from '../helpers/latency_aggregation_type'; -import { Setup } from '../helpers/setup_request'; -import { calculateFailedTransactionRate } from '../helpers/transaction_error_rate'; +} from '../../lib/helpers/latency_aggregation_type'; +import { Setup } from '../../lib/helpers/setup_request'; +import { calculateFailedTransactionRate } from '../../lib/helpers/transaction_error_rate'; export async function getServiceTransactionGroupDetailedStatistics({ environment, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_transaction_groups.ts b/x-pack/plugins/apm/server/routes/services/get_service_transaction_groups.ts similarity index 92% rename from x-pack/plugins/apm/server/lib/services/get_service_transaction_groups.ts rename to x-pack/plugins/apm/server/routes/services/get_service_transaction_groups.ts index 7f624693a3b9..711d6964221b 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_transaction_groups.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_transaction_groups.ts @@ -19,14 +19,14 @@ import { getDocumentTypeFilterForTransactions, getTransactionDurationFieldForTransactions, getProcessorEventForTransactions, -} from '../helpers/transactions'; -import { calculateThroughput } from '../helpers/calculate_throughput'; +} from '../../lib/helpers/transactions'; +import { calculateThroughput } from '../../lib/helpers/calculate_throughput'; import { getLatencyAggregation, getLatencyValue, -} from '../helpers/latency_aggregation_type'; -import { Setup } from '../helpers/setup_request'; -import { calculateFailedTransactionRate } from '../helpers/transaction_error_rate'; +} from '../../lib/helpers/latency_aggregation_type'; +import { Setup } from '../../lib/helpers/setup_request'; +import { calculateFailedTransactionRate } from '../../lib/helpers/transaction_error_rate'; export type ServiceOverviewTransactionGroupSortField = | 'name' diff --git a/x-pack/plugins/apm/server/lib/services/get_service_transaction_types.ts b/x-pack/plugins/apm/server/routes/services/get_service_transaction_types.ts similarity index 94% rename from x-pack/plugins/apm/server/lib/services/get_service_transaction_types.ts rename to x-pack/plugins/apm/server/routes/services/get_service_transaction_types.ts index 1c2d1c9207bc..a3761df72156 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_transaction_types.ts +++ b/x-pack/plugins/apm/server/routes/services/get_service_transaction_types.ts @@ -10,11 +10,11 @@ import { TRANSACTION_TYPE, } from '../../../common/elasticsearch_fieldnames'; import { rangeQuery } from '../../../../observability/server'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; import { getDocumentTypeFilterForTransactions, getProcessorEventForTransactions, -} from '../helpers/transactions'; +} from '../../lib/helpers/transactions'; export async function getServiceTransactionTypes({ setup, diff --git a/x-pack/plugins/apm/server/lib/services/get_services/get_health_statuses.ts b/x-pack/plugins/apm/server/routes/services/get_services/get_health_statuses.ts similarity index 92% rename from x-pack/plugins/apm/server/lib/services/get_services/get_health_statuses.ts rename to x-pack/plugins/apm/server/routes/services/get_services/get_health_statuses.ts index af6d0d9613b3..65fb04b821ff 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services/get_health_statuses.ts +++ b/x-pack/plugins/apm/server/routes/services/get_services/get_health_statuses.ts @@ -7,7 +7,7 @@ import { getSeverity } from '../../../../common/anomaly_detection'; import { getServiceHealthStatus } from '../../../../common/service_health_status'; -import { getServiceAnomalies } from '../../service_map/get_service_anomalies'; +import { getServiceAnomalies } from '../../../routes/service_map/get_service_anomalies'; import { ServicesItemsSetup } from './get_services_items'; interface AggregationParams { diff --git a/x-pack/plugins/apm/server/lib/services/get_services/get_legacy_data_status.ts b/x-pack/plugins/apm/server/routes/services/get_services/get_legacy_data_status.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/services/get_services/get_legacy_data_status.ts rename to x-pack/plugins/apm/server/routes/services/get_services/get_legacy_data_status.ts index 5b94bb231425..7275e34786e3 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services/get_legacy_data_status.ts +++ b/x-pack/plugins/apm/server/routes/services/get_services/get_legacy_data_status.ts @@ -8,7 +8,7 @@ import { rangeQuery } from '../../../../../observability/server'; import { ProcessorEvent } from '../../../../common/processor_event'; import { OBSERVER_VERSION_MAJOR } from '../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; // returns true if 6.x data is found export async function getLegacyDataStatus( diff --git a/x-pack/plugins/apm/server/lib/services/get_services/get_service_transaction_stats.ts b/x-pack/plugins/apm/server/routes/services/get_services/get_service_transaction_stats.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/services/get_services/get_service_transaction_stats.ts rename to x-pack/plugins/apm/server/routes/services/get_services/get_service_transaction_stats.ts index 36903f9ca229..3eaa8053b670 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services/get_service_transaction_stats.ts +++ b/x-pack/plugins/apm/server/routes/services/get_services/get_service_transaction_stats.ts @@ -22,12 +22,12 @@ import { getDocumentTypeFilterForTransactions, getTransactionDurationFieldForTransactions, getProcessorEventForTransactions, -} from '../../helpers/transactions'; -import { calculateThroughput } from '../../helpers/calculate_throughput'; +} from '../../../lib/helpers/transactions'; +import { calculateThroughput } from '../../../lib/helpers/calculate_throughput'; import { calculateFailedTransactionRate, getOutcomeAggregation, -} from '../../helpers/transaction_error_rate'; +} from '../../../lib/helpers/transaction_error_rate'; import { ServicesItemsSetup } from './get_services_items'; interface AggregationParams { diff --git a/x-pack/plugins/apm/server/lib/services/get_services/get_services_from_metric_documents.ts b/x-pack/plugins/apm/server/routes/services/get_services/get_services_from_metric_documents.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/services/get_services/get_services_from_metric_documents.ts rename to x-pack/plugins/apm/server/routes/services/get_services/get_services_from_metric_documents.ts index cffd106d1334..055d82a80781 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services/get_services_from_metric_documents.ts +++ b/x-pack/plugins/apm/server/routes/services/get_services/get_services_from_metric_documents.ts @@ -14,7 +14,7 @@ import { import { kqlQuery, rangeQuery } from '../../../../../observability/server'; import { environmentQuery } from '../../../../common/utils/environment_query'; import { ProcessorEvent } from '../../../../common/processor_event'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; export async function getServicesFromMetricDocuments({ environment, diff --git a/x-pack/plugins/apm/server/lib/services/get_services/get_services_items.ts b/x-pack/plugins/apm/server/routes/services/get_services/get_services_items.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/services/get_services/get_services_items.ts rename to x-pack/plugins/apm/server/routes/services/get_services/get_services_items.ts index 47f1f6e7e643..db3377b6710c 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services/get_services_items.ts +++ b/x-pack/plugins/apm/server/routes/services/get_services/get_services_items.ts @@ -7,7 +7,7 @@ import { Logger } from '@kbn/logging'; import { withApmSpan } from '../../../utils/with_apm_span'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { getHealthStatuses } from './get_health_statuses'; import { getServicesFromMetricDocuments } from './get_services_from_metric_documents'; import { getServiceTransactionStats } from './get_service_transaction_stats'; diff --git a/x-pack/plugins/apm/server/lib/services/get_services/index.ts b/x-pack/plugins/apm/server/routes/services/get_services/index.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/services/get_services/index.ts rename to x-pack/plugins/apm/server/routes/services/get_services/index.ts index d6a940bc14b5..9d1670fe8458 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services/index.ts +++ b/x-pack/plugins/apm/server/routes/services/get_services/index.ts @@ -7,7 +7,7 @@ import { Logger } from '@kbn/logging'; import { withApmSpan } from '../../../utils/with_apm_span'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { getLegacyDataStatus } from './get_legacy_data_status'; import { getServicesItems } from './get_services_items'; diff --git a/x-pack/plugins/apm/server/lib/services/get_services/merge_service_stats.test.ts b/x-pack/plugins/apm/server/routes/services/get_services/merge_service_stats.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/services/get_services/merge_service_stats.test.ts rename to x-pack/plugins/apm/server/routes/services/get_services/merge_service_stats.test.ts diff --git a/x-pack/plugins/apm/server/lib/services/get_services/merge_service_stats.ts b/x-pack/plugins/apm/server/routes/services/get_services/merge_service_stats.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/services/get_services/merge_service_stats.ts rename to x-pack/plugins/apm/server/routes/services/get_services/merge_service_stats.ts diff --git a/x-pack/plugins/apm/server/lib/services/get_services_detailed_statistics/get_service_transaction_detailed_statistics.ts b/x-pack/plugins/apm/server/routes/services/get_services_detailed_statistics/get_service_transaction_detailed_statistics.ts similarity index 92% rename from x-pack/plugins/apm/server/lib/services/get_services_detailed_statistics/get_service_transaction_detailed_statistics.ts rename to x-pack/plugins/apm/server/routes/services/get_services_detailed_statistics/get_service_transaction_detailed_statistics.ts index ea153a5ddcd4..95f2c6f400de 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services_detailed_statistics/get_service_transaction_detailed_statistics.ts +++ b/x-pack/plugins/apm/server/routes/services/get_services_detailed_statistics/get_service_transaction_detailed_statistics.ts @@ -21,14 +21,14 @@ import { getDocumentTypeFilterForTransactions, getTransactionDurationFieldForTransactions, getProcessorEventForTransactions, -} from '../../helpers/transactions'; -import { calculateThroughput } from '../../helpers/calculate_throughput'; -import { getBucketSizeForAggregatedTransactions } from '../../helpers/get_bucket_size_for_aggregated_transactions'; -import { Setup } from '../../helpers/setup_request'; +} from '../../../lib/helpers/transactions'; +import { calculateThroughput } from '../../../lib/helpers/calculate_throughput'; +import { getBucketSizeForAggregatedTransactions } from '../../../lib/helpers/get_bucket_size_for_aggregated_transactions'; +import { Setup } from '../../../lib/helpers/setup_request'; import { calculateFailedTransactionRate, getOutcomeAggregation, -} from '../../helpers/transaction_error_rate'; +} from '../../../lib/helpers/transaction_error_rate'; export async function getServiceTransactionDetailedStatistics({ serviceNames, diff --git a/x-pack/plugins/apm/server/lib/services/get_services_detailed_statistics/index.ts b/x-pack/plugins/apm/server/routes/services/get_services_detailed_statistics/index.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/services/get_services_detailed_statistics/index.ts rename to x-pack/plugins/apm/server/routes/services/get_services_detailed_statistics/index.ts index e2f2ee226ab1..228add10184b 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services_detailed_statistics/index.ts +++ b/x-pack/plugins/apm/server/routes/services/get_services_detailed_statistics/index.ts @@ -6,7 +6,7 @@ */ import { withApmSpan } from '../../../utils/with_apm_span'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { getServiceTransactionDetailedStatistics } from './get_service_transaction_detailed_statistics'; export async function getServicesDetailedStatistics({ diff --git a/x-pack/plugins/apm/server/lib/services/get_throughput.ts b/x-pack/plugins/apm/server/routes/services/get_throughput.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/services/get_throughput.ts rename to x-pack/plugins/apm/server/routes/services/get_throughput.ts index 3161066ebadf..4a0366cc2f6a 100644 --- a/x-pack/plugins/apm/server/lib/services/get_throughput.ts +++ b/x-pack/plugins/apm/server/routes/services/get_throughput.ts @@ -20,8 +20,8 @@ import { environmentQuery } from '../../../common/utils/environment_query'; import { getDocumentTypeFilterForTransactions, getProcessorEventForTransactions, -} from '../helpers/transactions'; -import { Setup } from '../helpers/setup_request'; +} from '../../lib/helpers/transactions'; +import { Setup } from '../../lib/helpers/setup_request'; interface Options { environment: string; diff --git a/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_statistics.ts b/x-pack/plugins/apm/server/routes/services/profiling/get_service_profiling_statistics.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_statistics.ts rename to x-pack/plugins/apm/server/routes/services/profiling/get_service_profiling_statistics.ts index 0b96a6bd3d45..009d974e3372 100644 --- a/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_statistics.ts +++ b/x-pack/plugins/apm/server/routes/services/profiling/get_service_profiling_statistics.ts @@ -23,8 +23,8 @@ import { } from '../../../../common/elasticsearch_fieldnames'; import { rangeQuery, kqlQuery } from '../../../../../observability/server'; import { environmentQuery } from '../../../../common/utils/environment_query'; -import { APMEventClient } from '../../helpers/create_es_client/create_apm_event_client'; -import { Setup } from '../../helpers/setup_request'; +import { APMEventClient } from '../../../lib/helpers/create_es_client/create_apm_event_client'; +import { Setup } from '../../../lib/helpers/setup_request'; import { withApmSpan } from '../../../utils/with_apm_span'; const MAX_STACK_IDS = 10000; diff --git a/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_timeline.ts b/x-pack/plugins/apm/server/routes/services/profiling/get_service_profiling_timeline.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_timeline.ts rename to x-pack/plugins/apm/server/routes/services/profiling/get_service_profiling_timeline.ts index ce1580fc4829..47df939467d0 100644 --- a/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_timeline.ts +++ b/x-pack/plugins/apm/server/routes/services/profiling/get_service_profiling_timeline.ts @@ -14,8 +14,8 @@ import { getValueTypeConfig, ProfilingValueType, } from '../../../../common/profiling'; -import { Setup } from '../../helpers/setup_request'; -import { getBucketSize } from '../../helpers/get_bucket_size'; +import { Setup } from '../../../lib/helpers/setup_request'; +import { getBucketSize } from '../../../lib/helpers/get_bucket_size'; import { environmentQuery } from '../../../../common/utils/environment_query'; import { kqlQuery, rangeQuery } from '../../../../../observability/server'; diff --git a/x-pack/plugins/apm/server/lib/services/queries.test.ts b/x-pack/plugins/apm/server/routes/services/queries.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/services/queries.test.ts rename to x-pack/plugins/apm/server/routes/services/queries.test.ts diff --git a/x-pack/plugins/apm/server/routes/services.ts b/x-pack/plugins/apm/server/routes/services/route.ts similarity index 89% rename from x-pack/plugins/apm/server/routes/services.ts rename to x-pack/plugins/apm/server/routes/services/route.ts index cb557f56d816..d395be4c6adc 100644 --- a/x-pack/plugins/apm/server/routes/services.ts +++ b/x-pack/plugins/apm/server/routes/services/route.ts @@ -11,42 +11,42 @@ import { isoToEpochRt } from '@kbn/io-ts-utils/iso_to_epoch_rt'; import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt'; import * as t from 'io-ts'; import { uniq } from 'lodash'; -import { latencyAggregationTypeRt } from '../../common/latency_aggregation_types'; -import { ProfilingValueType } from '../../common/profiling'; -import { getSearchAggregatedTransactions } from '../lib/helpers/transactions'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { getServiceAnnotations } from '../lib/services/annotations'; -import { getServices } from '../lib/services/get_services'; -import { getServiceAgent } from '../lib/services/get_service_agent'; -import { getServiceAlerts } from '../lib/services/get_service_alerts'; -import { getServiceDependencies } from '../lib/services/get_service_dependencies'; -import { getServiceInstanceMetadataDetails } from '../lib/services/get_service_instance_metadata_details'; -import { getServiceErrorGroupPeriods } from '../lib/services/get_service_error_groups/get_service_error_group_detailed_statistics'; -import { getServiceErrorGroupMainStatistics } from '../lib/services/get_service_error_groups/get_service_error_group_main_statistics'; -import { getServiceInstancesDetailedStatisticsPeriods } from '../lib/services/get_service_instances/detailed_statistics'; -import { getServiceInstancesMainStatistics } from '../lib/services/get_service_instances/main_statistics'; -import { getServiceMetadataDetails } from '../lib/services/get_service_metadata_details'; -import { getServiceMetadataIcons } from '../lib/services/get_service_metadata_icons'; -import { getServiceNodeMetadata } from '../lib/services/get_service_node_metadata'; -import { getServiceTransactionTypes } from '../lib/services/get_service_transaction_types'; -import { getThroughput } from '../lib/services/get_throughput'; -import { getServiceProfilingStatistics } from '../lib/services/profiling/get_service_profiling_statistics'; -import { getServiceProfilingTimeline } from '../lib/services/profiling/get_service_profiling_timeline'; -import { getServiceInfrastructure } from '../lib/services/get_service_infrastructure'; -import { withApmSpan } from '../utils/with_apm_span'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; +import { latencyAggregationTypeRt } from '../../../common/latency_aggregation_types'; +import { ProfilingValueType } from '../../../common/profiling'; +import { getSearchAggregatedTransactions } from '../../lib/helpers/transactions'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { getServiceAnnotations } from './annotations'; +import { getServices } from './get_services'; +import { getServiceAgent } from './get_service_agent'; +import { getServiceAlerts } from './get_service_alerts'; +import { getServiceDependencies } from './get_service_dependencies'; +import { getServiceInstanceMetadataDetails } from './get_service_instance_metadata_details'; +import { getServiceErrorGroupPeriods } from './get_service_error_groups/get_service_error_group_detailed_statistics'; +import { getServiceErrorGroupMainStatistics } from './get_service_error_groups/get_service_error_group_main_statistics'; +import { getServiceInstancesDetailedStatisticsPeriods } from './get_service_instances/detailed_statistics'; +import { getServiceInstancesMainStatistics } from './get_service_instances/main_statistics'; +import { getServiceMetadataDetails } from './get_service_metadata_details'; +import { getServiceMetadataIcons } from './get_service_metadata_icons'; +import { getServiceNodeMetadata } from './get_service_node_metadata'; +import { getServiceTransactionTypes } from './get_service_transaction_types'; +import { getThroughput } from './get_throughput'; +import { getServiceProfilingStatistics } from './profiling/get_service_profiling_statistics'; +import { getServiceProfilingTimeline } from './profiling/get_service_profiling_timeline'; +import { getServiceInfrastructure } from './get_service_infrastructure'; +import { withApmSpan } from '../../utils/with_apm_span'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; import { comparisonRangeRt, environmentRt, kueryRt, offsetRt, rangeRt, -} from './default_api_types'; -import { offsetPreviousPeriodCoordinates } from '../../common/utils/offset_previous_period_coordinate'; -import { getServicesDetailedStatistics } from '../lib/services/get_services_detailed_statistics'; -import { getServiceDependenciesBreakdown } from '../lib/services/get_service_dependencies_breakdown'; -import { getBucketSizeForAggregatedTransactions } from '../lib/helpers/get_bucket_size_for_aggregated_transactions'; +} from '../default_api_types'; +import { offsetPreviousPeriodCoordinates } from '../../../common/utils/offset_previous_period_coordinate'; +import { getServicesDetailedStatistics } from './get_services_detailed_statistics'; +import { getServiceDependenciesBreakdown } from './get_service_dependencies_breakdown'; +import { getBucketSizeForAggregatedTransactions } from '../../lib/helpers/get_bucket_size_for_aggregated_transactions'; const servicesRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/services', diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/routes/settings/agent_configuration/__snapshots__/queries.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/__snapshots__/queries.test.ts.snap rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/__snapshots__/queries.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/convert_settings_to_string.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/convert_settings_to_string.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/convert_settings_to_string.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/convert_settings_to_string.ts diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/create_agent_config_index.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/create_agent_config_index.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/create_agent_config_index.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/create_agent_config_index.ts diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/create_or_update_configuration.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/create_or_update_configuration.ts similarity index 89% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/create_or_update_configuration.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/create_or_update_configuration.ts index c112c3be3362..07a9f7982930 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/create_or_update_configuration.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration/create_or_update_configuration.ts @@ -6,12 +6,12 @@ */ import hash from 'object-hash'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { AgentConfiguration, AgentConfigurationIntake, } from '../../../../common/agent_configuration/configuration_types'; -import { APMIndexDocumentParams } from '../../helpers/create_es_client/create_internal_es_client'; +import { APMIndexDocumentParams } from '../../../lib/helpers/create_es_client/create_internal_es_client'; export function createOrUpdateConfiguration({ configurationId, diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/delete_configuration.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/delete_configuration.ts similarity index 91% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/delete_configuration.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/delete_configuration.ts index 125c97730a6f..5ac8437b1578 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/delete_configuration.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration/delete_configuration.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; export async function deleteConfiguration({ configurationId, diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/find_exact_configuration.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/find_exact_configuration.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/find_exact_configuration.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/find_exact_configuration.ts index 90f82442f9bf..ac95f3610799 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/find_exact_configuration.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration/find_exact_configuration.ts @@ -11,7 +11,7 @@ import { SERVICE_ENVIRONMENT, SERVICE_NAME, } from '../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { convertConfigSettingsToString } from './convert_settings_to_string'; export async function findExactConfiguration({ diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_agent_name_by_service.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/get_agent_name_by_service.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/get_agent_name_by_service.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/get_agent_name_by_service.ts index 6ea3e2a57805..d16af2d95d22 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_agent_name_by_service.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration/get_agent_name_by_service.ts @@ -6,7 +6,7 @@ */ import { ProcessorEvent } from '../../../../common/processor_event'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { SERVICE_NAME } from '../../../../common/elasticsearch_fieldnames'; import { AGENT_NAME } from '../../../../common/elasticsearch_fieldnames'; diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_environments/get_existing_environments_for_service.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/get_environments/get_existing_environments_for_service.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/get_environments/get_existing_environments_for_service.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/get_environments/get_existing_environments_for_service.ts index 4fd351f8708a..a3925c060a1c 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_environments/get_existing_environments_for_service.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration/get_environments/get_existing_environments_for_service.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../../../helpers/setup_request'; +import { Setup } from '../../../../lib/helpers/setup_request'; import { SERVICE_NAME, SERVICE_ENVIRONMENT, diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_environments/index.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/get_environments/index.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/get_environments/index.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/get_environments/index.ts index a22c1d35dc66..46ab82152caa 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_environments/index.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration/get_environments/index.ts @@ -7,7 +7,7 @@ import { withApmSpan } from '../../../../utils/with_apm_span'; import { getAllEnvironments } from '../../../environments/get_all_environments'; -import { Setup } from '../../../helpers/setup_request'; +import { Setup } from '../../../../lib/helpers/setup_request'; import { getExistingEnvironmentsForService } from './get_existing_environments_for_service'; import { ALL_OPTION_VALUE } from '../../../../../common/agent_configuration/all_option'; diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_service_names.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/get_service_names.ts similarity index 90% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/get_service_names.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/get_service_names.ts index fc5167159b98..18e359c5b942 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_service_names.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration/get_service_names.ts @@ -6,10 +6,10 @@ */ import { ProcessorEvent } from '../../../../common/processor_event'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { SERVICE_NAME } from '../../../../common/elasticsearch_fieldnames'; import { ALL_OPTION_VALUE } from '../../../../common/agent_configuration/all_option'; -import { getProcessorEventForTransactions } from '../../helpers/transactions'; +import { getProcessorEventForTransactions } from '../../../lib/helpers/transactions'; export async function getServiceNames({ setup, diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/list_configurations.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/list_configurations.ts similarity index 93% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/list_configurations.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/list_configurations.ts index 098888c23ccb..bc105106cb5e 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/list_configurations.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration/list_configurations.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { AgentConfiguration } from '../../../../common/agent_configuration/configuration_types'; import { convertConfigSettingsToString } from './convert_settings_to_string'; diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/mark_applied_by_agent.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/mark_applied_by_agent.ts similarity index 93% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/mark_applied_by_agent.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/mark_applied_by_agent.ts index 5fa499392157..78e0ce68624a 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/mark_applied_by_agent.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration/mark_applied_by_agent.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { AgentConfiguration } from '../../../../common/agent_configuration/configuration_types'; // We're not wrapping this function with a span as it is not blocking the request diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/queries.test.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/queries.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/queries.test.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/queries.test.ts diff --git a/x-pack/plugins/apm/server/routes/settings/agent_configuration.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/route.ts similarity index 86% rename from x-pack/plugins/apm/server/routes/settings/agent_configuration.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/route.ts index 563fa40c6c0d..1122c2095ed3 100644 --- a/x-pack/plugins/apm/server/routes/settings/agent_configuration.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration/route.ts @@ -8,25 +8,25 @@ import * as t from 'io-ts'; import Boom from '@hapi/boom'; import { toBooleanRt } from '@kbn/io-ts-utils/to_boolean_rt'; -import { maxSuggestions } from '../../../../observability/common'; -import { setupRequest } from '../../lib/helpers/setup_request'; -import { getServiceNames } from '../../lib/settings/agent_configuration/get_service_names'; -import { createOrUpdateConfiguration } from '../../lib/settings/agent_configuration/create_or_update_configuration'; -import { searchConfigurations } from '../../lib/settings/agent_configuration/search_configurations'; -import { findExactConfiguration } from '../../lib/settings/agent_configuration/find_exact_configuration'; -import { listConfigurations } from '../../lib/settings/agent_configuration/list_configurations'; -import { getEnvironments } from '../../lib/settings/agent_configuration/get_environments'; -import { deleteConfiguration } from '../../lib/settings/agent_configuration/delete_configuration'; -import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; -import { getAgentNameByService } from '../../lib/settings/agent_configuration/get_agent_name_by_service'; -import { markAppliedByAgent } from '../../lib/settings/agent_configuration/mark_applied_by_agent'; +import { maxSuggestions } from '../../../../../observability/common'; +import { setupRequest } from '../../../lib/helpers/setup_request'; +import { getServiceNames } from './get_service_names'; +import { createOrUpdateConfiguration } from './create_or_update_configuration'; +import { searchConfigurations } from './search_configurations'; +import { findExactConfiguration } from './find_exact_configuration'; +import { listConfigurations } from './list_configurations'; +import { getEnvironments } from './get_environments'; +import { deleteConfiguration } from './delete_configuration'; +import { createApmServerRoute } from '../../apm_routes/create_apm_server_route'; +import { getAgentNameByService } from './get_agent_name_by_service'; +import { markAppliedByAgent } from './mark_applied_by_agent'; import { serviceRt, agentConfigurationIntakeRt, -} from '../../../common/agent_configuration/runtime_types/agent_configuration_intake_rt'; -import { getSearchAggregatedTransactions } from '../../lib/helpers/transactions'; -import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; -import { syncAgentConfigsToApmPackagePolicies } from '../../lib/fleet/sync_agent_configs_to_apm_package_policies'; +} from '../../../../common/agent_configuration/runtime_types/agent_configuration_intake_rt'; +import { getSearchAggregatedTransactions } from '../../../lib/helpers/transactions'; +import { createApmServerRouteRepository } from '../../apm_routes/create_apm_server_route_repository'; +import { syncAgentConfigsToApmPackagePolicies } from '../../fleet/sync_agent_configs_to_apm_package_policies'; // get list of configurations const agentConfigurationRoute = createApmServerRoute({ diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/search_configurations.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration/search_configurations.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/settings/agent_configuration/search_configurations.ts rename to x-pack/plugins/apm/server/routes/settings/agent_configuration/search_configurations.ts index 1e37ae910857..194e1eff4e65 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/search_configurations.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration/search_configurations.ts @@ -10,7 +10,7 @@ import { SERVICE_NAME, SERVICE_ENVIRONMENT, } from '../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { AgentConfiguration } from '../../../../common/agent_configuration/configuration_types'; import { convertConfigSettingsToString } from './convert_settings_to_string'; diff --git a/x-pack/plugins/apm/server/routes/settings/anomaly_detection.ts b/x-pack/plugins/apm/server/routes/settings/anomaly_detection/route.ts similarity index 74% rename from x-pack/plugins/apm/server/routes/settings/anomaly_detection.ts rename to x-pack/plugins/apm/server/routes/settings/anomaly_detection/route.ts index e8b2ef5e119c..a924a9214977 100644 --- a/x-pack/plugins/apm/server/routes/settings/anomaly_detection.ts +++ b/x-pack/plugins/apm/server/routes/settings/anomaly_detection/route.ts @@ -7,19 +7,19 @@ import * as t from 'io-ts'; import Boom from '@hapi/boom'; -import { maxSuggestions } from '../../../../observability/common'; -import { isActivePlatinumLicense } from '../../../common/license_check'; -import { ML_ERRORS } from '../../../common/anomaly_detection'; -import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; -import { getAnomalyDetectionJobs } from '../../lib/anomaly_detection/get_anomaly_detection_jobs'; -import { createAnomalyDetectionJobs } from '../../lib/anomaly_detection/create_anomaly_detection_jobs'; -import { setupRequest } from '../../lib/helpers/setup_request'; -import { getAllEnvironments } from '../../lib/environments/get_all_environments'; -import { hasLegacyJobs } from '../../lib/anomaly_detection/has_legacy_jobs'; -import { getSearchAggregatedTransactions } from '../../lib/helpers/transactions'; -import { notifyFeatureUsage } from '../../feature'; -import { withApmSpan } from '../../utils/with_apm_span'; -import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { maxSuggestions } from '../../../../../observability/common'; +import { isActivePlatinumLicense } from '../../../../common/license_check'; +import { ML_ERRORS } from '../../../../common/anomaly_detection'; +import { createApmServerRoute } from '../../apm_routes/create_apm_server_route'; +import { getAnomalyDetectionJobs } from '../../../lib/anomaly_detection/get_anomaly_detection_jobs'; +import { createAnomalyDetectionJobs } from '../../../lib/anomaly_detection/create_anomaly_detection_jobs'; +import { setupRequest } from '../../../lib/helpers/setup_request'; +import { getAllEnvironments } from '../../environments/get_all_environments'; +import { hasLegacyJobs } from '../../../lib/anomaly_detection/has_legacy_jobs'; +import { getSearchAggregatedTransactions } from '../../../lib/helpers/transactions'; +import { notifyFeatureUsage } from '../../../feature'; +import { withApmSpan } from '../../../utils/with_apm_span'; +import { createApmServerRouteRepository } from '../../apm_routes/create_apm_server_route_repository'; // get ML anomaly detection jobs for each environment const anomalyDetectionJobsRoute = createApmServerRoute({ diff --git a/x-pack/plugins/apm/server/lib/settings/apm_indices/get_apm_indices.ts b/x-pack/plugins/apm/server/routes/settings/apm_indices/get_apm_indices.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/settings/apm_indices/get_apm_indices.ts rename to x-pack/plugins/apm/server/routes/settings/apm_indices/get_apm_indices.ts index a37720cbc379..6b917919bade 100644 --- a/x-pack/plugins/apm/server/lib/settings/apm_indices/get_apm_indices.ts +++ b/x-pack/plugins/apm/server/routes/settings/apm_indices/get_apm_indices.ts @@ -12,7 +12,7 @@ import { APM_INDICES_SAVED_OBJECT_ID, } from '../../../../common/apm_saved_object_constants'; import { APMConfig } from '../../..'; -import { APMRouteHandlerResources } from '../../../routes/typings'; +import { APMRouteHandlerResources } from '../../typings'; import { withApmSpan } from '../../../utils/with_apm_span'; import { ApmIndicesConfig } from '../../../../../observability/common/typings'; diff --git a/x-pack/plugins/apm/server/routes/settings/apm_indices.ts b/x-pack/plugins/apm/server/routes/settings/apm_indices/route.ts similarity index 82% rename from x-pack/plugins/apm/server/routes/settings/apm_indices.ts rename to x-pack/plugins/apm/server/routes/settings/apm_indices/route.ts index ed99f0c8862f..485ff8af8884 100644 --- a/x-pack/plugins/apm/server/routes/settings/apm_indices.ts +++ b/x-pack/plugins/apm/server/routes/settings/apm_indices/route.ts @@ -6,14 +6,11 @@ */ import * as t from 'io-ts'; -import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; -import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; -import { - getApmIndices, - getApmIndexSettings, -} from '../../lib/settings/apm_indices/get_apm_indices'; -import { saveApmIndices } from '../../lib/settings/apm_indices/save_apm_indices'; -import { APMConfig } from '../..'; +import { createApmServerRouteRepository } from '../../apm_routes/create_apm_server_route_repository'; +import { createApmServerRoute } from '../../apm_routes/create_apm_server_route'; +import { getApmIndices, getApmIndexSettings } from './get_apm_indices'; +import { saveApmIndices } from './save_apm_indices'; +import { APMConfig } from '../../../'; // get list of apm indices and values const apmIndexSettingsRoute = createApmServerRoute({ diff --git a/x-pack/plugins/apm/server/lib/settings/apm_indices/save_apm_indices.test.ts b/x-pack/plugins/apm/server/routes/settings/apm_indices/save_apm_indices.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/apm_indices/save_apm_indices.test.ts rename to x-pack/plugins/apm/server/routes/settings/apm_indices/save_apm_indices.test.ts diff --git a/x-pack/plugins/apm/server/lib/settings/apm_indices/save_apm_indices.ts b/x-pack/plugins/apm/server/routes/settings/apm_indices/save_apm_indices.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/apm_indices/save_apm_indices.ts rename to x-pack/plugins/apm/server/routes/settings/apm_indices/save_apm_indices.ts diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/get_transaction.test.ts.snap b/x-pack/plugins/apm/server/routes/settings/custom_link/__snapshots__/get_transaction.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/get_transaction.test.ts.snap rename to x-pack/plugins/apm/server/routes/settings/custom_link/__snapshots__/get_transaction.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/list_custom_links.test.ts.snap b/x-pack/plugins/apm/server/routes/settings/custom_link/__snapshots__/list_custom_links.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/list_custom_links.test.ts.snap rename to x-pack/plugins/apm/server/routes/settings/custom_link/__snapshots__/list_custom_links.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/create_custom_link_index.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/create_custom_link_index.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/custom_link/create_custom_link_index.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/create_custom_link_index.ts diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.test.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/create_or_update_custom_link.test.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.test.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/create_or_update_custom_link.test.ts index 1cec38ad4af6..7690210ac012 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.test.ts +++ b/x-pack/plugins/apm/server/routes/settings/custom_link/create_or_update_custom_link.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { mockNow } from '../../../utils/test_helpers'; import { CustomLink } from '../../../../common/custom_link/custom_link_types'; import { createOrUpdateCustomLink } from './create_or_update_custom_link'; diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/create_or_update_custom_link.ts similarity index 86% rename from x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/create_or_update_custom_link.ts index 8f14e87fe183..643139093676 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/create_or_update_custom_link.ts +++ b/x-pack/plugins/apm/server/routes/settings/custom_link/create_or_update_custom_link.ts @@ -9,9 +9,9 @@ import { CustomLink, CustomLinkES, } from '../../../../common/custom_link/custom_link_types'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { toESFormat } from './helper'; -import { APMIndexDocumentParams } from '../../helpers/create_es_client/create_internal_es_client'; +import { APMIndexDocumentParams } from '../../../lib/helpers/create_es_client/create_internal_es_client'; export function createOrUpdateCustomLink({ customLinkId, diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/custom_link_types.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/custom_link_types.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/custom_link/custom_link_types.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/custom_link_types.ts diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/delete_custom_link.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/delete_custom_link.ts similarity index 90% rename from x-pack/plugins/apm/server/lib/settings/custom_link/delete_custom_link.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/delete_custom_link.ts index bf7cfb33d87a..6366bbcfd9f0 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/delete_custom_link.ts +++ b/x-pack/plugins/apm/server/routes/settings/custom_link/delete_custom_link.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; export function deleteCustomLink({ customLinkId, diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.test.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/get_transaction.test.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.test.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/get_transaction.test.ts index 03d0120b0043..e6ba932ca58d 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.test.ts +++ b/x-pack/plugins/apm/server/routes/settings/custom_link/get_transaction.test.ts @@ -10,7 +10,7 @@ import { SearchParamsMock, } from '../../../utils/test_helpers'; import { getTransaction } from './get_transaction'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { SERVICE_NAME, TRANSACTION_TYPE, diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/get_transaction.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/get_transaction.ts index 1c3d1465527b..88d2ae9f339a 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.ts +++ b/x-pack/plugins/apm/server/routes/settings/custom_link/get_transaction.ts @@ -7,7 +7,7 @@ import * as t from 'io-ts'; import { compact } from 'lodash'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { ProcessorEvent } from '../../../../common/processor_event'; import { filterOptionsRt } from './custom_link_types'; import { splitFilterValueByComma } from './helper'; diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/helper.test.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/helper.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/custom_link/helper.test.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/helper.test.ts diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/helper.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/helper.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/settings/custom_link/helper.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/helper.ts diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.test.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/list_custom_links.test.ts similarity index 94% rename from x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.test.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/list_custom_links.test.ts index 844f886c21a4..8ea4061e46cf 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.test.ts +++ b/x-pack/plugins/apm/server/routes/settings/custom_link/list_custom_links.test.ts @@ -10,7 +10,7 @@ import { inspectSearchParams, SearchParamsMock, } from '../../../utils/test_helpers'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { SERVICE_NAME, TRANSACTION_NAME, diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/list_custom_links.ts similarity index 96% rename from x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/list_custom_links.ts index 633545e16acf..a64d958dabd0 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.ts +++ b/x-pack/plugins/apm/server/routes/settings/custom_link/list_custom_links.ts @@ -11,7 +11,7 @@ import { CustomLink, CustomLinkES, } from '../../../../common/custom_link/custom_link_types'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { fromESFormat } from './helper'; import { filterOptionsRt } from './custom_link_types'; diff --git a/x-pack/plugins/apm/server/routes/settings/custom_link.ts b/x-pack/plugins/apm/server/routes/settings/custom_link/route.ts similarity index 79% rename from x-pack/plugins/apm/server/routes/settings/custom_link.ts rename to x-pack/plugins/apm/server/routes/settings/custom_link/route.ts index 044b56c3c273..42232581f1af 100644 --- a/x-pack/plugins/apm/server/routes/settings/custom_link.ts +++ b/x-pack/plugins/apm/server/routes/settings/custom_link/route.ts @@ -8,21 +8,18 @@ import Boom from '@hapi/boom'; import * as t from 'io-ts'; import { pick } from 'lodash'; -import { isActiveGoldLicense } from '../../../common/license_check'; -import { INVALID_LICENSE } from '../../../common/custom_link'; -import { FILTER_OPTIONS } from '../../../common/custom_link/custom_link_filter_options'; -import { notifyFeatureUsage } from '../../feature'; -import { setupRequest } from '../../lib/helpers/setup_request'; -import { createOrUpdateCustomLink } from '../../lib/settings/custom_link/create_or_update_custom_link'; -import { - filterOptionsRt, - payloadRt, -} from '../../lib/settings/custom_link/custom_link_types'; -import { deleteCustomLink } from '../../lib/settings/custom_link/delete_custom_link'; -import { getTransaction } from '../../lib/settings/custom_link/get_transaction'; -import { listCustomLinks } from '../../lib/settings/custom_link/list_custom_links'; -import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { isActiveGoldLicense } from '../../../../common/license_check'; +import { INVALID_LICENSE } from '../../../../common/custom_link'; +import { FILTER_OPTIONS } from '../../../../common/custom_link/custom_link_filter_options'; +import { notifyFeatureUsage } from '../../../feature'; +import { setupRequest } from '../../../lib/helpers/setup_request'; +import { createOrUpdateCustomLink } from './create_or_update_custom_link'; +import { filterOptionsRt, payloadRt } from './custom_link_types'; +import { deleteCustomLink } from './delete_custom_link'; +import { getTransaction } from './get_transaction'; +import { listCustomLinks } from './list_custom_links'; +import { createApmServerRoute } from '../../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../../apm_routes/create_apm_server_route_repository'; const customLinkTransactionRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/settings/custom_links/transaction', diff --git a/x-pack/plugins/apm/server/routes/source_maps.ts b/x-pack/plugins/apm/server/routes/source_maps/route.ts similarity index 91% rename from x-pack/plugins/apm/server/routes/source_maps.ts rename to x-pack/plugins/apm/server/routes/source_maps/route.ts index 602a3a725eac..b0b7eb5134fc 100644 --- a/x-pack/plugins/apm/server/routes/source_maps.ts +++ b/x-pack/plugins/apm/server/routes/source_maps/route.ts @@ -14,11 +14,11 @@ import { listArtifacts, updateSourceMapsOnFleetPolicies, getCleanedBundleFilePath, -} from '../lib/fleet/source_maps'; -import { getInternalSavedObjectsClient } from '../lib/helpers/get_internal_saved_objects_client'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { stringFromBufferRt } from '../utils/string_from_buffer_rt'; +} from '../fleet/source_maps'; +import { getInternalSavedObjectsClient } from '../../lib/helpers/get_internal_saved_objects_client'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { stringFromBufferRt } from '../../utils/string_from_buffer_rt'; export const sourceMapRt = t.intersection([ t.type({ diff --git a/x-pack/plugins/apm/server/lib/suggestions/get_suggestions.ts b/x-pack/plugins/apm/server/routes/suggestions/get_suggestions.ts similarity index 87% rename from x-pack/plugins/apm/server/lib/suggestions/get_suggestions.ts rename to x-pack/plugins/apm/server/routes/suggestions/get_suggestions.ts index 5ea28debc443..624bf2bb4c01 100644 --- a/x-pack/plugins/apm/server/lib/suggestions/get_suggestions.ts +++ b/x-pack/plugins/apm/server/routes/suggestions/get_suggestions.ts @@ -6,8 +6,8 @@ */ import { ProcessorEvent } from '../../../common/processor_event'; -import { getProcessorEventForTransactions } from '../helpers/transactions'; -import { Setup } from '../helpers/setup_request'; +import { getProcessorEventForTransactions } from '../../lib/helpers/transactions'; +import { Setup } from '../../lib/helpers/setup_request'; export async function getSuggestions({ field, diff --git a/x-pack/plugins/apm/server/routes/suggestions.ts b/x-pack/plugins/apm/server/routes/suggestions/route.ts similarity index 72% rename from x-pack/plugins/apm/server/routes/suggestions.ts rename to x-pack/plugins/apm/server/routes/suggestions/route.ts index 9b8952d09d16..de3636c2c150 100644 --- a/x-pack/plugins/apm/server/routes/suggestions.ts +++ b/x-pack/plugins/apm/server/routes/suggestions/route.ts @@ -6,12 +6,12 @@ */ import * as t from 'io-ts'; -import { maxSuggestions } from '../../../observability/common'; -import { getSuggestions } from '../lib/suggestions/get_suggestions'; -import { getSearchAggregatedTransactions } from '../lib/helpers/transactions'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; +import { maxSuggestions } from '../../../../observability/common'; +import { getSuggestions } from '../suggestions/get_suggestions'; +import { getSearchAggregatedTransactions } from '../../lib/helpers/transactions'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; const suggestionsRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/suggestions', diff --git a/x-pack/plugins/apm/server/lib/traces/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/routes/traces/__snapshots__/queries.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/traces/__snapshots__/queries.test.ts.snap rename to x-pack/plugins/apm/server/routes/traces/__snapshots__/queries.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/traces/get_trace_items.ts b/x-pack/plugins/apm/server/routes/traces/get_trace_items.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/traces/get_trace_items.ts rename to x-pack/plugins/apm/server/routes/traces/get_trace_items.ts index 55204786b8e6..419c3e44d68a 100644 --- a/x-pack/plugins/apm/server/lib/traces/get_trace_items.ts +++ b/x-pack/plugins/apm/server/routes/traces/get_trace_items.ts @@ -15,7 +15,7 @@ import { ERROR_LOG_LEVEL, } from '../../../common/elasticsearch_fieldnames'; import { rangeQuery } from '../../../../observability/server'; -import { Setup } from '../helpers/setup_request'; +import { Setup } from '../../lib/helpers/setup_request'; export async function getTraceItems( traceId: string, diff --git a/x-pack/plugins/apm/server/lib/traces/queries.test.ts b/x-pack/plugins/apm/server/routes/traces/queries.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/traces/queries.test.ts rename to x-pack/plugins/apm/server/routes/traces/queries.test.ts diff --git a/x-pack/plugins/apm/server/routes/traces.ts b/x-pack/plugins/apm/server/routes/traces/route.ts similarity index 79% rename from x-pack/plugins/apm/server/routes/traces.ts rename to x-pack/plugins/apm/server/routes/traces/route.ts index 5fdac470a81e..24b5faeedfc0 100644 --- a/x-pack/plugins/apm/server/routes/traces.ts +++ b/x-pack/plugins/apm/server/routes/traces/route.ts @@ -6,15 +6,15 @@ */ import * as t from 'io-ts'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { getTraceItems } from '../lib/traces/get_trace_items'; -import { getTopTransactionGroupList } from '../lib/transaction_groups'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { environmentRt, kueryRt, rangeRt } from './default_api_types'; -import { getSearchAggregatedTransactions } from '../lib/helpers/transactions'; -import { getRootTransactionByTraceId } from '../lib/transactions/get_transaction_by_trace'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; -import { getTransaction } from '../lib/transactions/get_transaction'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { getTraceItems } from './get_trace_items'; +import { getTopTransactionGroupList } from '../../lib/transaction_groups'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { environmentRt, kueryRt, rangeRt } from '../default_api_types'; +import { getSearchAggregatedTransactions } from '../../lib/helpers/transactions'; +import { getRootTransactionByTraceId } from '../transactions/get_transaction_by_trace'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { getTransaction } from '../transactions/get_transaction'; const tracesRoute = createApmServerRoute({ endpoint: 'GET /internal/apm/traces', diff --git a/x-pack/plugins/apm/server/lib/transactions/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/routes/transactions/__snapshots__/queries.test.ts.snap similarity index 100% rename from x-pack/plugins/apm/server/lib/transactions/__snapshots__/queries.test.ts.snap rename to x-pack/plugins/apm/server/routes/transactions/__snapshots__/queries.test.ts.snap diff --git a/x-pack/plugins/apm/server/lib/transactions/breakdown/constants.ts b/x-pack/plugins/apm/server/routes/transactions/breakdown/constants.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/transactions/breakdown/constants.ts rename to x-pack/plugins/apm/server/routes/transactions/breakdown/constants.ts diff --git a/x-pack/plugins/apm/server/lib/transactions/breakdown/index.test.ts b/x-pack/plugins/apm/server/routes/transactions/breakdown/index.test.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/transactions/breakdown/index.test.ts rename to x-pack/plugins/apm/server/routes/transactions/breakdown/index.test.ts index 41d4c60fd72b..1d2602dcafc7 100644 --- a/x-pack/plugins/apm/server/lib/transactions/breakdown/index.test.ts +++ b/x-pack/plugins/apm/server/routes/transactions/breakdown/index.test.ts @@ -11,7 +11,7 @@ import noDataResponse from './mock_responses/no_data.json'; import dataResponse from './mock_responses/data.json'; import { APMConfig } from '../../..'; import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; -import { ApmIndicesConfig } from '../../settings/apm_indices/get_apm_indices'; +import { ApmIndicesConfig } from '../../../routes/settings/apm_indices/get_apm_indices'; const mockIndices: ApmIndicesConfig = { sourcemap: 'myIndex', diff --git a/x-pack/plugins/apm/server/lib/transactions/breakdown/index.ts b/x-pack/plugins/apm/server/routes/transactions/breakdown/index.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/transactions/breakdown/index.ts rename to x-pack/plugins/apm/server/routes/transactions/breakdown/index.ts index a5c11776c70b..2c3bca8443db 100644 --- a/x-pack/plugins/apm/server/lib/transactions/breakdown/index.ts +++ b/x-pack/plugins/apm/server/routes/transactions/breakdown/index.ts @@ -17,10 +17,10 @@ import { TRANSACTION_NAME, TRANSACTION_BREAKDOWN_COUNT, } from '../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { rangeQuery, kqlQuery } from '../../../../../observability/server'; import { environmentQuery } from '../../../../common/utils/environment_query'; -import { getMetricsDateHistogramParams } from '../../helpers/metrics'; +import { getMetricsDateHistogramParams } from '../../../lib/helpers/metrics'; import { MAX_KPIS } from './constants'; import { getVizColorForIndex } from '../../../../common/viz_colors'; diff --git a/x-pack/plugins/apm/server/lib/transactions/breakdown/mock_responses/data.json b/x-pack/plugins/apm/server/routes/transactions/breakdown/mock_responses/data.json similarity index 100% rename from x-pack/plugins/apm/server/lib/transactions/breakdown/mock_responses/data.json rename to x-pack/plugins/apm/server/routes/transactions/breakdown/mock_responses/data.json diff --git a/x-pack/plugins/apm/server/lib/transactions/breakdown/mock_responses/no_data.json b/x-pack/plugins/apm/server/routes/transactions/breakdown/mock_responses/no_data.json similarity index 100% rename from x-pack/plugins/apm/server/lib/transactions/breakdown/mock_responses/no_data.json rename to x-pack/plugins/apm/server/routes/transactions/breakdown/mock_responses/no_data.json diff --git a/x-pack/plugins/apm/server/lib/transactions/constants.ts b/x-pack/plugins/apm/server/routes/transactions/constants.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/transactions/constants.ts rename to x-pack/plugins/apm/server/routes/transactions/constants.ts diff --git a/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/fetcher.ts b/x-pack/plugins/apm/server/routes/transactions/get_anomaly_data/fetcher.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/fetcher.ts rename to x-pack/plugins/apm/server/routes/transactions/get_anomaly_data/fetcher.ts index dd723f24abe1..704bc751e577 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/fetcher.ts +++ b/x-pack/plugins/apm/server/routes/transactions/get_anomaly_data/fetcher.ts @@ -11,7 +11,7 @@ import { PromiseReturnType } from '../../../../../observability/typings/common'; import { rangeQuery } from '../../../../../observability/server'; import { asMutableArray } from '../../../../common/utils/as_mutable_array'; import { withApmSpan } from '../../../utils/with_apm_span'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { apmMlAnomalyQuery } from '../../../../common/anomaly_detection/apm_ml_anomaly_query'; import { ApmMlDetectorIndex } from '../../../../common/anomaly_detection/apm_ml_detectors'; diff --git a/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/index.ts b/x-pack/plugins/apm/server/routes/transactions/get_anomaly_data/index.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/index.ts rename to x-pack/plugins/apm/server/routes/transactions/get_anomaly_data/index.ts index c1123182586b..0cdbe1774504 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/index.ts +++ b/x-pack/plugins/apm/server/routes/transactions/get_anomaly_data/index.ts @@ -10,8 +10,8 @@ import { Logger } from 'src/core/server'; import { isFiniteNumber } from '../../../../common/utils/is_finite_number'; import { maybe } from '../../../../common/utils/maybe'; import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; -import { getBucketSize } from '../../helpers/get_bucket_size'; -import { Setup } from '../../helpers/setup_request'; +import { getBucketSize } from '../../../lib/helpers/get_bucket_size'; +import { Setup } from '../../../lib/helpers/setup_request'; import { anomalySeriesFetcher } from './fetcher'; import { getMLJobIds } from '../../service_map/get_service_anomalies'; import { ANOMALY_THRESHOLD } from '../../../../common/ml_constants'; diff --git a/x-pack/plugins/apm/server/lib/transactions/get_latency_charts/index.ts b/x-pack/plugins/apm/server/routes/transactions/get_latency_charts/index.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/transactions/get_latency_charts/index.ts rename to x-pack/plugins/apm/server/routes/transactions/get_latency_charts/index.ts index 4612d399b54a..5375da3606f1 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_latency_charts/index.ts +++ b/x-pack/plugins/apm/server/routes/transactions/get_latency_charts/index.ts @@ -25,11 +25,11 @@ import { getProcessorEventForTransactions, } from '../../../lib/helpers/transactions'; import { Setup } from '../../../lib/helpers/setup_request'; -import { getBucketSizeForAggregatedTransactions } from '../../helpers/get_bucket_size_for_aggregated_transactions'; +import { getBucketSizeForAggregatedTransactions } from '../../../lib/helpers/get_bucket_size_for_aggregated_transactions'; import { getLatencyAggregation, getLatencyValue, -} from '../../helpers/latency_aggregation_type'; +} from '../../../lib/helpers/latency_aggregation_type'; export type LatencyChartsSearchResponse = PromiseReturnType< typeof searchLatency >; diff --git a/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts b/x-pack/plugins/apm/server/routes/transactions/get_transaction/index.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts rename to x-pack/plugins/apm/server/routes/transactions/get_transaction/index.ts index 6d0bbcdb55ca..0522fb3a1899 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts +++ b/x-pack/plugins/apm/server/routes/transactions/get_transaction/index.ts @@ -10,7 +10,7 @@ import { TRANSACTION_ID, } from '../../../../common/elasticsearch_fieldnames'; import { rangeQuery, termQuery } from '../../../../../observability/server'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { ProcessorEvent } from '../../../../common/processor_event'; import { asMutableArray } from '../../../../common/utils/as_mutable_array'; diff --git a/x-pack/plugins/apm/server/lib/transactions/get_transaction_by_trace/index.ts b/x-pack/plugins/apm/server/routes/transactions/get_transaction_by_trace/index.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/transactions/get_transaction_by_trace/index.ts rename to x-pack/plugins/apm/server/routes/transactions/get_transaction_by_trace/index.ts index 568ce16e7aed..d9c6a64bdbcc 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_transaction_by_trace/index.ts +++ b/x-pack/plugins/apm/server/routes/transactions/get_transaction_by_trace/index.ts @@ -9,7 +9,7 @@ import { TRACE_ID, PARENT_ID, } from '../../../../common/elasticsearch_fieldnames'; -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { ProcessorEvent } from '../../../../common/processor_event'; export async function getRootTransactionByTraceId( diff --git a/x-pack/plugins/apm/server/lib/transactions/queries.test.ts b/x-pack/plugins/apm/server/routes/transactions/queries.test.ts similarity index 100% rename from x-pack/plugins/apm/server/lib/transactions/queries.test.ts rename to x-pack/plugins/apm/server/routes/transactions/queries.test.ts diff --git a/x-pack/plugins/apm/server/routes/transactions.ts b/x-pack/plugins/apm/server/routes/transactions/route.ts similarity index 90% rename from x-pack/plugins/apm/server/routes/transactions.ts rename to x-pack/plugins/apm/server/routes/transactions/route.ts index c0d83bac6e8e..5b3f4e4f3bd4 100644 --- a/x-pack/plugins/apm/server/routes/transactions.ts +++ b/x-pack/plugins/apm/server/routes/transactions/route.ts @@ -11,24 +11,24 @@ import * as t from 'io-ts'; import { LatencyAggregationType, latencyAggregationTypeRt, -} from '../../common/latency_aggregation_types'; -import { getSearchAggregatedTransactions } from '../lib/helpers/transactions'; -import { setupRequest } from '../lib/helpers/setup_request'; -import { getServiceTransactionGroups } from '../lib/services/get_service_transaction_groups'; -import { getServiceTransactionGroupDetailedStatisticsPeriods } from '../lib/services/get_service_transaction_group_detailed_statistics'; -import { getTransactionBreakdown } from '../lib/transactions/breakdown'; -import { getTransactionTraceSamples } from '../lib/transactions/trace_samples'; -import { getAnomalySeries } from '../lib/transactions/get_anomaly_data'; -import { getLatencyPeriods } from '../lib/transactions/get_latency_charts'; -import { getErrorRatePeriods } from '../lib/transaction_groups/get_error_rate'; -import { createApmServerRoute } from './apm_routes/create_apm_server_route'; -import { createApmServerRouteRepository } from './apm_routes/create_apm_server_route_repository'; +} from '../../../common/latency_aggregation_types'; +import { getSearchAggregatedTransactions } from '../../lib/helpers/transactions'; +import { setupRequest } from '../../lib/helpers/setup_request'; +import { getServiceTransactionGroups } from '../services/get_service_transaction_groups'; +import { getServiceTransactionGroupDetailedStatisticsPeriods } from '../services/get_service_transaction_group_detailed_statistics'; +import { getTransactionBreakdown } from './breakdown'; +import { getTransactionTraceSamples } from './trace_samples'; +import { getAnomalySeries } from './get_anomaly_data'; +import { getLatencyPeriods } from './get_latency_charts'; +import { getErrorRatePeriods } from '../../lib/transaction_groups/get_error_rate'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; import { comparisonRangeRt, environmentRt, kueryRt, rangeRt, -} from './default_api_types'; +} from '../default_api_types'; const transactionGroupsMainStatisticsRoute = createApmServerRoute({ endpoint: diff --git a/x-pack/plugins/apm/server/lib/transactions/trace_samples/get_trace_samples/index.ts b/x-pack/plugins/apm/server/routes/transactions/trace_samples/get_trace_samples/index.ts similarity index 97% rename from x-pack/plugins/apm/server/lib/transactions/trace_samples/get_trace_samples/index.ts rename to x-pack/plugins/apm/server/routes/transactions/trace_samples/get_trace_samples/index.ts index 9b96cf19c516..d4ceafd9f630 100644 --- a/x-pack/plugins/apm/server/lib/transactions/trace_samples/get_trace_samples/index.ts +++ b/x-pack/plugins/apm/server/routes/transactions/trace_samples/get_trace_samples/index.ts @@ -17,7 +17,7 @@ import { import { ProcessorEvent } from '../../../../../common/processor_event'; import { rangeQuery, kqlQuery } from '../../../../../../observability/server'; import { environmentQuery } from '../../../../../common/utils/environment_query'; -import { Setup } from '../../../helpers/setup_request'; +import { Setup } from '../../../../lib/helpers/setup_request'; const TRACE_SAMPLES_SIZE = 500; diff --git a/x-pack/plugins/apm/server/lib/transactions/trace_samples/index.ts b/x-pack/plugins/apm/server/routes/transactions/trace_samples/index.ts similarity index 95% rename from x-pack/plugins/apm/server/lib/transactions/trace_samples/index.ts rename to x-pack/plugins/apm/server/routes/transactions/trace_samples/index.ts index e422be417438..89bae10db5e8 100644 --- a/x-pack/plugins/apm/server/lib/transactions/trace_samples/index.ts +++ b/x-pack/plugins/apm/server/routes/transactions/trace_samples/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Setup } from '../../helpers/setup_request'; +import { Setup } from '../../../lib/helpers/setup_request'; import { getTraceSamples } from './get_trace_samples'; import { withApmSpan } from '../../../utils/with_apm_span'; diff --git a/x-pack/plugins/apm/server/tutorial/index.ts b/x-pack/plugins/apm/server/tutorial/index.ts index f04b794091ff..5d3ff8636df4 100644 --- a/x-pack/plugins/apm/server/tutorial/index.ts +++ b/x-pack/plugins/apm/server/tutorial/index.ts @@ -14,8 +14,8 @@ import { } from '../../../../../src/plugins/home/server'; import { CloudSetup } from '../../../cloud/server'; import { APM_STATIC_INDEX_PATTERN_ID } from '../../common/index_pattern_constants'; -import { getApmDataViewTitle } from '../lib/data_view/get_apm_data_view_title'; -import { ApmIndicesConfig } from '../lib/settings/apm_indices/get_apm_indices'; +import { getApmDataViewTitle } from '../routes/data_view/get_apm_data_view_title'; +import { ApmIndicesConfig } from '../routes/settings/apm_indices/get_apm_indices'; import { createElasticCloudInstructions } from './envs/elastic_cloud'; import { onPremInstructions } from './envs/on_prem'; import apmDataView from './index_pattern.json'; diff --git a/x-pack/plugins/apm/server/types.ts b/x-pack/plugins/apm/server/types.ts index c686c42beb6e..02aae547407e 100644 --- a/x-pack/plugins/apm/server/types.ts +++ b/x-pack/plugins/apm/server/types.ts @@ -47,7 +47,7 @@ import { FleetStartContract as FleetPluginStart, } from '../../fleet/server'; import { APMConfig } from '.'; -import { getApmIndices } from './lib/settings/apm_indices/get_apm_indices'; +import { getApmIndices } from './routes/settings/apm_indices/get_apm_indices'; import { createApmEventClient } from './lib/helpers/create_es_client/create_apm_event_client'; import { ApmPluginRequestHandlerContext } from './routes/typings'; diff --git a/x-pack/plugins/apm/server/utils/test_helpers.tsx b/x-pack/plugins/apm/server/utils/test_helpers.tsx index 0e1b9f2ba805..19644b5bc87f 100644 --- a/x-pack/plugins/apm/server/utils/test_helpers.tsx +++ b/x-pack/plugins/apm/server/utils/test_helpers.tsx @@ -12,7 +12,7 @@ import { ESSearchResponse, } from '../../../../../src/core/types/elasticsearch'; import { UxUIFilters } from '../../typings/ui_filters'; -import { ApmIndicesConfig } from '../lib/settings/apm_indices/get_apm_indices'; +import { ApmIndicesConfig } from '../routes/settings/apm_indices/get_apm_indices'; interface Options { mockResponse?: ( diff --git a/x-pack/plugins/canvas/common/lib/constants.ts b/x-pack/plugins/canvas/common/lib/constants.ts index 7212baf2414e..6a61ec595acb 100644 --- a/x-pack/plugins/canvas/common/lib/constants.ts +++ b/x-pack/plugins/canvas/common/lib/constants.ts @@ -6,6 +6,7 @@ */ import { SHAREABLE_RUNTIME_NAME } from '../../shareable_runtime/constants_static'; +import { FilterField } from '../../types'; export const CANVAS_TYPE = 'canvas-workpad'; export const CUSTOM_ELEMENT_TYPE = 'canvas-element'; @@ -25,6 +26,7 @@ export const SESSIONSTORAGE_LASTPATH = 'lastPath:canvas'; export const FETCH_TIMEOUT = 30000; // 30 seconds export const DEFAULT_WORKPAD_CSS = '.canvasPage {\n\n}'; export const DEFAULT_ELEMENT_CSS = '.canvasRenderEl{\n\n}'; +export const DEFAULT_GROUP_BY_FIELD: FilterField = 'filterGroup'; export const VALID_IMAGE_TYPES = ['gif', 'jpeg', 'png', 'svg+xml']; export const ASSET_MAX_SIZE = 25000; export const ELEMENT_SHIFT_OFFSET = 10; diff --git a/x-pack/plugins/canvas/public/components/sidebar/global_config.tsx b/x-pack/plugins/canvas/public/components/sidebar/global_config.tsx deleted file mode 100644 index 7602a4d3e95e..000000000000 --- a/x-pack/plugins/canvas/public/components/sidebar/global_config.tsx +++ /dev/null @@ -1,27 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React, { Fragment, FunctionComponent } from 'react'; -// @ts-expect-error unconverted component -import { ElementConfig } from '../element_config'; -// @ts-expect-error unconverted component -import { PageConfig } from '../page_config'; -import { WorkpadConfig } from '../workpad_config'; -// @ts-expect-error unconverted component -import { SidebarSection } from './sidebar_section'; - -export const GlobalConfig: FunctionComponent = () => ( - - - - - - - - - -); diff --git a/x-pack/plugins/canvas/public/components/sidebar/global_config/filter_config.tsx b/x-pack/plugins/canvas/public/components/sidebar/global_config/filter_config.tsx new file mode 100644 index 000000000000..305ad9f7931f --- /dev/null +++ b/x-pack/plugins/canvas/public/components/sidebar/global_config/filter_config.tsx @@ -0,0 +1,15 @@ +/* + * 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. + */ + +import React, { FC } from 'react'; +import { WorkpadFilters } from '../../workpad_filters'; +// @ts-expect-error unconverted component +import { SidebarSection } from '../sidebar_section'; + +export const FilterConfig: FC = () => { + return ; +}; diff --git a/x-pack/plugins/canvas/public/components/sidebar/global_config/general_config.tsx b/x-pack/plugins/canvas/public/components/sidebar/global_config/general_config.tsx new file mode 100644 index 000000000000..13031f306012 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/sidebar/global_config/general_config.tsx @@ -0,0 +1,29 @@ +/* + * 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. + */ + +import React, { Fragment, FC } from 'react'; +// @ts-expect-error unconverted component +import { ElementConfig } from '../../element_config'; +// @ts-expect-error unconverted component +import { PageConfig } from '../../page_config'; +import { WorkpadConfig } from '../../workpad_config'; +// @ts-expect-error unconverted component +import { SidebarSection } from '../sidebar_section'; + +export const GeneralConfig: FC = () => { + return ( + + + + + + + + + + ); +}; diff --git a/x-pack/plugins/canvas/public/components/sidebar/global_config/global_config.tsx b/x-pack/plugins/canvas/public/components/sidebar/global_config/global_config.tsx new file mode 100644 index 000000000000..ccdb0d88508e --- /dev/null +++ b/x-pack/plugins/canvas/public/components/sidebar/global_config/global_config.tsx @@ -0,0 +1,62 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { Fragment, FC } from 'react'; +import { EuiTabbedContent, EuiTitle, EuiSpacer } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { GeneralConfig } from './general_config'; +import { FilterConfig } from './filter_config'; + +const strings = { + getTitle: () => + i18n.translate('xpack.canvas.globalConfig.title', { + defaultMessage: 'Workpad settings', + }), + getGeneralLabel: () => + i18n.translate('xpack.canvas.globalConfig.general', { + defaultMessage: 'General', + }), + getFilterLabel: () => + i18n.translate('xpack.canvas.globalConfig.filter', { + defaultMessage: 'Filter', + }), +}; + +export const GlobalConfig: FC = () => { + const tabs = [ + { + id: 'general', + name: strings.getGeneralLabel(), + content: ( +
+ + +
+ ), + }, + { + id: 'filter', + name: strings.getFilterLabel(), + content: ( +
+ +
+ ), + }, + ]; + + return ( + +
+ +

{strings.getTitle()}

+
+
+ +
+ ); +}; diff --git a/x-pack/plugins/canvas/public/components/sidebar/global_config/index.tsx b/x-pack/plugins/canvas/public/components/sidebar/global_config/index.tsx new file mode 100644 index 000000000000..f7fb95e5454c --- /dev/null +++ b/x-pack/plugins/canvas/public/components/sidebar/global_config/index.tsx @@ -0,0 +1,8 @@ +/* + * 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 { GlobalConfig } from './global_config'; diff --git a/x-pack/plugins/canvas/public/components/sidebar/sidebar.scss b/x-pack/plugins/canvas/public/components/sidebar/sidebar.scss index 76d758197aa1..94c4ab6c1907 100644 --- a/x-pack/plugins/canvas/public/components/sidebar/sidebar.scss +++ b/x-pack/plugins/canvas/public/components/sidebar/sidebar.scss @@ -51,8 +51,12 @@ min-width: 0; } +.canvasSidebar__expandable { + width: 100%; +} + .canvasSidebar__expandable + .canvasSidebar__expandable { - margin-top: 0; + margin-top: 1px; .canvasSidebar__accordion:before { display: none; @@ -87,6 +91,9 @@ bottom: 0; } } +.canvasSidebar__accordion.filtersSidebar__accordion { + margin: auto; +} .canvasSidebar__accordionContent { padding-top: $euiSize; diff --git a/x-pack/plugins/canvas/public/components/var_config/edit_var.tsx b/x-pack/plugins/canvas/public/components/var_config/edit_var.tsx index 9090fa84c8ca..85f22da22445 100644 --- a/x-pack/plugins/canvas/public/components/var_config/edit_var.tsx +++ b/x-pack/plugins/canvas/public/components/var_config/edit_var.tsx @@ -103,6 +103,8 @@ export const EditVar: FC = ({ variables, selectedVar, onCancel, onSave }) const [value, setValue] = useState(isNew ? '' : selectedVar!.value); const hasDupeName = checkDupeName(name, selectedVar && selectedVar.name, variables); + const hasEmptyValue = value.toString().trim() === ''; + const hasEmptyName = !name; const typeOptions = [ { @@ -217,7 +219,7 @@ export const EditVar: FC = ({ variables, selectedVar, onCancel, onSave }) type, }) } - disabled={hasDupeName || !name} + disabled={hasDupeName || hasEmptyValue || hasEmptyName} iconType="save" > {strings.getSaveButtonLabel()} diff --git a/x-pack/plugins/canvas/public/components/var_config/var_value_field.tsx b/x-pack/plugins/canvas/public/components/var_config/var_value_field.tsx index a8ed014a9cf4..24b9a82e32e5 100644 --- a/x-pack/plugins/canvas/public/components/var_config/var_value_field.tsx +++ b/x-pack/plugins/canvas/public/components/var_config/var_value_field.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { FC } from 'react'; +import React, { FC, useCallback } from 'react'; import { EuiFieldText, EuiFieldNumber, EuiButtonGroup } from '@elastic/eui'; import { htmlIdGenerator } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; @@ -47,14 +47,18 @@ export const VarValueField: FC = ({ type, value, onChange }) => { }, ]; + const onNumberChange = useCallback( + (e) => { + const floatVal = parseFloat(e.target.value); + const varValue = isNaN(floatVal) ? '' : floatVal; + onChange(varValue); + }, + [onChange] + ); + if (type === 'number') { return ( - onChange(parseFloat(e.target.value))} - /> + ); } diff --git a/x-pack/plugins/canvas/public/components/workpad_config/workpad_config.component.tsx b/x-pack/plugins/canvas/public/components/workpad_config/workpad_config.component.tsx index 18e3f2dac977..b69893c46fb9 100644 --- a/x-pack/plugins/canvas/public/components/workpad_config/workpad_config.component.tsx +++ b/x-pack/plugins/canvas/public/components/workpad_config/workpad_config.component.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { FunctionComponent, useState } from 'react'; +import React, { FC, useState } from 'react'; import PropTypes from 'prop-types'; import { EuiFieldText, @@ -16,7 +16,6 @@ import { EuiFlexGroup, EuiFlexItem, EuiSpacer, - EuiTitle, EuiToolTip, EuiTextArea, EuiAccordion, @@ -76,10 +75,6 @@ const strings = { i18n.translate('xpack.canvas.workpadConfig.widthLabel', { defaultMessage: 'Width', }), - getTitle: () => - i18n.translate('xpack.canvas.workpadConfig.title', { - defaultMessage: 'Workpad settings', - }), getUSLetterButtonLabel: () => i18n.translate('xpack.canvas.workpadConfig.USLetterButtonLabel', { defaultMessage: 'US Letter', @@ -101,7 +96,7 @@ export interface Props { setWorkpadVariables: (vars: CanvasVariable[]) => void; } -export const WorkpadConfig: FunctionComponent = (props) => { +export const WorkpadConfig: FC = (props) => { const [css, setCSS] = useState(props.css); const { size, name, setSize, setName, setWorkpadCSS, variables, setWorkpadVariables } = props; const rotate = () => setSize({ width: size.height, height: size.width }); @@ -127,14 +122,6 @@ export const WorkpadConfig: FunctionComponent = (props) => { return (
-
- -

{strings.getTitle()}

-
-
- - - setName(e.target.value)} /> diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/__snapshots__/filter.component.stories.storyshot b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/__snapshots__/filter.component.stories.storyshot new file mode 100644 index 000000000000..7e1deefdf249 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/__snapshots__/filter.component.stories.storyshot @@ -0,0 +1,435 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Storyshots components/WorkpadFilters/FilterComponent default 1`] = ` +
+
+
+
+

+ Type +

+
+
+
+
+ exactly +
+
+
+
+

+ Column +

+
+
+
+
+ project +
+
+
+
+

+ Value +

+
+
+
+
+ kibana +
+
+
+
+

+ Filter group +

+
+
+
+
+ Group 1 +
+
+
+
+`; + +exports[`Storyshots components/WorkpadFilters/FilterComponent with component field 1`] = ` +
+
+
+
+

+ Type +

+
+
+
+
+ exactly +
+
+
+
+

+ Column +

+
+
+
+
+ project +
+
+
+
+

+ Value +

+
+
+
+
+
+ +

+ kibana +

+
+
+
+
+
+
+

+ Filter group +

+
+
+
+
+ Group 1 +
+
+
+
+`; + +exports[`Storyshots components/WorkpadFilters/FilterComponent with custom filter fields 1`] = ` +
+
+
+
+

+ Type +

+
+
+
+
+ exactly +
+
+
+
+

+ Column +

+
+
+
+
+ project +
+
+
+
+

+ Value +

+
+
+
+
+ kibana +
+
+
+
+

+ Filter group +

+
+
+
+
+ Group 1 +
+
+
+
+

+ Custom Field +

+
+
+
+
+ Some unknown field +
+
+
+
+`; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/__snapshots__/filters_group.component.stories.storyshot b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/__snapshots__/filters_group.component.stories.storyshot new file mode 100644 index 000000000000..d30fca5dc199 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/__snapshots__/filters_group.component.stories.storyshot @@ -0,0 +1,127 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Storyshots components/WorkpadFilters/FiltersGroupComponent default 1`] = ` +
+
+
+
+ + +
+
+
+
+
+`; + +exports[`Storyshots components/WorkpadFilters/FiltersGroupComponent empty group 1`] = ` +
+
+
+
+ + +
+
+
+
+
+`; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/__snapshots__/workpad_filters.component.stories.storyshot b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/__snapshots__/workpad_filters.component.stories.storyshot new file mode 100644 index 000000000000..31e473f527e0 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/__snapshots__/workpad_filters.component.stories.storyshot @@ -0,0 +1,706 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Storyshots components/WorkpadFilters/WorkpadFiltersComponent Empty filters groups 1`] = ` +
+
+
+
+
+
+
+
+ Group by +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+
+
+`; + +exports[`Storyshots components/WorkpadFilters/WorkpadFiltersComponent Filters groups without group name 1`] = ` +
+
+
+
+
+
+
+
+ Group by +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+`; + +exports[`Storyshots components/WorkpadFilters/WorkpadFiltersComponent Filters groups without name 1`] = ` +
+
+
+
+
+
+
+
+ Group by +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+`; + +exports[`Storyshots components/WorkpadFilters/WorkpadFiltersComponent Filters groups without name and filters 1`] = ` +
+
+
+
+
+
+
+
+ Group by +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+`; + +exports[`Storyshots components/WorkpadFilters/WorkpadFiltersComponent default 1`] = ` +
+
+
+
+
+
+
+
+ Group by +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+`; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/elements.ts b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/elements.ts new file mode 100644 index 000000000000..9eacfb54a411 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/elements.ts @@ -0,0 +1,66 @@ +/* + * 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. + */ + +import moment from 'moment'; +import { CanvasElement } from '../../../../types'; + +const timeFormat = 'MM.dd.YYYY HH:mm'; + +const generatePosition = (n: number): CanvasElement['position'] => ({ + left: n, + top: n, + width: n, + height: n, + angle: n, + parent: null, +}); + +const time1 = { + from: moment('1.01.2021 8:15', timeFormat).format(), + to: moment('2.01.2021 17:22', timeFormat).format(), +}; +const group1 = 'Group 1'; + +const time2 = { + from: moment('1.10.2021 12:20', timeFormat).format(), + to: moment('2.10.2021 12:33', timeFormat).format(), +}; +const group2 = 'Group 2'; + +const element1: CanvasElement = { + id: '1', + position: generatePosition(1), + type: 'element', + expression: '', + filter: `timefilter column="@timestamp" from="${time1.from}" to="${time1.to}" filterGroup="${group1}"`, +}; + +const element2: CanvasElement = { + id: '2', + position: generatePosition(2), + type: 'element', + expression: '', + filter: `exactly value="machine-learning" column="project1" filterGroup="${group1}"`, +}; + +const element3: CanvasElement = { + id: '3', + position: generatePosition(3), + type: 'element', + expression: '', + filter: `timefilter column="@timestamp" from="${time2.from}" to="${time2.to}"`, +}; + +const element4: CanvasElement = { + id: '4', + position: generatePosition(4), + type: 'element', + expression: '', + filter: `exactly value="kibana" column="project2" filterGroup="${group2}"`, +}; + +export const elements = [element1, element2, element3, element4]; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/filter.component.stories.tsx b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/filter.component.stories.tsx new file mode 100644 index 000000000000..2f80ffed5abf --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/filter.component.stories.tsx @@ -0,0 +1,53 @@ +/* + * 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. + */ + +import { EuiText, EuiTextColor } from '@elastic/eui'; +import { storiesOf } from '@storybook/react'; +import React, { FC } from 'react'; +import { FormattedFilterViewInstance } from '../../../../types'; +import { Filter } from '../filter.component'; + +const filter: FormattedFilterViewInstance = { + type: { + label: 'Type', + formattedValue: 'exactly', + }, + column: { + label: 'Column', + formattedValue: 'project', + }, + value: { + label: 'Value', + formattedValue: 'kibana', + }, + filterGroup: { + label: 'Filter group', + formattedValue: 'Group 1', + }, +}; + +const component: FC = ({ value }) => ( + + +

{value}

+
+
+); + +storiesOf('components/WorkpadFilters/FilterComponent', module) + .add('default', () => ) + .add('with component field', () => ( + + )) + .add('with custom filter fields', () => ( + + )); diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/filters_group.component.stories.tsx b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/filters_group.component.stories.tsx new file mode 100644 index 000000000000..bdeb963dc883 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/filters_group.component.stories.tsx @@ -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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { storiesOf } from '@storybook/react'; +import React from 'react'; +import moment from 'moment'; +import { FiltersGroup } from '../filters_group.component'; +import { FiltersGroup as FiltersGroupType } from '../types'; + +const timeFormat = 'MM.dd.YYYY HH:mm'; + +const filtersGroup: FiltersGroupType = { + name: 'Group 1', + filters: [ + { type: 'exactly', column: 'project', value: 'kibana', filterGroup: 'Group 1' }, + { + type: 'time', + column: '@timestamp', + value: { + from: moment('1.01.2021 8:15', timeFormat).format(), + to: moment('2.01.2021 17:22', timeFormat).format(), + }, + filterGroup: 'Group 1', + }, + { type: 'exactly', column: 'country', value: 'US', filterGroup: 'Group 1' }, + { + type: 'time', + column: 'time', + value: { + from: moment('05.21.2021 10:50', timeFormat).format(), + to: moment('05.22.2021 4:40', timeFormat).format(), + }, + filterGroup: 'Group 1', + }, + ], +}; + +storiesOf('components/WorkpadFilters/FiltersGroupComponent', module) + .addDecorator((story) =>
{story()}
) + .add('default', () => ) + .add('empty group', () => ( + + )); diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/workpad_filters.component.stories.tsx b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/workpad_filters.component.stories.tsx new file mode 100644 index 000000000000..8dc062886a12 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/workpad_filters.component.stories.tsx @@ -0,0 +1,95 @@ +/* + * 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. + */ + +import { storiesOf } from '@storybook/react'; +import { action } from '@storybook/addon-actions'; +import React from 'react'; +import moment from 'moment'; +import { WorkpadFilters } from '../workpad_filters.component'; +import { FiltersGroup as FiltersGroupType } from '../types'; +import { Filter } from '../../../../types'; + +const timeFormat = 'MM.dd.YYYY HH:mm'; + +const filters: Filter[] = [ + { type: 'exactly', column: 'project', value: 'kibana', filterGroup: 'Group 1' }, + { + type: 'time', + column: '@timestamp', + value: { + from: moment('1.01.2021 8:15', timeFormat).format(), + to: moment('2.01.2021 17:22', timeFormat).format(), + }, + filterGroup: 'Group 1', + }, + { type: 'exactly', column: 'country', value: 'US', filterGroup: 'Group 2' }, + { + type: 'time', + column: 'time', + value: { + from: moment('05.21.2021 10:50', timeFormat).format(), + to: moment('05.22.2021 4:40', timeFormat).format(), + }, + filterGroup: 'Group 2', + }, +]; + +const filtersGroups: FiltersGroupType[] = [ + { + name: filters[0].filterGroup, + filters: [filters[0], filters[1]], + }, + { + name: filters[2].filterGroup, + filters: [filters[2], filters[3]], + }, +]; + +storiesOf('components/WorkpadFilters/WorkpadFiltersComponent', module) + .addDecorator((story) => ( +
+
+
{story()}
+
+
+ )) + .add('default', () => ( + + )) + .add('Filters groups without name', () => ( + ((acc, group) => [...acc, ...group.filters], []), + }, + ]} + groupFiltersByField={'column'} + onGroupByChange={action('onGroupByChange')} + /> + )) + .add('Filters groups without group name', () => ( + ((acc, group) => [...acc, ...group.filters], []), + }, + ]} + groupFiltersByField={'filterGroup'} + onGroupByChange={action('onGroupByChange')} + /> + )) + .add('Filters groups without name and filters', () => ( + + )) + .add('Empty filters groups', () => ( + + )); diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/workpad_filters.stories.tsx b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/workpad_filters.stories.tsx new file mode 100644 index 000000000000..b97043bf8330 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/__stories__/workpad_filters.stories.tsx @@ -0,0 +1,23 @@ +/* + * 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. + */ + +import { storiesOf } from '@storybook/react'; +import React from 'react'; +import { reduxDecorator } from '../../../../storybook'; +import { WorkpadFilters } from '../workpad_filters'; +import { elements } from './elements'; + +storiesOf('components/WorkpadFilters/WorkpadFilters', module) + .addDecorator((story) => ( +
+
+
{story()}
+
+
+ )) + .addDecorator(reduxDecorator({ elements })) + .add('redux: default', () => ); diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/filter.component.tsx b/x-pack/plugins/canvas/public/components/workpad_filters/filter.component.tsx new file mode 100644 index 000000000000..bec6bec090d6 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/filter.component.tsx @@ -0,0 +1,64 @@ +/* + * 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. + */ + +import React, { FC } from 'react'; +import { EuiDescriptionList, EuiPanel, EuiText } from '@elastic/eui'; +import { FormattedFilterViewInstance } from '../../../types'; + +interface Props { + filter: FormattedFilterViewInstance; + updateFilter?: (value: any) => void; +} + +type CustomComponentProps = Omit & { value: string }; + +const titleStyle = { + width: '30%', +}; + +const descriptionStyle = { + width: '70%', +}; + +const renderElement = ( + Component: FC< + Omit & { onChange?: CustomComponentProps['updateFilter'] } + >, + { updateFilter, ...props }: CustomComponentProps +) => { + return ; +}; + +export const Filter: FC = ({ filter, ...restProps }) => { + const filterView = Object.values(filter).map((filterValue) => { + const description = filterValue.component + ? renderElement(filterValue.component, { value: filterValue.formattedValue, ...restProps }) + : filterValue.formattedValue; + + return { + title: ( + +

{filterValue.label}

+
+ ), + description: {description}, + }; + }); + + return ( + + + + ); +}; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/filter_views/default_filter.ts b/x-pack/plugins/canvas/public/components/workpad_filters/filter_views/default_filter.ts new file mode 100644 index 000000000000..b2686fb66053 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/filter_views/default_filter.ts @@ -0,0 +1,39 @@ +/* + * 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. + */ + +import { i18n } from '@kbn/i18n'; +import { FilterViewSpec } from '../../../../types'; +import { formatByKey } from '../utils'; + +const strings = { + getTypeLabel: () => + i18n.translate('xpack.canvas.workpadFilters.defaultFilter.type', { + defaultMessage: 'Type', + }), + getColumnLabel: () => + i18n.translate('xpack.canvas.workpadFilters.defaultFilter.column', { + defaultMessage: 'Column', + }), + getFilterGroupLabel: () => + i18n.translate('xpack.canvas.workpadFilters.defaultFilter.filterGroup', { + defaultMessage: 'Filter group', + }), + getValueLabel: () => + i18n.translate('xpack.canvas.workpadFilters.defaultFilter.value', { + defaultMessage: 'Value', + }), +}; + +export const defaultFilter: FilterViewSpec = { + name: 'default', + view: { + column: { label: strings.getColumnLabel() }, + value: { label: strings.getValueLabel() }, + type: { label: strings.getTypeLabel(), formatter: formatByKey('type') }, + filterGroup: { label: strings.getFilterGroupLabel() }, + }, +}; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/filter_views/index.ts b/x-pack/plugins/canvas/public/components/workpad_filters/filter_views/index.ts new file mode 100644 index 000000000000..98fad36c0015 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/filter_views/index.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ + +import { FilterViewSpec } from '../../../../types'; +import { defaultFilter } from './default_filter'; +import { timeFilter } from './time_filter'; + +export const filterViews: Record> = { + [defaultFilter.name]: defaultFilter, + [timeFilter.name]: timeFilter, +}; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/filter_views/time_filter.ts b/x-pack/plugins/canvas/public/components/workpad_filters/filter_views/time_filter.ts new file mode 100644 index 000000000000..1dc02f61d05f --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/filter_views/time_filter.ts @@ -0,0 +1,68 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import dateMath from '@elastic/datemath'; +import { i18n } from '@kbn/i18n'; +import { FilterType, FilterViewSpec, SimpleFilterViewField } from '../../../../types'; +import { formatByKey } from '../utils'; +import { defaultFilter } from './default_filter'; + +export interface TimeFilterValue { + to: string; + from: string; +} + +const strings = { + getFromLabel: () => + i18n.translate('xpack.canvas.workpadFilters.timeFilter.from', { + defaultMessage: 'From', + }), + getToLabel: () => + i18n.translate('xpack.canvas.workpadFilters.timeFilter.to', { + defaultMessage: 'To', + }), + getInvalidDateLabel: (date: string) => + i18n.translate('xpack.canvas.workpadFilters.timeFilter.invalidDate', { + defaultMessage: 'Invalid date: {date}', + values: { + date, + }, + }), +}; + +const { column, type, filterGroup } = defaultFilter.view; + +const formatTime = (str: string, roundUp: boolean) => { + const moment = dateMath.parse(str, { roundUp }); + if (!moment || !moment.isValid()) { + return strings.getInvalidDateLabel(str); + } + + return moment.format('YYYY-MM-DD HH:mm:ss'); +}; + +export const timeFilter: FilterViewSpec = { + name: FilterType.time, + view: { + column, + value: ({ to, from }) => ({ + from: { + label: strings.getFromLabel(), + formatter: () => formatTime(from, false), + }, + to: { + label: strings.getToLabel(), + formatter: () => formatTime(to, true), + }, + }), + type: { + label: (type as SimpleFilterViewField).label, + formatter: formatByKey('type'), + }, + filterGroup, + }, +}; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/filters_group.component.tsx b/x-pack/plugins/canvas/public/components/workpad_filters/filters_group.component.tsx new file mode 100644 index 000000000000..8ceb60fe7866 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/filters_group.component.tsx @@ -0,0 +1,50 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { EuiAccordion } from '@elastic/eui'; +import React, { FC } from 'react'; +import { FormattedFilterViewInstance } from '../../../types'; +import { createFilledFilterView } from '../../lib/filter'; +import { Filter } from './filter.component'; +import { filterViews } from './filter_views'; +import { FiltersGroup as FiltersGroupType } from './types'; + +interface Props { + filtersGroup: FiltersGroupType; + id: string | number; +} + +const panelStyle = { + paddingTop: '15px', +}; + +export const FiltersGroup: FC = ({ filtersGroup, id }) => { + const { name, filters: groupFilters } = filtersGroup; + + const filledFilterViews: FormattedFilterViewInstance[] = groupFilters.map((filter) => { + const filterView = filterViews[filter.type] ?? filterViews.default; + return createFilledFilterView(filterView.view, filter); + }); + + const filtersComponents = filledFilterViews.map((filter, index) => ( + + )); + + return ( +
+ +
{filtersComponents}
+
+
+ ); +}; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/hooks/index.ts b/x-pack/plugins/canvas/public/components/workpad_filters/hooks/index.ts new file mode 100644 index 000000000000..62f2a28130bf --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/hooks/index.ts @@ -0,0 +1,8 @@ +/* + * 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 { useCanvasFilters } from './use_canvas_filters'; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/hooks/use_canvas_filters.ts b/x-pack/plugins/canvas/public/components/workpad_filters/hooks/use_canvas_filters.ts new file mode 100644 index 000000000000..ce8e90def5aa --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/hooks/use_canvas_filters.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + +import { fromExpression } from '@kbn/interpreter/common'; +import { shallowEqual, useSelector } from 'react-redux'; +import { State } from '../../../../types'; +import { adaptCanvasFilter } from '../../../lib/filter_adapters'; +import { getGlobalFilters } from '../../../state/selectors/workpad'; + +const extractExpressionAST = (filtersExpressions: string[]) => + fromExpression(filtersExpressions.join(' | ')); + +export function useCanvasFilters() { + const filterExpressions = useSelector((state: State) => getGlobalFilters(state), shallowEqual); + const expression = extractExpressionAST(filterExpressions); + const filters = expression.chain.map(adaptCanvasFilter); + + return filters; +} diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/index.tsx b/x-pack/plugins/canvas/public/components/workpad_filters/index.tsx new file mode 100644 index 000000000000..684d5e09c18f --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/index.tsx @@ -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 + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { WorkpadFilters } from './workpad_filters'; +export { WorkpadFilters as WorkpadFiltersComponent } from './workpad_filters.component'; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/types.ts b/x-pack/plugins/canvas/public/components/workpad_filters/types.ts new file mode 100644 index 000000000000..4733c18da9be --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/types.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +import { Filter } from '../../../types'; + +export interface FiltersGroup { + name: string | null; + filters: Filter[]; +} diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/utils.ts b/x-pack/plugins/canvas/public/components/workpad_filters/utils.ts new file mode 100644 index 000000000000..cc5836112db8 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/utils.ts @@ -0,0 +1,42 @@ +/* + * 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. + */ + +import { i18n } from '@kbn/i18n'; +import { FilterField } from '../../../types'; + +const strings = { + getBlankLabel: () => + i18n.translate('xpack.canvas.workpadFilters.filter.blankTypeLabel', { + defaultMessage: '(Blank)', + }), + getExactlyFilterTypeLabel: () => + i18n.translate('xpack.canvas.workpadFilters.defaultFilter.typeLabel', { + defaultMessage: 'Dropdown', + }), + getTimeFilterTypeLabel: () => + i18n.translate('xpack.canvas.workpadFilters.timeFilter.typeLabel', { + defaultMessage: 'Time', + }), + getWithoutGroupLabel: () => + i18n.translate('xpack.canvas.workpadFilters.filters_group.withoutGroup', { + defaultMessage: 'Without group', + }), +}; + +const formatType = (type: unknown) => { + const types: Record = { + exactly: strings.getExactlyFilterTypeLabel(), + time: strings.getTimeFilterTypeLabel(), + }; + return typeof type === 'string' ? types[type] ?? type : null; +}; + +const formatters: Partial string | null>> = { + type: formatType, +}; + +export const formatByKey = (key: FilterField) => formatters[key]; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/workpad_filters.component.tsx b/x-pack/plugins/canvas/public/components/workpad_filters/workpad_filters.component.tsx new file mode 100644 index 000000000000..e3504f906fb3 --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/workpad_filters.component.tsx @@ -0,0 +1,98 @@ +/* + * 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. + */ + +import React, { FC, Fragment } from 'react'; +import { EuiFlexGroup, EuiFlexItem, EuiSelect, EuiText } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { identity } from 'lodash'; +import { FiltersGroup as FiltersGroupType } from './types'; +import { FiltersGroup } from './filters_group.component'; +import { FilterField } from '../../../types'; +import { formatByKey } from './utils'; + +interface Props { + filtersGroups: FiltersGroupType[]; + groupFiltersByField?: FilterField; + onGroupByChange: (groupBy: FilterField) => void; +} + +const strings = { + getGroupBySelectLabel: () => + i18n.translate('xpack.canvas.workpadFilters.groupBySelect', { + defaultMessage: 'Group by', + }), + getGroupByFilterGroupLabel: () => + i18n.translate('xpack.canvas.workpadFilters.groupByFilterGroup', { + defaultMessage: 'Filter group', + }), + getGroupByFilterTypeLabel: () => + i18n.translate('xpack.canvas.workpadFilters.groupByFilterType', { + defaultMessage: 'Filter type', + }), + getGroupByColumnLabel: () => + i18n.translate('xpack.canvas.workpadFilters.groupByColumn', { + defaultMessage: 'Column', + }), + getWithoutGroupLabel: () => + i18n.translate('xpack.canvas.workpadFilters.filters_group.withoutGroup', { + defaultMessage: 'Without group', + }), + getBlankValueLabel: () => + i18n.translate('xpack.canvas.workpadFilters.filters_group.blankValue', { + defaultMessage: '(Blank)', + }), +}; + +const groupByOptions: Array<{ value: FilterField; text: string }> = [ + { value: 'filterGroup', text: strings.getGroupByFilterGroupLabel() }, + { value: 'type', text: strings.getGroupByFilterTypeLabel() }, + { value: 'column', text: strings.getGroupByColumnLabel() }, +]; + +export const WorkpadFilters: FC = ({ + filtersGroups, + onGroupByChange, + groupFiltersByField, +}) => { + const groupedByFilterGroupField = groupFiltersByField === 'filterGroup'; + const formatter = groupFiltersByField ? formatByKey(groupFiltersByField) ?? identity : identity; + + const preparedFilterGroups = filtersGroups.map((filterGroup) => ({ + ...filterGroup, + name: + formatter(filterGroup.name) ?? + (groupedByFilterGroupField ? strings.getWithoutGroupLabel() : strings.getBlankValueLabel()), + })); + + const filtersGroupsComponents = preparedFilterGroups.map((filtersGroup, index) => { + return ; + }); + + return ( + +
+ + + +
{strings.getGroupBySelectLabel()}
+
+
+ + onGroupByChange(e.target.value as FilterField)} + aria-label="Use aria labels when no actual label is in use" + /> + +
+
+ {filtersGroupsComponents} +
+ ); +}; diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/workpad_filters.tsx b/x-pack/plugins/canvas/public/components/workpad_filters/workpad_filters.tsx new file mode 100644 index 000000000000..c04fe543804b --- /dev/null +++ b/x-pack/plugins/canvas/public/components/workpad_filters/workpad_filters.tsx @@ -0,0 +1,44 @@ +/* + * 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. + */ + +import React, { FC, useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { State, FilterField } from '../../../types'; +import { groupFiltersBy } from '../../lib/filter'; +import { setGroupFiltersByOption } from '../../state/actions/sidebar'; +import { getGroupFiltersByOption } from '../../state/selectors/sidebar'; +import { useCanvasFilters } from './hooks'; +import { WorkpadFilters as Component } from './workpad_filters.component'; + +export const WorkpadFilters: FC = () => { + const groupFiltersByField: FilterField = useSelector((state: State) => + getGroupFiltersByOption(state) + ); + + const dispatch = useDispatch(); + + const onGroupByChange = useCallback( + (groupByOption: FilterField) => { + dispatch(setGroupFiltersByOption(groupByOption)); + }, + [dispatch] + ); + + const canvasFilters = useCanvasFilters(); + + const filtersGroups = groupFiltersByField + ? groupFiltersBy(canvasFilters, groupFiltersByField) + : []; + + return ( + + ); +}; diff --git a/x-pack/plugins/canvas/public/lib/filter.test.ts b/x-pack/plugins/canvas/public/lib/filter.test.ts new file mode 100644 index 000000000000..497f75b91650 --- /dev/null +++ b/x-pack/plugins/canvas/public/lib/filter.test.ts @@ -0,0 +1,282 @@ +/* + * 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. + */ + +import { FC } from 'react'; +import { + Filter as FilterType, + FilterViewInstance, + FlattenFilterViewInstance, + SimpleFilterViewField, +} from '../../types'; +import { + defaultFormatter, + formatFilterView, + flattenFilterView, + createFilledFilterView, + groupFiltersBy, +} from './filter'; + +const formatterFactory = (value: unknown) => () => JSON.stringify(value); +const fc: FC = () => null; + +const simpleFilterValue: FilterType = { + type: 'exactly', + column: 'project', + value: 'kibana', + filterGroup: 'someGroup', +}; + +const filterWithNestedValue: FilterType = { + type: 'exactlyNested' as any, + column: 'project', + value: { nestedField1: 'nestedField1', nestedField2: 'nestedField2' }, + filterGroup: 'someGroup', +}; + +const simpleFilterView: FilterViewInstance = { + type: { label: 'label' }, + column: { label: 'column' }, + value: { label: 'value' }, + filterGroup: { label: 'filterGroup' }, +}; + +const nestedFilterView: FilterViewInstance = { + type: { label: 'label' }, + column: { label: 'column' }, + value: (value: unknown) => ({ + nested: { + label: 'nested', + formatter: formatterFactory(value), + }, + }), + filterGroup: { label: 'filterGroup' }, +}; + +describe('defaultFormatter', () => { + it('returns string when passed not null/undefined/falsy/emtpy value', () => { + expect(defaultFormatter(10)).toBe('10'); + expect(defaultFormatter('10')).toBe('10'); + const objToFormat = { field: 10 }; + expect(defaultFormatter(objToFormat)).toBe(objToFormat.toString()); + const arrToFormat = [10, 20]; + expect(defaultFormatter(arrToFormat)).toBe(arrToFormat.toString()); + }); + + it("returns '-' when passed null/undefined/falsy/emtpy value", () => { + const empty = '-'; + expect(defaultFormatter(null)).toBe(empty); + expect(defaultFormatter(undefined)).toBe(empty); + expect(defaultFormatter('')).toBe(empty); + expect(defaultFormatter(false)).toBe(empty); + }); +}); + +describe('flattenFilterView returns fn which', () => { + it('returns the same filter view if it expects all fiends to be simple values', () => { + const flattenFn = flattenFilterView(simpleFilterValue); + expect(flattenFn(simpleFilterView)).toEqual(simpleFilterView); + }); + + it('returns the same filter view if filterValue is empty object', () => { + const flattenFn = flattenFilterView({} as any); + expect(flattenFn(simpleFilterView)).toEqual(simpleFilterView); + }); + + it('returns empty filter view if filter view is empty object', () => { + const flattenFn = flattenFilterView(simpleFilterValue); + expect(flattenFn({} as any)).toEqual({}); + }); + + it('returns single nesting filter view if it expects some fields to be nested objects', () => { + const flattenFn = flattenFilterView(filterWithNestedValue); + const { value, ...restExpectedFields } = nestedFilterView; + const flattenFilterViewRes = flattenFn(nestedFilterView); + + expect(flattenFilterViewRes).toEqual({ + ...restExpectedFields, + nested: { + label: 'nested', + formatter: expect.any(Function), + }, + }); + expect(flattenFilterViewRes.nested.formatter?.()).toBe( + formatterFactory(filterWithNestedValue.value)() + ); + }); + + it('returns single nesting filter view if filterValue is empty object', () => { + const flattenFn = flattenFilterView({} as any); + const { value, ...rest } = nestedFilterView; + expect(flattenFn(nestedFilterView)).toEqual({ + ...rest, + nested: { + label: 'nested', + formatter: expect.any(Function), + }, + }); + }); +}); + +describe('formatFilterView returns fn which', () => { + const simpleFlattenFilterView: FlattenFilterViewInstance = { + type: { label: 'label' }, + value: { label: 'value' }, + column: { label: 'column' }, + filterGroup: { label: 'filterGroup' }, + nestedField: { label: 'nestedField', formatter: () => 'null' }, + }; + + it('returns formatted filter view with any passed keys', () => { + const formatFn = formatFilterView(simpleFilterValue); + expect(formatFn(simpleFlattenFilterView)).toEqual({ + type: { label: 'label', formattedValue: simpleFilterValue.type }, + value: { label: 'value', formattedValue: simpleFilterValue.value }, + column: { label: 'column', formattedValue: simpleFilterValue.column }, + filterGroup: { label: 'filterGroup', formattedValue: simpleFilterValue.filterGroup }, + nestedField: { label: 'nestedField', formattedValue: 'null' }, + }); + }); + + it("returns formatted filter view with formattedValue = '-' ", () => { + const formatFn = formatFilterView({} as any); + expect(formatFn(simpleFlattenFilterView)).toEqual({ + type: { label: 'label', formattedValue: '-' }, + value: { label: 'value', formattedValue: '-' }, + column: { label: 'column', formattedValue: '-' }, + filterGroup: { label: 'filterGroup', formattedValue: '-' }, + nestedField: { label: 'nestedField', formattedValue: 'null' }, + }); + }); + + it('returns emtpy object when filter view is empty object', () => { + const formatFn = formatFilterView(simpleFilterValue); + expect(formatFn({} as any)).toEqual({}); + }); + + it('returns filter view fields with component property if defined at filter view', () => { + const flattenFilterViewWithComponent: FlattenFilterViewInstance = { + ...simpleFlattenFilterView, + nestedField: { + ...simpleFlattenFilterView.nestedField, + component: fc, + }, + }; + + const formatFn = formatFilterView(simpleFilterValue); + expect(formatFn(flattenFilterViewWithComponent)).toEqual({ + type: { label: 'label', formattedValue: simpleFilterValue.type }, + value: { label: 'value', formattedValue: simpleFilterValue.value }, + column: { label: 'column', formattedValue: simpleFilterValue.column }, + filterGroup: { label: 'filterGroup', formattedValue: simpleFilterValue.filterGroup }, + nestedField: { label: 'nestedField', formattedValue: 'null', component: fc }, + }); + }); +}); + +describe('createFilledFilterView', () => { + it('returns simple filter view with formattedValue and components', () => { + const simpleFilterValueWithComponent = { + ...simpleFilterView, + value: { + ...(simpleFilterView.value as SimpleFilterViewField), + component: fc, + }, + }; + + expect(createFilledFilterView(simpleFilterValueWithComponent, simpleFilterValue)).toEqual({ + type: { label: 'label', formattedValue: simpleFilterValue.type }, + value: { label: 'value', formattedValue: simpleFilterValue.value, component: fc }, + column: { label: 'column', formattedValue: simpleFilterValue.column }, + filterGroup: { label: 'filterGroup', formattedValue: simpleFilterValue.filterGroup }, + }); + }); + + it('returns nested filter view with formattedValue and components', () => { + const nestedFilterViewWithComponent = { + ...nestedFilterView, + value: (value: unknown) => ({ + nested: { + label: 'nested', + formatter: formatterFactory(value), + component: fc, + }, + }), + }; + + expect(createFilledFilterView(nestedFilterViewWithComponent, filterWithNestedValue)).toEqual({ + type: { label: 'label', formattedValue: filterWithNestedValue.type }, + column: { label: 'column', formattedValue: filterWithNestedValue.column }, + filterGroup: { label: 'filterGroup', formattedValue: filterWithNestedValue.filterGroup }, + nested: { + label: 'nested', + formattedValue: formatterFactory(filterWithNestedValue.value)(), + component: fc, + }, + }); + }); +}); + +describe('groupFiltersBy', () => { + const filters: FilterType[] = [ + { type: 'exactly', column: 'project', value: 'kibana', filterGroup: 'someGroup' }, + { + type: 'time', + column: '@timestamp', + value: { from: 'some time', to: 'some time' }, + filterGroup: 'someGroup2', + }, + { type: 'exactly', column: 'country', value: 'US', filterGroup: 'someGroup2' }, + { + type: 'time', + column: 'time', + value: { from: 'some time', to: 'some time' }, + filterGroup: null, + }, + ]; + + it('groups by type', () => { + const grouped = groupFiltersBy(filters, 'type'); + expect(grouped).toEqual([ + { name: 'exactly', filters: [filters[0], filters[2]] }, + { name: 'time', filters: [filters[1], filters[3]] }, + ]); + }); + + it('groups by column', () => { + const grouped = groupFiltersBy(filters, 'column'); + expect(grouped).toEqual([ + { name: 'project', filters: [filters[0]] }, + { name: '@timestamp', filters: [filters[1]] }, + { name: 'country', filters: [filters[2]] }, + { name: 'time', filters: [filters[3]] }, + ]); + }); + + it('groups by filterGroup', () => { + const grouped = groupFiltersBy(filters, 'filterGroup'); + expect(grouped).toEqual([ + { name: 'someGroup', filters: [filters[0]] }, + { name: 'someGroup2', filters: [filters[1], filters[2]] }, + { name: null, filters: [filters[3]] }, + ]); + }); + + it('groups by field on empty array', () => { + const grouped = groupFiltersBy([], 'filterGroup'); + expect(grouped).toEqual([]); + }); + + it('groups by empty field', () => { + const filtersWithoutGroups = filters.map(({ filterGroup, ...rest }) => ({ + ...rest, + filterGroup: null, + })); + + const grouped = groupFiltersBy(filtersWithoutGroups, 'filterGroup'); + expect(grouped).toEqual([{ name: null, filters: filtersWithoutGroups }]); + }); +}); diff --git a/x-pack/plugins/canvas/public/lib/filter.ts b/x-pack/plugins/canvas/public/lib/filter.ts new file mode 100644 index 000000000000..ae75822e4a7c --- /dev/null +++ b/x-pack/plugins/canvas/public/lib/filter.ts @@ -0,0 +1,55 @@ +/* + * 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. + */ + +import { flowRight, groupBy } from 'lodash'; +import { + Filter as FilterType, + FilterField, + FilterViewInstance, + FlattenFilterViewInstance, +} from '../../types/filters'; + +export const defaultFormatter = (value: unknown) => (value || null ? `${value}` : '-'); + +export const formatFilterView = + (filterValue: FilterType) => (filterView: FlattenFilterViewInstance) => { + const filterViewKeys = Object.keys(filterView) as Array; + return filterViewKeys.reduce( + (acc, key) => ({ + ...acc, + [key]: { + label: filterView[key].label, + formattedValue: (filterView[key].formatter ?? defaultFormatter)(filterValue[key]), + component: filterView[key].component, + }, + }), + {} + ); + }; + +export const flattenFilterView = (filterValue: FilterType) => (filterView: FilterViewInstance) => { + const filterViewKeys = Object.keys(filterView) as Array; + return filterViewKeys.reduce((acc, key) => { + const filterField = filterView[key]; + if (typeof filterField === 'function') { + const val = filterField(filterValue[key]); + return { ...acc, ...val }; + } + return { ...acc, [key]: filterField }; + }, {}); +}; + +export const createFilledFilterView = (filterView: FilterViewInstance, filter: FilterType) => + flowRight(formatFilterView(filter), flattenFilterView(filter))(filterView); + +export const groupFiltersBy = (filters: FilterType[], groupByField: FilterField) => { + const groupedFilters = groupBy(filters, (filter) => filter[groupByField]); + return Object.keys(groupedFilters).map((key) => ({ + name: groupedFilters[key]?.[0]?.[groupByField] ? key : null, + filters: groupedFilters[key], + })); +}; diff --git a/x-pack/plugins/canvas/public/lib/filter_adapters.test.ts b/x-pack/plugins/canvas/public/lib/filter_adapters.test.ts new file mode 100644 index 000000000000..5061e47a4434 --- /dev/null +++ b/x-pack/plugins/canvas/public/lib/filter_adapters.test.ts @@ -0,0 +1,59 @@ +/* + * 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. + */ + +import { ExpressionFunctionAST } from '@kbn/interpreter/common'; +import { adaptCanvasFilter } from './filter_adapters'; + +describe('adaptCanvasFilter', () => { + const filterAST: ExpressionFunctionAST = { + type: 'function', + function: 'exactly', + arguments: { + type: ['exactly'], + column: ['project'], + filterGroup: [], + value: ['kibana'], + }, + }; + + it('returns filter when AST arguments consists of arrays with one element', () => { + const resultFilter = { type: 'exactly', column: 'project', filterGroup: null, value: 'kibana' }; + + const filter = adaptCanvasFilter(filterAST); + expect(filter).toEqual(resultFilter); + }); + + it('returns filter with all additional fields stored on value field', () => { + const { value, ...rest } = filterAST.arguments; + const additionalArguments = { value1: ['value1'], value2: ['value2'] }; + const newFilterAST = { ...filterAST, arguments: { ...rest, ...additionalArguments } }; + + const resultFilter = { + type: 'exactly', + column: 'project', + filterGroup: null, + value: { value1: 'value1', value2: 'value2' }, + }; + + const filter = adaptCanvasFilter(newFilterAST); + expect(filter).toEqual(resultFilter); + }); + + it('returns filter if args are empty', () => { + const { arguments: args, ...rest } = filterAST; + + const resultFilter = { + type: 'exactly', + column: null, + filterGroup: null, + value: null, + }; + + const filter = adaptCanvasFilter({ ...rest, arguments: {} }); + expect(filter).toEqual(resultFilter); + }); +}); diff --git a/x-pack/plugins/canvas/public/lib/filter_adapters.ts b/x-pack/plugins/canvas/public/lib/filter_adapters.ts new file mode 100644 index 000000000000..478b0a530263 --- /dev/null +++ b/x-pack/plugins/canvas/public/lib/filter_adapters.ts @@ -0,0 +1,48 @@ +/* + * 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. + */ + +import { ExpressionFunctionAST } from '@kbn/interpreter/common'; +import { identity } from 'lodash'; +import { ExpressionAstArgument, Filter, FilterType } from '../../types'; + +const functionToFilter: Record = { + timefilter: FilterType.time, + exactly: FilterType.exactly, +}; + +const defaultFormatter = (arg: ExpressionAstArgument) => arg.toString(); + +const argToValue = ( + arg: ExpressionAstArgument[], + formatter: (arg: ExpressionAstArgument) => string | null = defaultFormatter +) => (arg?.[0] ? formatter(arg[0]) : null); + +const convertFunctionToFilterType = (func: string) => functionToFilter[func] ?? FilterType.exactly; + +const collectArgs = (args: ExpressionFunctionAST['arguments']) => { + const argsKeys = Object.keys(args); + + if (!argsKeys.length) { + return null; + } + + return argsKeys.reduce>( + (acc, key) => ({ ...acc, [key]: argToValue(args[key], identity) }), + {} + ); +}; + +export function adaptCanvasFilter(filter: ExpressionFunctionAST): Filter { + const { function: type, arguments: args } = filter; + const { column, filterGroup, value: valueArg, type: typeArg, ...rest } = args ?? {}; + return { + type: convertFunctionToFilterType(type), + column: argToValue(column), + filterGroup: argToValue(filterGroup), + value: argToValue(valueArg) ?? collectArgs(rest), + }; +} diff --git a/x-pack/plugins/canvas/public/state/actions/sidebar.ts b/x-pack/plugins/canvas/public/state/actions/sidebar.ts new file mode 100644 index 000000000000..309cb43fcd93 --- /dev/null +++ b/x-pack/plugins/canvas/public/state/actions/sidebar.ts @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { createAction } from 'redux-actions'; +import { FilterField } from '../../../types'; + +export type SetGroupFiltersByOptionPayload = FilterField; +export const SetGroupFiltersByOptionType = 'setGroupFiltersByOption'; + +export const setGroupFiltersByOption = createAction( + SetGroupFiltersByOptionType +); diff --git a/x-pack/plugins/canvas/public/state/defaults.js b/x-pack/plugins/canvas/public/state/defaults.js index a245d515a32d..40e8425c98ff 100644 --- a/x-pack/plugins/canvas/public/state/defaults.js +++ b/x-pack/plugins/canvas/public/state/defaults.js @@ -6,7 +6,7 @@ */ import { getId } from '../lib/get_id'; -import { DEFAULT_WORKPAD_CSS } from '../../common/lib/constants'; +import { DEFAULT_WORKPAD_CSS, DEFAULT_GROUP_BY_FIELD } from '../../common/lib/constants'; export const getDefaultElement = () => { return { @@ -86,3 +86,7 @@ export const getDefaultWorkpad = () => { isWriteable: true, }; }; + +export const getDefaultSidebar = () => ({ + groupFiltersByOption: DEFAULT_GROUP_BY_FIELD, +}); diff --git a/x-pack/plugins/canvas/public/state/initial_state.js b/x-pack/plugins/canvas/public/state/initial_state.js index c652cc573abe..d676b27c7a90 100644 --- a/x-pack/plugins/canvas/public/state/initial_state.js +++ b/x-pack/plugins/canvas/public/state/initial_state.js @@ -7,7 +7,7 @@ import { get } from 'lodash'; import { pluginServices } from '../services'; -import { getDefaultWorkpad } from './defaults'; +import { getDefaultWorkpad, getDefaultSidebar } from './defaults'; export const getInitialState = (path) => { const platformService = pluginServices.getServices().platform; @@ -40,6 +40,7 @@ export const getInitialState = (path) => { // In there will live an object with a status (string), value (any), and error (Error) property. // If the state is 'error', the error property will be the error object, the value will not change // See the resolved_args reducer for more information. + sidebar: getDefaultSidebar(), }, persistent: { schemaVersion: 2, diff --git a/x-pack/plugins/canvas/public/state/reducers/index.js b/x-pack/plugins/canvas/public/state/reducers/index.js index 5a901fc3bb29..a07de70d9a00 100644 --- a/x-pack/plugins/canvas/public/state/reducers/index.js +++ b/x-pack/plugins/canvas/public/state/reducers/index.js @@ -18,12 +18,13 @@ import { elementsReducer } from './elements'; import { assetsReducer } from './assets'; import { historyReducer } from './history'; import { embeddableReducer } from './embeddable'; +import { sidebarReducer } from './sidebar'; export function getRootReducer(initialState) { return combineReducers({ assets: assetsReducer, app: appReducer, - transient: reduceReducers(transientReducer, resolvedArgsReducer), + transient: reduceReducers(transientReducer, resolvedArgsReducer, sidebarReducer), persistent: reduceReducers( historyReducer, combineReducers({ diff --git a/x-pack/plugins/canvas/public/state/reducers/sidebar.ts b/x-pack/plugins/canvas/public/state/reducers/sidebar.ts new file mode 100644 index 000000000000..55697b17c09e --- /dev/null +++ b/x-pack/plugins/canvas/public/state/reducers/sidebar.ts @@ -0,0 +1,22 @@ +/* + * 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. + */ + +import { handleActions } from 'redux-actions'; +import { State } from '../../../types'; +import { SetGroupFiltersByOptionType, SetGroupFiltersByOptionPayload } from '../actions/sidebar'; + +export const sidebarReducer = handleActions( + { + [SetGroupFiltersByOptionType]: (transientState, { payload }) => { + return { + ...transientState, + sidebar: { ...transientState.sidebar, groupFiltersByOption: payload }, + }; + }, + }, + {} as State['transient'] +); diff --git a/x-pack/plugins/canvas/public/state/selectors/sidebar.ts b/x-pack/plugins/canvas/public/state/selectors/sidebar.ts new file mode 100644 index 000000000000..637264a200b9 --- /dev/null +++ b/x-pack/plugins/canvas/public/state/selectors/sidebar.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +import { DEFAULT_GROUP_BY_FIELD } from '../../../common/lib'; +import { FilterField, State } from '../../../types'; + +export const getGroupFiltersByOption = (state: State): FilterField => { + return state.transient.sidebar.groupFiltersByOption ?? DEFAULT_GROUP_BY_FIELD; +}; diff --git a/x-pack/plugins/canvas/types/canvas.ts b/x-pack/plugins/canvas/types/canvas.ts index 0868054d0a48..efb121b2948a 100644 --- a/x-pack/plugins/canvas/types/canvas.ts +++ b/x-pack/plugins/canvas/types/canvas.ts @@ -6,6 +6,7 @@ */ import { ElementPosition } from './elements'; +import { FilterField } from './filters'; export interface CanvasAsset { '@created': string; @@ -44,6 +45,10 @@ export interface CanvasVariable { type: 'boolean' | 'number' | 'string'; } +export interface Sidebar { + groupFiltersByOption?: FilterField; +} + export interface CanvasWorkpad { '@created': string; '@timestamp': string; diff --git a/x-pack/plugins/canvas/types/filters.ts b/x-pack/plugins/canvas/types/filters.ts index 942e4259d780..8529b37e40b1 100644 --- a/x-pack/plugins/canvas/types/filters.ts +++ b/x-pack/plugins/canvas/types/filters.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { FC } from 'react'; import { ExpressionValueFilter } from '.'; export enum FilterType { @@ -31,3 +32,41 @@ export type CanvasExactlyFilter = ExpressionValueFilter & { }; export type CanvasFilter = CanvasTimeFilter | CanvasExactlyFilter | CanvasLuceneFilter; + +export interface Filter { + type: keyof typeof FilterType; + column: string | null; + value: unknown; + filterGroup: string | null; +} + +export type ComplexFilterViewField = ( + value: FilterValue +) => Record; + +export interface SimpleFilterViewField { + label: string; + formatter?: (value?: unknown) => string | null; + component?: FC; +} + +export interface FormattedFilterViewField { + label: string; + formattedValue: string; + component?: FC; +} + +export type FilterViewInstance = Record< + keyof Filter, + SimpleFilterViewField | ComplexFilterViewField +>; + +export interface FilterViewSpec { + name: string; + view: FilterViewInstance; +} + +export type FlattenFilterViewInstance = Record; +export type FormattedFilterViewInstance = Record; + +export type FilterField = 'column' | 'type' | 'filterGroup'; diff --git a/x-pack/plugins/canvas/types/state.ts b/x-pack/plugins/canvas/types/state.ts index a3c770f12f22..b283de1386f5 100644 --- a/x-pack/plugins/canvas/types/state.ts +++ b/x-pack/plugins/canvas/types/state.ts @@ -18,7 +18,7 @@ import { } from 'src/plugins/expressions'; import { Datasource, Model, Transform, View } from '../public/expression_types'; import { AssetType } from './assets'; -import { CanvasWorkpad } from './canvas'; +import { CanvasWorkpad, Sidebar } from './canvas'; export enum AppStateKeys { FULLSCREEN = '__fullscreen', @@ -75,7 +75,7 @@ export interface ResolvedArgType { expressionContext: ExpressionContext; } -interface TransientState { +export interface TransientState { canUserWrite: boolean; zoomScale: number; elementStats: ElementStatsType; @@ -90,6 +90,7 @@ interface TransientState { interval: number; }; inFlight: boolean; + sidebar: Sidebar; } interface PersistentState { diff --git a/x-pack/plugins/cases/common/utils/markdown_plugins/utils.ts b/x-pack/plugins/cases/common/utils/markdown_plugins/utils.ts index ca8b26a09c84..b6b061fcb41d 100644 --- a/x-pack/plugins/cases/common/utils/markdown_plugins/utils.ts +++ b/x-pack/plugins/cases/common/utils/markdown_plugins/utils.ts @@ -11,8 +11,8 @@ import markdown from 'remark-parse'; import remarkStringify from 'remark-stringify'; import unified from 'unified'; -import { TimeRange } from 'src/plugins/data/server'; import { SerializableRecord } from '@kbn/utility-types'; +import type { TimeRange } from 'src/plugins/data/common'; import { LENS_ID, LensParser, LensSerializer } from './lens'; import { TimelineSerializer, TimelineParser } from './timeline'; diff --git a/x-pack/plugins/cases/server/authorization/types.ts b/x-pack/plugins/cases/server/authorization/types.ts index 40d2b1fc4f6e..8abea391cc9a 100644 --- a/x-pack/plugins/cases/server/authorization/types.ts +++ b/x-pack/plugins/cases/server/authorization/types.ts @@ -6,7 +6,7 @@ */ import { EcsEventType, KibanaRequest } from 'kibana/server'; -import { KueryNode } from 'src/plugins/data/common'; +import type { KueryNode } from '@kbn/es-query'; import { Space } from '../../../spaces/server'; /** diff --git a/x-pack/plugins/cases/server/authorization/utils.test.ts b/x-pack/plugins/cases/server/authorization/utils.test.ts index 3ebf6ee398e3..2afffbbb768b 100644 --- a/x-pack/plugins/cases/server/authorization/utils.test.ts +++ b/x-pack/plugins/cases/server/authorization/utils.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { nodeBuilder } from '../../../../../src/plugins/data/common'; +import { nodeBuilder } from '@kbn/es-query'; import { OWNER_FIELD } from '../../common'; import { combineFilterWithAuthorizationFilter, diff --git a/x-pack/plugins/cases/server/authorization/utils.ts b/x-pack/plugins/cases/server/authorization/utils.ts index 92293d281447..f3a851254843 100644 --- a/x-pack/plugins/cases/server/authorization/utils.ts +++ b/x-pack/plugins/cases/server/authorization/utils.ts @@ -6,7 +6,7 @@ */ import { remove, uniq } from 'lodash'; -import { nodeBuilder, KueryNode } from '../../../../../src/plugins/data/common'; +import { nodeBuilder, KueryNode } from '@kbn/es-query'; import { OWNER_FIELD } from '../../common'; export const getOwnersFilter = ( diff --git a/x-pack/plugins/cases/server/client/attachments/add.ts b/x-pack/plugins/cases/server/client/attachments/add.ts index 159ff3b41aba..7f6ede930e4c 100644 --- a/x-pack/plugins/cases/server/client/attachments/add.ts +++ b/x-pack/plugins/cases/server/client/attachments/add.ts @@ -10,6 +10,7 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; +import { nodeBuilder } from '@kbn/es-query'; import { SavedObject, SavedObjectsClientContract, @@ -17,7 +18,6 @@ import { SavedObjectsUtils, } from '../../../../../../src/core/server'; import { LensServerPluginSetup } from '../../../../lens/server'; -import { nodeBuilder } from '../../../../../../src/plugins/data/common'; import { AlertCommentRequestRt, diff --git a/x-pack/plugins/cases/server/client/cases/update.ts b/x-pack/plugins/cases/server/client/cases/update.ts index ed19444414d5..da1c25c83a37 100644 --- a/x-pack/plugins/cases/server/client/cases/update.ts +++ b/x-pack/plugins/cases/server/client/cases/update.ts @@ -18,7 +18,7 @@ import { SavedObjectsFindResult, } from 'kibana/server'; -import { nodeBuilder } from '../../../../../../src/plugins/data/common'; +import { nodeBuilder } from '@kbn/es-query'; import { AssociationType, diff --git a/x-pack/plugins/cases/server/client/sub_cases/update.ts b/x-pack/plugins/cases/server/client/sub_cases/update.ts index c8cb96cbb6b8..c0d3d571bb1e 100644 --- a/x-pack/plugins/cases/server/client/sub_cases/update.ts +++ b/x-pack/plugins/cases/server/client/sub_cases/update.ts @@ -16,7 +16,7 @@ import { Logger, } from 'kibana/server'; -import { nodeBuilder } from '../../../../../../src/plugins/data/common'; +import { nodeBuilder } from '@kbn/es-query'; import { CasesService } from '../../services'; import { CASE_COMMENT_SAVED_OBJECT, diff --git a/x-pack/plugins/cases/server/client/utils.ts b/x-pack/plugins/cases/server/client/utils.ts index a6fd9984bfea..87bf4d04b3e8 100644 --- a/x-pack/plugins/cases/server/client/utils.ts +++ b/x-pack/plugins/cases/server/client/utils.ts @@ -12,8 +12,7 @@ import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import { pipe } from 'fp-ts/lib/pipeable'; -import { nodeBuilder, KueryNode } from '../../../../../src/plugins/data/common'; -import { esKuery } from '../../../../../src/plugins/data/server'; +import { nodeBuilder, fromKueryExpression, KueryNode } from '@kbn/es-query'; import { AlertCommentRequestRt, ActionsCommentRequestRt, @@ -183,7 +182,7 @@ export function stringToKueryNode(expression?: string): KueryNode | undefined { return; } - return esKuery.fromKueryExpression(expression); + return fromKueryExpression(expression); } /** diff --git a/x-pack/plugins/cases/server/common/types.ts b/x-pack/plugins/cases/server/common/types.ts index 067f2fc7c311..364be027221d 100644 --- a/x-pack/plugins/cases/server/common/types.ts +++ b/x-pack/plugins/cases/server/common/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { KueryNode } from '../../../../../src/plugins/data/server'; +import type { KueryNode } from '@kbn/es-query'; import { SavedObjectFindOptions } from '../../common'; /** diff --git a/x-pack/plugins/cases/server/services/attachments/index.ts b/x-pack/plugins/cases/server/services/attachments/index.ts index 105b6a312552..95a66fd9af19 100644 --- a/x-pack/plugins/cases/server/services/attachments/index.ts +++ b/x-pack/plugins/cases/server/services/attachments/index.ts @@ -12,7 +12,7 @@ import { SavedObjectsUpdateOptions, } from 'kibana/server'; -import { KueryNode } from '../../../../../../src/plugins/data/common'; +import type { KueryNode } from '@kbn/es-query'; import { AttributesTypeAlerts, CASE_COMMENT_SAVED_OBJECT, diff --git a/x-pack/plugins/cases/server/services/cases/index.ts b/x-pack/plugins/cases/server/services/cases/index.ts index 4a22793f78af..15e60c49768a 100644 --- a/x-pack/plugins/cases/server/services/cases/index.ts +++ b/x-pack/plugins/cases/server/services/cases/index.ts @@ -20,7 +20,7 @@ import { } from 'kibana/server'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { nodeBuilder, KueryNode } from '../../../../../../src/plugins/data/common'; +import { nodeBuilder, KueryNode } from '@kbn/es-query'; import { SecurityPluginSetup } from '../../../../security/server'; import { diff --git a/x-pack/plugins/enterprise_search/server/routes/app_search/search_ui.test.ts b/x-pack/plugins/enterprise_search/server/routes/app_search/search_ui.test.ts index fa0694fed9d0..e92dc63952eb 100644 --- a/x-pack/plugins/enterprise_search/server/routes/app_search/search_ui.test.ts +++ b/x-pack/plugins/enterprise_search/server/routes/app_search/search_ui.test.ts @@ -33,7 +33,7 @@ describe('reference application routes', () => { }); expect(mockRequestHandler.createRequest).toHaveBeenCalledWith({ - path: '/as/engines/:engineName/reference_application/field_config', + path: '/as/engines/:engineName/search_experience/field_config', }); }); }); diff --git a/x-pack/plugins/enterprise_search/server/routes/app_search/search_ui.ts b/x-pack/plugins/enterprise_search/server/routes/app_search/search_ui.ts index 2a9d99e6e588..3d9a671b6e81 100644 --- a/x-pack/plugins/enterprise_search/server/routes/app_search/search_ui.ts +++ b/x-pack/plugins/enterprise_search/server/routes/app_search/search_ui.ts @@ -23,7 +23,7 @@ export function registerSearchUIRoutes({ }, }, enterpriseSearchRequestHandler.createRequest({ - path: '/as/engines/:engineName/reference_application/field_config', + path: '/as/engines/:engineName/search_experience/field_config', }) ); } diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/no_custom_attributes_messages.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/no_custom_attributes_messages.tsx index 4d948ac202eb..f3738805a8d4 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/no_custom_attributes_messages.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/no_custom_attributes_messages.tsx @@ -9,21 +9,26 @@ import React from 'react'; import { EuiLink } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +import { DocLinksStart } from 'src/core/public'; import { getNodeAllocationMigrationLink } from '../../../../../../../services/documentation'; +export interface Props { + docLinks: DocLinksStart; +} + export const noCustomAttributesTitle = i18n.translate( 'xpack.indexLifecycleMgmt.editPolicy.noCustomAttributesTitle', { defaultMessage: 'No custom attributes defined' } ); -export const nodeAllocationMigrationGuidance = ( +export const nodeAllocationMigrationGuidance = ({ docLinks }: Props) => ( + {i18n.translate( 'xpack.indexLifecycleMgmt.editPolicy.defaultToDataNodesDescription.migrationGuidanceMessage', { diff --git a/x-pack/plugins/index_lifecycle_management/public/application/services/documentation.ts b/x-pack/plugins/index_lifecycle_management/public/application/services/documentation.ts index 27e571248d66..721d00582bdb 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/services/documentation.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/services/documentation.ts @@ -11,6 +11,8 @@ * in future. The pattern in this file is legacy and should be updated to conform to the plugin lifecycle. */ +import { DocLinksStart } from 'src/core/public'; + export let skippingDisconnectedClustersUrl: string; export let remoteClustersUrl: string; export let transportPortUrl: string; @@ -22,5 +24,5 @@ export function init(esDocBasePath: string): void { } export const createDocLink = (docPath: string): string => `${_esDocBasePath}${docPath}`; -export const getNodeAllocationMigrationLink = () => - `${_esDocBasePath}migrate-index-allocation-filters.html`; +export const getNodeAllocationMigrationLink = ({ links }: DocLinksStart) => + `${links.elasticsearch.migrateIndexAllocationFilters}`; diff --git a/x-pack/plugins/ingest_pipelines/server/lib/mapper.test.ts b/x-pack/plugins/ingest_pipelines/server/lib/mapper.test.ts index 0c2f52d3c3bd..2e02d83b17bf 100644 --- a/x-pack/plugins/ingest_pipelines/server/lib/mapper.test.ts +++ b/x-pack/plugins/ingest_pipelines/server/lib/mapper.test.ts @@ -31,16 +31,29 @@ describe('mapper', () => { ); }); - it('missing the required headers errors', () => { - const noHeadersCsv = 'srcip,,,,source.address,Copying srcip to source.address'; + describe('missing the required headers errors', () => { + it('single missing headers', () => { + const noHeadersCsv = + 'test_header,copy_action,format_action,timestamp_format,destination_field,Notes\nsrcip,,,,source.address,Copying srcip to source.address'; - expect(() => { - csvToIngestPipeline(noHeadersCsv, FieldCopyAction.Copy); - }).toThrow( - new Error( - 'Missing required headers: Include [source_field, destination_field] header(s) in the CSV file.' - ) - ); + expect(() => { + csvToIngestPipeline(noHeadersCsv, FieldCopyAction.Copy); + }).toThrow( + new Error('Missing required headers: Include source_field header in the CSV file.') + ); + }); + + it('multiple missing headers', () => { + const noHeadersCsv = 'srcip,,,,source.address,Copying srcip to source.address'; + + expect(() => { + csvToIngestPipeline(noHeadersCsv, FieldCopyAction.Copy); + }).toThrow( + new Error( + 'Missing required headers: Include source_field, destination_field headers in the CSV file.' + ) + ); + }); }); it('unacceptable format action errors', () => { diff --git a/x-pack/plugins/ingest_pipelines/server/lib/mapper.ts b/x-pack/plugins/ingest_pipelines/server/lib/mapper.ts index 86a2a886156d..421ee636856b 100644 --- a/x-pack/plugins/ingest_pipelines/server/lib/mapper.ts +++ b/x-pack/plugins/ingest_pipelines/server/lib/mapper.ts @@ -79,8 +79,12 @@ function parseAndValidate(file: string) { if (missingHeaders.length > 0) { throw new Error( i18n.translate('xpack.ingestPipelines.mapToIngestPipeline.error.missingHeaders', { - defaultMessage: 'Missing required headers: Include [{missing}] header(s) in the CSV file.', - values: { missing: missingHeaders.join(', ') }, + defaultMessage: + 'Missing required headers: Include {missingHeaders} {missingHeadersCount, plural, one {header} other {headers}} in the CSV file.', + values: { + missingHeaders: missingHeaders.join(', '), + missingHeadersCount: missingHeaders.length, + }, }) ); } diff --git a/x-pack/plugins/lens/common/expressions/metric_chart/metric_chart.ts b/x-pack/plugins/lens/common/expressions/metric_chart/metric_chart.ts index 6676ead2bca9..4a79644d7fe5 100644 --- a/x-pack/plugins/lens/common/expressions/metric_chart/metric_chart.ts +++ b/x-pack/plugins/lens/common/expressions/metric_chart/metric_chart.ts @@ -5,6 +5,8 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; +import { ColorMode } from '../../../../../../src/plugins/charts/common'; import type { ExpressionFunctionDefinition } from '../../../../../../src/plugins/expressions/common'; import type { LensMultiTable } from '../../types'; import type { MetricConfig } from './types'; @@ -32,7 +34,9 @@ export const metricChart: ExpressionFunctionDefinition< args: { title: { types: ['string'], - help: 'The chart title.', + help: i18n.translate('xpack.lens.metric.title.help', { + defaultMessage: 'The chart title.', + }), }, description: { types: ['string'], @@ -40,17 +44,38 @@ export const metricChart: ExpressionFunctionDefinition< }, metricTitle: { types: ['string'], - help: 'The title of the metric shown.', + help: i18n.translate('xpack.lens.metric.metricTitle.help', { + defaultMessage: 'The title of the metric shown.', + }), }, accessor: { types: ['string'], - help: 'The column whose value is being displayed', + help: i18n.translate('xpack.lens.metric.accessor.help', { + defaultMessage: 'The column whose value is being displayed', + }), }, mode: { types: ['string'], options: ['reduced', 'full'], default: 'full', - help: 'The display mode of the chart - reduced will only show the metric itself without min size', + help: i18n.translate('xpack.lens.metric.mode.help', { + defaultMessage: + 'The display mode of the chart - reduced will only show the metric itself without min size', + }), + }, + colorMode: { + types: ['string'], + default: `"${ColorMode.None}"`, + options: [ColorMode.None, ColorMode.Labels, ColorMode.Background], + help: i18n.translate('xpack.lens.metric.colorMode.help', { + defaultMessage: 'Which part of metric to color', + }), + }, + palette: { + types: ['palette'], + help: i18n.translate('xpack.lens.metric.palette.help', { + defaultMessage: 'Provides colors for the values', + }), }, }, inputTypes: ['lens_multitable'], diff --git a/x-pack/plugins/lens/common/expressions/metric_chart/types.ts b/x-pack/plugins/lens/common/expressions/metric_chart/types.ts index 65a72632a549..8a52506a83ec 100644 --- a/x-pack/plugins/lens/common/expressions/metric_chart/types.ts +++ b/x-pack/plugins/lens/common/expressions/metric_chart/types.ts @@ -5,17 +5,26 @@ * 2.0. */ -import { LayerType } from '../../types'; +import { + ColorMode, + CustomPaletteState, + PaletteOutput, +} from '../../../../../../src/plugins/charts/common'; +import { CustomPaletteParams, LayerType } from '../../types'; export interface MetricState { layerId: string; accessor?: string; layerType: LayerType; + colorMode?: ColorMode; + palette?: PaletteOutput; } -export interface MetricConfig extends MetricState { +export interface MetricConfig extends Omit { title: string; description: string; metricTitle: string; mode: 'reduced' | 'full'; + colorMode: ColorMode; + palette: PaletteOutput; } diff --git a/x-pack/plugins/lens/public/metric_visualization/dimension_editor.scss b/x-pack/plugins/lens/public/metric_visualization/dimension_editor.scss new file mode 100644 index 000000000000..d7664b9d2da1 --- /dev/null +++ b/x-pack/plugins/lens/public/metric_visualization/dimension_editor.scss @@ -0,0 +1,3 @@ +.lnsDynamicColoringRow { + align-items: center; +} \ No newline at end of file diff --git a/x-pack/plugins/lens/public/metric_visualization/dimension_editor.test.tsx b/x-pack/plugins/lens/public/metric_visualization/dimension_editor.test.tsx new file mode 100644 index 000000000000..ef0687a2cd51 --- /dev/null +++ b/x-pack/plugins/lens/public/metric_visualization/dimension_editor.test.tsx @@ -0,0 +1,224 @@ +/* + * 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. + */ + +import React from 'react'; +import { EuiButtonGroup } from '@elastic/eui'; +import { FramePublicAPI, VisualizationDimensionEditorProps } from '../types'; +import { createMockDatasource, createMockFramePublicAPI } from '../mocks'; +import { mountWithIntl } from '@kbn/test/jest'; +import { MetricDimensionEditor } from './dimension_editor'; +import { chartPluginMock } from 'src/plugins/charts/public/mocks'; +import { ColorMode, PaletteOutput, PaletteRegistry } from 'src/plugins/charts/public'; +import { act } from 'react-dom/test-utils'; +import { CustomizablePalette, PalettePanelContainer } from '../shared_components'; +import { CustomPaletteParams, layerTypes } from '../../common'; +import { MetricState } from '../../common/expressions'; + +// mocking random id generator function +jest.mock('@elastic/eui', () => { + const original = jest.requireActual('@elastic/eui'); + + return { + ...original, + htmlIdGenerator: (fn: unknown) => { + let counter = 0; + return () => counter++; + }, + }; +}); + +function paletteParamsContaining(paramsToCheck: PaletteOutput['params']) { + return expect.objectContaining({ + palette: expect.objectContaining({ + params: expect.objectContaining(paramsToCheck), + }), + }); +} + +describe('metric dimension editor', () => { + let frame: FramePublicAPI; + let state: MetricState; + let setState: (newState: MetricState) => void; + let props: VisualizationDimensionEditorProps & { + paletteService: PaletteRegistry; + }; + + function testState(): MetricState { + return { + layerId: 'first', + layerType: layerTypes.DATA, + accessor: 'foo', + }; + } + + beforeEach(() => { + state = testState(); + frame = createMockFramePublicAPI(); + frame.datasourceLayers = { + first: createMockDatasource('test').publicAPIMock, + }; + frame.activeData = { + first: { + type: 'datatable', + columns: [ + { + id: 'foo', + name: 'foo', + meta: { + type: 'string', + }, + }, + ], + rows: [{ foo: 5 }], + }, + }; + setState = jest.fn(); + props = { + accessor: 'foo', + frame, + groupId: 'columns', + layerId: 'first', + state, + setState, + paletteService: chartPluginMock.createPaletteRegistry(), + panelRef: React.createRef(), + }; + // add a div to the ref + props.panelRef.current = document.createElement('div'); + }); + + it('should not show the dynamic coloring option for non numeric columns', () => { + const instance = mountWithIntl(); + expect(instance.find('[data-test-subj="lnsMetric_dynamicColoring_groups"]').exists()).toBe( + false + ); + expect(instance.find('[data-test-subj="lnsMetric_dynamicColoring_palette"]').exists()).toBe( + false + ); + }); + + it('should set the dynamic coloring default to "none"', () => { + frame.activeData!.first.columns[0].meta.type = 'number'; + const instance = mountWithIntl(); + expect( + instance + .find('[data-test-subj="lnsMetric_dynamicColoring_groups"]') + .find(EuiButtonGroup) + .prop('idSelected') + ).toEqual(expect.stringContaining(ColorMode.None)); + + expect(instance.find('[data-test-subj="lnsMetric_dynamicColoring_palette"]').exists()).toBe( + false + ); + }); + + it('should show the dynamic palette display ony when colorMode is different from "none"', () => { + frame.activeData!.first.columns[0].meta.type = 'number'; + state.colorMode = ColorMode.Labels; + const instance = mountWithIntl(); + expect( + instance + .find('[data-test-subj="lnsMetric_dynamicColoring_groups"]') + .find(EuiButtonGroup) + .prop('idSelected') + ).toEqual(expect.stringContaining(ColorMode.Labels)); + + expect(instance.find('[data-test-subj="lnsMetric_dynamicColoring_palette"]').exists()).toBe( + true + ); + }); + + it('should prefill the palette stops with some colors when enabling coloring', () => { + frame.activeData!.first.columns[0].meta.type = 'number'; + const instance = mountWithIntl(); + + act(() => { + instance + .find('[data-test-subj="lnsMetric_dynamicColoring_groups"]') + .find(EuiButtonGroup) + .prop('onChange')!(ColorMode.Labels); + }); + instance.update(); + + expect(props.setState).toHaveBeenCalledWith( + paletteParamsContaining({ + stops: expect.any(Array), // shallow check it's ok + }) + ); + }); + + it('should open the palette panel when "Settings" link is clicked in the palette input', () => { + frame.activeData!.first.columns[0].meta.type = 'number'; + state.colorMode = ColorMode.Background; + const instance = mountWithIntl(); + + act(() => { + instance + .find('[data-test-subj="lnsMetric_dynamicColoring_trigger"]') + .first() + .simulate('click'); + }); + instance.update(); + + expect(instance.find(PalettePanelContainer).exists()).toBe(true); + }); + + it('should provide have a special data min/max for zero metric value', () => { + frame.activeData!.first.columns[0].meta.type = 'number'; + frame.activeData!.first.rows[0].foo = 0; + state.colorMode = ColorMode.Background; + const instance = mountWithIntl(); + + act(() => { + instance + .find('[data-test-subj="lnsMetric_dynamicColoring_trigger"]') + .first() + .simulate('click'); + }); + instance.update(); + + expect(instance.find(CustomizablePalette).prop('dataBounds')).toEqual({ min: -50, max: 100 }); + }); + + it('should work for negative metric value', () => { + frame.activeData!.first.columns[0].meta.type = 'number'; + frame.activeData!.first.rows[0].foo = -1; + state.colorMode = ColorMode.Background; + const instance = mountWithIntl(); + + act(() => { + instance + .find('[data-test-subj="lnsMetric_dynamicColoring_trigger"]') + .first() + .simulate('click'); + }); + instance.update(); + + expect(instance.find(CustomizablePalette).prop('dataBounds')).toEqual({ min: -2, max: 0 }); + }); + + it('should apply an initial range with shifted stops (first stop === rangeMin)', () => { + frame.activeData!.first.columns[0].meta.type = 'number'; + frame.activeData!.first.rows[0].foo = 5; + state.colorMode = ColorMode.None; + state.palette = undefined; + const instance = mountWithIntl(); + + act(() => { + instance + .find('[data-test-subj="lnsMetric_dynamicColoring_groups"]') + .find(EuiButtonGroup) + .prop('onChange')!(ColorMode.Background); + }); + + expect(setState).toHaveBeenCalledWith( + paletteParamsContaining({ + stops: expect.arrayContaining([]), + }) + ); + }); +}); diff --git a/x-pack/plugins/lens/public/metric_visualization/dimension_editor.tsx b/x-pack/plugins/lens/public/metric_visualization/dimension_editor.tsx new file mode 100644 index 000000000000..fd804ee5a82a --- /dev/null +++ b/x-pack/plugins/lens/public/metric_visualization/dimension_editor.tsx @@ -0,0 +1,224 @@ +/* + * 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. + */ +import { + EuiButtonEmpty, + EuiButtonGroup, + EuiColorPaletteDisplay, + EuiFlexGroup, + EuiFlexItem, + EuiFormRow, + htmlIdGenerator, +} from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import React, { useCallback, useState } from 'react'; +import { ColorMode } from '../../../../../src/plugins/charts/common'; +import type { PaletteRegistry } from '../../../../../src/plugins/charts/public'; +import { isNumericFieldForDatatable, MetricState } from '../../common/expressions'; +import { + applyPaletteParams, + CustomizablePalette, + CUSTOM_PALETTE, + FIXED_PROGRESSION, + getStopsForFixedMode, + PalettePanelContainer, +} from '../shared_components'; +import type { VisualizationDimensionEditorProps } from '../types'; +import { defaultPaletteParams } from './palette_config'; + +import './dimension_editor.scss'; + +const idPrefix = htmlIdGenerator()(); + +export function MetricDimensionEditor( + props: VisualizationDimensionEditorProps & { + paletteService: PaletteRegistry; + } +) { + const { state, setState, frame, accessor } = props; + const [isPaletteOpen, setIsPaletteOpen] = useState(false); + + const togglePalette = useCallback(() => { + setIsPaletteOpen(!isPaletteOpen); + }, [isPaletteOpen]); + + const currentData = frame.activeData?.[state.layerId]; + const [firstRow] = currentData?.rows || []; + + if (accessor == null || firstRow == null || !isNumericFieldForDatatable(currentData, accessor)) { + return null; + } + const currentColorMode = state?.colorMode || ColorMode.None; + const hasDynamicColoring = currentColorMode !== ColorMode.None; + + const currentMinMax = { + min: Math.min(firstRow[accessor] * 2, firstRow[accessor] === 0 ? -50 : 0), + // if value is 0, then fallback to 100 as last resort + max: Math.max(firstRow[accessor] * 2, firstRow[accessor] === 0 ? 100 : 0), + }; + + const activePalette = state?.palette || { + type: 'palette', + name: defaultPaletteParams.name, + params: { + ...defaultPaletteParams, + stops: undefined, + colorStops: undefined, + rangeMin: currentMinMax.min, + rangeMax: (currentMinMax.max * 3) / 4, + }, + }; + + // need to tell the helper that the colorStops are required to display + const displayStops = applyPaletteParams(props.paletteService, activePalette, currentMinMax); + + return ( + <> + + { + const newMode = id.replace(idPrefix, '') as ColorMode; + const params: Partial = { + colorMode: newMode, + }; + if (!state?.palette && newMode !== ColorMode.None) { + params.palette = { + ...activePalette, + params: { + ...activePalette.params, + // align this initial computation with same format for default + // palettes in the panel. This to avoid custom computation issue with metric + // fake data range + stops: displayStops.map((v, i, array) => ({ + ...v, + stop: currentMinMax.min + (i === 0 ? 0 : array[i - 1].stop), + })), + }, + }; + } + // clear up when switching to no coloring + if (state?.palette && newMode === ColorMode.None) { + params.palette = undefined; + } + setState({ + ...state, + ...params, + }); + }} + /> + + {hasDynamicColoring && ( + + + + color) + } + type={FIXED_PROGRESSION} + onClick={togglePalette} + /> + + + + {i18n.translate('xpack.lens.paletteTableGradient.customize', { + defaultMessage: 'Edit', + })} + + + { + // if the new palette is not custom, replace the rangeMin with the artificial one + if ( + newPalette.name !== CUSTOM_PALETTE && + newPalette.params && + newPalette.params.rangeMin !== currentMinMax.min + ) { + newPalette.params.rangeMin = currentMinMax.min; + } + setState({ + ...state, + palette: newPalette, + }); + }} + showRangeTypeSelector={false} + /> + + + + + )} + + ); +} diff --git a/x-pack/plugins/lens/public/metric_visualization/expression.scss b/x-pack/plugins/lens/public/metric_visualization/expression.scss index 233903153999..ad2a175b5b5f 100644 --- a/x-pack/plugins/lens/public/metric_visualization/expression.scss +++ b/x-pack/plugins/lens/public/metric_visualization/expression.scss @@ -6,4 +6,15 @@ width: 100%; height: 100%; text-align: center; -} + + .lnsMetricExpression__value { + font-size: $euiSizeXXL * 2; + font-weight: $euiFontWeightSemiBold; + border-radius: $euiBorderRadius; + padding: 0 $euiSize; + } + + .lnsMetricExpression__title { + font-size: $euiSizeXL; + } +} \ No newline at end of file diff --git a/x-pack/plugins/lens/public/metric_visualization/expression.test.tsx b/x-pack/plugins/lens/public/metric_visualization/expression.test.tsx index baa0a5adc3b7..56bb9235aa3a 100644 --- a/x-pack/plugins/lens/public/metric_visualization/expression.test.tsx +++ b/x-pack/plugins/lens/public/metric_visualization/expression.test.tsx @@ -13,6 +13,8 @@ import { createMockExecutionContext } from '../../../../../src/plugins/expressio import type { IFieldFormat } from '../../../../../src/plugins/field_formats/common'; import { layerTypes } from '../../common'; import type { LensMultiTable } from '../../common'; +import { IUiSettingsClient } from 'kibana/public'; +import { ColorMode } from 'src/plugins/charts/common'; function sampleArgs() { const data: LensMultiTable = { @@ -43,6 +45,8 @@ function sampleArgs() { description: 'Fancy chart description', metricTitle: 'My fanci metric chart', mode: 'full', + colorMode: ColorMode.None, + palette: { type: 'palette', name: 'status' }, }; const noAttributesArgs: MetricConfig = { @@ -53,6 +57,8 @@ function sampleArgs() { description: '', metricTitle: 'My fanci metric chart', mode: 'full', + colorMode: ColorMode.None, + palette: { type: 'palette', name: 'status' }, }; return { data, args, noAttributesArgs }; @@ -82,6 +88,7 @@ describe('metric_expression', () => { data={data} args={args} formatFactory={() => ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} /> ) ).toMatchInlineSnapshot(` @@ -92,23 +99,15 @@ describe('metric_expression', () => { key="3" >
3
My fanci metric chart
@@ -127,6 +126,7 @@ describe('metric_expression', () => { data={data} args={args} formatFactory={() => ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} /> ) ).toMatchInlineSnapshot(` @@ -137,23 +137,15 @@ describe('metric_expression', () => { key="last" >
last
My fanci metric chart
@@ -171,6 +163,7 @@ describe('metric_expression', () => { data={data} args={noAttributesArgs} formatFactory={() => ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} /> ) ).toMatchInlineSnapshot(` @@ -181,23 +174,15 @@ describe('metric_expression', () => { key="3" >
3
My fanci metric chart
@@ -215,6 +200,7 @@ describe('metric_expression', () => { data={data} args={{ ...noAttributesArgs, mode: 'reduced' }} formatFactory={() => ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} /> ) ).toMatchInlineSnapshot(` @@ -225,13 +211,9 @@ describe('metric_expression', () => { key="3" >
3
@@ -249,6 +231,7 @@ describe('metric_expression', () => { data={{ ...data, tables: {} }} args={noAttributesArgs} formatFactory={() => ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} /> ) ).toMatchInlineSnapshot(` @@ -273,6 +256,7 @@ describe('metric_expression', () => { data={data} args={noAttributesArgs} formatFactory={() => ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} /> ) ).toMatchInlineSnapshot(` @@ -297,6 +281,7 @@ describe('metric_expression', () => { data={data} args={noAttributesArgs} formatFactory={() => ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} /> ) ).toMatchInlineSnapshot(` @@ -307,23 +292,15 @@ describe('metric_expression', () => { key="0" >
0
My fanci metric chart
@@ -336,8 +313,237 @@ describe('metric_expression', () => { const { data, args } = sampleArgs(); const factory = jest.fn(() => ({ convert: (x) => x } as IFieldFormat)); - shallow(); + shallow( + + ); expect(factory).toHaveBeenCalledWith({ id: 'percent', params: { format: '0.000%' } }); }); + + test('it renders the correct color styling for numeric value if coloring config is passed', () => { + const { data, args } = sampleArgs(); + + args.colorMode = ColorMode.Labels; + args.palette.params = { + rangeMin: 0, + rangeMax: 400, + stops: [100, 200, 400], + gradient: false, + range: 'number', + colors: ['red', 'yellow', 'green'], + }; + + const instance = shallow( + ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + /> + ); + + expect(instance.find('[data-test-subj="lns_metric_value"]').first().prop('style')).toEqual( + expect.objectContaining({ + color: 'red', + }) + ); + }); + + test('it renders no color styling for numeric value if value is lower then rangeMin and continuity is "above"', () => { + const { data, args } = sampleArgs(); + + data.tables.l1.rows[0].c = -1; + args.colorMode = ColorMode.Labels; + args.palette.params = { + rangeMin: 0, + rangeMax: 400, + stops: [100, 200, 400], + gradient: false, + range: 'number', + colors: ['red', 'yellow', 'green'], + continuity: 'above', + }; + + const instance = shallow( + ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + /> + ); + + expect( + instance.find('[data-test-subj="lns_metric_value"]').first().prop('style') + ).not.toEqual( + expect.objectContaining({ + color: expect.any(String), + }) + ); + }); + test('it renders no color styling for numeric value if value is higher than rangeMax and continuity is "below"', () => { + const { data, args } = sampleArgs(); + + data.tables.l1.rows[0].c = 500; + args.colorMode = ColorMode.Labels; + args.palette.params = { + rangeMin: 0, + rangeMax: 400, + stops: [100, 200, 400], + gradient: false, + range: 'number', + colors: ['red', 'yellow', 'green'], + continuity: 'below', + }; + + const instance = shallow( + ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + /> + ); + + expect( + instance.find('[data-test-subj="lns_metric_value"]').first().prop('style') + ).not.toEqual( + expect.objectContaining({ + color: expect.any(String), + }) + ); + }); + + test('it renders no color styling for numeric value if value is higher than rangeMax and continuity is "none"', () => { + const { data, args } = sampleArgs(); + + data.tables.l1.rows[0].c = 500; + args.colorMode = ColorMode.Labels; + args.palette.params = { + rangeMin: 0, + rangeMax: 400, + stops: [100, 200, 400], + gradient: false, + range: 'number', + colors: ['red', 'yellow', 'green'], + continuity: 'none', + }; + + const instance = shallow( + ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + /> + ); + + expect( + instance.find('[data-test-subj="lns_metric_value"]').first().prop('style') + ).not.toEqual( + expect.objectContaining({ + color: expect.any(String), + }) + ); + }); + + test('it renders no color styling for numeric value if value is lower than rangeMin and continuity is "none"', () => { + const { data, args } = sampleArgs(); + + data.tables.l1.rows[0].c = -1; + args.colorMode = ColorMode.Labels; + args.palette.params = { + rangeMin: 0, + rangeMax: 400, + stops: [100, 200, 400], + gradient: false, + range: 'number', + colors: ['red', 'yellow', 'green'], + continuity: 'none', + }; + + const instance = shallow( + ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + /> + ); + + expect( + instance.find('[data-test-subj="lns_metric_value"]').first().prop('style') + ).not.toEqual( + expect.objectContaining({ + color: expect.any(String), + }) + ); + }); + + test('it renders the color styling for numeric value if value is higher than rangeMax and continuity is "all"', () => { + const { data, args } = sampleArgs(); + + data.tables.l1.rows[0].c = 500; + args.colorMode = ColorMode.Labels; + args.palette.params = { + rangeMin: 0, + rangeMax: 400, + stops: [100, 200, 400], + gradient: false, + range: 'number', + colors: ['red', 'yellow', 'green'], + continuity: 'all', + }; + + const instance = shallow( + ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + /> + ); + + expect(instance.find('[data-test-subj="lns_metric_value"]').first().prop('style')).toEqual( + expect.objectContaining({ + color: 'green', + }) + ); + }); + + test('it renders the color styling for numeric value if value is lower than rangeMin and continuity is "all"', () => { + const { data, args } = sampleArgs(); + + data.tables.l1.rows[0].c = -1; + args.colorMode = ColorMode.Labels; + args.palette.params = { + rangeMin: 0, + rangeMax: 400, + stops: [100, 200, 400], + gradient: false, + range: 'number', + colors: ['red', 'yellow', 'green'], + continuity: 'all', + }; + + const instance = shallow( + ({ convert: (x) => x } as IFieldFormat)} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + /> + ); + + expect(instance.find('[data-test-subj="lns_metric_value"]').first().prop('style')).toEqual( + expect.objectContaining({ + color: 'red', + }) + ); + }); }); }); diff --git a/x-pack/plugins/lens/public/metric_visualization/expression.tsx b/x-pack/plugins/lens/public/metric_visualization/expression.tsx index 6ec9e94bde58..fd4b4f20c5c5 100644 --- a/x-pack/plugins/lens/public/metric_visualization/expression.tsx +++ b/x-pack/plugins/lens/public/metric_visualization/expression.tsx @@ -9,20 +9,27 @@ import './expression.scss'; import { I18nProvider } from '@kbn/i18n/react'; import React from 'react'; import ReactDOM from 'react-dom'; +import { IUiSettingsClient } from 'kibana/public'; import type { ExpressionRenderDefinition, IInterpreterRenderHandlers, } from '../../../../../src/plugins/expressions/public'; +import { + ColorMode, + CustomPaletteState, + PaletteOutput, +} from '../../../../../src/plugins/charts/public'; import { AutoScale } from './auto_scale'; import { VisualizationContainer } from '../visualization_container'; -import { EmptyPlaceholder } from '../shared_components'; +import { EmptyPlaceholder, getContrastColor } from '../shared_components'; import { LensIconChartMetric } from '../assets/chart_metric'; import type { FormatFactory } from '../../common'; import type { MetricChartProps } from '../../common/expressions'; export type { MetricChartProps, MetricState, MetricConfig } from '../../common/expressions'; export const getMetricChartRenderer = ( - formatFactory: FormatFactory + formatFactory: FormatFactory, + uiSettings: IUiSettingsClient ): ExpressionRenderDefinition => ({ name: 'lens_metric_chart_renderer', displayName: 'Metric chart', @@ -32,7 +39,7 @@ export const getMetricChartRenderer = ( render: (domNode: Element, config: MetricChartProps, handlers: IInterpreterRenderHandlers) => { ReactDOM.render( - + , domNode, () => { @@ -43,12 +50,61 @@ export const getMetricChartRenderer = ( }, }); +function getColorStyling( + value: number, + colorMode: ColorMode, + palette: PaletteOutput | undefined, + isDarkTheme: boolean +) { + if ( + colorMode === ColorMode.None || + !palette?.params || + !palette?.params.colors?.length || + isNaN(value) + ) { + return {}; + } + + const { continuity = 'above', rangeMin, stops, colors } = palette.params; + const penultimateStop = stops[stops.length - 2]; + + if (continuity === 'none' && (value < rangeMin || value > penultimateStop)) { + return {}; + } + if (continuity === 'below' && value > penultimateStop) { + return {}; + } + if (continuity === 'above' && value < rangeMin) { + return {}; + } + const cssProp = colorMode === ColorMode.Background ? 'backgroundColor' : 'color'; + const rawIndex = stops.findIndex((v) => v > value); + + let colorIndex = rawIndex; + if (['all', 'below'].includes(continuity) && value < rangeMin && colorIndex < 0) { + colorIndex = 0; + } + if (['all', 'above'].includes(continuity) && value > penultimateStop && colorIndex < 0) { + colorIndex = stops.length - 1; + } + + const color = colors[colorIndex]; + const styling = { + [cssProp]: color, + }; + if (colorMode === ColorMode.Background && color) { + styling.color = getContrastColor(color, isDarkTheme); + } + return styling; +} + export function MetricChart({ data, args, formatFactory, -}: MetricChartProps & { formatFactory: FormatFactory }) { - const { metricTitle, accessor, mode } = args; + uiSettings, +}: MetricChartProps & { formatFactory: FormatFactory; uiSettings: IUiSettingsClient }) { + const { metricTitle, accessor, mode, colorMode, palette } = args; const firstTable = Object.values(data.tables)[0]; const getEmptyState = () => ( @@ -66,27 +122,29 @@ export function MetricChart({ if (!column || !row) { return getEmptyState(); } + const rawValue = row[accessor]; // NOTE: Cardinality and Sum never receives "null" as value, but always 0, even for empty dataset. // Mind falsy values here as 0! - const shouldShowResults = row[accessor] != null; - if (!shouldShowResults) { + if (!['number', 'string'].includes(typeof rawValue)) { return getEmptyState(); } const value = column && column.meta?.params - ? formatFactory(column.meta?.params).convert(row[accessor]) - : Number(Number(row[accessor]).toFixed(3)).toString(); + ? formatFactory(column.meta?.params).convert(rawValue) + : Number(Number(rawValue).toFixed(3)).toString(); + + const color = getColorStyling(rawValue, colorMode, palette, uiSettings.get('theme:darkMode')); return ( -
+
{value}
{mode === 'full' && ( -
+
{metricTitle}
)} diff --git a/x-pack/plugins/lens/public/metric_visualization/index.ts b/x-pack/plugins/lens/public/metric_visualization/index.ts index 20c25b285bd5..bff5f71f8ba1 100644 --- a/x-pack/plugins/lens/public/metric_visualization/index.ts +++ b/x-pack/plugins/lens/public/metric_visualization/index.ts @@ -7,6 +7,7 @@ import type { CoreSetup } from 'kibana/public'; import type { ExpressionsSetup } from '../../../../../src/plugins/expressions/public'; +import type { ChartsPluginSetup } from '../../../../../src/plugins/charts/public'; import type { EditorFrameSetup } from '../types'; import type { FormatFactory } from '../../common'; @@ -14,18 +15,20 @@ export interface MetricVisualizationPluginSetupPlugins { expressions: ExpressionsSetup; formatFactory: FormatFactory; editorFrame: EditorFrameSetup; + charts: ChartsPluginSetup; } export class MetricVisualization { setup( - _core: CoreSetup | null, - { expressions, formatFactory, editorFrame }: MetricVisualizationPluginSetupPlugins + core: CoreSetup, + { expressions, formatFactory, editorFrame, charts }: MetricVisualizationPluginSetupPlugins ) { editorFrame.registerVisualization(async () => { - const { metricVisualization, getMetricChartRenderer } = await import('../async_services'); + const { getMetricVisualization, getMetricChartRenderer } = await import('../async_services'); + const palettes = await charts.palettes.getPalettes(); - expressions.registerRenderer(() => getMetricChartRenderer(formatFactory)); - return metricVisualization; + expressions.registerRenderer(() => getMetricChartRenderer(formatFactory, core.uiSettings)); + return getMetricVisualization({ paletteService: palettes }); }); } } diff --git a/x-pack/plugins/lens/public/metric_visualization/palette_config.tsx b/x-pack/plugins/lens/public/metric_visualization/palette_config.tsx new file mode 100644 index 000000000000..59147a33963d --- /dev/null +++ b/x-pack/plugins/lens/public/metric_visualization/palette_config.tsx @@ -0,0 +1,18 @@ +/* + * 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. + */ + +import { RequiredPaletteParamTypes } from '../../common'; +import { defaultPaletteParams as sharedDefaultParams } from '../shared_components/'; + +export const DEFAULT_PALETTE_NAME = 'status'; +export const DEFAULT_COLOR_STEPS = 3; +export const defaultPaletteParams: RequiredPaletteParamTypes = { + ...sharedDefaultParams, + name: DEFAULT_PALETTE_NAME, + rangeType: 'number', + steps: DEFAULT_COLOR_STEPS, +}; diff --git a/x-pack/plugins/lens/public/metric_visualization/visualization.test.ts b/x-pack/plugins/lens/public/metric_visualization/visualization.test.ts index ef9d7959ed10..889b711739fb 100644 --- a/x-pack/plugins/lens/public/metric_visualization/visualization.test.ts +++ b/x-pack/plugins/lens/public/metric_visualization/visualization.test.ts @@ -5,12 +5,14 @@ * 2.0. */ -import { metricVisualization } from './visualization'; +import { getMetricVisualization } from './visualization'; import { MetricState } from '../../common/expressions'; import { layerTypes } from '../../common'; import { createMockDatasource, createMockFramePublicAPI } from '../mocks'; import { generateId } from '../id_generator'; import { DatasourcePublicAPI, FramePublicAPI } from '../types'; +import { chartPluginMock } from 'src/plugins/charts/public/mocks'; +import { ColorMode } from 'src/plugins/charts/common'; jest.mock('../id_generator'); @@ -32,6 +34,10 @@ function mockFrame(): FramePublicAPI { }; } +const metricVisualization = getMetricVisualization({ + paletteService: chartPluginMock.createPaletteRegistry(), +}); + describe('metric_visualization', () => { describe('#initialize', () => { it('loads default state', () => { @@ -110,6 +116,54 @@ describe('metric_visualization', () => { ], }); }); + + it('should show the palette when metric has coloring enabled', () => { + expect( + metricVisualization.getConfiguration({ + state: { + accessor: 'a', + layerId: 'l1', + layerType: layerTypes.DATA, + palette: { + type: 'palette', + name: 'status', + }, + }, + layerId: 'l1', + frame: mockFrame(), + }) + ).toEqual({ + groups: [ + expect.objectContaining({ + accessors: expect.arrayContaining([ + { columnId: 'a', triggerIcon: 'colorBy', palette: [] }, + ]), + }), + ], + }); + }); + + it('should not show the palette when not enabled', () => { + expect( + metricVisualization.getConfiguration({ + state: { + accessor: 'a', + layerId: 'l1', + layerType: layerTypes.DATA, + }, + layerId: 'l1', + frame: mockFrame(), + }) + ).toEqual({ + groups: [ + expect.objectContaining({ + accessors: expect.arrayContaining([ + { columnId: 'a', triggerIcon: undefined, palette: undefined }, + ]), + }), + ], + }); + }); }); describe('#setDimension', () => { @@ -151,6 +205,41 @@ describe('metric_visualization', () => { accessor: undefined, layerId: 'l1', layerType: layerTypes.DATA, + colorMode: ColorMode.None, + palette: undefined, + }); + }); + + it('removes the palette configuration', () => { + expect( + metricVisualization.removeDimension({ + prevState: { + accessor: 'a', + layerId: 'l1', + layerType: layerTypes.DATA, + colorMode: ColorMode.Background, + palette: { + type: 'palette', + name: 'status', + params: { + rangeType: 'number', + stops: [ + { color: 'blue', stop: 100 }, + { color: 'red', stop: 150 }, + ], + }, + }, + }, + layerId: 'l1', + columnId: 'a', + frame: mockFrame(), + }) + ).toEqual({ + accessor: undefined, + layerId: 'l1', + layerType: layerTypes.DATA, + colorMode: ColorMode.None, + palette: undefined, }); }); }); @@ -196,6 +285,9 @@ describe('metric_visualization', () => { "accessor": Array [ "a", ], + "colorMode": Array [ + "None", + ], "description": Array [ "", ], @@ -205,6 +297,7 @@ describe('metric_visualization', () => { "mode": Array [ "full", ], + "palette": Array [], "title": Array [ "", ], diff --git a/x-pack/plugins/lens/public/metric_visualization/visualization.tsx b/x-pack/plugins/lens/public/metric_visualization/visualization.tsx index 5693d67546f9..63da7c4b4431 100644 --- a/x-pack/plugins/lens/public/metric_visualization/visualization.tsx +++ b/x-pack/plugins/lens/public/metric_visualization/visualization.tsx @@ -5,18 +5,26 @@ * 2.0. */ +import React from 'react'; import { i18n } from '@kbn/i18n'; +import { I18nProvider } from '@kbn/i18n/react'; +import { render } from 'react-dom'; import { Ast } from '@kbn/interpreter/common'; +import { ColorMode } from '../../../../../src/plugins/charts/common'; +import { PaletteRegistry } from '../../../../../src/plugins/charts/public'; import { getSuggestions } from './metric_suggestions'; import { LensIconChartMetric } from '../assets/chart_metric'; import { Visualization, OperationMetadata, DatasourcePublicAPI } from '../types'; -import type { MetricState } from '../../common/expressions'; +import type { MetricConfig, MetricState } from '../../common/expressions'; import { layerTypes } from '../../common'; +import { CUSTOM_PALETTE, getStopsForFixedMode, shiftPalette } from '../shared_components'; +import { MetricDimensionEditor } from './dimension_editor'; const toExpression = ( + paletteService: PaletteRegistry, state: MetricState, datasourceLayers: Record, - attributes?: { mode?: 'reduced' | 'full'; title?: string; description?: string } + attributes?: Partial> ): Ast | null => { if (!state.accessor) { return null; @@ -25,6 +33,22 @@ const toExpression = ( const [datasource] = Object.values(datasourceLayers); const operation = datasource && datasource.getOperationForColumnId(state.accessor); + const stops = state.palette?.params?.stops || []; + const isCustomPalette = state.palette?.params?.name === CUSTOM_PALETTE; + + const paletteParams = { + ...state.palette?.params, + colors: stops.map(({ color }) => color), + stops: + isCustomPalette || state.palette?.params?.rangeMax == null + ? stops.map(({ stop }) => stop) + : shiftPalette( + stops, + Math.max(state.palette?.params?.rangeMax, ...stops.map(({ stop }) => stop)) + ).map(({ stop }) => stop), + reverse: false, + }; + return { type: 'expression', chain: [ @@ -34,16 +58,24 @@ const toExpression = ( arguments: { title: [attributes?.title || ''], description: [attributes?.description || ''], - metricTitle: [(operation && operation.label) || ''], + metricTitle: [operation?.label || ''], accessor: [state.accessor], mode: [attributes?.mode || 'full'], + colorMode: [state?.colorMode || ColorMode.None], + palette: + state?.colorMode && state?.colorMode !== ColorMode.None + ? [paletteService.get(CUSTOM_PALETTE).toExpression(paletteParams)] + : [], }, }, ], }; }; - -export const metricVisualization: Visualization = { +export const getMetricVisualization = ({ + paletteService, +}: { + paletteService: PaletteRegistry; +}): Visualization => ({ id: 'lnsMetric', visualizationTypes: [ @@ -97,15 +129,30 @@ export const metricVisualization: Visualization = { }, getConfiguration(props) { + const hasColoring = props.state.palette != null; + const stops = props.state.palette?.params?.stops || []; return { groups: [ { groupId: 'metric', groupLabel: i18n.translate('xpack.lens.metric.label', { defaultMessage: 'Metric' }), layerId: props.state.layerId, - accessors: props.state.accessor ? [{ columnId: props.state.accessor }] : [], + accessors: props.state.accessor + ? [ + { + columnId: props.state.accessor, + triggerIcon: hasColoring ? 'colorBy' : undefined, + palette: hasColoring + ? props.state.palette?.params?.name === CUSTOM_PALETTE + ? getStopsForFixedMode(stops, props.state.palette?.params.colorStops) + : stops.map(({ color }) => color) + : undefined, + }, + ] + : [], supportsMoreColumns: !props.state.accessor, filterOperations: (op: OperationMetadata) => !op.isBucketed && op.dataType === 'number', + enableDimensionEditor: true, required: true, }, ], @@ -129,20 +176,30 @@ export const metricVisualization: Visualization = { } }, - toExpression, + toExpression: (state, datasourceLayers, attributes) => + toExpression(paletteService, state, datasourceLayers, { ...attributes }), toPreviewExpression: (state, datasourceLayers) => - toExpression(state, datasourceLayers, { mode: 'reduced' }), + toExpression(paletteService, state, datasourceLayers, { mode: 'reduced' }), setDimension({ prevState, columnId }) { return { ...prevState, accessor: columnId }; }, removeDimension({ prevState }) { - return { ...prevState, accessor: undefined }; + return { ...prevState, accessor: undefined, colorMode: ColorMode.None, palette: undefined }; + }, + + renderDimensionEditor(domElement, props) { + render( + + + , + domElement + ); }, getErrorMessages(state) { // Is it possible to break it? return undefined; }, -}; +}); diff --git a/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.test.tsx b/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.test.tsx index 120975b5f385..0840c19495ea 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.test.tsx +++ b/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.test.tsx @@ -257,6 +257,17 @@ describe('palette panel', () => { }) ); }); + + it('should not render the switch disabled from props', () => { + const instance = mountWithIntl( + + ); + expect( + instance + .find('[data-test-subj="lnsPalettePanel_dynamicColoring_custom_range_groups"]') + .exists() + ).toBe(false); + }); }); describe('custom stops', () => { diff --git a/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.tsx b/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.tsx index 0493a212f46d..d1f1bc813dea 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.tsx +++ b/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.tsx @@ -73,12 +73,14 @@ export function CustomizablePalette({ setPalette, dataBounds, showContinuity = true, + showRangeTypeSelector = true, }: { palettes: PaletteRegistry; activePalette?: PaletteOutput; setPalette: (palette: PaletteOutput) => void; dataBounds?: { min: number; max: number }; showContinuity?: boolean; + showRangeTypeSelector?: boolean; }) { if (!dataBounds || !activePalette) { return null; @@ -218,98 +220,100 @@ export function CustomizablePalette({ /> )} - - {i18n.translate('xpack.lens.table.dynamicColoring.rangeType.label', { - defaultMessage: 'Value type', - })}{' '} - - - } - display="rowCompressed" - > - + {i18n.translate('xpack.lens.table.dynamicColoring.rangeType.label', { + defaultMessage: 'Value type', + })}{' '} + + } - onChange={(id) => { - const newRangeType = id.replace( - idPrefix, - '' - ) as RequiredPaletteParamTypes['rangeType']; + display="rowCompressed" + > + { + const newRangeType = id.replace( + idPrefix, + '' + ) as RequiredPaletteParamTypes['rangeType']; - const params: CustomPaletteParams = { rangeType: newRangeType }; - const { min: newMin, max: newMax } = getDataMinMax(newRangeType, dataBounds); - const { min: oldMin, max: oldMax } = getDataMinMax( - activePalette.params?.rangeType, - dataBounds - ); - const newColorStops = remapStopsByNewInterval(colorStopsToShow, { - oldInterval: oldMax - oldMin, - newInterval: newMax - newMin, - newMin, - oldMin, - }); - if (isCurrentPaletteCustom) { - const stops = getPaletteStops( - palettes, - { ...activePalette.params, colorStops: newColorStops, ...params }, - { dataBounds } - ); - params.colorStops = newColorStops; - params.stops = stops; - } else { - params.stops = getPaletteStops( - palettes, - { ...activePalette.params, ...params }, - { prevPalette: activePalette.name, dataBounds } + const params: CustomPaletteParams = { rangeType: newRangeType }; + const { min: newMin, max: newMax } = getDataMinMax(newRangeType, dataBounds); + const { min: oldMin, max: oldMax } = getDataMinMax( + activePalette.params?.rangeType, + dataBounds ); - } - // why not use newMin/newMax here? - // That's because there's the concept of continuity to accomodate, where in some scenarios it has to - // take into account the stop value rather than the data value - params.rangeMin = newColorStops[0].stop; - params.rangeMax = newColorStops[newColorStops.length - 1].stop; - setPalette(mergePaletteParams(activePalette, params)); - }} - /> - + const newColorStops = remapStopsByNewInterval(colorStopsToShow, { + oldInterval: oldMax - oldMin, + newInterval: newMax - newMin, + newMin, + oldMin, + }); + if (isCurrentPaletteCustom) { + const stops = getPaletteStops( + palettes, + { ...activePalette.params, colorStops: newColorStops, ...params }, + { dataBounds } + ); + params.colorStops = newColorStops; + params.stops = stops; + } else { + params.stops = getPaletteStops( + palettes, + { ...activePalette.params, ...params }, + { prevPalette: activePalette.name, dataBounds } + ); + } + // why not use newMin/newMax here? + // That's because there's the concept of continuity to accomodate, where in some scenarios it has to + // take into account the stop value rather than the data value + params.rangeMin = newColorStops[0].stop; + params.rangeMax = newColorStops[newColorStops.length - 1].stop; + setPalette(mergePaletteParams(activePalette, params)); + }} + /> + + )} diff --git a/x-pack/plugins/lens/public/shared_components/coloring/palette_picker.tsx b/x-pack/plugins/lens/public/shared_components/coloring/palette_picker.tsx index b21b732820ea..19da4eef2996 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/palette_picker.tsx +++ b/x-pack/plugins/lens/public/shared_components/coloring/palette_picker.tsx @@ -27,7 +27,10 @@ function getCustomPaletteConfig( if (activePalette && activePalette.name !== CUSTOM_PALETTE) { const currentPalette = palettes.get(activePalette.name); if (currentPalette) { - const stops = currentPalette.getCategoricalColors(DEFAULT_COLOR_STEPS, activePalette?.params); + const stops = currentPalette.getCategoricalColors( + activePalette?.params?.steps || DEFAULT_COLOR_STEPS, + activePalette?.params + ); const palette = activePalette.params?.reverse ? stops.reverse() : stops; return { value: id, @@ -76,7 +79,7 @@ export function PalettePicker({ ) .map(({ id, title, getCategoricalColors }) => { const colors = getCategoricalColors( - DEFAULT_COLOR_STEPS, + activePalette?.params?.steps || DEFAULT_COLOR_STEPS, id === activePalette?.name ? activePalette?.params : undefined ); return { diff --git a/x-pack/plugins/lens/public/shared_components/coloring/utils.ts b/x-pack/plugins/lens/public/shared_components/coloring/utils.ts index 182e502563cd..6b61b4e568cf 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/utils.ts +++ b/x-pack/plugins/lens/public/shared_components/coloring/utils.ts @@ -42,19 +42,19 @@ export function applyPaletteParams> dataBounds: { min: number; max: number } ) { // make a copy of it as they have to be manipulated later on - let displayStops = getPaletteStops(palettes, activePalette?.params || {}, { + const displayStops = getPaletteStops(palettes, activePalette?.params || {}, { dataBounds, defaultPaletteName: activePalette?.name, }); if (activePalette?.params?.reverse && activePalette?.params?.name !== CUSTOM_PALETTE) { - displayStops = reversePalette(displayStops); + return reversePalette(displayStops); } return displayStops; } // Need to shift the Custom palette in order to correctly visualize it when in display mode -function shiftPalette(stops: ColorStop[], max: number) { +export function shiftPalette(stops: ColorStop[], max: number) { // shift everything right and add an additional stop at the end const result = stops.map((entry, i, array) => ({ ...entry, @@ -136,14 +136,16 @@ export function getPaletteStops( // need to generate the palette from the existing controlStops return shiftPalette(activePaletteParams.colorStops, maxValue); } + + const steps = activePaletteParams?.steps || defaultPaletteParams.steps; // generate a palette from predefined ones and customize the domain const colorStopsFromPredefined = palettes .get( prevPalette || activePaletteParams?.name || defaultPaletteName || defaultPaletteParams.name ) - .getCategoricalColors(defaultPaletteParams.steps, otherParams); + .getCategoricalColors(steps, otherParams); - const newStopsMin = mapFromMinValue ? minValue : interval / defaultPaletteParams.steps; + const newStopsMin = mapFromMinValue ? minValue : interval / steps; const stops = remapStopsByNewInterval( colorStopsFromPredefined.map((color, index) => ({ color, stop: index })), @@ -198,7 +200,8 @@ export function isValidColor(colorString: string) { export function roundStopValues(colorStops: ColorStop[]) { return colorStops.map(({ color, stop }) => { - const roundedStop = Number(stop.toFixed(2)); + // when rounding mind to not go in excess, rather use the floor function + const roundedStop = Number((Math.floor(stop * 100) / 100).toFixed(2)); return { color, stop: roundedStop }; }); } diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/builder.stories.tsx b/x-pack/plugins/lists/public/exceptions/components/builder/builder.stories.tsx index 73b7fe53b1cc..5fcb8270c33a 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/builder.stories.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/builder/builder.stories.tsx @@ -9,7 +9,7 @@ import { Story, addDecorator } from '@storybook/react'; import React from 'react'; import { HttpStart } from 'kibana/public'; -import { AutocompleteStart } from '../../../../../../../src/plugins/data/public'; +import type { AutocompleteStart } from '../../../../../../../src/plugins/data/public'; import { EuiThemeProvider } from '../../../../../../../src/plugins/kibana_react/common'; import { fields, getField } from '../../../../../../../src/plugins/data/common/mocks'; import { getEntryMatchAnyMock } from '../../../../common/schemas/types/entry_match_any.mock'; diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.stories.tsx b/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.stories.tsx index b1357f35d140..b0a32df8b4d0 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.stories.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.stories.tsx @@ -14,7 +14,7 @@ import { ListOperatorTypeEnum as OperatorTypeEnum, } from '@kbn/securitysolution-io-ts-list-types'; -import { AutocompleteStart } from '../../../../../../../src/plugins/data/public'; +import type { AutocompleteStart } from '../../../../../../../src/plugins/data/public'; import { fields } from '../../../../../../../src/plugins/data/common/mocks'; import { EuiThemeProvider } from '../../../../../../../src/plugins/kibana_react/common'; diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.test.tsx b/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.test.tsx index a06115c97022..1ac35608f884 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.test.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.test.tsx @@ -20,7 +20,7 @@ import { isOperator, } from '@kbn/securitysolution-list-utils'; import { useFindLists } from '@kbn/securitysolution-list-hooks'; -import { FieldSpec } from 'src/plugins/data/common'; +import type { FieldSpec } from 'src/plugins/data/common'; import { fields, getField } from '../../../../../../../src/plugins/data/common/mocks'; import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks'; diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.tsx b/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.tsx index e2650b9c8cfb..88a83b354cf8 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.tsx @@ -37,7 +37,7 @@ import { } from '@kbn/securitysolution-autocomplete'; import { IndexPatternBase, IndexPatternFieldBase } from '@kbn/es-query'; -import { AutocompleteStart } from '../../../../../../../src/plugins/data/public'; +import type { AutocompleteStart } from '../../../../../../../src/plugins/data/public'; import { HttpStart } from '../../../../../../../src/core/public'; import { getEmptyValue } from '../../../common/empty_value'; diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/exception_item_renderer.tsx b/x-pack/plugins/lists/public/exceptions/components/builder/exception_item_renderer.tsx index 4b3f094aa4f2..708543ac8888 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/exception_item_renderer.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/builder/exception_item_renderer.tsx @@ -9,7 +9,7 @@ import React, { useCallback, useMemo } from 'react'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import styled from 'styled-components'; import { HttpStart } from 'kibana/public'; -import { AutocompleteStart } from 'src/plugins/data/public'; +import type { AutocompleteStart } from 'src/plugins/data/public'; import { ExceptionListType, OsTypeArray } from '@kbn/securitysolution-io-ts-list-types'; import { BuilderEntry, diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/exception_items_renderer.tsx b/x-pack/plugins/lists/public/exceptions/components/builder/exception_items_renderer.tsx index 280dd8acbc7e..064d227c6f3d 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/exception_items_renderer.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/builder/exception_items_renderer.tsx @@ -33,7 +33,7 @@ import { } from '@kbn/securitysolution-list-utils'; import { IndexPatternBase } from '@kbn/es-query'; -import { AutocompleteStart } from '../../../../../../../src/plugins/data/public'; +import type { AutocompleteStart } from '../../../../../../../src/plugins/data/public'; import { AndOrBadge } from '../and_or_badge'; import { BuilderExceptionListItemComponent } from './exception_item_renderer'; diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/helpers.test.ts b/x-pack/plugins/lists/public/exceptions/components/builder/helpers.test.ts index fab49453958d..43d392b40e9f 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/helpers.test.ts +++ b/x-pack/plugins/lists/public/exceptions/components/builder/helpers.test.ts @@ -58,7 +58,7 @@ import { ENTRIES_WITH_IDS } from '../../../../common/constants.mock'; import { getEntryExistsMock } from '../../../../common/schemas/types/entry_exists.mock'; import { getExceptionListItemSchemaMock } from '../../../../common/schemas/response/exception_list_item_schema.mock'; import { fields, getField } from '../../../../../../../src/plugins/data/common/mocks'; -import { FieldSpec } from '../../../../../../../src/plugins/data/common'; +import type { FieldSpec } from '../../../../../../../src/plugins/data/common'; import { getEntryNestedMock } from '../../../../common/schemas/types/entry_nested.mock'; import { getEntryMatchMock } from '../../../../common/schemas/types/entry_match.mock'; import { getEntryMatchAnyMock } from '../../../../common/schemas/types/entry_match_any.mock'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_items_by_list.ts b/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_items_by_list.ts index 23c389f2a533..873fe66b1ad3 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_items_by_list.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_items_by_list.ts @@ -9,7 +9,7 @@ import type { ListId, NamespaceType } from '@kbn/securitysolution-io-ts-list-typ import { getSavedObjectType } from '@kbn/securitysolution-list-utils'; import { asyncForEach } from '@kbn/std'; -import { SavedObjectsClientContract } from '../../../../../../src/core/server/'; +import { SavedObjectsClientContract } from '../../../../../../src/core/server'; import { findExceptionListItem } from './find_exception_list_item'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/get_exception_list.ts b/x-pack/plugins/lists/server/services/exception_lists/get_exception_list.ts index 2b09642f59c9..b0b66ffb70d7 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/get_exception_list.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/get_exception_list.ts @@ -16,7 +16,7 @@ import { getSavedObjectType } from '@kbn/securitysolution-list-utils'; import { SavedObjectsClientContract, SavedObjectsErrorHelpers, -} from '../../../../../../src/core/server/'; +} from '../../../../../../src/core/server'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { transformSavedObjectToExceptionList } from './utils'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_item.ts b/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_item.ts index ef825b4cf5e3..12580af8a1d0 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_item.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_item.ts @@ -16,7 +16,7 @@ import { getSavedObjectType } from '@kbn/securitysolution-list-utils'; import { SavedObjectsClientContract, SavedObjectsErrorHelpers, -} from '../../../../../../src/core/server/'; +} from '../../../../../../src/core/server'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { transformSavedObjectToExceptionListItem } from './utils'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_summary.ts b/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_summary.ts index f5722ea26ccf..272fd70bcb32 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_summary.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_summary.ts @@ -16,7 +16,7 @@ import { getSavedObjectType } from '@kbn/securitysolution-list-utils'; import { SavedObjectsClientContract, SavedObjectsErrorHelpers, -} from '../../../../../../src/core/server/'; +} from '../../../../../../src/core/server'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; interface GetExceptionListSummaryOptions { diff --git a/x-pack/plugins/observability/kibana.json b/x-pack/plugins/observability/kibana.json index 822e0cf9efe7..343e16f4a409 100644 --- a/x-pack/plugins/observability/kibana.json +++ b/x-pack/plugins/observability/kibana.json @@ -11,6 +11,7 @@ "observability" ], "optionalPlugins": [ + "discover", "embeddable", "home", "lens", diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts index 56e6cb521035..7eab266ea35d 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts @@ -5,10 +5,15 @@ * 2.0. */ import rison, { RisonValue } from 'rison-node'; +import { buildQueryFilter } from '@kbn/es-query'; import type { ReportViewType, SeriesUrl, UrlFilter } from '../types'; import type { AllSeries, AllShortSeries } from '../hooks/use_series_storage'; import { IndexPattern } from '../../../../../../../../src/plugins/data/common'; -import { esFilters, ExistsFilter } from '../../../../../../../../src/plugins/data/public'; +import { + esFilters, + ExistsFilter, + PhraseFilter, +} from '../../../../../../../../src/plugins/data/public'; import { URL_KEYS } from './constants/url_constants'; import { PersistableFilter } from '../../../../../../lens/common'; @@ -64,9 +69,32 @@ export function buildPhraseFilter(field: string, value: string, indexPattern: In return []; } +export function getQueryFilter(field: string, value: string[], indexPattern: IndexPattern) { + const fieldMeta = indexPattern?.fields.find((fieldT) => fieldT.name === field); + if (fieldMeta && indexPattern.id) { + return value.map((val) => + buildQueryFilter( + { + query_string: { + fields: [field], + query: `*${val}*`, + }, + }, + indexPattern.id!, + '' + ) + ); + } + + return []; +} + export function buildPhrasesFilter(field: string, value: string[], indexPattern: IndexPattern) { const fieldMeta = indexPattern?.fields.find((fieldT) => fieldT.name === field); if (fieldMeta) { + if (value.length === 1) { + return [esFilters.buildPhraseFilter(fieldMeta, value[0], indexPattern)]; + } return [esFilters.buildPhrasesFilter(fieldMeta, value, indexPattern)]; } return []; @@ -80,7 +108,7 @@ export function buildExistsFilter(field: string, indexPattern: IndexPattern) { return []; } -type FiltersType = PersistableFilter[] | ExistsFilter[]; +type FiltersType = Array; export function urlFilterToPersistedFilter({ urlFilters, @@ -88,23 +116,36 @@ export function urlFilterToPersistedFilter({ indexPattern, }: { urlFilters: UrlFilter[]; - initFilters: FiltersType; + initFilters?: FiltersType; indexPattern: IndexPattern; }) { const parsedFilters: FiltersType = initFilters ? [...initFilters] : []; - urlFilters.forEach(({ field, values = [], notValues = [] }) => { - if (values?.length > 0) { - const filter = buildPhrasesFilter(field, values, indexPattern); - parsedFilters.push(...filter); - } + urlFilters.forEach( + ({ field, values = [], notValues = [], wildcards = [], notWildcards = ([] = []) }) => { + if (values.length > 0) { + const filter = buildPhrasesFilter(field, values, indexPattern); + parsedFilters.push(...filter); + } + + if (notValues.length > 0) { + const filter = buildPhrasesFilter(field, notValues, indexPattern)[0]; + filter.meta.negate = true; + parsedFilters.push(filter); + } - if (notValues?.length > 0) { - const filter = buildPhrasesFilter(field, notValues, indexPattern)[0]; - filter.meta.negate = true; - parsedFilters.push(filter); + if (wildcards.length > 0) { + const filter = getQueryFilter(field, wildcards, indexPattern); + parsedFilters.push(...filter); + } + + if (notWildcards.length > 0) { + const filter = getQueryFilter(field, notWildcards, indexPattern)[0]; + filter.meta.negate = true; + parsedFilters.push(filter); + } } - }); + ); return parsedFilters; } diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/hooks/use_discover_link.tsx b/x-pack/plugins/observability/public/components/shared/exploratory_view/hooks/use_discover_link.tsx index 4f19a8131f66..03396ffef9d8 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/hooks/use_discover_link.tsx +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/hooks/use_discover_link.tsx @@ -9,7 +9,7 @@ import { useCallback, useEffect, useState } from 'react'; import { useKibana } from '../../../../utils/kibana_react'; import { SeriesConfig, SeriesUrl } from '../types'; import { useAppIndexPatternContext } from './use_app_index_pattern'; -import { buildExistsFilter, buildPhraseFilter, buildPhrasesFilter } from '../configurations/utils'; +import { buildExistsFilter, urlFilterToPersistedFilter } from '../configurations/utils'; import { getFiltersFromDefs } from './use_lens_attributes'; import { RECORDS_FIELD, RECORDS_PERCENTAGE_FIELD } from '../configurations/constants'; @@ -32,42 +32,42 @@ export const useDiscoverLink = ({ series, seriesConfig }: UseDiscoverLink) => { useEffect(() => { const indexPattern = indexPatterns?.[series.dataType]; - const definitions = series.reportDefinitions ?? {}; - const filters = [...(seriesConfig?.baseFilters ?? [])]; + if (indexPattern) { + const definitions = series.reportDefinitions ?? {}; - const definitionFilters = getFiltersFromDefs(definitions); + const urlFilters = (series.filters ?? []).concat(getFiltersFromDefs(definitions)); - definitionFilters.forEach(({ field, values = [] }) => { - if (values.length > 1) { - filters.push(buildPhrasesFilter(field, values, indexPattern)[0]); - } else { - filters.push(buildPhraseFilter(field, values[0], indexPattern)[0]); - } - }); + const filters = urlFilterToPersistedFilter({ + indexPattern, + urlFilters, + initFilters: seriesConfig?.baseFilters, + }); - const selectedMetricField = series.selectedMetricField; + const selectedMetricField = series.selectedMetricField; - if ( - selectedMetricField && - selectedMetricField !== RECORDS_FIELD && - selectedMetricField !== RECORDS_PERCENTAGE_FIELD - ) { - filters.push(buildExistsFilter(selectedMetricField, indexPattern)[0]); - } + if ( + selectedMetricField && + selectedMetricField !== RECORDS_FIELD && + selectedMetricField !== RECORDS_PERCENTAGE_FIELD + ) { + filters.push(buildExistsFilter(selectedMetricField, indexPattern)[0]); + } - const getDiscoverUrl = async () => { - if (!urlGenerator?.createUrl) return; + const getDiscoverUrl = async () => { + if (!urlGenerator?.createUrl) return; - const newUrl = await urlGenerator.createUrl({ - filters, - indexPatternId: indexPattern?.id, - }); - setDiscoverUrl(newUrl); - }; - getDiscoverUrl(); + const newUrl = await urlGenerator.createUrl({ + filters, + indexPatternId: indexPattern?.id, + }); + setDiscoverUrl(newUrl); + }; + getDiscoverUrl(); + } }, [ indexPatterns, series.dataType, + series.filters, series.reportDefinitions, series.selectedMetricField, seriesConfig?.baseFilters, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/report_definition_field.tsx b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/report_definition_field.tsx index f3e0eb767d33..2808dfae8352 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/report_definition_field.tsx +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/report_definition_field.tsx @@ -66,7 +66,9 @@ export function ReportDefinitionField({ const values = selectedReportDefinitions?.[fieldT]; if (!values.includes(ALL_VALUES_SELECTED)) { const valueFilter = buildPhrasesFilter(fieldT, values, indexPattern)[0]; - filtersN.push(valueFilter.query); + if (valueFilter.query) { + filtersN.push(valueFilter.query); + } } } }); diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/series_actions.tsx b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/series_actions.tsx index c1462ce74b42..640e928b8ab9 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/series_actions.tsx +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/series_actions.tsx @@ -12,6 +12,7 @@ import { RemoveSeries } from './remove_series'; import { useSeriesStorage } from '../../hooks/use_series_storage'; import { SeriesConfig, SeriesUrl } from '../../types'; import { useDiscoverLink } from '../../hooks/use_discover_link'; +import { useAppIndexPatternContext } from '../../hooks/use_app_index_pattern'; interface Props { seriesId: number; @@ -25,6 +26,10 @@ export function SeriesActions({ seriesId, series, seriesConfig, onEditClick }: P const { href: discoverHref } = useDiscoverLink({ series, seriesConfig }); + const { indexPatterns } = useAppIndexPatternContext(); + + const indexPattern = indexPatterns?.[series.dataType]; + const copySeries = () => { let copySeriesId: string = `${series.name}-copy`; if (allSeries.find(({ name }) => name === copySeriesId)) { @@ -63,7 +68,7 @@ export function SeriesActions({ seriesId, series, seriesConfig, onEditClick }: P color="text" target="_blank" href={discoverHref} - isDisabled={!series.dataType || !series.selectedMetricField} + isDisabled={!series.dataType || !series.selectedMetricField || !indexPattern} /> diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx index 922fd59c56d1..83fe807f9a3c 100644 --- a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx +++ b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx @@ -11,7 +11,7 @@ jest.mock('./api_keys_grid', () => ({ import { act } from '@testing-library/react'; -import { coreMock, scopedHistoryMock } from 'src/core/public/mocks'; +import { coreMock, scopedHistoryMock, themeServiceMock } from 'src/core/public/mocks'; import type { Unmount } from 'src/plugins/management/public/types'; import { securityMock } from '../../mocks'; @@ -52,6 +52,7 @@ describe('apiKeysManagementApp', () => { element: container, setBreadcrumbs, history: scopedHistoryMock.create(), + theme$: themeServiceMock.createTheme$(), }); }); diff --git a/x-pack/plugins/security/public/management/management_urls.ts b/x-pack/plugins/security/public/management/management_urls.ts index 4a950b2ba1a1..371de4fb7f48 100644 --- a/x-pack/plugins/security/public/management/management_urls.ts +++ b/x-pack/plugins/security/public/management/management_urls.ts @@ -9,3 +9,8 @@ export const EDIT_ROLE_MAPPING_PATH = `/edit`; export const getEditRoleMappingHref = (roleMappingName: string) => `${EDIT_ROLE_MAPPING_PATH}/${encodeURIComponent(roleMappingName)}`; + +export const CLONE_ROLE_MAPPING_PATH = `/clone`; + +export const getCloneRoleMappingHref = (roleMappingName: string) => + `${CLONE_ROLE_MAPPING_PATH}/${encodeURIComponent(roleMappingName)}`; diff --git a/x-pack/plugins/security/public/management/role_mappings/components/delete_provider/delete_provider.tsx b/x-pack/plugins/security/public/management/role_mappings/components/delete_provider/delete_provider.tsx index f9194860ddde..9130a6ba1830 100644 --- a/x-pack/plugins/security/public/management/role_mappings/components/delete_provider/delete_provider.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/components/delete_provider/delete_provider.tsx @@ -24,10 +24,12 @@ interface Props { export type DeleteRoleMappings = ( roleMappings: RoleMapping[], - onSuccess?: OnSuccessCallback + onSuccess?: OnSuccessCallback, + onCancel?: OnCancelCallback ) => void; type OnSuccessCallback = (deletedRoleMappings: string[]) => void; +type OnCancelCallback = () => void; export const DeleteProvider: React.FunctionComponent = ({ roleMappingsAPI, @@ -39,10 +41,12 @@ export const DeleteProvider: React.FunctionComponent = ({ const [isDeleteInProgress, setIsDeleteInProgress] = useState(false); const onSuccessCallback = useRef(null); + const onCancelCallback = useRef(null); const deleteRoleMappingsPrompt: DeleteRoleMappings = ( roleMappingsToDelete, - onSuccess = () => undefined + onSuccess = () => undefined, + onCancel = () => undefined ) => { if (!roleMappingsToDelete || !roleMappingsToDelete.length) { throw new Error('No Role Mappings specified for delete'); @@ -50,6 +54,7 @@ export const DeleteProvider: React.FunctionComponent = ({ setIsModalOpen(true); setRoleMappings(roleMappingsToDelete); onSuccessCallback.current = onSuccess; + onCancelCallback.current = onCancel; }; const closeModal = () => { @@ -57,6 +62,13 @@ export const DeleteProvider: React.FunctionComponent = ({ setRoleMappings([]); }; + const handleCancelModel = () => { + closeModal(); + if (onCancelCallback.current) { + onCancelCallback.current(); + } + }; + const deleteRoleMappings = async () => { let result; @@ -161,7 +173,7 @@ export const DeleteProvider: React.FunctionComponent = ({ } ) } - onCancel={closeModal} + onCancel={handleCancelModel} onConfirm={deleteRoleMappings} cancelButtonText={i18n.translate( 'xpack.security.management.roleMappings.deleteRoleMapping.confirmModal.cancelButtonLabel', diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx index b624da2cd88b..af7a2fb8d524 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx @@ -39,6 +39,7 @@ describe('EditRoleMappingPage', () => { return mountWithIntl( ; rolesAPIClient: PublicMethodsOf; @@ -295,13 +296,17 @@ export class EditRoleMappingPage extends Component { }); }; - private editingExistingRoleMapping = () => typeof this.props.name === 'string'; + private editingExistingRoleMapping = () => + typeof this.props.name === 'string' && this.props.action === 'edit'; + + private cloningExistingRoleMapping = () => + typeof this.props.name === 'string' && this.props.action === 'clone'; private async loadAppData() { try { const [features, roleMapping] = await Promise.all([ this.props.roleMappingsAPI.checkRoleMappingFeatures(), - this.editingExistingRoleMapping() + this.editingExistingRoleMapping() || this.cloningExistingRoleMapping() ? this.props.roleMappingsAPI.getRoleMapping(this.props.name!) : Promise.resolve({ name: '', @@ -327,7 +332,10 @@ export class EditRoleMappingPage extends Component { hasCompatibleRealms, canUseStoredScripts, canUseInlineScripts, - roleMapping, + roleMapping: { + ...roleMapping, + name: this.cloningExistingRoleMapping() ? '' : roleMapping.name, + }, }); } catch (e) { this.props.notifications.toasts.addDanger({ diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx index 5f237e6504d3..d9009d49b592 100644 --- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx @@ -10,7 +10,7 @@ import { act } from '@testing-library/react'; import React from 'react'; import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test/jest'; -import type { CoreStart, ScopedHistory } from 'src/core/public'; +import type { CoreStart } from 'src/core/public'; import { coreMock, scopedHistoryMock } from 'src/core/public/mocks'; import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; @@ -21,7 +21,7 @@ import { EmptyPrompt } from './empty_prompt'; import { RoleMappingsGridPage } from './role_mappings_grid_page'; describe('RoleMappingsGridPage', () => { - let history: ScopedHistory; + let history: ReturnType; let coreStart: CoreStart; const renderView = ( @@ -44,6 +44,7 @@ describe('RoleMappingsGridPage', () => { beforeEach(() => { history = scopedHistoryMock.create(); + history.createHref.mockImplementation((location) => location.pathname!); coreStart = coreMock.createStart(); }); @@ -188,6 +189,7 @@ describe('RoleMappingsGridPage', () => { expect(roleMappingsAPI.getRoleMappings).toHaveBeenCalledTimes(1); expect(roleMappingsAPI.deleteRoleMappings).not.toHaveBeenCalled(); + findTestSubject(wrapper, `euiCollapsedItemActionsButton`).simulate('click'); findTestSubject(wrapper, `deleteRoleMappingButton-some-realm`).simulate('click'); expect(findTestSubject(wrapper, 'deleteRoleMappingConfirmationModal')).toHaveLength(1); @@ -246,4 +248,55 @@ describe('RoleMappingsGridPage', () => { `"The kibana_user role is deprecated. I don't like you."` ); }); + + it('renders role mapping actions as appropriate', async () => { + const roleMappingsAPI = roleMappingsAPIClientMock.create(); + roleMappingsAPI.getRoleMappings.mockResolvedValue([ + { + name: 'some-realm', + enabled: true, + roles: ['superuser'], + rules: { field: { username: '*' } }, + }, + ]); + roleMappingsAPI.checkRoleMappingFeatures.mockResolvedValue({ + canManageRoleMappings: true, + hasCompatibleRealms: true, + }); + roleMappingsAPI.deleteRoleMappings.mockResolvedValue([ + { + name: 'some-realm', + success: true, + }, + ]); + + const wrapper = renderView(roleMappingsAPI); + await nextTick(); + wrapper.update(); + + const editButton = wrapper.find( + 'EuiButtonEmpty[data-test-subj="editRoleMappingButton-some-realm"]' + ); + expect(editButton).toHaveLength(1); + expect(editButton.prop('href')).toBe('/edit/some-realm'); + + const cloneButton = wrapper.find( + 'EuiButtonEmpty[data-test-subj="cloneRoleMappingButton-some-realm"]' + ); + expect(cloneButton).toHaveLength(1); + expect(cloneButton.prop('href')).toBe('/clone/some-realm'); + + const actionMenuButton = wrapper.find( + 'EuiButtonIcon[data-test-subj="euiCollapsedItemActionsButton"]' + ); + expect(actionMenuButton).toHaveLength(1); + + actionMenuButton.simulate('click'); + wrapper.update(); + + const deleteButton = wrapper.find( + 'EuiButtonEmpty[data-test-subj="deleteRoleMappingButton-some-realm"]' + ); + expect(deleteButton).toHaveLength(1); + }); }); diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx index 175afe489746..c983f2c704f4 100644 --- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx @@ -6,7 +6,7 @@ */ import { EuiButton, - EuiButtonIcon, + EuiButtonEmpty, EuiCallOut, EuiFlexGroup, EuiFlexItem, @@ -32,18 +32,23 @@ import type { import { reactRouterNavigate } from '../../../../../../../src/plugins/kibana_react/public'; import type { Role, RoleMapping } from '../../../../common/model'; import { DisabledBadge, EnabledBadge } from '../../badges'; -import { EDIT_ROLE_MAPPING_PATH, getEditRoleMappingHref } from '../../management_urls'; +import { + EDIT_ROLE_MAPPING_PATH, + getCloneRoleMappingHref, + getEditRoleMappingHref, +} from '../../management_urls'; import { RoleTableDisplay } from '../../role_table_display'; import type { RolesAPIClient } from '../../roles'; +import { ActionsEuiTableFormatting } from '../../table_utils'; import { DeleteProvider, NoCompatibleRealms, PermissionDenied, SectionLoading, } from '../components'; +import type { DeleteRoleMappings } from '../components/delete_provider/delete_provider'; import type { RoleMappingsAPIClient } from '../role_mappings_api_client'; import { EmptyPrompt } from './empty_prompt'; - interface Props { rolesAPIClient: PublicMethodsOf; roleMappingsAPI: PublicMethodsOf; @@ -63,6 +68,7 @@ interface State { } export class RoleMappingsGridPage extends Component { + private tableRef: React.RefObject>; constructor(props: any) { super(props); this.state = { @@ -73,6 +79,7 @@ export class RoleMappingsGridPage extends Component { selectedItems: [], error: undefined, }; + this.tableRef = React.createRef(); } public componentDidMount() { @@ -224,7 +231,13 @@ export class RoleMappingsGridPage extends Component { {(deleteRoleMappingsPrompt) => { return ( deleteRoleMappingsPrompt(selectedItems, this.onRoleMappingsDeleted)} + onClick={() => + deleteRoleMappingsPrompt( + selectedItems, + this.onRoleMappingsDeleted, + this.onRoleMappingsDeleteCancel + ) + } color="danger" data-test-subj="bulkDeleteActionButton" > @@ -260,27 +273,40 @@ export class RoleMappingsGridPage extends Component { }; return ( - { - return { - 'data-test-subj': 'roleMappingRow', - }; + + {(deleteRoleMappingPrompt) => { + return ( + + { + return { + 'data-test-subj': 'roleMappingRow', + }; + }} + /> + + ); }} - /> + ); }; - private getColumnConfig = () => { + private getColumnConfig = (deleteRoleMappingPrompt: DeleteRoleMappings) => { const config = [ { field: 'name', @@ -357,72 +383,97 @@ export class RoleMappingsGridPage extends Component { }), actions: [ { + isPrimary: true, render: (record: RoleMapping) => { + const title = i18n.translate( + 'xpack.security.management.roleMappings.actionCloneTooltip', + { defaultMessage: 'Clone' } + ); + const label = i18n.translate( + 'xpack.security.management.roleMappings.actionCloneAriaLabel', + { + defaultMessage: `Clone '{name}'`, + values: { name: record.name }, + } + ); return ( - - + = 1} {...reactRouterNavigate( this.props.history, - getEditRoleMappingHref(record.name) + getCloneRoleMappingHref(record.name) )} - /> + > + {title} + + + ); + }, + }, + { + render: (record: RoleMapping) => { + const title = i18n.translate( + 'xpack.security.management.roleMappings.actionDeleteTooltip', + { defaultMessage: 'Delete' } + ); + const label = i18n.translate( + 'xpack.security.management.roleMappings.actionDeleteAriaLabel', + { + defaultMessage: `Delete '{name}'`, + values: { name: record.name }, + } + ); + return ( + + = 1} + onClick={() => deleteRoleMappingPrompt([record], this.onRoleMappingsDeleted)} + > + {title} + ); }, }, { + isPrimary: true, render: (record: RoleMapping) => { + const label = i18n.translate( + 'xpack.security.management.roleMappings.actionEditAriaLabel', + { + defaultMessage: `Edit '{name}'`, + values: { name: record.name }, + } + ); + const title = i18n.translate( + 'xpack.security.management.roleMappings.actionEditTooltip', + { defaultMessage: 'Edit' } + ); return ( - - - - {(deleteRoleMappingPrompt) => { - return ( - - - deleteRoleMappingPrompt([record], this.onRoleMappingsDeleted) - } - /> - - ); - }} - - - + + = 1} + {...reactRouterNavigate( + this.props.history, + getEditRoleMappingHref(record.name) + )} + > + {title} + + ); }, }, @@ -438,6 +489,10 @@ export class RoleMappingsGridPage extends Component { } }; + private onRoleMappingsDeleteCancel = () => { + this.tableRef.current?.setSelection([]); + }; + private async checkPrivileges() { try { const { canManageRoleMappings, hasCompatibleRealms } = diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx index f6d17327b711..3b7e96ffabd1 100644 --- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx @@ -8,7 +8,7 @@ import { act } from '@testing-library/react'; import { noop } from 'lodash'; -import { coreMock, scopedHistoryMock } from 'src/core/public/mocks'; +import { coreMock, scopedHistoryMock, themeServiceMock } from 'src/core/public/mocks'; import type { Unmount } from 'src/plugins/management/public/types'; import { roleMappingsManagementApp } from './role_mappings_management_app'; @@ -46,6 +46,7 @@ async function mountApp(basePath: string, pathname: string) { element: container, setBreadcrumbs, history: scopedHistoryMock.create({ pathname }), + theme$: themeServiceMock.createTheme$(), }); }); @@ -100,7 +101,7 @@ describe('roleMappingsManagementApp', () => { expect(docTitle.reset).not.toHaveBeenCalled(); expect(container).toMatchInlineSnapshot(`
- Role Mapping Edit Page: {"roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit","search":"","hash":""}}} + Role Mapping Edit Page: {"action":"edit","roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit","search":"","hash":""}}}
`); @@ -128,7 +129,7 @@ describe('roleMappingsManagementApp', () => { expect(docTitle.reset).not.toHaveBeenCalled(); expect(container).toMatchInlineSnapshot(`
- Role Mapping Edit Page: {"name":"role@mapping","roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@mapping","search":"","hash":""}}} + Role Mapping Edit Page: {"action":"edit","name":"role@mapping","roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@mapping","search":"","hash":""}}}
`); diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx index 22d09e9e2a67..41e6a9562612 100644 --- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx @@ -56,7 +56,7 @@ export const roleMappingsManagementApp = Object.freeze({ const roleMappingsAPIClient = new RoleMappingsAPIClient(core.http); - const EditRoleMappingsPageWithBreadcrumbs = () => { + const EditRoleMappingsPageWithBreadcrumbs = ({ action }: { action: 'edit' | 'clone' }) => { const { name } = useParams<{ name?: string }>(); // Additional decoding is a workaround for a bug in react-router's version of the `history` module. @@ -64,7 +64,7 @@ export const roleMappingsManagementApp = Object.freeze({ const decodedName = name ? tryDecodeURIComponent(name) : undefined; const breadcrumbObj = - name && decodedName + action === 'edit' && name && decodedName ? { text: decodedName, href: `/edit/${encodeURIComponent(name)}` } : { text: i18n.translate('xpack.security.roleMappings.createBreadcrumb', { @@ -75,6 +75,7 @@ export const roleMappingsManagementApp = Object.freeze({ return ( - + + + + diff --git a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx index 9194fea27144..aa507cf823ef 100644 --- a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx +++ b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx @@ -144,31 +144,33 @@ describe('', () => { expect(wrapper.find(PermissionDenied)).toHaveLength(0); - let editButton = wrapper.find('EuiButtonIcon[data-test-subj="edit-role-action-test-role-1"]'); + let editButton = wrapper.find('EuiButtonEmpty[data-test-subj="edit-role-action-test-role-1"]'); expect(editButton).toHaveLength(1); expect(editButton.prop('href')).toBe('/edit/test-role-1'); editButton = wrapper.find( - 'EuiButtonIcon[data-test-subj="edit-role-action-special%chars%role"]' + 'EuiButtonEmpty[data-test-subj="edit-role-action-special%chars%role"]' ); expect(editButton).toHaveLength(1); expect(editButton.prop('href')).toBe('/edit/special%25chars%25role'); - let cloneButton = wrapper.find('EuiButtonIcon[data-test-subj="clone-role-action-test-role-1"]'); + let cloneButton = wrapper.find( + 'EuiButtonEmpty[data-test-subj="clone-role-action-test-role-1"]' + ); expect(cloneButton).toHaveLength(1); expect(cloneButton.prop('href')).toBe('/clone/test-role-1'); cloneButton = wrapper.find( - 'EuiButtonIcon[data-test-subj="clone-role-action-special%chars%role"]' + 'EuiButtonEmpty[data-test-subj="clone-role-action-special%chars%role"]' ); expect(cloneButton).toHaveLength(1); expect(cloneButton.prop('href')).toBe('/clone/special%25chars%25role'); expect( - wrapper.find('EuiButtonIcon[data-test-subj="edit-role-action-disabled-role"]') + wrapper.find('EuiButtonEmpty[data-test-subj="edit-role-action-disabled-role"]') ).toHaveLength(1); expect( - wrapper.find('EuiButtonIcon[data-test-subj="clone-role-action-disabled-role"]') + wrapper.find('EuiButtonEmpty[data-test-subj="clone-role-action-disabled-role"]') ).toHaveLength(1); }); diff --git a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.tsx b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.tsx index 909c5b1193cd..d34a8bfea27b 100644 --- a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.tsx +++ b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.tsx @@ -8,7 +8,7 @@ import type { EuiBasicTableColumn, EuiSwitchEvent } from '@elastic/eui'; import { EuiButton, - EuiButtonIcon, + EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiInMemoryTable, @@ -17,6 +17,7 @@ import { EuiSpacer, EuiSwitch, EuiText, + EuiToolTip, } from '@elastic/eui'; import _ from 'lodash'; import React, { Component } from 'react'; @@ -36,6 +37,7 @@ import { isRoleReserved, } from '../../../../common/model'; import { DeprecatedBadge, DisabledBadge, ReservedBadge } from '../../badges'; +import { ActionsEuiTableFormatting } from '../../table_utils'; import type { RolesAPIClient } from '../roles_api_client'; import { ConfirmDelete } from './confirm_delete'; import { PermissionDenied } from './permission_denied'; @@ -61,6 +63,7 @@ const getRoleManagementHref = (action: 'edit' | 'clone', roleName?: string) => { }; export class RolesGridPage extends Component { + private tableRef: React.RefObject>; constructor(props: Props) { super(props); this.state = { @@ -72,6 +75,7 @@ export class RolesGridPage extends Component { permissionDenied: false, includeReservedRoles: true, }; + this.tableRef = React.createRef(); } public componentDidMount() { @@ -129,53 +133,56 @@ export class RolesGridPage extends Component { /> ) : null} - !role.metadata || !role.metadata._reserved, - selectableMessage: (selectable: boolean) => (!selectable ? 'Role is reserved' : ''), - onSelectionChange: (selection: Role[]) => this.setState({ selection }), - }} - pagination={{ - initialPageSize: 20, - pageSizeOptions: [10, 20, 30, 50, 100], - }} - items={this.state.visibleRoles} - loading={roles.length === 0} - search={{ - toolsLeft: this.renderToolsLeft(), - toolsRight: this.renderToolsRight(), - box: { - incremental: true, - 'data-test-subj': 'searchRoles', - }, - onChange: (query: Record) => { - this.setState({ - filter: query.queryText, - visibleRoles: this.getVisibleRoles( - this.state.roles, - query.queryText, - this.state.includeReservedRoles - ), - }); - }, - }} - sorting={{ - sort: { - field: 'name', - direction: 'asc', - }, - }} - rowProps={() => { - return { - 'data-test-subj': 'roleRow', - }; - }} - isSelectable - /> + + !role.metadata || !role.metadata._reserved, + selectableMessage: (selectable: boolean) => (!selectable ? 'Role is reserved' : ''), + onSelectionChange: (selection: Role[]) => this.setState({ selection }), + }} + pagination={{ + initialPageSize: 20, + pageSizeOptions: [10, 20, 30, 50, 100], + }} + items={this.state.visibleRoles} + loading={roles.length === 0} + search={{ + toolsLeft: this.renderToolsLeft(), + toolsRight: this.renderToolsRight(), + box: { + incremental: true, + 'data-test-subj': 'searchRoles', + }, + onChange: (query: Record) => { + this.setState({ + filter: query.queryText, + visibleRoles: this.getVisibleRoles( + this.state.roles, + query.queryText, + this.state.includeReservedRoles + ), + }); + }, + }} + sorting={{ + sort: { + field: 'name', + direction: 'asc', + }, + }} + ref={this.tableRef} + rowProps={(role: Role) => { + return { + 'data-test-subj': `roleRow`, + }; + }} + isSelectable + /> + ); }; @@ -219,48 +226,98 @@ export class RolesGridPage extends Component { width: '150px', actions: [ { - available: (role: Role) => !isRoleReadOnly(role), + available: (role: Role) => !isRoleReserved(role), + isPrimary: true, render: (role: Role) => { - const title = i18n.translate('xpack.security.management.roles.editRoleActionName', { - defaultMessage: `Edit {roleName}`, + const title = i18n.translate('xpack.security.management.roles.cloneRoleActionName', { + defaultMessage: `Clone`, + }); + + const label = i18n.translate('xpack.security.management.roles.cloneRoleActionLabel', { + defaultMessage: `Clone {roleName}`, values: { roleName: role.name }, }); return ( - + + = 1} + iconType={'copy'} + {...reactRouterNavigate( + this.props.history, + getRoleManagementHref('clone', role.name) + )} + > + {title} + + ); }, }, { - available: (role: Role) => !isRoleReserved(role), + available: (role: Role) => !role.metadata || !role.metadata._reserved, render: (role: Role) => { - const title = i18n.translate('xpack.security.management.roles.cloneRoleActionName', { - defaultMessage: `Clone {roleName}`, + const title = i18n.translate('xpack.security.management.roles.deleteRoleActionName', { + defaultMessage: `Delete`, + }); + + const label = i18n.translate( + 'xpack.security.management.roles.deleteRoleActionLabel', + { + defaultMessage: `Delete {roleName}`, + values: { roleName: role.name }, + } + ); + + return ( + + = 1} + iconType={'trash'} + onClick={() => this.deleteOneRole(role)} + > + {title} + + + ); + }, + }, + { + available: (role: Role) => !isRoleReadOnly(role), + enable: () => this.state.selection.length === 0, + isPrimary: true, + render: (role: Role) => { + const title = i18n.translate('xpack.security.management.roles.editRoleActionName', { + defaultMessage: `Edit`, + }); + + const label = i18n.translate('xpack.security.management.roles.editRoleActionLabel', { + defaultMessage: `Edit {roleName}`, values: { roleName: role.name }, }); return ( - + + = 1} + iconType={'pencil'} + {...reactRouterNavigate( + this.props.history, + getRoleManagementHref('edit', role.name) + )} + > + {title} + + ); }, }, @@ -337,6 +394,13 @@ export class RolesGridPage extends Component { this.loadRoles(); }; + private deleteOneRole = (roleToDelete: Role) => { + this.setState({ + selection: [roleToDelete], + showDeleteConfirmation: true, + }); + }; + private async loadRoles() { try { const roles = await this.props.rolesAPIClient.getRoles(); @@ -385,6 +449,7 @@ export class RolesGridPage extends Component {
); } + private renderToolsRight() { return ( { ); } private onCancelDelete = () => { - this.setState({ showDeleteConfirmation: false }); + this.setState({ showDeleteConfirmation: false, selection: [] }); + this.tableRef.current?.setSelection([]); }; } diff --git a/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx b/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx index faab47a858d6..007c3e306372 100644 --- a/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx +++ b/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx @@ -8,7 +8,7 @@ import { act } from '@testing-library/react'; import { noop } from 'lodash'; -import { coreMock, scopedHistoryMock } from 'src/core/public/mocks'; +import { coreMock, scopedHistoryMock, themeServiceMock } from 'src/core/public/mocks'; import type { Unmount } from 'src/plugins/management/public/types'; import { featuresPluginMock } from '../../../../features/public/mocks'; @@ -48,6 +48,7 @@ async function mountApp(basePath: string, pathname: string) { element: container, setBreadcrumbs, history: scopedHistoryMock.create({ pathname }), + theme$: themeServiceMock.createTheme$(), }); }); diff --git a/x-pack/plugins/security/public/management/table_utils.tsx b/x-pack/plugins/security/public/management/table_utils.tsx new file mode 100644 index 000000000000..3f240daf3bd0 --- /dev/null +++ b/x-pack/plugins/security/public/management/table_utils.tsx @@ -0,0 +1,37 @@ +/* + * 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. + */ +import { css } from '@emotion/react'; +import type { ReactNode } from 'react'; +import React from 'react'; + +interface ActionsEuiTableFormattingProps { + children: ReactNode; +} + +/* + * Notes to future engineer: + * We created this component because as this time EUI actions table where not allowing to pass + * props href on an action. In our case, we want our actions to work with href + * and onClick. Then the problem is that the design did not match with EUI example, therefore + * we are doing some css magic to only have icon showing up when user is hovering a row + */ +export const ActionsEuiTableFormatting = React.memo( + ({ children }) => ( +
+ {children} +
+ ) +); diff --git a/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.test.tsx b/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.test.tsx index e3ad83fd0b93..b340a915bc05 100644 --- a/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.test.tsx +++ b/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.test.tsx @@ -73,6 +73,66 @@ describe('UsersGridPage', () => { expect(findTestSubject(wrapper, 'userDisabled')).toHaveLength(0); }); + it('renders the loading indication on the table when fetching user with data', async () => { + const apiClientMock = userAPIClientMock.create(); + apiClientMock.getUsers.mockImplementation(() => { + return Promise.resolve([ + { + username: 'foo', + email: 'foo@bar.net', + full_name: 'foo bar', + roles: ['kibana_user'], + enabled: true, + }, + { + username: 'reserved', + email: 'reserved@bar.net', + full_name: '', + roles: ['superuser'], + enabled: true, + metadata: { + _reserved: true, + }, + }, + ]); + }); + + const wrapper = mountWithIntl( + + ); + + expect(wrapper.find('.euiBasicTable-loading').exists()).toBeTruthy(); + await waitForRender(wrapper); + expect(wrapper.find('.euiBasicTable-loading').exists()).toBeFalsy(); + }); + + it('renders the loading indication on the table when fetching user with no data', async () => { + const apiClientMock = userAPIClientMock.create(); + apiClientMock.getUsers.mockImplementation(() => { + return Promise.resolve([]); + }); + + const wrapper = mountWithIntl( + + ); + + expect(wrapper.find('.euiBasicTable-loading').exists()).toBeTruthy(); + await waitForRender(wrapper); + expect(wrapper.find('.euiBasicTable-loading').exists()).toBeFalsy(); + }); + it('generates valid links when usernames contain special characters', async () => { const apiClientMock = userAPIClientMock.create(); apiClientMock.getUsers.mockImplementation(() => { diff --git a/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.tsx b/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.tsx index b7cdf27dc6be..974ca2be219c 100644 --- a/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.tsx +++ b/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.tsx @@ -51,6 +51,7 @@ interface State { permissionDenied: boolean; filter: string; includeReservedUsers: boolean; + isTableLoading: boolean; } export class UsersGridPage extends Component { @@ -65,6 +66,7 @@ export class UsersGridPage extends Component { permissionDenied: false, filter: '', includeReservedUsers: true, + isTableLoading: false, }; } @@ -73,7 +75,7 @@ export class UsersGridPage extends Component { } public render() { - const { users, roles, permissionDenied, showDeleteConfirmation, selection } = this.state; + const { roles, permissionDenied, showDeleteConfirmation, selection } = this.state; if (permissionDenied) { return ( @@ -268,7 +270,7 @@ export class UsersGridPage extends Component { selection={selectionConfig} pagination={pagination} items={this.state.visibleUsers} - loading={users.length === 0} + loading={this.state.isTableLoading} search={search} sorting={sorting} rowProps={rowProps} @@ -311,11 +313,15 @@ export class UsersGridPage extends Component { private async loadUsersAndRoles() { try { + this.setState({ + isTableLoading: true, + }); const [users, roles] = await Promise.all([ this.props.userAPIClient.getUsers(), this.props.rolesAPIClient.getRoles(), ]); this.setState({ + isTableLoading: false, users, roles, visibleUsers: this.getVisibleUsers( @@ -325,9 +331,8 @@ export class UsersGridPage extends Component { ), }); } catch (e) { - if (e.body.statusCode === 403) { - this.setState({ permissionDenied: true }); - } else { + this.setState({ permissionDenied: e.body.statusCode === 403, isTableLoading: false }); + if (e.body.statusCode !== 403) { this.props.notifications.toasts.addDanger( i18n.translate('xpack.security.management.users.fetchingUsersErrorMessage', { defaultMessage: 'Error fetching users: {message}', diff --git a/x-pack/plugins/security/public/management/users/users_management_app.test.tsx b/x-pack/plugins/security/public/management/users/users_management_app.test.tsx index f25fb211cb9d..84a6e82bf12a 100644 --- a/x-pack/plugins/security/public/management/users/users_management_app.test.tsx +++ b/x-pack/plugins/security/public/management/users/users_management_app.test.tsx @@ -8,7 +8,7 @@ import { act } from '@testing-library/react'; import { noop } from 'lodash'; -import { coreMock, scopedHistoryMock } from 'src/core/public/mocks'; +import { coreMock, scopedHistoryMock, themeServiceMock } from 'src/core/public/mocks'; import type { Unmount } from 'src/plugins/management/public/types'; import { securityMock } from '../../mocks'; @@ -33,6 +33,7 @@ describe('usersManagementApp', () => { element, setBreadcrumbs, history, + theme$: themeServiceMock.createTheme$(), }); }); diff --git a/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.test.ts b/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.test.ts index d017d0095e89..61e1ebb47464 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.test.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.test.ts @@ -6,7 +6,7 @@ */ import { getQueryFilter, getAllFilters, buildEqlSearchRequest } from './get_query_filter'; -import { Filter } from 'src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; import { getExceptionListItemSchemaMock } from '../../../lists/common/schemas/response/exception_list_item_schema.mock'; describe('get_filter', () => { diff --git a/x-pack/plugins/security_solution/common/jest.config.js b/x-pack/plugins/security_solution/common/jest.config.js index ca6f7cd368f2..1b5f75f8380b 100644 --- a/x-pack/plugins/security_solution/common/jest.config.js +++ b/x-pack/plugins/security_solution/common/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/common', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/common/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/common/search_strategy/common/index.ts b/x-pack/plugins/security_solution/common/search_strategy/common/index.ts index 095ba4ca20af..f1a2977b27e1 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/common/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/common/index.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { IEsSearchResponse } from '../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../src/plugins/data/common'; export type { Inspect, SortField, diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/cti/index.mock.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/cti/index.mock.ts index 4656a200ccac..9d98a480a620 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/cti/index.mock.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/cti/index.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from 'src/plugins/data/public'; +import type { IEsSearchResponse } from 'src/plugins/data/public'; import { CtiEnrichment, diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/cti/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/cti/index.ts index 69a6841c7c14..26bf4ce6740a 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/cti/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/cti/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from 'src/plugins/data/public'; +import type { IEsSearchResponse } from 'src/plugins/data/public'; import { EVENT_ENRICHMENT_INDICATOR_FIELD_MAP } from '../../../cti/constants'; import { Inspect } from '../../common'; import { RequestBasicOptions } from '..'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/all/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/all/index.ts index 974e892a7312..feb2f6e19e49 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/all/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/all/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { HostItem, HostsFields } from '../common'; import { CursorType, Direction, Inspect, Maybe, PageInfoPaginated } from '../../../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/authentications/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/authentications/index.ts index a000fcf6136e..85255f51382f 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/authentications/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/authentications/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { UserEcs } from '../../../../ecs/user'; import { SourceEcs } from '../../../../ecs/source'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/details/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/details/index.ts index 315f6eeb69f3..e17703ff57a2 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/details/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/details/index.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe, TimerangeInput } from '../../../common'; import { HostItem, HostsFields } from '../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/first_last_seen/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/first_last_seen/index.ts index df95f859e3f3..70a7af9356d1 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/first_last_seen/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/first_last_seen/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe, Direction } from '../../../common'; import { RequestOptionsPaginated } from '../..'; import { HostsFields } from '../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/authentications/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/authentications/index.ts index 81e1945dcd01..73729b613c38 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/authentications/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/authentications/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe } from '../../../../common'; import { RequestBasicOptions } from '../../..'; import { HostsKpiHistogramData } from '../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/hosts/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/hosts/index.ts index 816b240223b5..ca03a9a7252b 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/hosts/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/hosts/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe } from '../../../../common'; import { RequestBasicOptions } from '../../..'; import { HostsKpiHistogramData } from '../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/unique_ips/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/unique_ips/index.ts index 0551ceb055cf..a51b08ad77f5 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/unique_ips/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/kpi/unique_ips/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe } from '../../../../common'; import { RequestBasicOptions } from '../../..'; import { HostsKpiHistogramData } from '../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/overview/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/overview/index.ts index 72f65e978aab..dcf10173ccfd 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/overview/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/overview/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe, SearchHit } from '../../../common'; import { RequestBasicOptions } from '../..'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/risk_score/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/risk_score/index.ts index 39f648eab8cd..f931694a4e22 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/risk_score/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/risk_score/index.ts @@ -6,7 +6,7 @@ */ import { FactoryQueryTypes } from '../..'; -import { +import type { IEsSearchRequest, IEsSearchResponse, } from '../../../../../../../../src/plugins/data/common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/uncommon_processes/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/uncommon_processes/index.ts index 4e885dee113d..0b987f4bf3f4 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/uncommon_processes/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/uncommon_processes/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { HostEcs } from '../../../../ecs/host'; import { UserEcs } from '../../../../ecs/user'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/index.ts index 91a2956e2528..00cbdb941c11 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/index.ts @@ -5,7 +5,7 @@ * 2.0. */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { IEsSearchRequest } from '../../../../../../src/plugins/data/common'; +import type { IEsSearchRequest } from '../../../../../../src/plugins/data/common'; import { ESQuery } from '../../typed_json'; import { HostDetailsStrategyResponse, diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/matrix_histogram/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/matrix_histogram/index.ts index a229ce2281b0..a4d68d251e5a 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/matrix_histogram/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/matrix_histogram/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../src/plugins/data/common'; import { AuthenticationHit } from '../hosts'; import { Inspect, Maybe, TimerangeInput } from '../../common'; import { RequestBasicOptions } from '../'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/details/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/details/index.ts index 3843a6505a67..0495ad24a6b1 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/details/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/details/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { HostEcs } from '../../../../ecs/host'; import { GeoEcs } from '../../../../ecs/geo'; import { Inspect, Maybe, TotalValue, Hit, ShardsResponse } from '../../../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/dns/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/dns/index.ts index e302d0bd3a5c..bd79532e4885 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/dns/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/dns/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { CursorType, Inspect, Maybe, PageInfoPaginated, SortField } from '../../../common'; import { RequestOptionsPaginated } from '../..'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/http/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/http/index.ts index 2edba849b1dd..0b19f475c452 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/http/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/http/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { Maybe, CursorType, Inspect, PageInfoPaginated, GenericBuckets } from '../../../common'; import { RequestOptionsPaginated } from '../..'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/dns/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/dns/index.ts index 2a4535c82bf3..8e631ffcdb74 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/dns/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/dns/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe } from '../../../../common'; import { RequestBasicOptions } from '../../..'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/network_events/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/network_events/index.ts index fc9e5f9b491e..5a404c2c0c0a 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/network_events/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/network_events/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe } from '../../../../common'; import { RequestBasicOptions } from '../../..'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/tls_handshakes/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/tls_handshakes/index.ts index 4da67551e832..c772d5d0c6ce 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/tls_handshakes/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/tls_handshakes/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe } from '../../../../common'; import { RequestBasicOptions } from '../../..'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/unique_flows/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/unique_flows/index.ts index 95b6452be4ae..9f72eac8afad 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/unique_flows/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/unique_flows/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe } from '../../../../common'; import { RequestBasicOptions } from '../../..'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/unique_private_ips/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/unique_private_ips/index.ts index 65591df10fe3..f1b06c68e378 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/unique_private_ips/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/kpi/unique_private_ips/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe } from '../../../../common'; import { RequestBasicOptions } from '../../..'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/overview/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/overview/index.ts index ed124d22c2e1..22325dff8e14 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/overview/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/overview/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe, SearchHit } from '../../../common'; import { RequestBasicOptions } from '../..'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/tls/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/tls/index.ts index 80b6e10444ba..c4c3ece61005 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/tls/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/tls/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { CursorType, Inspect, Maybe, PageInfoPaginated } from '../../../common'; import { RequestOptionsPaginated } from '../..'; import { FlowTargetSourceDest } from '../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/top_countries/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/top_countries/index.ts index 7860cde41f57..7de0bbbb53f5 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/top_countries/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/top_countries/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { CursorType, Inspect, Maybe, PageInfoPaginated } from '../../../common'; import { RequestOptionsPaginated } from '../..'; import { diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/top_n_flow/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/top_n_flow/index.ts index 207d24d920bb..676daa108692 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/top_n_flow/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/top_n_flow/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { GeoItem, FlowTargetSourceDest, diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/users/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/users/index.ts index 0bd6b7ed6490..029ae4aa6233 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/users/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/network/users/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { CursorType, Inspect, Maybe, PageInfoPaginated, SortField } from '../../../common'; import { FlowTarget } from '../common'; import { RequestOptionsPaginated } from '../..'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/host_rules/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/host_rules/index.ts index cb6469c6209a..98ea5ce58e13 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/host_rules/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/host_rules/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { HostRulesItem, HostRulesFields } from '../common'; import { CursorType, Hit, Inspect, Maybe, PageInfoPaginated, SortField } from '../../../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/host_tactics/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/host_tactics/index.ts index c55058dc6be0..13c8550e7a48 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/host_tactics/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/host_tactics/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { HostTacticsItem, HostTacticsFields } from '../common'; import { CursorType, Hit, Inspect, Maybe, PageInfoPaginated, SortField } from '../../../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/risk_score/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/risk_score/index.ts index 14c153375505..c753dbb9e0e3 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/risk_score/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/risk_score/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { RiskScoreItem, RiskScoreFields } from '../common'; import { CursorType, Hit, Inspect, Maybe, PageInfoPaginated, SortField } from '../../../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/user_rules/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/user_rules/index.ts index c7302c10fab3..5329d12b62b7 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/user_rules/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/ueba/user_rules/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { HostRulesFields, UserRulesFields } from '../common'; import { Hit, Inspect, Maybe, PageInfoPaginated, SearchHit, SortField } from '../../../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/timeline/index.ts b/x-pack/plugins/security_solution/common/search_strategy/timeline/index.ts index 2d94a36a937d..a66a10110f5b 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/timeline/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/timeline/index.ts @@ -6,7 +6,7 @@ */ import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { IEsSearchRequest } from '../../../../../../src/plugins/data/common'; +import type { IEsSearchRequest } from '../../../../../../src/plugins/data/common'; import { ESQuery } from '../../typed_json'; import { TimelineEventsQueries, diff --git a/x-pack/plugins/security_solution/common/types/timeline/store.ts b/x-pack/plugins/security_solution/common/types/timeline/store.ts index 75cd44ba2b7d..1b32f12dafd5 100644 --- a/x-pack/plugins/security_solution/common/types/timeline/store.ts +++ b/x-pack/plugins/security_solution/common/types/timeline/store.ts @@ -5,6 +5,7 @@ * 2.0. */ +import type { Filter } from '@kbn/es-query'; import { ColumnHeaderOptions, ColumnId, @@ -12,8 +13,6 @@ import { TimelineExpandedDetail, TimelineTypeLiteral, } from '.'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Filter } from '../../../../../../src/plugins/data/public'; import { Direction } from '../../search_strategy'; import { DataProvider } from './data_provider'; diff --git a/x-pack/plugins/security_solution/public/app/jest.config.js b/x-pack/plugins/security_solution/public/app/jest.config.js index 452cee5e5b3a..8674e6754aab 100644 --- a/x-pack/plugins/security_solution/public/app/jest.config.js +++ b/x-pack/plugins/security_solution/public/app/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/app', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/public/app/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/cases/jest.config.js b/x-pack/plugins/security_solution/public/cases/jest.config.js index 4b0a49fd65af..9089585ce868 100644 --- a/x-pack/plugins/security_solution/public/cases/jest.config.js +++ b/x-pack/plugins/security_solution/public/cases/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/cases', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/public/cases/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/common/components/add_filter_to_global_search_bar/helpers.ts b/x-pack/plugins/security_solution/public/common/components/add_filter_to_global_search_bar/helpers.ts index f009b96a8d2a..68da00bd7ef0 100644 --- a/x-pack/plugins/security_solution/public/common/components/add_filter_to_global_search_bar/helpers.ts +++ b/x-pack/plugins/security_solution/public/common/components/add_filter_to_global_search_bar/helpers.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Filter } from '../../../../../../../src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; export const createFilter = ( key: string, diff --git a/x-pack/plugins/security_solution/public/common/components/add_filter_to_global_search_bar/index.tsx b/x-pack/plugins/security_solution/public/common/components/add_filter_to_global_search_bar/index.tsx index 7c26a7eb17e8..85e3a435af81 100644 --- a/x-pack/plugins/security_solution/public/common/components/add_filter_to_global_search_bar/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/add_filter_to_global_search_bar/index.tsx @@ -7,8 +7,7 @@ import { EuiButtonIcon, EuiToolTip } from '@elastic/eui'; import React, { useCallback, useMemo } from 'react'; - -import { Filter } from '../../../../../../../src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; import { WithHoverActions } from '../with_hover_actions'; import { useKibana } from '../../lib/kibana'; diff --git a/x-pack/plugins/security_solution/public/common/components/alerts_viewer/alerts_table.tsx b/x-pack/plugins/security_solution/public/common/components/alerts_viewer/alerts_table.tsx index fff5b465956d..a9335fe7f4c6 100644 --- a/x-pack/plugins/security_solution/public/common/components/alerts_viewer/alerts_table.tsx +++ b/x-pack/plugins/security_solution/public/common/components/alerts_viewer/alerts_table.tsx @@ -7,8 +7,8 @@ import React, { useEffect, useMemo } from 'react'; import { useDispatch } from 'react-redux'; +import type { Filter } from '@kbn/es-query'; import { timelineActions } from '../../../timelines/store/timeline'; -import { Filter } from '../../../../../../../src/plugins/data/public'; import { TimelineIdLiteral } from '../../../../common/types/timeline'; import { StatefulEventsViewer } from '../events_viewer'; import { alertsDefaultModel } from './default_headers'; diff --git a/x-pack/plugins/security_solution/public/common/components/alerts_viewer/types.ts b/x-pack/plugins/security_solution/public/common/components/alerts_viewer/types.ts index 3c439a9eff1e..010c8b4e0e8e 100644 --- a/x-pack/plugins/security_solution/public/common/components/alerts_viewer/types.ts +++ b/x-pack/plugins/security_solution/public/common/components/alerts_viewer/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Filter } from '../../../../../../../src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; import type { EntityType } from '../../../../../timelines/common'; import { TimelineIdLiteral } from '../../../../common/types/timeline'; import { HostsComponentsQueryProps } from '../../../hosts/pages/navigation/types'; diff --git a/x-pack/plugins/security_solution/public/common/components/event_details/table/field_name_cell.tsx b/x-pack/plugins/security_solution/public/common/components/event_details/table/field_name_cell.tsx index 5482288b7d27..a52099b905d2 100644 --- a/x-pack/plugins/security_solution/public/common/components/event_details/table/field_name_cell.tsx +++ b/x-pack/plugins/security_solution/public/common/components/event_details/table/field_name_cell.tsx @@ -10,7 +10,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiBadge, EuiText, EuiToolTip } from '@elast import { isEmpty } from 'lodash'; import { FieldIcon } from '@kbn/react-field/field_icon'; import * as i18n from '../translations'; -import { DataViewField } from '../../../../../../../../src/plugins/data_views/common'; +import type { DataViewField } from '../../../../../../../../src/plugins/data_views/common'; import { getExampleText } from '../helpers'; import { BrowserField } from '../../../containers/source'; import { EventFieldsData } from '../types'; diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx index 55be8ad94ec5..5c2312a8795c 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx @@ -9,13 +9,13 @@ import React, { useCallback, useMemo, useEffect } from 'react'; import { connect, ConnectedProps, useDispatch } from 'react-redux'; import deepEqual from 'fast-deep-equal'; import styled from 'styled-components'; +import type { Filter } from '@kbn/es-query'; import { inputsModel, inputsSelectors, State } from '../../store'; import { inputsActions } from '../../store/actions'; import { ControlColumnProps, RowRenderer, TimelineId } from '../../../../common/types/timeline'; import { timelineSelectors, timelineActions } from '../../../timelines/store/timeline'; import type { SubsetTimelineModel, TimelineModel } from '../../../timelines/store/timeline/model'; import { Status } from '../../../../common/detection_engine/schemas/common/schemas'; -import { Filter } from '../../../../../../../src/plugins/data/public'; import { InspectButtonContainer } from '../inspect'; import { useGlobalFullScreen } from '../../containers/use_full_screen'; import { useIsExperimentalFeatureEnabled } from '../../hooks/use_experimental_features'; diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.test.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.test.tsx index 37f250ffd2d4..3ef80794275d 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.test.tsx @@ -42,7 +42,7 @@ import { getCommentsArrayMock } from '../../../../../lists/common/schemas/types/ import { fields } from '../../../../../../../src/plugins/data/common/mocks'; import { ENTRIES, OLD_DATE_RELATIVE_TO_DATE_NOW } from '../../../../../lists/common/constants.mock'; import { CodeSignature } from '../../../../common/ecs/file'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; jest.mock('uuid', () => ({ v4: jest.fn().mockReturnValue('123'), diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.tsx index e14c151ed367..4030c1f90d10 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.tsx @@ -33,7 +33,7 @@ import { addIdToEntries, ExceptionsBuilderExceptionItem, } from '@kbn/securitysolution-list-utils'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import * as i18n from './translations'; import { AlertData, Flattened } from './types'; diff --git a/x-pack/plugins/security_solution/public/common/components/hover_actions/actions/show_top_n.tsx b/x-pack/plugins/security_solution/public/common/components/hover_actions/actions/show_top_n.tsx index 40b978cfe20f..3e49ef763273 100644 --- a/x-pack/plugins/security_solution/public/common/components/hover_actions/actions/show_top_n.tsx +++ b/x-pack/plugins/security_solution/public/common/components/hover_actions/actions/show_top_n.tsx @@ -14,6 +14,7 @@ import { EuiToolTip, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import type { Filter } from '@kbn/es-query'; import { StatefulTopN } from '../../top_n'; import { TimelineId } from '../../../../../common/types/timeline'; import { SourcererScopeName } from '../../../store/sourcerer/model'; @@ -21,7 +22,6 @@ import { useSourcererDataView } from '../../../containers/sourcerer'; import { TooltipWithKeyboardShortcut } from '../../accessibility'; import { getAdditionalScreenReaderOnlyContext } from '../utils'; import { SHOW_TOP_N_KEYBOARD_SHORTCUT } from '../keyboard_shortcut_constants'; -import { Filter } from '../../../../../../../../src/plugins/data/public'; const SHOW_TOP = (fieldName: string) => i18n.translate('xpack.securitySolution.hoverActions.showTopTooltip', { diff --git a/x-pack/plugins/security_solution/public/common/components/navigation/helpers.ts b/x-pack/plugins/security_solution/public/common/components/navigation/helpers.ts index 610a3c086fc2..35b5f62629dc 100644 --- a/x-pack/plugins/security_solution/public/common/components/navigation/helpers.ts +++ b/x-pack/plugins/security_solution/public/common/components/navigation/helpers.ts @@ -8,6 +8,7 @@ import { isEmpty } from 'lodash/fp'; import { Location } from 'history'; +import type { Filter, Query } from '@kbn/es-query'; import { UrlInputsModel } from '../../store/inputs/model'; import { TimelineUrl } from '../../../timelines/store/timeline/model'; import { CONSTANTS } from '../url_state/constants'; @@ -17,7 +18,6 @@ import { replaceStateKeyInQueryString, getQueryStringFromLocation, } from '../url_state/helpers'; -import { Query, Filter } from '../../../../../../../src/plugins/data/public'; import { SearchNavTab } from './types'; import { SourcererUrlState } from '../../store/sourcerer/model'; diff --git a/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/types.ts b/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/types.ts index 9a066037b276..75f18abf7555 100644 --- a/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/types.ts +++ b/x-pack/plugins/security_solution/public/common/components/navigation/tab_navigation/types.ts @@ -5,11 +5,11 @@ * 2.0. */ +import type { Filter, Query } from '@kbn/es-query'; import { UrlInputsModel } from '../../../store/inputs/model'; import { CONSTANTS } from '../../url_state/constants'; import { SourcererUrlState } from '../../../store/sourcerer/model'; import { TimelineUrl } from '../../../../timelines/store/timeline/model'; -import { Filter, Query } from '../../../../../../../../src/plugins/data/public'; import { SecuritySolutionTabNavigationProps } from '../types'; import { SiemRouteType } from '../../../utils/route/types'; diff --git a/x-pack/plugins/security_solution/public/common/components/query_bar/index.tsx b/x-pack/plugins/security_solution/public/common/components/query_bar/index.tsx index 253f2c3862e0..18f60db89595 100644 --- a/x-pack/plugins/security_solution/public/common/components/query_bar/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/query_bar/index.tsx @@ -8,7 +8,7 @@ import React, { memo, useMemo, useCallback } from 'react'; import deepEqual from 'fast-deep-equal'; -import { DataViewBase, Filter, Query } from '@kbn/es-query'; +import type { DataViewBase, Filter, Query } from '@kbn/es-query'; import { FilterManager, TimeHistory, diff --git a/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx b/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx index 9531443e9851..22cba877b496 100644 --- a/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx @@ -14,8 +14,8 @@ import { Subscription } from 'rxjs'; import styled from 'styled-components'; import deepEqual from 'fast-deep-equal'; -import { DataViewBase, Filter, Query } from '@kbn/es-query'; -import { FilterManager, TimeRange, SavedQuery } from 'src/plugins/data/public'; +import type { DataViewBase, Filter, Query } from '@kbn/es-query'; +import type { FilterManager, TimeRange, SavedQuery } from 'src/plugins/data/public'; import { OnTimeChangeProps } from '@elastic/eui'; diff --git a/x-pack/plugins/security_solution/public/common/components/search_bar/selectors.ts b/x-pack/plugins/security_solution/public/common/components/search_bar/selectors.ts index d47638b2067c..3e4f7acd1ee8 100644 --- a/x-pack/plugins/security_solution/public/common/components/search_bar/selectors.ts +++ b/x-pack/plugins/security_solution/public/common/components/search_bar/selectors.ts @@ -6,8 +6,9 @@ */ import { createSelector } from 'reselect'; +import type { Query } from '@kbn/es-query'; import { InputsRange } from '../../store/inputs/model'; -import { Query, SavedQuery } from '../../../../../../../src/plugins/data/public'; +import type { SavedQuery } from '../../../../../../../src/plugins/data/public'; export { endSelector, diff --git a/x-pack/plugins/security_solution/public/common/components/threat_match/entry_item.test.tsx b/x-pack/plugins/security_solution/public/common/components/threat_match/entry_item.test.tsx index 0550ef389585..d99d813e1af8 100644 --- a/x-pack/plugins/security_solution/public/common/components/threat_match/entry_item.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/threat_match/entry_item.test.tsx @@ -11,7 +11,7 @@ import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui'; import { EntryItem } from './entry_item'; import { fields, getField } from '../../../../../../../src/plugins/data/common/mocks'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; jest.mock('../../../common/lib/kibana'); diff --git a/x-pack/plugins/security_solution/public/common/components/threat_match/entry_item.tsx b/x-pack/plugins/security_solution/public/common/components/threat_match/entry_item.tsx index 777ef2069ff4..3087a92aba72 100644 --- a/x-pack/plugins/security_solution/public/common/components/threat_match/entry_item.tsx +++ b/x-pack/plugins/security_solution/public/common/components/threat_match/entry_item.tsx @@ -10,7 +10,7 @@ import { EuiFormRow, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import styled from 'styled-components'; import { FieldComponent } from '@kbn/securitysolution-autocomplete'; -import { DataViewBase, DataViewFieldBase } from '@kbn/es-query'; +import type { DataViewBase, DataViewFieldBase } from '@kbn/es-query'; import { FormattedEntry, Entry } from './types'; import * as i18n from './translations'; import { getEntryOnFieldChange, getEntryOnThreatFieldChange } from './helpers'; diff --git a/x-pack/plugins/security_solution/public/common/components/threat_match/helpers.test.tsx b/x-pack/plugins/security_solution/public/common/components/threat_match/helpers.test.tsx index 9a5051fe0caf..272d056eed14 100644 --- a/x-pack/plugins/security_solution/public/common/components/threat_match/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/threat_match/helpers.test.tsx @@ -7,8 +7,8 @@ import { fields, getField } from '../../../../../../../src/plugins/data/common/mocks'; import { Entry, EmptyEntry, ThreatMapEntries, FormattedEntry } from './types'; -import { FieldSpec } from '../../../../../../../src/plugins/data/common'; -import { DataViewBase } from '@kbn/es-query'; +import type { FieldSpec } from '../../../../../../../src/plugins/data/common'; +import type { DataViewBase } from '@kbn/es-query'; import moment from 'moment-timezone'; import { diff --git a/x-pack/plugins/security_solution/public/common/components/threat_match/helpers.tsx b/x-pack/plugins/security_solution/public/common/components/threat_match/helpers.tsx index 7b0385ab6902..2358f4dd5b9c 100644 --- a/x-pack/plugins/security_solution/public/common/components/threat_match/helpers.tsx +++ b/x-pack/plugins/security_solution/public/common/components/threat_match/helpers.tsx @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import { addIdToItem } from '@kbn/securitysolution-utils'; import { ThreatMap, threatMap, ThreatMapping } from '@kbn/securitysolution-io-ts-alerting-types'; -import { DataViewBase, DataViewFieldBase } from '@kbn/es-query'; +import type { DataViewBase, DataViewFieldBase } from '@kbn/es-query'; import { Entry, FormattedEntry, ThreatMapEntries, EmptyEntry } from './types'; import { ValidationFunc } from '../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib'; import { ERROR_CODE } from '../../../../../../../src/plugins/es_ui_shared/static/forms/helpers/field_validators/types'; diff --git a/x-pack/plugins/security_solution/public/common/components/threat_match/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/threat_match/index.test.tsx index e26c889b7e94..20fd2821ed9b 100644 --- a/x-pack/plugins/security_solution/public/common/components/threat_match/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/threat_match/index.test.tsx @@ -16,7 +16,7 @@ import { useKibana } from '../../../common/lib/kibana'; import { ThreatMatchComponent } from './'; import { ThreatMapEntries } from './types'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { getMockTheme } from '../../lib/kibana/kibana_react.mock'; const mockTheme = getMockTheme({ diff --git a/x-pack/plugins/security_solution/public/common/components/threat_match/index.tsx b/x-pack/plugins/security_solution/public/common/components/threat_match/index.tsx index 5ea17939ed78..1f3268b84bdb 100644 --- a/x-pack/plugins/security_solution/public/common/components/threat_match/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/threat_match/index.tsx @@ -8,7 +8,7 @@ import React, { useCallback, useEffect, useReducer } from 'react'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import styled from 'styled-components'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { ThreatMapping } from '@kbn/securitysolution-io-ts-alerting-types'; import { ListItemComponent } from './list_item'; import { AndOrBadge } from '../and_or_badge'; diff --git a/x-pack/plugins/security_solution/public/common/components/threat_match/list_item.test.tsx b/x-pack/plugins/security_solution/public/common/components/threat_match/list_item.test.tsx index e2325ace2659..0cb1ed830cec 100644 --- a/x-pack/plugins/security_solution/public/common/components/threat_match/list_item.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/threat_match/list_item.test.tsx @@ -14,7 +14,7 @@ import { fields } from '../../../../../../../src/plugins/data/common/mocks'; import { ListItemComponent } from './list_item'; import { ThreatMapEntries } from './types'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { getMockTheme } from '../../lib/kibana/kibana_react.mock'; const mockTheme = getMockTheme({ diff --git a/x-pack/plugins/security_solution/public/common/components/threat_match/list_item.tsx b/x-pack/plugins/security_solution/public/common/components/threat_match/list_item.tsx index e01c28ecb54e..47d367e6c04a 100644 --- a/x-pack/plugins/security_solution/public/common/components/threat_match/list_item.tsx +++ b/x-pack/plugins/security_solution/public/common/components/threat_match/list_item.tsx @@ -9,7 +9,7 @@ import React, { useMemo, useCallback } from 'react'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import styled from 'styled-components'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { getFormattedEntries, getUpdatedEntriesOnDelete } from './helpers'; import { FormattedEntry, ThreatMapEntries, Entry } from './types'; import { EntryItem } from './entry_item'; diff --git a/x-pack/plugins/security_solution/public/common/components/top_n/index.tsx b/x-pack/plugins/security_solution/public/common/components/top_n/index.tsx index ac9acb62c583..28f942dfa61c 100644 --- a/x-pack/plugins/security_solution/public/common/components/top_n/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/top_n/index.tsx @@ -8,11 +8,11 @@ import React, { useMemo } from 'react'; import { connect, ConnectedProps } from 'react-redux'; -import { DataViewBase, Filter, Query } from '@kbn/es-query'; +import type { DataViewBase, Filter, Query } from '@kbn/es-query'; import { useGlobalTime } from '../../containers/use_global_time'; import { BrowserFields } from '../../containers/source'; import { useKibana } from '../../lib/kibana'; -import { esQuery } from '../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common'; import { inputsModel, inputsSelectors, State } from '../../store'; import { timelineDefaults } from '../../../timelines/store/timeline/defaults'; import { timelineSelectors } from '../../../timelines/store/timeline'; @@ -117,7 +117,7 @@ const StatefulTopNComponent: React.FC = ({ timelineId === TimelineId.active ? combineQueries({ browserFields, - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), dataProviders, filters: activeTimelineFilters, indexPattern, diff --git a/x-pack/plugins/security_solution/public/common/components/top_n/top_n.tsx b/x-pack/plugins/security_solution/public/common/components/top_n/top_n.tsx index 9c99189e1b79..f0d7000e4ed9 100644 --- a/x-pack/plugins/security_solution/public/common/components/top_n/top_n.tsx +++ b/x-pack/plugins/security_solution/public/common/components/top_n/top_n.tsx @@ -11,7 +11,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { useSelector } from 'react-redux'; import styled from 'styled-components'; -import { DataViewBase, Filter, Query } from '@kbn/es-query'; +import type { DataViewBase, Filter, Query } from '@kbn/es-query'; import { GlobalTimeArgs } from '../../containers/use_global_time'; import { EventsByDataset } from '../../../overview/components/events_by_dataset'; import { SignalsByCategory } from '../../../overview/components/signals_by_category'; diff --git a/x-pack/plugins/security_solution/public/common/components/url_state/helpers.ts b/x-pack/plugins/security_solution/public/common/components/url_state/helpers.ts index 1ff98528a20b..4537b7be01f5 100644 --- a/x-pack/plugins/security_solution/public/common/components/url_state/helpers.ts +++ b/x-pack/plugins/security_solution/public/common/components/url_state/helpers.ts @@ -10,7 +10,8 @@ import { parse, stringify } from 'query-string'; import { decode, encode } from 'rison-node'; import * as H from 'history'; -import { Query, Filter } from '../../../../../../../src/plugins/data/public'; +import type { Filter, Query } from '@kbn/es-query'; + import { url } from '../../../../../../../src/plugins/kibana_utils/public'; import { TimelineId, TimelineTabs } from '../../../../common/types/timeline'; diff --git a/x-pack/plugins/security_solution/public/common/components/url_state/initialize_redux_by_url.tsx b/x-pack/plugins/security_solution/public/common/components/url_state/initialize_redux_by_url.tsx index 11312e942c1e..7c87aa19484b 100644 --- a/x-pack/plugins/security_solution/public/common/components/url_state/initialize_redux_by_url.tsx +++ b/x-pack/plugins/security_solution/public/common/components/url_state/initialize_redux_by_url.tsx @@ -10,7 +10,7 @@ import { Dispatch } from 'redux'; import { useCallback, useMemo } from 'react'; import { useDispatch } from 'react-redux'; -import { Query, Filter } from '../../../../../../../src/plugins/data/public'; +import type { Filter, Query } from '@kbn/es-query'; import { inputsActions, sourcererActions } from '../../store/actions'; import { InputsModelId, TimeRangeKinds } from '../../store/inputs/constants'; import { diff --git a/x-pack/plugins/security_solution/public/common/components/url_state/test_dependencies.ts b/x-pack/plugins/security_solution/public/common/components/url_state/test_dependencies.ts index f722c5ec0da0..9820b771ca12 100644 --- a/x-pack/plugins/security_solution/public/common/components/url_state/test_dependencies.ts +++ b/x-pack/plugins/security_solution/public/common/components/url_state/test_dependencies.ts @@ -5,13 +5,13 @@ * 2.0. */ +import type { Query } from '@kbn/es-query'; import { navTabs } from '../../../app/home/home_navigations'; import { SecurityPageName } from '../../../app/types'; import { inputsActions } from '../../store/actions'; import { CONSTANTS } from './constants'; import { UrlStateContainerPropTypes, LocationTypes } from './types'; -import { Query } from '../../../../../../../src/plugins/data/public'; import { networkModel } from '../../../network/store'; import { hostsModel } from '../../../hosts/store'; import { HostsTableType } from '../../../hosts/store/model'; diff --git a/x-pack/plugins/security_solution/public/common/components/url_state/types.ts b/x-pack/plugins/security_solution/public/common/components/url_state/types.ts index 2626f4fb03c2..d9c91f337185 100644 --- a/x-pack/plugins/security_solution/public/common/components/url_state/types.ts +++ b/x-pack/plugins/security_solution/public/common/components/url_state/types.ts @@ -5,8 +5,8 @@ * 2.0. */ -import { Filter, FilterManager, Query, SavedQueryService } from 'src/plugins/data/public'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase, Filter, Query } from '@kbn/es-query'; +import type { FilterManager, SavedQueryService } from 'src/plugins/data/public'; import { UrlInputsModel } from '../../store/inputs/model'; import { TimelineUrl } from '../../../timelines/store/timeline/model'; import { RouteSpyState } from '../../utils/route/types'; diff --git a/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts b/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts index 179b4a53e367..f668f96cce96 100644 --- a/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts +++ b/x-pack/plugins/security_solution/public/common/containers/cti/event_enrichment/api.ts @@ -8,7 +8,7 @@ import { Observable } from 'rxjs'; import { filter } from 'rxjs/operators'; -import { DataPublicPluginStart } from 'src/plugins/data/public'; +import type { DataPublicPluginStart } from 'src/plugins/data/public'; import { isErrorResponse, isCompleteResponse, diff --git a/x-pack/plugins/security_solution/public/common/containers/source/index.tsx b/x-pack/plugins/security_solution/public/common/containers/source/index.tsx index 8ddd33d76034..f833c2f8c4fc 100644 --- a/x-pack/plugins/security_solution/public/common/containers/source/index.tsx +++ b/x-pack/plugins/security_solution/public/common/containers/source/index.tsx @@ -8,7 +8,7 @@ import { isEmpty, isEqual, isUndefined, keyBy, pick } from 'lodash/fp'; import memoizeOne from 'memoize-one'; import { useCallback, useEffect, useRef, useState } from 'react'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { Subscription } from 'rxjs'; import { useKibana } from '../../lib/kibana'; diff --git a/x-pack/plugins/security_solution/public/common/hooks/eql/api.ts b/x-pack/plugins/security_solution/public/common/hooks/eql/api.ts index 7e7942317788..a5b73517c4fb 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/eql/api.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/eql/api.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { DataPublicPluginStart } from '../../../../../../../src/plugins/data/public'; +import type { DataPublicPluginStart } from '../../../../../../../src/plugins/data/public'; import { EqlSearchStrategyRequest, EqlSearchStrategyResponse, diff --git a/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts b/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts index 107a691b6dbe..278e84f327d0 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; +import type { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; import { Source } from './types'; import { EqlSearchResponse } from '../../../../common/detection_engine/types'; import type { Connection } from '@elastic/elasticsearch'; diff --git a/x-pack/plugins/security_solution/public/common/hooks/eql/helpers.test.ts b/x-pack/plugins/security_solution/public/common/hooks/eql/helpers.test.ts index 2dba3e3af377..abdb3d2d06e9 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/eql/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/eql/helpers.test.ts @@ -7,7 +7,7 @@ import moment from 'moment'; -import { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; +import type { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; import { Source } from './types'; import { EqlSearchResponse } from '../../../../common/detection_engine/types'; import { inputsModel } from '../../../common/store'; diff --git a/x-pack/plugins/security_solution/public/common/hooks/eql/helpers.ts b/x-pack/plugins/security_solution/public/common/hooks/eql/helpers.ts index 68a8cb53b381..7594696336ed 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/eql/helpers.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/eql/helpers.ts @@ -9,7 +9,7 @@ import moment from 'moment'; import { Unit } from '@elastic/datemath'; import { inputsModel } from '../../../common/store'; -import { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; +import type { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; import { InspectResponse } from '../../../types'; import { EqlPreviewResponse, Source } from './types'; import { BaseHit, EqlSearchResponse } from '../../../../common/detection_engine/types'; diff --git a/x-pack/plugins/security_solution/public/common/hooks/eql/use_eql_preview.test.ts b/x-pack/plugins/security_solution/public/common/hooks/eql/use_eql_preview.test.ts index b1cd14fa039b..00edace90b7f 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/eql/use_eql_preview.test.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/eql/use_eql_preview.test.ts @@ -11,7 +11,7 @@ import { of, throwError } from 'rxjs'; import { delay } from 'rxjs/operators'; import * as i18n from '../translations'; -import { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; +import type { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; import { Source } from './types'; import { EqlSearchResponse } from '../../../../common/detection_engine/types'; import { useKibana } from '../../../common/lib/kibana'; diff --git a/x-pack/plugins/security_solution/public/common/hooks/use_app_toasts.test.ts b/x-pack/plugins/security_solution/public/common/hooks/use_app_toasts.test.ts index fffc982d8aa5..786f25d8c6ab 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/use_app_toasts.test.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/use_app_toasts.test.ts @@ -6,7 +6,7 @@ */ import { renderHook } from '@testing-library/react-hooks'; -import { IEsError } from 'src/plugins/data/public'; +import type { IEsError } from 'src/plugins/data/public'; import { KibanaError, SecurityAppError } from '@kbn/securitysolution-t-grid'; import { useToasts } from '../lib/kibana'; diff --git a/x-pack/plugins/security_solution/public/common/hooks/use_invalid_filter_query.tsx b/x-pack/plugins/security_solution/public/common/hooks/use_invalid_filter_query.tsx index e03efcac4bbf..a0cb9f941783 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/use_invalid_filter_query.tsx +++ b/x-pack/plugins/security_solution/public/common/hooks/use_invalid_filter_query.tsx @@ -7,7 +7,7 @@ import { useEffect, useMemo } from 'react'; import { useDispatch } from 'react-redux'; -import { Query } from 'src/plugins/data/public'; +import type { Query } from '@kbn/es-query'; import { appSelectors } from '../store'; import { appActions } from '../store/app'; import { useAppToasts } from './use_app_toasts'; diff --git a/x-pack/plugins/security_solution/public/common/jest.config.js b/x-pack/plugins/security_solution/public/common/jest.config.js index e59f9c68f759..3fedce946d63 100644 --- a/x-pack/plugins/security_solution/public/common/jest.config.js +++ b/x-pack/plugins/security_solution/public/common/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/common', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/public/common/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/common/lib/cell_actions/expanded_cell_value_actions.tsx b/x-pack/plugins/security_solution/public/common/lib/cell_actions/expanded_cell_value_actions.tsx index 4b50fff48fe0..94ae557dfc30 100644 --- a/x-pack/plugins/security_solution/public/common/lib/cell_actions/expanded_cell_value_actions.tsx +++ b/x-pack/plugins/security_solution/public/common/lib/cell_actions/expanded_cell_value_actions.tsx @@ -9,7 +9,7 @@ import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { noop } from 'lodash/fp'; import React, { useMemo, useState, useCallback } from 'react'; import styled from 'styled-components'; -import { Filter } from '../../../../../../../src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; import { BrowserFields } from '../../../../../timelines/common/search_strategy'; import { allowTopN } from '../../components/drag_and_drop/helpers'; import { ShowTopNButton } from '../../components/hover_actions/actions/show_top_n'; diff --git a/x-pack/plugins/security_solution/public/common/mock/timeline_results.ts b/x-pack/plugins/security_solution/public/common/mock/timeline_results.ts index a6c16a82deca..0f814d758e7f 100644 --- a/x-pack/plugins/security_solution/public/common/mock/timeline_results.ts +++ b/x-pack/plugins/security_solution/public/common/mock/timeline_results.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { FilterStateStore } from '../../../../../../src/plugins/data/common'; +import { FilterStateStore } from '@kbn/es-query'; import { TimelineId, diff --git a/x-pack/plugins/security_solution/public/common/store/inputs/actions.ts b/x-pack/plugins/security_solution/public/common/store/inputs/actions.ts index 1e38b76909ca..3da18090eb44 100644 --- a/x-pack/plugins/security_solution/public/common/store/inputs/actions.ts +++ b/x-pack/plugins/security_solution/public/common/store/inputs/actions.ts @@ -7,9 +7,11 @@ import actionCreatorFactory from 'typescript-fsa'; +import type { Filter } from '@kbn/es-query'; import { InspectQuery, Refetch, RefetchKql } from './model'; import { InputsModelId } from './constants'; -import { Filter, SavedQuery } from '../../../../../../../src/plugins/data/public'; + +import type { SavedQuery } from '../../../../../../../src/plugins/data/public'; const actionCreator = actionCreatorFactory('x-pack/security_solution/local/inputs'); diff --git a/x-pack/plugins/security_solution/public/common/store/inputs/model.ts b/x-pack/plugins/security_solution/public/common/store/inputs/model.ts index 5791a4940cbe..f5e31d42e22e 100644 --- a/x-pack/plugins/security_solution/public/common/store/inputs/model.ts +++ b/x-pack/plugins/security_solution/public/common/store/inputs/model.ts @@ -6,9 +6,10 @@ */ import { Dispatch } from 'redux'; +import type { Filter, Query } from '@kbn/es-query'; import { InputsModelId } from './constants'; import { CONSTANTS } from '../../components/url_state/constants'; -import { Query, Filter, SavedQuery } from '../../../../../../../src/plugins/data/public'; +import type { SavedQuery } from '../../../../../../../src/plugins/data/public'; export interface AbsoluteTimeRange { kind: 'absolute'; diff --git a/x-pack/plugins/security_solution/public/common/store/inputs/selectors.ts b/x-pack/plugins/security_solution/public/common/store/inputs/selectors.ts index 3aedc4696f30..864a473a8209 100644 --- a/x-pack/plugins/security_solution/public/common/store/inputs/selectors.ts +++ b/x-pack/plugins/security_solution/public/common/store/inputs/selectors.ts @@ -7,7 +7,7 @@ import { createSelector } from 'reselect'; -import { Filter, Query } from '../../../../../../../src/plugins/data/public'; +import type { Filter, Query } from '@kbn/es-query'; import { State } from '../types'; import { InputsModel, InputsRange, GlobalQuery } from './model'; diff --git a/x-pack/plugins/security_solution/public/common/types.ts b/x-pack/plugins/security_solution/public/common/types.ts index 83a93769603e..443edc0a9c4a 100644 --- a/x-pack/plugins/security_solution/public/common/types.ts +++ b/x-pack/plugins/security_solution/public/common/types.ts @@ -6,7 +6,7 @@ */ import { ResponseErrorAttributes } from 'kibana/server'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { FieldSpec } from '../../../../../src/plugins/data_views/common'; export interface ServerApiError { diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_count_panel/index.test.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_count_panel/index.test.tsx index f1b7d8b06644..9660916d4f32 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_count_panel/index.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_count_panel/index.test.tsx @@ -9,8 +9,6 @@ import React from 'react'; import { waitFor, act } from '@testing-library/react'; import { mount } from 'enzyme'; -import { esQuery } from '../../../../../../../../src/plugins/data/public'; - import { TestProviders } from '../../../../common/mock'; import { AlertsCountPanel } from './index'; @@ -34,10 +32,11 @@ describe('AlertsCountPanel', () => { describe('Query', () => { it('it render with a illegal KQL', async () => { - const spyOnBuildEsQuery = jest.spyOn(esQuery, 'buildEsQuery'); - spyOnBuildEsQuery.mockImplementation(() => { - throw new Error('Something went wrong'); - }); + jest.mock('@kbn/es-query', () => ({ + buildEsQuery: jest.fn().mockImplementation(() => { + throw new Error('Something went wrong'); + }), + })); const props = { ...defaultProps, query: { query: 'host.name: "', language: 'kql' } }; const wrapper = mount( diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_count_panel/index.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_count_panel/index.tsx index 29324d186784..94b09c4a5ea2 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_count_panel/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_count_panel/index.tsx @@ -8,6 +8,8 @@ import React, { memo, useMemo, useState, useEffect } from 'react'; import uuid from 'uuid'; +import type { Filter, Query } from '@kbn/es-query'; +import { buildEsQuery } from '@kbn/es-query'; import { useGlobalTime } from '../../../../common/containers/use_global_time'; import { HeaderSection } from '../../../../common/components/header_section'; @@ -20,7 +22,6 @@ import { AlertsCount } from './alerts_count'; import type { AlertsCountAggregation } from './types'; import { DEFAULT_STACK_BY_FIELD } from '../common/config'; import type { AlertsStackByField } from '../common/types'; -import { Filter, esQuery, Query } from '../../../../../../../../src/plugins/data/public'; import { KpiPanel, StackBySelect } from '../common/components'; import { useInspectButton } from '../common/hooks'; @@ -52,7 +53,7 @@ export const AlertsCountPanel = memo( const additionalFilters = useMemo(() => { try { return [ - esQuery.buildEsQuery( + buildEsQuery( undefined, query != null ? [query] : [], filters?.filter((f) => f.meta.disabled === false) ?? [] diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.test.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.test.tsx index f53141ca9c10..09c184bb62bd 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { waitFor, act } from '@testing-library/react'; import { mount } from 'enzyme'; -import { esQuery, Filter } from '../../../../../../../../src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; import { TestProviders } from '../../../../common/mock'; import { SecurityPageName } from '../../../../app/types'; @@ -133,10 +133,11 @@ describe('AlertsHistogramPanel', () => { describe('Query', () => { it('it render with a illegal KQL', async () => { await act(async () => { - const spyOnBuildEsQuery = jest.spyOn(esQuery, 'buildEsQuery'); - spyOnBuildEsQuery.mockImplementation(() => { - throw new Error('Something went wrong'); - }); + jest.mock('@kbn/es-query', () => ({ + buildEsQuery: jest.fn().mockImplementation(() => { + throw new Error('Something went wrong'); + }), + })); const props = { ...defaultProps, query: { query: 'host.name: "', language: 'kql' } }; const wrapper = mount( diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.tsx index 9095f181b00c..873b5d40184e 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/index.tsx @@ -13,13 +13,14 @@ import styled from 'styled-components'; import { isEmpty } from 'lodash/fp'; import uuid from 'uuid'; +import { Filter, buildEsQuery, Query } from '@kbn/es-query'; import { useGlobalTime } from '../../../../common/containers/use_global_time'; import { DEFAULT_NUMBER_FORMAT, APP_UI_ID } from '../../../../../common/constants'; import type { UpdateDateRange } from '../../../../common/components/charts/common'; import type { LegendItem } from '../../../../common/components/charts/draggable_legend_item'; import { escapeDataProviderId } from '../../../../common/components/drag_and_drop/helpers'; import { HeaderSection } from '../../../../common/components/header_section'; -import { Filter, esQuery, Query } from '../../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../../src/plugins/data/common'; import { useQueryAlerts } from '../../../containers/detection_engine/alerts/use_query'; import { getDetectionEngineUrl, useFormatUrl } from '../../../../common/components/link_to'; import { defaultLegendColors } from '../../../../common/components/matrix_histogram/utils'; @@ -214,12 +215,12 @@ export const AlertsHistogramPanel = memo( if (combinedQueries != null) { converted = parseCombinedQueries(combinedQueries); } else { - converted = esQuery.buildEsQuery( + converted = buildEsQuery( undefined, query != null ? [query] : [], filters?.filter((f) => f.meta.disabled === false) ?? [], { - ...esQuery.getEsQueryConfig(kibana.services.uiSettings), + ...getEsQueryConfig(kibana.services.uiSettings), dateFormatTZ: undefined, } ); diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx index d37ba65eb8a8..73af79327512 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx @@ -23,7 +23,7 @@ import { TimelineStatus, TimelineTabs, } from '../../../../common/types/timeline'; -import { ISearchStart } from '../../../../../../../src/plugins/data/public'; +import type { ISearchStart } from '../../../../../../../src/plugins/data/public'; import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks'; import { getTimelineTemplate } from '../../../timelines/containers/api'; import { defaultHeaders } from '../../../timelines/components/timeline/body/column_headers/default_headers'; diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/default_config.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/default_config.tsx index 6c9d41b27ae2..3d64d2d45fbf 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/default_config.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/default_config.tsx @@ -17,11 +17,10 @@ import { ALERT_RULE_CATEGORY, } from '@kbn/rule-data-utils/technical_field_names'; +import type { Filter } from '@kbn/es-query'; import { defaultColumnHeaderType } from '../../../timelines/components/timeline/body/column_headers/default_headers'; import { ColumnHeaderOptions, RowRendererId } from '../../../../common/types/timeline'; import { Status } from '../../../../common/detection_engine/schemas/common/schemas'; -import { Filter } from '../../../../../../../src/plugins/data/common/es_query'; - import { SubsetTimelineModel } from '../../../timelines/store/timeline/model'; import { timelineDefaults } from '../../../timelines/store/timeline/defaults'; import { columns } from '../../configurations/security_solution_detections/columns'; diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.test.ts b/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.test.ts index 44d4c62c384a..11c25e4d3c9e 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/helpers.test.ts @@ -6,7 +6,7 @@ */ import { TimelineType } from '../../../../common/types/timeline'; -import { esFilters, Filter } from '../../../../../../../src/plugins/data/public'; +import { Filter, FilterStateStore } from '@kbn/es-query'; import { DataProvider, DataProviderType, @@ -563,7 +563,7 @@ describe('helpers', () => { }, }, $state: { - store: esFilters.FilterStateStore.APP_STATE, + store: FilterStateStore.APP_STATE, }, }, ]); diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/index.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/index.tsx index 76603c637f4c..bbab423738ca 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/index.tsx @@ -9,7 +9,8 @@ import { isEmpty } from 'lodash/fp'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { connect, ConnectedProps, useDispatch } from 'react-redux'; import { Dispatch } from 'redux'; -import { esQuery, Filter } from '../../../../../../../src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; +import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common'; import { Status } from '../../../../common/detection_engine/schemas/common/schemas'; import { RowRendererId, TimelineIdLiteral } from '../../../../common/types/timeline'; import { StatefulEventsViewer } from '../../../common/components/events_viewer'; @@ -113,7 +114,7 @@ export const AlertsTableComponent: React.FC = ({ (customFilters: Filter[]) => { if (browserFields != null && indexPatterns != null) { return combineQueries({ - config: esQuery.getEsQueryConfig(kibana.services.uiSettings), + config: getEsQueryConfig(kibana.services.uiSettings), dataProviders: [], indexPattern: indexPatterns, browserFields, diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/types.ts b/x-pack/plugins/security_solution/public/detections/components/alerts_table/types.ts index 3e525bfe25ad..1ca0fc9b7ca2 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/types.ts +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ISearchStart } from '../../../../../../../src/plugins/data/public'; +import type { ISearchStart } from '../../../../../../../src/plugins/data/public'; import { Status } from '../../../../common/detection_engine/schemas/common/schemas'; import { Ecs } from '../../../../common/ecs'; import { NoteResult } from '../../../../common/types/timeline/note'; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/autocomplete_field/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/autocomplete_field/index.tsx index 91dbadbb209e..3c733870e849 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/autocomplete_field/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/autocomplete_field/index.tsx @@ -8,7 +8,7 @@ import React, { useCallback, useMemo } from 'react'; import { EuiFormRow } from '@elastic/eui'; import { FieldComponent } from '@kbn/securitysolution-autocomplete'; -import { DataViewBase, DataViewFieldBase } from '@kbn/es-query'; +import type { DataViewBase, DataViewFieldBase } from '@kbn/es-query'; import { FieldHook } from '../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib'; interface AutocompleteFieldProps { diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/description_step/helpers.test.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/description_step/helpers.test.tsx index 1ab9f92bc6d8..7c345c3e07a2 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/description_step/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/description_step/helpers.test.tsx @@ -11,11 +11,11 @@ import { EuiLoadingSpinner } from '@elastic/eui'; import { coreMock } from '../../../../../../../../src/core/public/mocks'; import { - esFilters, FilterManager, UI_SETTINGS, + FilterLabel, } from '../../../../../../../../src/plugins/data/public'; -import { DataViewBase } from '@kbn/es-query'; +import { DataViewBase, FilterStateStore } from '@kbn/es-query'; import { SeverityBadge } from '../severity_badge'; import * as i18n from './translations'; @@ -49,7 +49,7 @@ const mockQueryBar = { filters: [ { $state: { - store: esFilters.FilterStateStore.GLOBAL_STATE, + store: FilterStateStore.GLOBAL_STATE, }, meta: { alias: null, @@ -149,7 +149,7 @@ describe('helpers', () => { } as unknown as DataViewBase, }); const wrapper = shallow(result[0].description as React.ReactElement); - const filterLabelComponent = wrapper.find(esFilters.FilterLabel).at(0); + const filterLabelComponent = wrapper.find(FilterLabel).at(0); expect(result[0].title).toEqual(<>{i18n.FILTERS_LABEL} ); expect(filterLabelComponent.prop('valueLabel')).toEqual('file'); diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/description_step/helpers.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/description_step/helpers.tsx index 305e0fcd46ef..b72c11fc3568 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/description_step/helpers.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/description_step/helpers.tsx @@ -28,7 +28,10 @@ import { assertUnreachable } from '../../../../../common/utility_types'; import * as i18nSeverity from '../severity_mapping/translations'; import * as i18nRiskScore from '../risk_score_mapping/translations'; import { Threshold } from '../../../../../common/detection_engine/schemas/common/schemas'; -import { esFilters } from '../../../../../../../../src/plugins/data/public'; +import { + getDisplayValueFromFilter, + FilterLabel, +} from '../../../../../../../../src/plugins/data/public'; import { subtechniquesOptions, @@ -82,9 +85,9 @@ export const buildQueryBarDescription = ({ {indexPatterns != null ? ( - ) : ( diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/description_step/index.test.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/description_step/index.test.tsx index b403e4a6fe19..70fc4cf61503 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/description_step/index.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/description_step/index.test.tsx @@ -15,12 +15,8 @@ import { getDescriptionItem, } from '.'; -import { - esFilters, - Filter, - FilterManager, - UI_SETTINGS, -} from '../../../../../../../../src/plugins/data/public'; +import { FilterManager, UI_SETTINGS } from '../../../../../../../../src/plugins/data/public'; +import { Filter, FilterStateStore } from '@kbn/es-query'; import { mockAboutStepRule, mockDefineStepRule, @@ -85,7 +81,7 @@ describe('description_step', () => { const filters: Filter[] = [ { $state: { - store: esFilters.FilterStateStore.GLOBAL_STATE, + store: FilterStateStore.GLOBAL_STATE, }, meta: { alias: null, @@ -105,7 +101,7 @@ describe('description_step', () => { }, { $state: { - store: esFilters.FilterStateStore.GLOBAL_STATE, + store: FilterStateStore.GLOBAL_STATE, }, meta: { alias: null, @@ -128,7 +124,7 @@ describe('description_step', () => { const expected: Filter[] = [ { $state: { - store: esFilters.FilterStateStore.GLOBAL_STATE, + store: FilterStateStore.GLOBAL_STATE, }, meta: { alias: null, @@ -148,7 +144,7 @@ describe('description_step', () => { }, { $state: { - store: esFilters.FilterStateStore.GLOBAL_STATE, + store: FilterStateStore.GLOBAL_STATE, }, meta: { alias: null, @@ -211,7 +207,7 @@ describe('description_step', () => { const expected: Filter[] = [ { $state: { - store: esFilters.FilterStateStore.APP_STATE, + store: FilterStateStore.APP_STATE, }, meta: { alias: null, @@ -231,7 +227,7 @@ describe('description_step', () => { }, { $state: { - store: esFilters.FilterStateStore.APP_STATE, + store: FilterStateStore.APP_STATE, }, meta: { alias: null, diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/description_step/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/description_step/index.tsx index e403da9e4909..62ea034dd0b3 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/description_step/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/description_step/index.tsx @@ -11,8 +11,8 @@ import React, { memo, useState } from 'react'; import styled from 'styled-components'; import { ThreatMapping, Threats, Type } from '@kbn/securitysolution-io-ts-alerting-types'; -import { DataViewBase } from '@kbn/es-query'; -import { Filter, esFilters, FilterManager } from '../../../../../../../../src/plugins/data/public'; +import { DataViewBase, Filter, FilterStateStore } from '@kbn/es-query'; +import { FilterManager } from '../../../../../../../../src/plugins/data/public'; import { DEFAULT_TIMELINE_TITLE } from '../../../../timelines/components/timeline/translations'; import { useKibana } from '../../../../common/lib/kibana'; import { AboutStepRiskScore, AboutStepSeverity } from '../../../pages/detection_engine/rules/types'; @@ -144,7 +144,7 @@ export const buildListItems = ( export const addFilterStateIfNotThere = (filters: Filter[]): Filter[] => { return filters.map((filter) => { if (filter.$state == null) { - return { $state: { store: esFilters.FilterStateStore.APP_STATE }, ...filter }; + return { $state: { store: FilterStateStore.APP_STATE }, ...filter }; } else { return filter; } diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/description_step/types.ts b/x-pack/plugins/security_solution/public/detections/components/rules/description_step/types.ts index 02c25e5c12be..ab7c0ea9ed47 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/description_step/types.ts +++ b/x-pack/plugins/security_solution/public/detections/components/rules/description_step/types.ts @@ -7,8 +7,8 @@ import { ReactNode } from 'react'; import { Threats } from '@kbn/securitysolution-io-ts-alerting-types'; -import { DataViewBase } from '@kbn/es-query'; -import { Filter, FilterManager } from '../../../../../../../../src/plugins/data/public'; +import type { DataViewBase, Filter } from '@kbn/es-query'; +import type { FilterManager } from '../../../../../../../../src/plugins/data/public'; export interface ListItems { title: NonNullable; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/query_bar/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/query_bar/index.tsx index 42f92f8cb6ce..0440ca8c311f 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/query_bar/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/query_bar/index.tsx @@ -10,7 +10,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { Subscription } from 'rxjs'; import styled from 'styled-components'; import deepEqual from 'fast-deep-equal'; -import { DataViewBase, Filter, Query } from '@kbn/es-query'; +import type { DataViewBase, Filter, Query } from '@kbn/es-query'; import { FilterManager, SavedQuery } from '../../../../../../../../src/plugins/data/public'; import { BrowserFields } from '../../../../common/containers/source'; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/query_preview/index.test.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/query_preview/index.test.tsx index 2ef114a25f32..f14bd5f7354d 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/query_preview/index.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/query_preview/index.test.tsx @@ -17,7 +17,7 @@ import { getMockEqlResponse } from '../../../../common/hooks/eql/eql_search_resp import { useMatrixHistogram } from '../../../../common/containers/matrix_histogram'; import { useEqlPreview } from '../../../../common/hooks/eql/'; import { getMockTheme } from '../../../../common/lib/kibana/kibana_react.mock'; -import { FilterMeta } from 'src/plugins/data/common'; +import type { FilterMeta } from '@kbn/es-query'; const mockTheme = getMockTheme({ eui: { diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/query_preview/reducer.ts b/x-pack/plugins/security_solution/public/detections/components/rules/query_preview/reducer.ts index 690e68561988..4e83db29de65 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/query_preview/reducer.ts +++ b/x-pack/plugins/security_solution/public/detections/components/rules/query_preview/reducer.ts @@ -9,8 +9,8 @@ import { Unit } from '@elastic/datemath'; import { EuiSelectOption } from '@elastic/eui'; import { Type, Language } from '@kbn/securitysolution-io-ts-alerting-types'; +import type { Filter } from '@kbn/es-query'; import * as i18n from '../rule_preview/translations'; -import { Filter } from '../../../../../../../../src/plugins/data/common/es_query'; import { ESQuery } from '../../../../../common/typed_json'; import { FieldValueQueryBar } from '../query_bar'; import { formatDate } from '../../../../common/components/super_date_picker'; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/risk_score_mapping/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/risk_score_mapping/index.tsx index fbeea64cae7d..fcc95f2398cf 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/risk_score_mapping/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/risk_score_mapping/index.tsx @@ -21,7 +21,7 @@ import styled from 'styled-components'; import { noop } from 'lodash/fp'; import { RiskScoreMapping } from '@kbn/securitysolution-io-ts-alerting-types'; import { FieldComponent } from '@kbn/securitysolution-autocomplete'; -import { DataViewBase, DataViewFieldBase } from '@kbn/es-query'; +import type { DataViewBase, DataViewFieldBase } from '@kbn/es-query'; import * as i18n from './translations'; import { FieldHook } from '../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib'; import { AboutStepRiskScore } from '../../../pages/detection_engine/rules/types'; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/helpers.ts b/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/helpers.ts index 9844afdf360b..9de802a39bf0 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/helpers.ts +++ b/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/helpers.ts @@ -9,14 +9,13 @@ import { Position, ScaleType } from '@elastic/charts'; import { EuiSelectOption } from '@elastic/eui'; import { Type, Language, ThreatMapping } from '@kbn/securitysolution-io-ts-alerting-types'; import { Unit } from '@elastic/datemath'; +import type { Filter } from '@kbn/es-query'; import * as i18n from './translations'; import { histogramDateTimeFormatter } from '../../../../common/components/utils'; import { ChartSeriesConfigs } from '../../../../common/components/charts/common'; import { getQueryFilter } from '../../../../../common/detection_engine/get_query_filter'; import { FieldValueQueryBar } from '../query_bar'; import { ESQuery } from '../../../../../common/typed_json'; -import { Filter } from '../../../../../../../../src/plugins/data/common/es_query'; - /** * Determines whether or not to display noise warning. * Is considered noisy if alerts/hour rate > 1 diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/severity_mapping/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/severity_mapping/index.tsx index f6578fab0c5f..da7b1e006769 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/severity_mapping/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/severity_mapping/index.tsx @@ -29,7 +29,7 @@ import { AutocompleteFieldMatchComponent, } from '@kbn/securitysolution-autocomplete'; -import { DataViewBase, DataViewFieldBase } from '@kbn/es-query'; +import type { DataViewBase, DataViewFieldBase } from '@kbn/es-query'; import * as i18n from './translations'; import { FieldHook } from '../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib'; import { SeverityOptionItem } from '../step_about_rule/data'; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/threatmatch_input/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/threatmatch_input/index.tsx index 91158979a82c..961007f2dac4 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/threatmatch_input/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/threatmatch_input/index.tsx @@ -7,7 +7,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiFormRow } from '@elastic/eui'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { ThreatMapEntries } from '../../../../common/components/threat_match/types'; import { ThreatMatchComponent } from '../../../../common/components/threat_match'; import { BrowserField } from '../../../../common/containers/source'; diff --git a/x-pack/plugins/security_solution/public/detections/jest.config.js b/x-pack/plugins/security_solution/public/detections/jest.config.js index 23bc914b6493..1121326c4ee3 100644 --- a/x-pack/plugins/security_solution/public/detections/jest.config.js +++ b/x-pack/plugins/security_solution/public/detections/jest.config.js @@ -15,4 +15,12 @@ module.exports = { collectCoverageFrom: [ '/x-pack/plugins/security_solution/public/detections/**/*.{ts,tsx}', ], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/__mocks__/mock.ts b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/__mocks__/mock.ts index 821413b36170..77de8902be33 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/__mocks__/mock.ts +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/__mocks__/mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { esFilters } from '../../../../../../../../../../src/plugins/data/public'; +import { FilterStateStore } from '@kbn/es-query'; import { Rule, RuleError } from '../../../../../containers/detection_engine/rules'; import { AboutStepRule, ActionsStepRule, DefineStepRule, ScheduleStepRule } from '../../types'; import { FieldValueQueryBar } from '../../../../../components/rules/query_bar'; @@ -20,7 +20,7 @@ export const mockQueryBar: FieldValueQueryBar = { filters: [ { $state: { - store: esFilters.FilterStateStore.GLOBAL_STATE, + store: FilterStateStore.GLOBAL_STATE, }, meta: { alias: null, @@ -94,7 +94,7 @@ export const mockRuleWithEverything = (id: string): Rule => ({ filters: [ { $state: { - store: esFilters.FilterStateStore.GLOBAL_STATE, + store: FilterStateStore.GLOBAL_STATE, }, meta: { alias: null, diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.test.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.test.tsx index fa600d9ce4a0..d8c17f064d01 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.test.tsx @@ -22,7 +22,8 @@ import { fillEmptySeverityMappings, } from './helpers'; import { mockRuleWithEverything, mockRule } from './all/__mocks__/mock'; -import { esFilters } from '../../../../../../../../src/plugins/data/public'; +import { FilterStateStore } from '@kbn/es-query'; + import { Rule } from '../../../containers/detection_engine/rules'; import { AboutStepRule, @@ -60,7 +61,7 @@ describe('rule helpers', () => { filters: [ { $state: { - store: esFilters.FilterStateStore.GLOBAL_STATE, + store: FilterStateStore.GLOBAL_STATE, }, meta: { alias: null, diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.tsx index 18b5d7451619..39a6b12d6313 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.tsx @@ -19,12 +19,12 @@ import { Severity, } from '@kbn/securitysolution-io-ts-alerting-types'; import { ENDPOINT_LIST_ID } from '@kbn/securitysolution-list-constants'; +import type { Filter } from '@kbn/es-query'; import { ActionVariables } from '../../../../../../triggers_actions_ui/public'; import { normalizeThresholdField } from '../../../../../common/detection_engine/utils'; import { RuleAlertAction } from '../../../../../common/detection_engine/types'; import { assertUnreachable } from '../../../../../common/utility_types'; import { transformRuleToAlertAction } from '../../../../../common/detection_engine/transform_actions'; -import { Filter } from '../../../../../../../../src/plugins/data/public'; import { Rule } from '../../../containers/detection_engine/rules'; import { AboutStepRule, diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/types.ts b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/types.ts index dc580f591da5..c1141ba527db 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/types.ts +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/types.ts @@ -15,9 +15,9 @@ import { SeverityMapping, Severity, } from '@kbn/securitysolution-io-ts-alerting-types'; +import type { Filter } from '@kbn/es-query'; import { RuleAlertAction } from '../../../../../common/detection_engine/types'; import { AlertAction } from '../../../../../../alerting/common'; -import { Filter } from '../../../../../../../../src/plugins/data/common'; import { FieldValueQueryBar } from '../../../components/rules/query_bar'; import { FieldValueTimeline } from '../../../components/rules/pick_timeline'; import { FieldValueThreshold } from '../../../components/rules/threshold_input'; diff --git a/x-pack/plugins/security_solution/public/hosts/jest.config.js b/x-pack/plugins/security_solution/public/hosts/jest.config.js index b0ead04130b7..d8354b47c3cb 100644 --- a/x-pack/plugins/security_solution/public/hosts/jest.config.js +++ b/x-pack/plugins/security_solution/public/hosts/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/hosts', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/public/hosts/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/hosts/pages/details/helpers.test.ts b/x-pack/plugins/security_solution/public/hosts/pages/details/helpers.test.ts index 3139cc4ed4ff..77cb6f5f54a7 100644 --- a/x-pack/plugins/security_solution/public/hosts/pages/details/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/hosts/pages/details/helpers.test.ts @@ -6,7 +6,7 @@ */ import { getHostDetailsEventsKqlQueryExpression, getHostDetailsPageFilters } from './helpers'; -import { Filter } from '../../../../../../../src/plugins/data/common/es_query'; +import type { Filter } from '@kbn/es-query'; describe('hosts page helpers', () => { describe('getHostDetailsEventsKqlQueryExpression', () => { diff --git a/x-pack/plugins/security_solution/public/hosts/pages/details/helpers.ts b/x-pack/plugins/security_solution/public/hosts/pages/details/helpers.ts index b768e3188d14..0a09c7ec6dad 100644 --- a/x-pack/plugins/security_solution/public/hosts/pages/details/helpers.ts +++ b/x-pack/plugins/security_solution/public/hosts/pages/details/helpers.ts @@ -5,8 +5,8 @@ * 2.0. */ +import type { Filter } from '@kbn/es-query'; import { escapeQueryValue } from '../../../common/lib/keury'; -import { Filter } from '../../../../../../../src/plugins/data/public'; /** Returns the kqlQueryExpression for the `Events` widget on the `Host Details` page */ export const getHostDetailsEventsKqlQueryExpression = ({ diff --git a/x-pack/plugins/security_solution/public/hosts/pages/details/index.tsx b/x-pack/plugins/security_solution/public/hosts/pages/details/index.tsx index 55c799f3bda4..15011b88f439 100644 --- a/x-pack/plugins/security_solution/public/hosts/pages/details/index.tsx +++ b/x-pack/plugins/security_solution/public/hosts/pages/details/index.tsx @@ -10,6 +10,7 @@ import { noop } from 'lodash/fp'; import React, { useEffect, useCallback, useMemo } from 'react'; import { useDispatch } from 'react-redux'; +import type { Filter } from '@kbn/es-query'; import { HostItem, LastEventIndexKey } from '../../../../common/search_strategy'; import { SecurityPageName } from '../../../app/types'; import { UpdateDateRange } from '../../../common/components/charts/common'; @@ -33,7 +34,7 @@ import { inputsSelectors } from '../../../common/store'; import { setHostDetailsTablesActivePageToZero } from '../../store/actions'; import { setAbsoluteRangeDatePicker } from '../../../common/store/inputs/actions'; import { SpyRoute } from '../../../common/utils/route/spy_routes'; -import { esQuery, Filter } from '../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common'; import { OverviewEmpty } from '../../../overview/components/overview_empty'; import { HostDetailsTabs } from './details_tabs'; @@ -106,7 +107,7 @@ const HostDetailsComponent: React.FC = ({ detailName, hostDeta skip: selectedPatterns.length === 0, }); const [filterQuery, kqlError] = convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(kibana.services.uiSettings), + config: getEsQueryConfig(kibana.services.uiSettings), indexPattern, queries: [query], filters: getFilters(), diff --git a/x-pack/plugins/security_solution/public/hosts/pages/details/types.ts b/x-pack/plugins/security_solution/public/hosts/pages/details/types.ts index cd9ee9ce0186..a06aac50b760 100644 --- a/x-pack/plugins/security_solution/public/hosts/pages/details/types.ts +++ b/x-pack/plugins/security_solution/public/hosts/pages/details/types.ts @@ -6,7 +6,7 @@ */ import { ActionCreator } from 'typescript-fsa'; -import { DataViewBase, Filter, Query } from '@kbn/es-query'; +import type { DataViewBase, Filter, Query } from '@kbn/es-query'; import { InputsModelId } from '../../../common/store/inputs/constants'; import { HostsTableType } from '../../store/model'; import { HostsQueryProps } from '../types'; diff --git a/x-pack/plugins/security_solution/public/hosts/pages/hosts.test.tsx b/x-pack/plugins/security_solution/public/hosts/pages/hosts.test.tsx index 51dd9d230324..2305c2faad8a 100644 --- a/x-pack/plugins/security_solution/public/hosts/pages/hosts.test.tsx +++ b/x-pack/plugins/security_solution/public/hosts/pages/hosts.test.tsx @@ -9,7 +9,7 @@ import { mount } from 'enzyme'; import React from 'react'; import { Router } from 'react-router-dom'; -import { Filter } from '../../../../../../src/plugins/data/common/es_query'; +import type { Filter } from '@kbn/es-query'; import '../../common/mock/match_media'; import { TestProviders, diff --git a/x-pack/plugins/security_solution/public/hosts/pages/hosts.tsx b/x-pack/plugins/security_solution/public/hosts/pages/hosts.tsx index 8417e8f3ae8b..96086e2de1b3 100644 --- a/x-pack/plugins/security_solution/public/hosts/pages/hosts.tsx +++ b/x-pack/plugins/security_solution/public/hosts/pages/hosts.tsx @@ -33,7 +33,7 @@ import { inputsSelectors } from '../../common/store'; import { setAbsoluteRangeDatePicker } from '../../common/store/inputs/actions'; import { SpyRoute } from '../../common/utils/route/spy_routes'; -import { esQuery } from '../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../src/plugins/data/common'; import { useMlCapabilities } from '../../common/components/ml/hooks/use_ml_capabilities'; import { OverviewEmpty } from '../../overview/components/overview_empty'; import { Display } from './display'; @@ -115,7 +115,7 @@ const HostsComponent = () => { const [filterQuery, kqlError] = useMemo( () => convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), indexPattern, queries: [query], filters, @@ -125,7 +125,7 @@ const HostsComponent = () => { const [tabsFilterQuery] = useMemo( () => convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), indexPattern, queries: [query], filters: tabsFilters, diff --git a/x-pack/plugins/security_solution/public/hosts/pages/navigation/alerts_query_tab_body.tsx b/x-pack/plugins/security_solution/public/hosts/pages/navigation/alerts_query_tab_body.tsx index 2d83efa7b0bd..41c0f93760cb 100644 --- a/x-pack/plugins/security_solution/public/hosts/pages/navigation/alerts_query_tab_body.tsx +++ b/x-pack/plugins/security_solution/public/hosts/pages/navigation/alerts_query_tab_body.tsx @@ -7,7 +7,7 @@ import React, { useMemo } from 'react'; -import { Filter } from '../../../../../../../src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; import { TimelineId } from '../../../../common/types/timeline'; import { AlertsView } from '../../../common/components/alerts_viewer'; import { AlertsComponentQueryProps } from './types'; diff --git a/x-pack/plugins/security_solution/public/hosts/pages/navigation/types.ts b/x-pack/plugins/security_solution/public/hosts/pages/navigation/types.ts index c051d85f0556..0daf3cad34aa 100644 --- a/x-pack/plugins/security_solution/public/hosts/pages/navigation/types.ts +++ b/x-pack/plugins/security_solution/public/hosts/pages/navigation/types.ts @@ -5,8 +5,9 @@ * 2.0. */ +import type { Filter } from '@kbn/es-query'; import { ESTermQuery } from '../../../../common/typed_json'; -import { Filter } from '../../../../../../../src/plugins/data/public'; + import { NarrowDateRange } from '../../../common/components/ml/types'; import { GlobalTimeArgs } from '../../../common/containers/use_global_time'; import { HostsTableType, HostsType } from '../../store/model'; diff --git a/x-pack/plugins/security_solution/public/jest.config.js b/x-pack/plugins/security_solution/public/jest.config.js index f2bde770370f..5eb349b2c16e 100644 --- a/x-pack/plugins/security_solution/public/jest.config.js +++ b/x-pack/plugins/security_solution/public/jest.config.js @@ -15,4 +15,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/public/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/management/jest.config.js b/x-pack/plugins/security_solution/public/management/jest.config.js index fdb6212ef6c8..3e5560b56aa0 100644 --- a/x-pack/plugins/security_solution/public/management/jest.config.js +++ b/x-pack/plugins/security_solution/public/management/jest.config.js @@ -15,4 +15,12 @@ module.exports = { collectCoverageFrom: [ '/x-pack/plugins/security_solution/public/management/**/*.{ts,tsx}', ], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/models/index_pattern.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/models/index_pattern.ts index 71e7c82f4a65..65aa832226d5 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/models/index_pattern.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/models/index_pattern.ts @@ -6,9 +6,9 @@ */ import { all } from 'deepmerge'; -import { IIndexPattern } from '../../../../../../../../src/plugins/data/common'; +import type { DataViewBase } from '@kbn/es-query'; import { Immutable } from '../../../../../common/endpoint/types'; -export function clone(value: IIndexPattern | Immutable): IIndexPattern { - return all([value]) as IIndexPattern; +export function clone(value: DataViewBase | Immutable): DataViewBase { + return all([value]) as DataViewBase; } diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/action.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/action.ts index 6e9c1f69cb06..c838f0bee7c6 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/action.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/action.ts @@ -7,7 +7,7 @@ import { Action } from 'redux'; import { EuiSuperDatePickerRecentRange } from '@elastic/eui'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { HostResultList, HostInfo, diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts index 9f8c280fac30..287f66a48fce 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts @@ -9,7 +9,7 @@ import { Dispatch } from 'redux'; import semverGte from 'semver/functions/gte'; import { CoreStart, HttpStart } from 'kibana/public'; -import { DataViewBase, Query } from '@kbn/es-query'; +import type { DataViewBase, Query } from '@kbn/es-query'; import { ActivityLog, GetHostPolicyResponse, diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/selectors.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/selectors.ts index a6fed8d6528c..caf5b40a6834 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/selectors.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/selectors.ts @@ -10,6 +10,7 @@ import querystring from 'querystring'; import { createSelector } from 'reselect'; import { matchPath } from 'react-router-dom'; import { decode } from 'rison-node'; +import { Query } from '@kbn/es-query'; import { Immutable, HostPolicyResponseAppliedAction, @@ -26,7 +27,6 @@ import { MANAGEMENT_DEFAULT_PAGE_SIZE, MANAGEMENT_ROUTING_ENDPOINTS_PATH, } from '../../../common/constants'; -import { Query } from '../../../../../../../../src/plugins/data/common/query/types'; import { getLastLoadedResourceState, isFailedResourceState, diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts index 1a87223cdd01..0a5e1362edaf 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts @@ -6,7 +6,7 @@ */ import { EuiSuperDatePickerRecentRange } from '@elastic/eui'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { ActivityLog, HostInfo, diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/components/search_bar.tsx b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/components/search_bar.tsx index 18d22e0cd1b1..ec65239d340d 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/components/search_bar.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/components/search_bar.tsx @@ -9,7 +9,8 @@ import React, { memo, useCallback, useMemo } from 'react'; import { useHistory } from 'react-router-dom'; import { encode, RisonValue } from 'rison-node'; import styled from 'styled-components'; -import { Query, SearchBar, TimeHistory } from '../../../../../../../../../src/plugins/data/public'; +import type { Query } from '@kbn/es-query'; +import { SearchBar, TimeHistory } from '../../../../../../../../../src/plugins/data/public'; import { Storage } from '../../../../../../../../../src/plugins/kibana_utils/public'; import { urlFromQueryParams } from '../url_from_query_params'; import { useEndpointSelector } from '../hooks'; diff --git a/x-pack/plugins/security_solution/public/network/components/embeddables/embedded_map.tsx b/x-pack/plugins/security_solution/public/network/components/embeddables/embedded_map.tsx index 15a0f870d7bd..cc87a3894443 100644 --- a/x-pack/plugins/security_solution/public/network/components/embeddables/embedded_map.tsx +++ b/x-pack/plugins/security_solution/public/network/components/embeddables/embedded_map.tsx @@ -11,6 +11,7 @@ import React, { useEffect, useState, useMemo } from 'react'; import { createPortalNode, InPortal } from 'react-reverse-portal'; import styled, { css } from 'styled-components'; +import type { Filter, Query } from '@kbn/es-query'; import { ErrorEmbeddable, isErrorEmbeddable, @@ -26,7 +27,6 @@ import { MapToolTip } from './map_tool_tip/map_tool_tip'; import * as i18n from './translations'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { MapEmbeddable } from '../../../../../../plugins/maps/public/embeddable'; -import { Query, Filter } from '../../../../../../../src/plugins/data/public'; import { useKibana } from '../../../common/lib/kibana'; import { getLayerList } from './map_config'; import { sourcererSelectors } from '../../../common/store/sourcerer'; diff --git a/x-pack/plugins/security_solution/public/network/components/embeddables/embedded_map_helpers.tsx b/x-pack/plugins/security_solution/public/network/components/embeddables/embedded_map_helpers.tsx index b02e6513d9b4..3789c41f23a7 100644 --- a/x-pack/plugins/security_solution/public/network/components/embeddables/embedded_map_helpers.tsx +++ b/x-pack/plugins/security_solution/public/network/components/embeddables/embedded_map_helpers.tsx @@ -9,6 +9,7 @@ import uuid from 'uuid'; import React from 'react'; import { OutPortal, PortalNode } from 'react-reverse-portal'; import minimatch from 'minimatch'; +import type { Filter, Query } from '@kbn/es-query'; import { IndexPatternMapping } from './types'; import { getLayerList } from './map_config'; import { MAP_SAVED_OBJECT_TYPE } from '../../../../../maps/public'; @@ -18,7 +19,7 @@ import type { MapEmbeddableInput, } from '../../../../../../plugins/maps/public'; import * as i18n from './translations'; -import { Query, Filter } from '../../../../../../../src/plugins/data/public'; + import { EmbeddableStart, isErrorEmbeddable, diff --git a/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/columns.tsx b/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/columns.tsx index 4c50a3a0f49c..5a2780164a8a 100644 --- a/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/columns.tsx +++ b/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/columns.tsx @@ -8,7 +8,7 @@ import { get } from 'lodash/fp'; import numeral from '@elastic/numeral'; import React from 'react'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { CountryFlagAndName } from '../source_destination/country_flag'; import { FlowTargetSourceDest, diff --git a/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/index.tsx b/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/index.tsx index 23b453c0f738..80de694f8948 100644 --- a/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/index.tsx +++ b/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/index.tsx @@ -9,7 +9,7 @@ import { last } from 'lodash/fp'; import React, { useCallback, useMemo } from 'react'; import { useDispatch } from 'react-redux'; import deepEqual from 'fast-deep-equal'; -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { networkActions, networkModel, networkSelectors } from '../../store'; import { diff --git a/x-pack/plugins/security_solution/public/network/jest.config.js b/x-pack/plugins/security_solution/public/network/jest.config.js index 6059805c0652..98b45b1e5699 100644 --- a/x-pack/plugins/security_solution/public/network/jest.config.js +++ b/x-pack/plugins/security_solution/public/network/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/network', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/public/network/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/network/pages/details/index.tsx b/x-pack/plugins/security_solution/public/network/pages/details/index.tsx index e0ede2d23846..ef7dea516446 100644 --- a/x-pack/plugins/security_solution/public/network/pages/details/index.tsx +++ b/x-pack/plugins/security_solution/public/network/pages/details/index.tsx @@ -45,7 +45,7 @@ import { NetworkTopNFlowQueryTable } from './network_top_n_flow_query_table'; import { TlsQueryTable } from './tls_query_table'; import { UsersQueryTable } from './users_query_table'; import { AnomaliesQueryTabBody } from '../../../common/containers/anomalies/anomalies_query_tab_body'; -import { esQuery } from '../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common'; import { networkModel } from '../../store'; import { SecurityPageName } from '../../../app/types'; import { useSourcererDataView } from '../../../common/containers/sourcerer'; @@ -95,7 +95,7 @@ const NetworkDetailsComponent: React.FC = () => { const { docValueFields, indicesExist, indexPattern, selectedPatterns } = useSourcererDataView(); const ip = decodeIpv6(detailName); const [filterQuery, kqlError] = convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), indexPattern, queries: [query], filters, diff --git a/x-pack/plugins/security_solution/public/network/pages/details/types.ts b/x-pack/plugins/security_solution/public/network/pages/details/types.ts index 02722f4709bc..7a8b95c1e62f 100644 --- a/x-pack/plugins/security_solution/public/network/pages/details/types.ts +++ b/x-pack/plugins/security_solution/public/network/pages/details/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { ESTermQuery } from '../../../../common/typed_json'; import { NetworkType } from '../../store/model'; diff --git a/x-pack/plugins/security_solution/public/network/pages/navigation/alerts_query_tab_body.tsx b/x-pack/plugins/security_solution/public/network/pages/navigation/alerts_query_tab_body.tsx index 553281144ebf..026aa9f68871 100644 --- a/x-pack/plugins/security_solution/public/network/pages/navigation/alerts_query_tab_body.tsx +++ b/x-pack/plugins/security_solution/public/network/pages/navigation/alerts_query_tab_body.tsx @@ -7,7 +7,7 @@ import React from 'react'; -import { Filter } from '../../../../../../../src/plugins/data/common/es_query'; +import type { Filter } from '@kbn/es-query'; import { TimelineId } from '../../../../common/types/timeline'; import { AlertsView } from '../../../common/components/alerts_viewer'; import { NetworkComponentQueryProps } from './types'; diff --git a/x-pack/plugins/security_solution/public/network/pages/navigation/types.ts b/x-pack/plugins/security_solution/public/network/pages/navigation/types.ts index 96b72caf0330..6c1fd99415c4 100644 --- a/x-pack/plugins/security_solution/public/network/pages/navigation/types.ts +++ b/x-pack/plugins/security_solution/public/network/pages/navigation/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { DataViewBase } from '@kbn/es-query'; +import type { DataViewBase } from '@kbn/es-query'; import { ESTermQuery } from '../../../../common/typed_json'; import { NavTab } from '../../../common/components/navigation/types'; diff --git a/x-pack/plugins/security_solution/public/network/pages/network.test.tsx b/x-pack/plugins/security_solution/public/network/pages/network.test.tsx index d0fff882cdc8..014beb28c374 100644 --- a/x-pack/plugins/security_solution/public/network/pages/network.test.tsx +++ b/x-pack/plugins/security_solution/public/network/pages/network.test.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { Router } from 'react-router-dom'; import { waitFor } from '@testing-library/react'; import '../../common/mock/match_media'; -import { Filter } from '../../../../../../src/plugins/data/common/es_query'; +import type { Filter } from '@kbn/es-query'; import { useSourcererDataView } from '../../common/containers/sourcerer'; import { TestProviders, diff --git a/x-pack/plugins/security_solution/public/network/pages/network.tsx b/x-pack/plugins/security_solution/public/network/pages/network.tsx index f38a26da0059..d1d686bfe09d 100644 --- a/x-pack/plugins/security_solution/public/network/pages/network.tsx +++ b/x-pack/plugins/security_solution/public/network/pages/network.tsx @@ -13,7 +13,7 @@ import { useParams } from 'react-router-dom'; import styled from 'styled-components'; import { isTab } from '../../../../timelines/public'; -import { esQuery } from '../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../src/plugins/data/common'; import { SecurityPageName } from '../../app/types'; import { UpdateDateRange } from '../../common/components/charts/common'; import { EmbeddedMap } from '../components/embeddables/embedded_map'; @@ -136,13 +136,13 @@ const NetworkComponent = React.memo( ); const [filterQuery, kqlError] = convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(kibana.services.uiSettings), + config: getEsQueryConfig(kibana.services.uiSettings), indexPattern, queries: [query], filters, }); const [tabsFilterQuery] = convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(kibana.services.uiSettings), + config: getEsQueryConfig(kibana.services.uiSettings), indexPattern, queries: [query], filters: tabsFilters, diff --git a/x-pack/plugins/security_solution/public/overview/components/alerts_by_category/index.tsx b/x-pack/plugins/security_solution/public/overview/components/alerts_by_category/index.tsx index bce9dd9fa9d0..acf85dcf55d1 100644 --- a/x-pack/plugins/security_solution/public/overview/components/alerts_by_category/index.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/alerts_by_category/index.tsx @@ -9,13 +9,13 @@ import numeral from '@elastic/numeral'; import React, { useEffect, useMemo, useCallback } from 'react'; import { Position } from '@elastic/charts'; -import { DataViewBase, Filter, Query } from '@kbn/es-query'; +import type { DataViewBase, Filter, Query } from '@kbn/es-query'; import { DEFAULT_NUMBER_FORMAT, APP_UI_ID } from '../../../../common/constants'; import { SHOWING, UNIT } from '../../../common/components/alerts_viewer/translations'; import { MatrixHistogram } from '../../../common/components/matrix_histogram'; import { useKibana, useUiSetting$ } from '../../../common/lib/kibana'; import { convertToBuildEsQuery } from '../../../common/lib/keury'; -import { esQuery } from '../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common'; import { HostsTableType } from '../../../hosts/store/model'; import * as i18n from '../../pages/translations'; @@ -101,7 +101,7 @@ const AlertsByCategoryComponent: React.FC = ({ const [filterQuery, kqlError] = useMemo( () => convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), indexPattern, queries: [query], filters, diff --git a/x-pack/plugins/security_solution/public/overview/components/event_counts/index.tsx b/x-pack/plugins/security_solution/public/overview/components/event_counts/index.tsx index 8ec38549477f..b8e04e40e6df 100644 --- a/x-pack/plugins/security_solution/public/overview/components/event_counts/index.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/event_counts/index.tsx @@ -9,7 +9,7 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React, { useMemo } from 'react'; import styled from 'styled-components'; -import { DataViewBase, Filter, Query } from '@kbn/es-query'; +import type { DataViewBase, Filter, Query } from '@kbn/es-query'; import { ID as OverviewHostQueryId } from '../../containers/overview_host'; import { OverviewHost } from '../overview_host'; import { OverviewNetwork } from '../overview_network'; @@ -17,7 +17,7 @@ import { filterHostData } from '../../../hosts/pages/navigation/alerts_query_tab import { useKibana } from '../../../common/lib/kibana'; import { convertToBuildEsQuery } from '../../../common/lib/keury'; import { filterNetworkData } from '../../../network/pages/navigation/alerts_query_tab_body'; -import { esQuery } from '../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common'; import { GlobalTimeArgs } from '../../../common/containers/use_global_time'; import { useInvalidFilterQuery } from '../../../common/hooks/use_invalid_filter_query'; @@ -46,7 +46,7 @@ const EventCountsComponent: React.FC = ({ const [hostFilterQuery, hostKqlError] = useMemo( () => convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), indexPattern, queries: [query], filters: [...filters, ...filterHostData], @@ -57,7 +57,7 @@ const EventCountsComponent: React.FC = ({ const [networkFilterQuery] = useMemo( () => convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), indexPattern, queries: [query], filters: [...filters, ...filterNetworkData], diff --git a/x-pack/plugins/security_solution/public/overview/components/events_by_dataset/index.tsx b/x-pack/plugins/security_solution/public/overview/components/events_by_dataset/index.tsx index a184ba572d77..7f0726b14305 100644 --- a/x-pack/plugins/security_solution/public/overview/components/events_by_dataset/index.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/events_by_dataset/index.tsx @@ -10,7 +10,7 @@ import numeral from '@elastic/numeral'; import React, { useEffect, useMemo, useCallback } from 'react'; import uuid from 'uuid'; -import { DataViewBase, Filter, Query } from '@kbn/es-query'; +import type { DataViewBase, Filter, Query } from '@kbn/es-query'; import { DEFAULT_NUMBER_FORMAT, APP_UI_ID } from '../../../../common/constants'; import { SHOWING, UNIT } from '../../../common/components/events_viewer/translations'; import { getTabsOnHostsUrl } from '../../../common/components/link_to/redirect_to_hosts'; @@ -23,7 +23,7 @@ import { eventsStackByOptions } from '../../../hosts/pages/navigation'; import { convertToBuildEsQuery } from '../../../common/lib/keury'; import { useKibana, useUiSetting$ } from '../../../common/lib/kibana'; import { histogramConfigs } from '../../../hosts/pages/navigation/events_query_tab_body'; -import { esQuery } from '../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common'; import { HostsTableType } from '../../../hosts/store/model'; import { InputsModelId } from '../../../common/store/inputs/constants'; import { GlobalTimeArgs } from '../../../common/containers/use_global_time'; @@ -120,7 +120,7 @@ const EventsByDatasetComponent: React.FC = ({ const [filterQuery, kqlError] = useMemo(() => { if (combinedQueries == null) { return convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(kibana.services.uiSettings), + config: getEsQueryConfig(kibana.services.uiSettings), indexPattern, queries: [query], filters, diff --git a/x-pack/plugins/security_solution/public/overview/components/signals_by_category/use_filters_for_signals_by_category.ts b/x-pack/plugins/security_solution/public/overview/components/signals_by_category/use_filters_for_signals_by_category.ts index 6f87cb72763d..69d43d822eff 100644 --- a/x-pack/plugins/security_solution/public/overview/components/signals_by_category/use_filters_for_signals_by_category.ts +++ b/x-pack/plugins/security_solution/public/overview/components/signals_by_category/use_filters_for_signals_by_category.ts @@ -6,7 +6,7 @@ */ import { useMemo } from 'react'; -import { Filter } from '@kbn/es-query'; +import type { Filter } from '@kbn/es-query'; import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features'; import { diff --git a/x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_request_event_counts.ts b/x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_request_event_counts.ts index 14a5bf8ca254..a1bf4d9d35f6 100644 --- a/x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_request_event_counts.ts +++ b/x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_request_event_counts.ts @@ -7,7 +7,7 @@ import { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { convertToBuildEsQuery } from '../../../common/lib/keury'; -import { getEsQueryConfig } from '../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common'; import { MatrixHistogramType } from '../../../../common/search_strategy'; import { EVENT_DATASET } from '../../../../common/cti/constants'; import { useMatrixHistogram } from '../../../common/containers/matrix_histogram'; diff --git a/x-pack/plugins/security_solution/public/overview/containers/overview_risky_host_links/use_hosts_risk_score_complete.ts b/x-pack/plugins/security_solution/public/overview/containers/overview_risky_host_links/use_hosts_risk_score_complete.ts index 22e3b5869212..f925339e6849 100644 --- a/x-pack/plugins/security_solution/public/overview/containers/overview_risky_host_links/use_hosts_risk_score_complete.ts +++ b/x-pack/plugins/security_solution/public/overview/containers/overview_risky_host_links/use_hosts_risk_score_complete.ts @@ -8,11 +8,10 @@ import { Observable } from 'rxjs'; import { filter } from 'rxjs/operators'; import { useObservable, withOptionalSignal } from '@kbn/securitysolution-hook-utils'; -import { - DataPublicPluginStart, - isCompleteResponse, - isErrorResponse, -} from '../../../../../../../src/plugins/data/public'; +import type { DataPublicPluginStart } from '../../../../../../../src/plugins/data/public'; + +import { isCompleteResponse, isErrorResponse } from '../../../../../../../src/plugins/data/common'; + import { HostsQueries, HostsRiskScoreRequestOptions, diff --git a/x-pack/plugins/security_solution/public/overview/jest.config.js b/x-pack/plugins/security_solution/public/overview/jest.config.js index 673eece7a36f..b34dea8802c5 100644 --- a/x-pack/plugins/security_solution/public/overview/jest.config.js +++ b/x-pack/plugins/security_solution/public/overview/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/overview', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/public/overview/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/resolver/jest.config.js b/x-pack/plugins/security_solution/public/resolver/jest.config.js index 43e1202d9d8d..f517075bf596 100644 --- a/x-pack/plugins/security_solution/public/resolver/jest.config.js +++ b/x-pack/plugins/security_solution/public/resolver/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/resolver', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/public/resolver/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.test.tsx index 4fb2b9419c37..d373710c2944 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.test.tsx @@ -15,7 +15,7 @@ import { import { TestProviders } from '../../../common/mock'; import { useKibana } from '../../../common/lib/kibana'; -import { DataView } from '../../../../../../../src/plugins/data/common'; +import type { DataView } from '../../../../../../../src/plugins/data/common'; import { TimelineId } from '../../../../common'; const useKibanaMock = useKibana as jest.Mocked; diff --git a/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx index 33d8587eca81..8c6b8a01ea1f 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx @@ -10,7 +10,7 @@ import { EuiButton } from '@elastic/eui'; import styled from 'styled-components'; import { useDispatch } from 'react-redux'; -import { IndexPattern, IndexPatternField } from '../../../../../../../src/plugins/data/public'; +import type { DataViewField, DataView } from '../../../../../../../src/plugins/data_views/common'; import { useKibana } from '../../../common/lib/kibana'; import * as i18n from './translations'; @@ -34,7 +34,7 @@ const StyledButton = styled(EuiButton)` export const CreateFieldButton = React.memo( ({ selectedDataViewId, onClick: onClickParam, timelineId }) => { - const [dataView, setDataView] = useState(null); + const [dataView, setDataView] = useState(null); const dispatch = useDispatch(); const { indexFieldsSearch } = useDataView(); @@ -53,7 +53,7 @@ export const CreateFieldButton = React.memo( if (dataView) { indexPatternFieldEditor?.openEditor({ ctx: { indexPattern: dataView }, - onSave: (field: IndexPatternField) => { + onSave: (field: DataViewField) => { // Fetch the updated list of fields indexFieldsSearch(selectedDataViewId); diff --git a/x-pack/plugins/security_solution/public/timelines/components/flyout/header/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/flyout/header/index.tsx index 2f54cd6ce296..bddd6256a992 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/flyout/header/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/flyout/header/index.tsx @@ -39,7 +39,7 @@ import { SaveTimelineButton } from '../../timeline/header/save_timeline_button'; import { useGetUserCasesPermissions, useKibana } from '../../../../common/lib/kibana'; import { InspectButton } from '../../../../common/components/inspect'; import { useTimelineKpis } from '../../../containers/kpis'; -import { esQuery } from '../../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../../src/plugins/data/common'; import { useSourcererDataView } from '../../../../common/containers/sourcerer'; import { TimelineModel } from '../../../../timelines/store/timeline/model'; import { @@ -78,7 +78,7 @@ const FlyoutHeaderPanelComponent: React.FC = ({ timeline const dispatch = useDispatch(); const { browserFields, indexPattern } = useSourcererDataView(SourcererScopeName.timeline); const { uiSettings } = useKibana().services; - const esQueryConfig = useMemo(() => esQuery.getEsQueryConfig(uiSettings), [uiSettings]); + const esQueryConfig = useMemo(() => getEsQueryConfig(uiSettings), [uiSettings]); const getTimeline = useMemo(() => timelineSelectors.getTimelineByIdSelector(), []); const { activeTab, @@ -367,7 +367,7 @@ const FlyoutHeaderComponent: React.FC = ({ timelineId }) => { } }); const { uiSettings } = useKibana().services; - const esQueryConfig = useMemo(() => esQuery.getEsQueryConfig(uiSettings), [uiSettings]); + const esQueryConfig = useMemo(() => getEsQueryConfig(uiSettings), [uiSettings]); const getTimeline = useMemo(() => timelineSelectors.getTimelineByIdSelector(), []); const timeline: TimelineModel = useSelector( (state: State) => getTimeline(state, timelineId) ?? timelineDefaults diff --git a/x-pack/plugins/security_solution/public/timelines/components/netflow/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/netflow/index.test.tsx index 23a52b878472..8a88a7182af0 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/netflow/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/netflow/index.test.tsx @@ -11,7 +11,6 @@ import { shallow } from 'enzyme'; import { removeExternalLinkText } from '@kbn/securitysolution-io-ts-utils'; import { asArrayIfExists } from '../../../common/lib/helpers'; -import { getMockNetflowData } from '../../../common/mock'; import '../../../common/mock/match_media'; import { TestProviders } from '../../../common/mock/test_providers'; import { @@ -61,6 +60,7 @@ import { NETWORK_TRANSPORT_FIELD_NAME, } from '../../../network/components/source_destination/field_names'; import { useMountAppended } from '../../../common/utils/use_mount_appended'; +import { getMockNetflowData } from '../../../common/mock/netflow'; jest.mock('../../../common/lib/kibana'); diff --git a/x-pack/plugins/security_solution/public/timelines/components/side_panel/network_details/expandable_network.tsx b/x-pack/plugins/security_solution/public/timelines/components/side_panel/network_details/expandable_network.tsx index 5b13f3f2a3b1..133079584165 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/side_panel/network_details/expandable_network.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/side_panel/network_details/expandable_network.tsx @@ -23,7 +23,7 @@ import { convertToBuildEsQuery } from '../../../../common/lib/keury'; import { inputsSelectors } from '../../../../common/store'; import { setAbsoluteRangeDatePicker } from '../../../../common/store/inputs/actions'; import { OverviewEmpty } from '../../../../overview/components/overview_empty'; -import { esQuery } from '../../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../../src/plugins/data/common'; import { useSourcererDataView } from '../../../../common/containers/sourcerer'; import { useNetworkDetails } from '../../../../network/containers/details'; import { networkModel } from '../../../../network/store'; @@ -100,7 +100,7 @@ export const ExpandableNetworkDetails = ({ const { docValueFields, indicesExist, indexPattern, selectedPatterns } = useSourcererDataView(); const [filterQuery, kqlError] = convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), indexPattern, queries: [query], filters, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/column_renderer.ts b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/column_renderer.ts index 0ec974f87689..d05386c2504c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/column_renderer.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/column_renderer.ts @@ -6,7 +6,7 @@ */ import type React from 'react'; -import { Filter } from '../../../../../../../../../src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; import { BrowserFields } from '../../../../../../../timelines/common/search_strategy'; import { ColumnHeaderOptions, RowRenderer } from '../../../../../../common'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_column_renderer.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_column_renderer.tsx index 2f0653826d11..f00eb332c564 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_column_renderer.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_column_renderer.tsx @@ -7,7 +7,7 @@ import { head } from 'lodash/fp'; import React from 'react'; -import { Filter } from '../../../../../../../../../src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; import { ColumnHeaderOptions } from '../../../../../../common'; import { TimelineNonEcsData } from '../../../../../../common/search_strategy/timeline'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/header/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/header/index.tsx index 5741f0d2ea39..61b9c8b2e958 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/header/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/header/index.tsx @@ -7,7 +7,7 @@ import { EuiCallOut } from '@elastic/eui'; import React from 'react'; -import { FilterManager } from 'src/plugins/data/public'; +import type { FilterManager } from 'src/plugins/data/public'; import { DataProviders } from '../data_providers'; import { StatefulSearchOrFilter } from '../search_or_filter'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx index 8383da6bf28a..8014a0e25797 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx @@ -12,7 +12,7 @@ import { DataProviderType } from './data_providers/data_provider'; import { mockDataProviders } from './data_providers/mock/mock_data_providers'; import { buildGlobalQuery, combineQueries, resolverIsShowing, showGlobalFilters } from './helpers'; import { mockBrowserFields } from '../../../common/containers/source/mock'; -import { EsQueryConfig, Filter, esFilters } from '../../../../../../../src/plugins/data/public'; +import { EsQueryConfig, FilterStateStore, Filter } from '@kbn/es-query'; const cleanUpKqlQuery = (str: string) => str.replace(/\n/g, '').replace(/\s\s+/g, ' '); @@ -269,7 +269,7 @@ describe('Combined Queries', () => { browserFields: mockBrowserFields, filters: [ { - $state: { store: esFilters.FilterStateStore.APP_STATE }, + $state: { store: FilterStateStore.APP_STATE }, meta: { alias: null, disabled: false, @@ -281,7 +281,7 @@ describe('Combined Queries', () => { query: { match_phrase: { 'event.category': 'file' } }, }, { - $state: { store: esFilters.FilterStateStore.APP_STATE }, + $state: { store: FilterStateStore.APP_STATE }, meta: { alias: null, disabled: false, @@ -521,7 +521,7 @@ describe('Combined Queries', () => { }, }, $state: { - store: esFilters.FilterStateStore.APP_STATE, + store: FilterStateStore.APP_STATE, }, } as Filter, ], @@ -543,7 +543,7 @@ describe('Combined Queries', () => { browserFields: mockBrowserFields, filters: [ { - $state: { store: esFilters.FilterStateStore.APP_STATE }, + $state: { store: FilterStateStore.APP_STATE }, meta: { alias: null, disabled: false, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.tsx index d9b1be8c20b6..04b108835d53 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.tsx @@ -8,7 +8,7 @@ import { isEmpty, get } from 'lodash/fp'; import memoizeOne from 'memoize-one'; -import { DataViewBase, EsQueryConfig, Filter, Query } from '@kbn/es-query'; +import type { DataViewBase, EsQueryConfig, Filter, Query } from '@kbn/es-query'; import { handleSkipFocus, elementOrChildrenHasFocus, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/index.test.tsx index bb1281c0eff2..f5ceebf9cdb1 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/index.test.tsx @@ -13,18 +13,26 @@ import { DragDropContextWrapper } from '../../../common/components/drag_and_drop import '../../../common/mock/match_media'; import { mockBrowserFields, mockDocValueFields } from '../../../common/containers/source/mock'; import { TimelineId } from '../../../../common/types/timeline'; -import { mockIndexNames, mockIndexPattern, TestProviders } from '../../../common/mock'; +import { + mockGlobalState, + mockIndexNames, + mockIndexPattern, + TestProviders, +} from '../../../common/mock'; import { StatefulTimeline, Props as StatefulTimelineOwnProps } from './index'; import { useTimelineEvents } from '../../containers/index'; import { DefaultCellRenderer } from './cell_rendering/default_cell_renderer'; import { SELECTOR_TIMELINE_GLOBAL_CONTAINER } from './styles'; import { defaultRowRenderers } from './body/renderers'; +import { useSourcererDataView } from '../../../common/containers/sourcerer'; jest.mock('../../containers/index', () => ({ useTimelineEvents: jest.fn(), })); +jest.mock('./tabs_content'); + jest.mock('../../../common/lib/kibana'); jest.mock('../../../common/components/url_state/normalize_time_range.ts'); jest.mock('@kbn/i18n/react', () => { @@ -54,21 +62,29 @@ jest.mock('react-router-dom', () => { useHistory: jest.fn(), }; }); -jest.mock('../../../common/containers/sourcerer', () => { - const originalModule = jest.requireActual('../../../common/containers/sourcerer'); +const mockDispatch = jest.fn(); + +jest.mock('react-redux', () => { + const actual = jest.requireActual('react-redux'); return { - ...originalModule, - useSourcererDataView: jest.fn().mockReturnValue({ - browserFields: mockBrowserFields, - docValueFields: mockDocValueFields, - loading: false, - indexPattern: mockIndexPattern, - pageInfo: { activePage: 0, querySize: 0 }, - selectedPatterns: mockIndexNames, - }), + ...actual, + useDispatch: () => mockDispatch, }; }); + +const mockUseSourcererDataView: jest.Mock = useSourcererDataView as jest.Mock; +jest.mock('../../../common/containers/sourcerer'); +const mockDataView = { + dataViewId: mockGlobalState.timeline.timelineById.test?.dataViewId, + browserFields: mockBrowserFields, + docValueFields: mockDocValueFields, + loading: false, + indexPattern: mockIndexPattern, + pageInfo: { activePage: 0, querySize: 0 }, + selectedPatterns: mockGlobalState.timeline.timelineById.test?.indexNames, +}; +mockUseSourcererDataView.mockReturnValue(mockDataView); describe('StatefulTimeline', () => { const props: StatefulTimelineOwnProps = { renderCellValue: DefaultCellRenderer, @@ -77,6 +93,7 @@ describe('StatefulTimeline', () => { }; beforeEach(() => { + jest.clearAllMocks(); (useTimelineEvents as jest.Mock).mockReturnValue([ false, { @@ -97,6 +114,25 @@ describe('StatefulTimeline', () => { ); expect(wrapper.find('[data-test-subj="timeline"]')).toBeTruthy(); + expect(mockDispatch).toBeCalledTimes(1); + }); + + test('data view updates, updates timeline', () => { + mockUseSourcererDataView.mockReturnValue({ ...mockDataView, selectedPatterns: mockIndexNames }); + mount( + + + + ); + expect(mockDispatch).toBeCalledTimes(2); + expect(mockDispatch).toHaveBeenNthCalledWith(2, { + payload: { + id: 'test', + dataViewId: mockDataView.dataViewId, + indexNames: mockIndexNames, + }, + type: 'x-pack/security_solution/local/timeline/UPDATE_DATA_VIEW', + }); }); test(`it add attribute data-timeline-id in ${SELECTOR_TIMELINE_GLOBAL_CONTAINER}`, () => { diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/index.tsx index 48f9274fa563..12bd3113f3ea 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/index.tsx @@ -64,9 +64,16 @@ const StatefulTimelineComponent: React.FC = ({ const getTimeline = useMemo(() => timelineSelectors.getTimelineByIdSelector(), []); const { dataViewId, selectedPatterns } = useSourcererDataView(SourcererScopeName.timeline); - const { graphEventId, savedObjectId, timelineType, description } = useDeepEqualSelector((state) => + const { + dataViewId: dataViewIdCurrent, + indexNames: selectedPatternsCurrent, + graphEventId, + savedObjectId, + timelineType, + description, + } = useDeepEqualSelector((state) => pick( - ['graphEventId', 'savedObjectId', 'timelineType', 'description'], + ['indexNames', 'dataViewId', 'graphEventId', 'savedObjectId', 'timelineType', 'description'], getTimeline(state, timelineId) ?? timelineDefaults ) ); @@ -88,6 +95,38 @@ const StatefulTimelineComponent: React.FC = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + const onDataViewChange = useCallback(() => { + if ( + // initial state will get set on create + (dataViewIdCurrent === '' && selectedPatternsCurrent.length === 0) || + // don't update if no change + (dataViewIdCurrent === dataViewId && + selectedPatternsCurrent.sort().join() === selectedPatterns.sort().join()) + ) { + return; + } + + dispatch( + timelineActions.updateDataView({ + id: timelineId, + dataViewId, + indexNames: selectedPatterns, + }) + ); + }, [ + dataViewId, + dataViewIdCurrent, + dispatch, + selectedPatterns, + selectedPatternsCurrent, + timelineId, + ]); + + useEffect(() => { + onDataViewChange(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [dataViewId, selectedPatterns]); + const onSkipFocusBeforeEventsTable = useCallback(() => { const exitFullScreenButton = containerElement.current?.querySelector( EXIT_FULL_SCREEN_CLASS_NAME diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.test.tsx index 0f0f2a8641ac..066d466bf914 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.test.tsx @@ -14,7 +14,8 @@ import { mockBrowserFields } from '../../../../common/containers/source/mock'; import { convertKueryToElasticSearchQuery } from '../../../../common/lib/keury'; import { mockIndexPattern, TestProviders } from '../../../../common/mock'; import { QueryBar } from '../../../../common/components/query_bar'; -import { esFilters, FilterManager } from '../../../../../../../../src/plugins/data/public'; +import { FilterStateStore } from '@kbn/es-query'; +import { FilterManager } from '../../../../../../../../src/plugins/data/public'; import { mockDataProviders } from '../data_providers/mock/mock_data_providers'; import { buildGlobalQuery } from '../helpers'; @@ -44,7 +45,7 @@ describe('Timeline QueryBar ', () => { test('check if we format the appropriate props to QueryBar', () => { const filters = [ { - $state: { store: esFilters.FilterStateStore.APP_STATE }, + $state: { store: FilterStateStore.APP_STATE }, meta: { alias: null, controlledBy: TIMELINE_FILTER_DROP_AREA, @@ -58,7 +59,7 @@ describe('Timeline QueryBar ', () => { query: { match: { 'event.category': { query: 'file', type: 'phrase' } } }, }, { - $state: { store: esFilters.FilterStateStore.APP_STATE }, + $state: { store: FilterStateStore.APP_STATE }, meta: { alias: null, controlledBy: undefined, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.tsx index 450a43b43ef5..c561c2638389 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/index.tsx @@ -11,12 +11,11 @@ import { useDispatch } from 'react-redux'; import { Subscription } from 'rxjs'; import deepEqual from 'fast-deep-equal'; +import { FilterStateStore, Filter, Query } from '@kbn/es-query'; import { useSourcererDataView } from '../../../../common/containers/sourcerer'; import { SourcererScopeName } from '../../../../common/store/sourcerer/model'; -import { - Query, - Filter, - esFilters, + +import type { FilterManager, SavedQuery, SavedQueryTimeFilter, @@ -300,7 +299,7 @@ export const getDataProviderFilter = (dataProviderDsl: string): Filter => { value: dataProviderDsl, }, $state: { - store: esFilters.FilterStateStore.APP_STATE, + store: FilterStateStore.APP_STATE, }, }; }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/index.tsx index 643bd679e04e..ca8993325268 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/index.tsx @@ -33,7 +33,8 @@ import { Footer, footerHeight } from '../footer'; import { TimelineHeader } from '../header'; import { calculateTotalPages, combineQueries } from '../helpers'; import { TimelineRefetch } from '../refetch_timeline'; -import { esQuery, FilterManager } from '../../../../../../../../src/plugins/data/public'; +import { FilterManager } from '../../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../../src/plugins/data/common'; import { ControlColumnProps, KueryFilterQueryKind, @@ -60,7 +61,6 @@ import { HeaderActions } from '../body/actions/header_actions'; import { getDefaultControlColumn } from '../body/control_columns'; import { useDeepEqualSelector } from '../../../../common/hooks/use_selector'; import { Sourcerer } from '../../../../common/components/sourcerer'; - const TimelineHeaderContainer = styled.div` margin-top: 6px; width: 100%; @@ -205,7 +205,7 @@ export const QueryTabContentComponent: React.FC = ({ [activeFilterManager, uiSettings] ); - const esQueryConfig = useMemo(() => esQuery.getEsQueryConfig(uiSettings), [uiSettings]); + const esQueryConfig = useMemo(() => getEsQueryConfig(uiSettings), [uiSettings]); const kqlQuery: { query: string; language: KueryFilterQueryKind; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/index.tsx index 96ca26a099d2..98e74269ae2d 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/index.tsx @@ -10,8 +10,9 @@ import React, { useCallback } from 'react'; import { connect, ConnectedProps } from 'react-redux'; import { Dispatch } from 'redux'; import deepEqual from 'fast-deep-equal'; +import type { Filter } from '@kbn/es-query'; -import { Filter, FilterManager } from '../../../../../../../../src/plugins/data/public'; +import type { FilterManager } from '../../../../../../../../src/plugins/data/public'; import { State, inputsModel, inputsSelectors } from '../../../../common/store'; import { timelineActions, timelineSelectors } from '../../../store/timeline'; import { KqlMode, TimelineModel } from '../../../../timelines/store/timeline/model'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/search_or_filter.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/search_or_filter.tsx index f1c4b7c3ef08..127f404a4075 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/search_or_filter.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/search_or_filter.tsx @@ -8,8 +8,9 @@ import { EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui'; import React, { useCallback } from 'react'; import styled, { createGlobalStyle } from 'styled-components'; +import type { Filter } from '@kbn/es-query'; -import { Filter, FilterManager } from '../../../../../../../../src/plugins/data/public'; +import type { FilterManager } from '../../../../../../../../src/plugins/data/public'; import { KqlMode } from '../../../../timelines/store/timeline/model'; import { DispatchUpdateReduxTime } from '../../../../common/components/super_date_picker'; import { KueryFilterQuery } from '../../../../../common/types/timeline'; diff --git a/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx index ac96cc334f79..9dfbad3a3906 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx @@ -20,7 +20,7 @@ import { TimelineEventsDetailsRequestOptions, TimelineEventsDetailsStrategyResponse, } from '../../../../common/search_strategy'; -import { isCompleteResponse, isErrorResponse } from '../../../../../../../src/plugins/data/public'; +import { isCompleteResponse, isErrorResponse } from '../../../../../../../src/plugins/data/common'; import { useAppToasts } from '../../../common/hooks/use_app_toasts'; import * as i18n from './translations'; import { EntityType } from '../../../../../timelines/common'; diff --git a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx index c755159dd6b1..1b0e42806df4 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx @@ -13,7 +13,8 @@ import { Subscription } from 'rxjs'; import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ESQuery } from '../../../common/typed_json'; -import { isCompleteResponse, isErrorResponse } from '../../../../../../src/plugins/data/public'; +import { isCompleteResponse, isErrorResponse } from '../../../../../../src/plugins/data/common'; + import { useIsExperimentalFeatureEnabled } from '../../common/hooks/use_experimental_features'; import { inputsModel } from '../../common/store'; import { useKibana } from '../../common/lib/kibana'; diff --git a/x-pack/plugins/security_solution/public/timelines/jest.config.js b/x-pack/plugins/security_solution/public/timelines/jest.config.js index 94434b9303d4..ac28fe2d3497 100644 --- a/x-pack/plugins/security_solution/public/timelines/jest.config.js +++ b/x-pack/plugins/security_solution/public/timelines/jest.config.js @@ -15,4 +15,12 @@ module.exports = { collectCoverageFrom: [ '/x-pack/plugins/security_solution/public/timelines/**/*.{ts,tsx}', ], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/timelines/store/timeline/actions.ts b/x-pack/plugins/security_solution/public/timelines/store/timeline/actions.ts index 6002a7b2cf39..2264e62d6bed 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/timeline/actions.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/timeline/actions.ts @@ -6,8 +6,8 @@ */ import actionCreatorFactory from 'typescript-fsa'; +import type { Filter } from '@kbn/es-query'; -import { Filter } from '../../../../../../../src/plugins/data/public'; import { DataProvider, DataProviderType, diff --git a/x-pack/plugins/security_solution/public/timelines/store/timeline/epic.test.ts b/x-pack/plugins/security_solution/public/timelines/store/timeline/epic.test.ts index 175e6804c04a..ba376a0b4097 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/timeline/epic.test.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/timeline/epic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Filter, esFilters } from '../../../../../../../src/plugins/data/public'; +import { FilterStateStore, Filter } from '@kbn/es-query'; import { Direction } from '../../../../common/search_strategy'; import { TimelineType, TimelineStatus, TimelineTabs } from '../../../../common/types/timeline'; import { convertTimelineAsInput } from './epic'; @@ -106,7 +106,7 @@ describe('Epic Timeline', () => { historyIds: [], filters: [ { - $state: { store: esFilters.FilterStateStore.APP_STATE }, + $state: { store: FilterStateStore.APP_STATE }, meta: { alias: null, disabled: false, @@ -118,7 +118,7 @@ describe('Epic Timeline', () => { query: { match_phrase: { 'event.category': 'file' } }, }, { - $state: { store: esFilters.FilterStateStore.APP_STATE }, + $state: { store: FilterStateStore.APP_STATE }, meta: { alias: null, disabled: false, diff --git a/x-pack/plugins/security_solution/public/timelines/store/timeline/epic.ts b/x-pack/plugins/security_solution/public/timelines/store/timeline/epic.ts index c973cf9a5bbb..57580c96d06b 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/timeline/epic.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/timeline/epic.ts @@ -18,7 +18,17 @@ import { import { Action } from 'redux'; import { Epic } from 'redux-observable'; import { from, empty, merge } from 'rxjs'; -import { Filter, MatchAllFilter, isScriptedRangeFilter } from '@kbn/es-query'; +import { + Filter, + MatchAllFilter, + isScriptedRangeFilter, + isExistsFilter, + isRangeFilter, + isMatchAllFilter, + isPhraseFilter, + isQueryStringFilter, + isPhrasesFilter, +} from '@kbn/es-query'; import { filter, map, @@ -31,7 +41,6 @@ import { takeUntil, } from 'rxjs/operators'; -import { esFilters } from '../../../../../../.../../../src/plugins/data/public'; import { TimelineStatus, TimelineErrorResponse, @@ -375,10 +384,10 @@ export const convertTimelineAsInput = ( meta: { ...basicFilter.meta, field: - (esFilters.isMatchAllFilter(basicFilter) || - esFilters.isPhraseFilter(basicFilter) || - esFilters.isPhrasesFilter(basicFilter) || - esFilters.isRangeFilter(basicFilter)) && + (isMatchAllFilter(basicFilter) || + isPhraseFilter(basicFilter) || + isPhrasesFilter(basicFilter) || + isRangeFilter(basicFilter)) && basicFilter.meta.field != null ? convertToString(basicFilter.meta.field) : null, @@ -391,7 +400,7 @@ export const convertTimelineAsInput = ( ? convertToString(basicFilter.meta.params) : null, }, - ...(esFilters.isMatchAllFilter(basicFilter) + ...(isMatchAllFilter(basicFilter) ? { query: { match_all: convertToString( @@ -400,15 +409,14 @@ export const convertTimelineAsInput = ( }, } : { match_all: null }), - ...(esFilters.isExistsFilter(basicFilter) && basicFilter.query.exists != null + ...(isExistsFilter(basicFilter) && basicFilter.query.exists != null ? { query: { exists: convertToString(basicFilter.query.exists) } } : { exists: null }), - ...((esFilters.isQueryStringFilter(basicFilter) || - get('query', basicFilter) != null) && + ...((isQueryStringFilter(basicFilter) || get('query', basicFilter) != null) && basicFilter.query != null ? { query: convertToString(basicFilter.query) } : { query: null }), - ...(esFilters.isRangeFilter(basicFilter) && basicFilter.query.range != null + ...(isRangeFilter(basicFilter) && basicFilter.query.range != null ? { query: { range: convertToString(basicFilter.query.range) } } : { range: null }), ...(isScriptedRangeFilter(basicFilter) && diff --git a/x-pack/plugins/security_solution/public/timelines/store/timeline/helpers.ts b/x-pack/plugins/security_solution/public/timelines/store/timeline/helpers.ts index b7af561ae2a0..a123cdeb8f92 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/timeline/helpers.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/timeline/helpers.ts @@ -8,7 +8,8 @@ import { getOr, omit, uniq, isEmpty, isEqualWith, union } from 'lodash/fp'; import uuid from 'uuid'; -import { Filter } from '../../../../../../../src/plugins/data/public'; + +import type { Filter } from '@kbn/es-query'; import { Sort } from '../../../timelines/components/timeline/body/sort'; import { diff --git a/x-pack/plugins/security_solution/public/timelines/store/timeline/reducer.test.ts b/x-pack/plugins/security_solution/public/timelines/store/timeline/reducer.test.ts index 50992cf7b21d..3e7ebed675d8 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/timeline/reducer.test.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/timeline/reducer.test.ts @@ -52,7 +52,7 @@ import { TimelineModel } from './model'; import { timelineDefaults } from './defaults'; import { TimelineById } from './types'; import { Direction } from '../../../../common/search_strategy'; -import { FilterManager } from '../../../../../../../src/plugins/data/public'; +import type { FilterManager } from '../../../../../../../src/plugins/data/public'; jest.mock('../../../common/components/url_state/normalize_time_range.ts'); jest.mock('../../../common/utils/default_date_settings', () => { diff --git a/x-pack/plugins/security_solution/public/transforms/jest.config.js b/x-pack/plugins/security_solution/public/transforms/jest.config.js index 30847fa39a8d..095a70933abc 100644 --- a/x-pack/plugins/security_solution/public/transforms/jest.config.js +++ b/x-pack/plugins/security_solution/public/transforms/jest.config.js @@ -15,4 +15,12 @@ module.exports = { collectCoverageFrom: [ '/x-pack/plugins/security_solution/public/transforms/**/*.{ts,tsx}', ], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/public/types.ts b/x-pack/plugins/security_solution/public/types.ts index 7c0b8d46b8bb..475aa71a4b56 100644 --- a/x-pack/plugins/security_solution/public/types.ts +++ b/x-pack/plugins/security_solution/public/types.ts @@ -7,7 +7,7 @@ import { CoreStart } from '../../../../src/core/public'; import { HomePublicPluginSetup } from '../../../../src/plugins/home/public'; -import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; +import type { DataPublicPluginStart } from '../../../../src/plugins/data/public'; import { EmbeddableStart } from '../../../../src/plugins/embeddable/public'; import { LensPublicStart } from '../../../plugins/lens/public'; import { NewsfeedPublicPluginStart } from '../../../../src/plugins/newsfeed/public'; diff --git a/x-pack/plugins/security_solution/public/ueba/pages/details/helpers.ts b/x-pack/plugins/security_solution/public/ueba/pages/details/helpers.ts index 70f8027b1f55..d8a824a07ddf 100644 --- a/x-pack/plugins/security_solution/public/ueba/pages/details/helpers.ts +++ b/x-pack/plugins/security_solution/public/ueba/pages/details/helpers.ts @@ -5,8 +5,8 @@ * 2.0. */ +import type { Filter } from '@kbn/es-query'; import { escapeQueryValue } from '../../../common/lib/keury'; -import { Filter } from '../../../../../../../src/plugins/data/public'; /** Returns the kqlQueryExpression for the `Events` widget on the `Host Details` page */ export const getUebaDetailsEventsKqlQueryExpression = ({ diff --git a/x-pack/plugins/security_solution/public/ueba/pages/details/index.tsx b/x-pack/plugins/security_solution/public/ueba/pages/details/index.tsx index 51c06fffb7b6..599b003ff034 100644 --- a/x-pack/plugins/security_solution/public/ueba/pages/details/index.tsx +++ b/x-pack/plugins/security_solution/public/ueba/pages/details/index.tsx @@ -10,6 +10,7 @@ import { noop } from 'lodash/fp'; import React, { useEffect, useMemo } from 'react'; import { useDispatch } from 'react-redux'; +import type { Filter } from '@kbn/es-query'; import { LastEventIndexKey } from '../../../../common/search_strategy'; import { SecurityPageName } from '../../../app/types'; import { FiltersGlobal } from '../../../common/components/filters_global'; @@ -25,7 +26,7 @@ import { inputsSelectors } from '../../../common/store'; import { setUebaDetailsTablesActivePageToZero } from '../../store/actions'; import { setAbsoluteRangeDatePicker } from '../../../common/store/inputs/actions'; import { SpyRoute } from '../../../common/utils/route/spy_routes'; -import { esQuery, Filter } from '../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common'; import { OverviewEmpty } from '../../../overview/components/overview_empty'; import { UebaDetailsTabs } from './details_tabs'; @@ -74,7 +75,7 @@ const UebaDetailsComponent: React.FC = ({ detailName, uebaDeta ); const [filterQuery, kqlError] = convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(kibana.services.uiSettings), + config: getEsQueryConfig(kibana.services.uiSettings), indexPattern, queries: [query], filters: getFilters(), diff --git a/x-pack/plugins/security_solution/public/ueba/pages/details/types.ts b/x-pack/plugins/security_solution/public/ueba/pages/details/types.ts index e46a128e15f8..45d75637fd7c 100644 --- a/x-pack/plugins/security_solution/public/ueba/pages/details/types.ts +++ b/x-pack/plugins/security_solution/public/ueba/pages/details/types.ts @@ -6,7 +6,7 @@ */ import { ActionCreator } from 'typescript-fsa'; -import { DataViewBase, Filter, Query } from '@kbn/es-query'; +import type { DataViewBase, Filter, Query } from '@kbn/es-query'; import { InputsModelId } from '../../../common/store/inputs/constants'; import { UebaTableType } from '../../store/model'; import { UebaQueryProps } from '../types'; diff --git a/x-pack/plugins/security_solution/public/ueba/pages/navigation/types.ts b/x-pack/plugins/security_solution/public/ueba/pages/navigation/types.ts index e24b3271cf53..a8aea32f7139 100644 --- a/x-pack/plugins/security_solution/public/ueba/pages/navigation/types.ts +++ b/x-pack/plugins/security_solution/public/ueba/pages/navigation/types.ts @@ -5,11 +5,11 @@ * 2.0. */ +import type { Filter } from '@kbn/es-query'; import { UebaTableType, UebaType } from '../../store/model'; import { GlobalTimeArgs } from '../../../common/containers/use_global_time'; import { ESTermQuery } from '../../../../common/typed_json'; import { DocValueFields } from '../../../../../timelines/common'; -import { Filter } from '../../../../../../../src/plugins/data/common'; import { UpdateDateRange } from '../../../common/components/charts/common'; import { NarrowDateRange } from '../../../common/components/ml/types'; import { NavTab } from '../../../common/components/navigation/types'; diff --git a/x-pack/plugins/security_solution/public/ueba/pages/ueba.tsx b/x-pack/plugins/security_solution/public/ueba/pages/ueba.tsx index 93e22efdba3d..0c837e60cd2d 100644 --- a/x-pack/plugins/security_solution/public/ueba/pages/ueba.tsx +++ b/x-pack/plugins/security_solution/public/ueba/pages/ueba.tsx @@ -29,7 +29,7 @@ import { inputsSelectors } from '../../common/store'; import { setAbsoluteRangeDatePicker } from '../../common/store/inputs/actions'; import { SpyRoute } from '../../common/utils/route/spy_routes'; -import { esQuery } from '../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../src/plugins/data/common'; import { OverviewEmpty } from '../../overview/components/overview_empty'; import { Display } from './display'; import { UebaTabs } from './ueba_tabs'; @@ -82,7 +82,7 @@ const UebaComponent = () => { const [filterQuery, kqlError] = useMemo( () => convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), indexPattern, queries: [query], filters, @@ -92,7 +92,7 @@ const UebaComponent = () => { const [tabsFilterQuery] = useMemo( () => convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), indexPattern, queries: [query], filters: tabsFilters, diff --git a/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts b/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts new file mode 100644 index 000000000000..2a430c47cc12 --- /dev/null +++ b/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts @@ -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 + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +// See: https://github.com/elastic/kibana/issues/117255, this creates mocks to avoid memory leaks from kibana core. +module.exports = {}; diff --git a/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts b/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts new file mode 100644 index 000000000000..917eb205837a --- /dev/null +++ b/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts @@ -0,0 +1,19 @@ +/* + * 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. + */ + +// See: https://github.com/elastic/kibana/issues/117255, this creates mocks to avoid memory leaks from kibana core. + +import { parseDuration } from '../../../alerting/common/parse_duration'; +// We _must_ import from the restricted path or we pull in _everything_ including memory leaks from Kibana core +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { ReadOperations, WriteOperations } from '../../../alerting/server/authorization'; + +module.exports = { + parseDuration, + ReadOperations, + WriteOperations, +}; diff --git a/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts b/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts new file mode 100644 index 000000000000..c5e07f9c135a --- /dev/null +++ b/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ + +// See: https://github.com/elastic/kibana/issues/117255, this creates mocks to avoid memory leaks from kibana core. + +// We _must_ import from the restricted path or we pull in _everything_ including memory leaks from Kibana core +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { SavedObjectsUtils } from '../../../../../src/core/server/saved_objects/service/lib/utils'; +module.exports = { + SavedObjectsUtils, +}; diff --git a/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts b/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts new file mode 100644 index 000000000000..e61080e56ea6 --- /dev/null +++ b/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts @@ -0,0 +1,14 @@ +/* + * 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. + */ + +// See: https://github.com/elastic/kibana/issues/117255, this creates mocks to avoid memory leaks from kibana core. + +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { TaskStatus } from '../../../task_manager/server/task'; +module.exports = { + TaskStatus, +}; diff --git a/x-pack/plugins/security_solution/server/client/jest.config.js b/x-pack/plugins/security_solution/server/client/jest.config.js index ba3dd88f8330..593eb77b287e 100644 --- a/x-pack/plugins/security_solution/server/client/jest.config.js +++ b/x-pack/plugins/security_solution/server/client/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/client', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/server/client/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/server/endpoint/jest.config.js b/x-pack/plugins/security_solution/server/endpoint/jest.config.js index 4fed1c5e7ac1..9bdafcc7668e 100644 --- a/x-pack/plugins/security_solution/server/endpoint/jest.config.js +++ b/x-pack/plugins/security_solution/server/endpoint/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/endpoint', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/server/endpoint/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/policy/service.ts b/x-pack/plugins/security_solution/server/endpoint/routes/policy/service.ts index ce46395a1f09..ced0e00d3458 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/policy/service.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/policy/service.ts @@ -14,7 +14,7 @@ import { GetHostPolicyResponse, HostPolicyResponse } from '../../../../common/en import { INITIAL_POLICY_ID } from './index'; import { Agent } from '../../../../../fleet/common/types/models'; import { EndpointAppContext } from '../../types'; -import { ISearchRequestParams } from '../../../../../../../src/plugins/data/common'; +import type { ISearchRequestParams } from '../../../../../../../src/plugins/data/common'; export const getESQueryPolicyResponseByAgentID = ( agentID: string, diff --git a/x-pack/plugins/security_solution/server/endpoint/utils/audit_log_helpers.ts b/x-pack/plugins/security_solution/server/endpoint/utils/audit_log_helpers.ts index c50a460a377c..c601f5954be7 100644 --- a/x-pack/plugins/security_solution/server/endpoint/utils/audit_log_helpers.ts +++ b/x-pack/plugins/security_solution/server/endpoint/utils/audit_log_helpers.ts @@ -6,7 +6,7 @@ */ import { Logger } from 'kibana/server'; -import { SearchRequest } from 'src/plugins/data/public'; +import type { SearchRequest } from 'src/plugins/data/public'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { TransportResult } from '@elastic/elasticsearch'; import { AGENT_ACTIONS_INDEX, AGENT_ACTIONS_RESULTS_INDEX } from '../../../../fleet/common'; diff --git a/x-pack/plugins/security_solution/server/fleet_integration/jest.config.js b/x-pack/plugins/security_solution/server/fleet_integration/jest.config.js index 81625081c40c..abcd1a214c20 100644 --- a/x-pack/plugins/security_solution/server/fleet_integration/jest.config.js +++ b/x-pack/plugins/security_solution/server/fleet_integration/jest.config.js @@ -15,4 +15,12 @@ module.exports = { collectCoverageFrom: [ '/x-pack/plugins/security_solution/server/fleet_integration/**/*.{ts,tsx}', ], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/server/jest.config.js b/x-pack/plugins/security_solution/server/jest.config.js index 2fc23670388b..3f5aa91c5fae 100644 --- a/x-pack/plugins/security_solution/server/jest.config.js +++ b/x-pack/plugins/security_solution/server/jest.config.js @@ -15,4 +15,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/server/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_context.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_context.ts index fc88e7b8b2be..86bba6969919 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_context.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_context.ts @@ -11,7 +11,11 @@ import { coreMock } from 'src/core/server/mocks'; import { ActionsApiRequestHandlerContext } from '../../../../../../actions/server'; import { AlertingApiRequestHandlerContext } from '../../../../../../alerting/server'; import { rulesClientMock } from '../../../../../../alerting/server/mocks'; -import { actionsClientMock } from '../../../../../../actions/server/mocks'; + +// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. +// We cannot import from "../../../../../../actions/server" directly here or we have a really bad memory issue. We cannot add this to the existing mocks we created, this fix must be here. +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { actionsClientMock } from '../../../../../../actions/server/actions_client.mock'; import { licensingMock } from '../../../../../../licensing/server/mocks'; import { listMock } from '../../../../../../lists/server/mocks'; import { ruleRegistryMocks } from '../../../../../../rule_registry/server/mocks'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/__mocks__/eql.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/__mocks__/eql.ts index 096d2a533004..da65c7e48342 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/__mocks__/eql.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/__mocks__/eql.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { EqlSearchStrategyResponse } from '../../../../../../../../src/plugins/data/common'; +import type { EqlSearchStrategyResponse } from '../../../../../../../../src/plugins/data/common'; import { EqlSearchResponse } from '../../../../../common/detection_engine/types'; export const sequenceResponse = { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.mock.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.mock.ts index 592ab137ee28..0e660b6038b5 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.mock.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.mock.ts @@ -6,7 +6,8 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ThreatMapping } from '@kbn/securitysolution-io-ts-alerting-types'; -import { Filter } from 'src/plugins/data/common'; + +import type { Filter } from '@kbn/es-query'; import { ThreatListDoc, ThreatListItem } from './types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.ts index 2aaa57ff96ca..dfc66f7c5222 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.ts @@ -6,7 +6,7 @@ */ import get from 'lodash/fp/get'; -import { Filter } from '@kbn/es-query'; +import type { Filter } from '@kbn/es-query'; import { ThreatMapping } from '@kbn/securitysolution-io-ts-alerting-types'; import { BooleanFilter, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threshold/get_threshold_bucket_filters.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threshold/get_threshold_bucket_filters.ts index 610be59deaa5..bc9dc69dbe19 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threshold/get_threshold_bucket_filters.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threshold/get_threshold_bucket_filters.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Filter } from 'src/plugins/data/common'; +import type { Filter } from '@kbn/es-query'; import { ESFilter } from '../../../../../../../../src/core/types/elasticsearch'; import { ThresholdSignalHistory, ThresholdSignalHistoryRecord } from '../types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/types.ts index 9eb160ed2da5..206ccb3b7835 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/types.ts @@ -27,6 +27,7 @@ import { import { Version } from '@kbn/securitysolution-io-ts-types'; import type { ListArrayOrUndefined } from '@kbn/securitysolution-io-ts-list-types'; +import type { Filter } from '@kbn/es-query'; import { AnomalyThresholdOrUndefined, Description, @@ -52,7 +53,6 @@ import { EventCategoryOverrideOrUndefined, } from '../../../common/detection_engine/schemas/common/schemas'; -import { Filter } from '../../../../../../src/plugins/data/server'; import { AlertTypeParams } from '../../../../alerting/common'; export type PartialFilter = Partial; diff --git a/x-pack/plugins/security_solution/server/lib/jest.config.js b/x-pack/plugins/security_solution/server/lib/jest.config.js index 4c4c7d8d4a6b..88b4ff927971 100644 --- a/x-pack/plugins/security_solution/server/lib/jest.config.js +++ b/x-pack/plugins/security_solution/server/lib/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/lib', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/server/lib/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/server/lib/machine_learning/authz.ts b/x-pack/plugins/security_solution/server/lib/machine_learning/authz.ts index d5e8e951397c..3b96de2d4b1d 100644 --- a/x-pack/plugins/security_solution/server/lib/machine_learning/authz.ts +++ b/x-pack/plugins/security_solution/server/lib/machine_learning/authz.ts @@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n'; import { Type } from '@kbn/securitysolution-io-ts-alerting-types'; -import { KibanaRequest, SavedObjectsClientContract } from '../../../../../../src/core/server/'; +import { KibanaRequest, SavedObjectsClientContract } from '../../../../../../src/core/server'; import { ILicense } from '../../../../licensing/server'; import { MlPluginSetup } from '../../../../ml/server'; import { SetupPlugins } from '../../plugin'; diff --git a/x-pack/plugins/security_solution/server/search_strategy/jest.config.js b/x-pack/plugins/security_solution/server/search_strategy/jest.config.js index 93b9ddbf7a27..22999d3c5820 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/jest.config.js +++ b/x-pack/plugins/security_solution/server/search_strategy/jest.config.js @@ -15,4 +15,12 @@ module.exports = { collectCoverageFrom: [ '/x-pack/plugins/security_solution/server/search_strategy/**/*.{ts,tsx}', ], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts index d6e456e70667..ce640f7d367d 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { Direction, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/index.ts index 7c318b24a7a3..987420f4bf4b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { HostAggEsItem, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts index bc405e89bf7a..d3758df94074 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts @@ -6,7 +6,7 @@ */ import { isEmpty } from 'lodash/fp'; -import { ISearchRequestParams } from '../../../../../../../../../src/plugins/data/common'; +import type { ISearchRequestParams } from '../../../../../../../../../src/plugins/data/common'; import { Direction, HostsRequestOptions, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts index 94124bc9567b..73f35091ae09 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts @@ -6,7 +6,7 @@ */ import { isEmpty } from 'lodash/fp'; -import { ISearchRequestParams } from '../../../../../../../../../src/plugins/data/common'; +import type { ISearchRequestParams } from '../../../../../../../../../src/plugins/data/common'; import { Direction, HostsRequestOptions, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts index bdc4755c6a02..6e43d771d1a0 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { AuthenticationHit, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/index.tsx b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/index.tsx index fa78a8d59803..e32d3592d341 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/index.tsx +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/index.tsx @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts index ec8c7d7ca686..0cb4f3dd9007 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { Direction, HostsQueries, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/index.ts index 562b7e4fbc16..7a4301185de4 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/index.ts @@ -7,7 +7,7 @@ import { get } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { HostAggEsData, HostDetailsStrategyResponse, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts index 003149a9501b..d34e9d9c8453 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ISearchRequestParams } from '../../../../../../../../../src/plugins/data/common'; +import type { ISearchRequestParams } from '../../../../../../../../../src/plugins/data/common'; import { cloudFieldsMap, hostFieldsMap } from '../../../../../../common/ecs/ecs_fields'; import { HostDetailsRequestOptions } from '../../../../../../common/search_strategy/security_solution'; import { reduceFields } from '../../../../../utils/build_query/reduce_fields'; diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/index.ts index 88c8bed1dbce..1512dc1b7da6 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { HostsKpiQueries, HostsKpiAuthenticationsStrategyResponse, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/index.ts index 6bf2ccd5a273..a8082822b277 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { HostsKpiQueries, HostsKpiHostsStrategyResponse, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/index.ts index 83849f886163..b81d9a4d2322 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { HostsKpiQueries, HostsKpiUniqueIpsStrategyResponse, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/index.ts index fee9a49e42c4..bab799620ad6 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { HostFirstLastSeenStrategyResponse, HostsQueries, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts index 85bce797f52a..33623c198913 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { HostOverviewRequestOptions, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/index.ts index 5866695ab164..19ea4c3bc37d 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/index.ts @@ -7,7 +7,7 @@ import { get, getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { HostsOverviewStrategyResponse, HostsQueries, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts index 92d194e78284..7a215a2e781f 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts @@ -6,7 +6,7 @@ */ import { createQueryFilterClauses } from '../../../../../utils/build_query'; -import { ISearchRequestParams } from '../../../../../../../../../src/plugins/data/common'; +import type { ISearchRequestParams } from '../../../../../../../../../src/plugins/data/common'; import { HostOverviewRequestOptions } from '../../../../../../common/search_strategy/security_solution/hosts'; export const buildOverviewHostQuery = ({ diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/index.ts index 2a440ad614d9..a609a8b356f1 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/index.ts @@ -11,7 +11,7 @@ import { HostsQueries, HostsRiskScoreStrategyResponse, } from '../../../../../../common'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { inspectStringifyObject } from '../../../../../utils/build_query'; import { buildHostsRiskScoreQuery } from './query.hosts_risk.dsl'; diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/index.ts index 08e1f6601976..79cd2973a309 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { HostsQueries } from '../../../../../../common/search_strategy/security_solution'; diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts index c75b20f44035..a357e1ee9216 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { MatrixHistogramStrategyResponse } from '../../../../../../common/search_strategy'; diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/index.ts index 6e3a6d8f8d4b..db9fcc6067a7 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { FactoryQueryTypes, MatrixHistogramRequestOptions, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts index 158b63e6e845..12452c7a79fb 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { NetworkDetailsRequestOptions, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/index.ts index 6b7d7f7493b3..c5689954942e 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { NetworkDetailsStrategyResponse, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts index f1bae35f53eb..ac5272b8d04f 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { Direction, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/helpers.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/helpers.ts index a8dea7fdcefa..85f836463686 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/helpers.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/helpers.ts @@ -7,7 +7,7 @@ import { get, getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { NetworkDnsBuckets, NetworkDnsEdges, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/index.ts index 9a73fb30a074..87bcc9a1225e 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts index f831b9f20e8c..733b8584e77d 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { Direction, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/helpers.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/helpers.ts index e8155a998f3f..fb0217f0aebf 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/helpers.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/helpers.ts @@ -7,7 +7,7 @@ import { get, getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { NetworkHttpBuckets, NetworkHttpEdges, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/index.ts index 259b45f43612..cada5212b812 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/index.ts index c5298c4498cd..b8a21d4791c5 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { NetworkKpiQueries, NetworkKpiDnsStrategyResponse, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/index.ts index ca29aac1bb6d..ac3d01512428 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { NetworkKpiQueries, NetworkKpiNetworkEventsStrategyResponse, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/index.ts index f911eaa0c406..cb57d63f4f3a 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { NetworkKpiQueries, NetworkKpiTlsHandshakesStrategyResponse, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/index.ts index b5e6c3db3591..2581249d179f 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { NetworkKpiQueries, NetworkKpiUniqueFlowsStrategyResponse, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/index.ts index ffe53c95efaf..927e2a2fb5ae 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { NetworkKpiQueries, NetworkKpiUniquePrivateIpsStrategyResponse, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts index 0b5019d6fec9..ad2a6dd7cdf7 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { NetworkOverviewRequestOptions, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/index.ts index 069125c6700e..473a192b7292 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/index.ts @@ -7,7 +7,7 @@ import { get, getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { NetworkQueries, NetworkOverviewStrategyResponse, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts index f911850c8cd9..d2b530c2b4a1 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts @@ -6,7 +6,7 @@ */ import { createQueryFilterClauses } from '../../../../../utils/build_query'; -import { ISearchRequestParams } from '../../../../../../../../../src/plugins/data/common'; +import type { ISearchRequestParams } from '../../../../../../../../../src/plugins/data/common'; import { NetworkOverviewRequestOptions } from '../../../../../../common/search_strategy/security_solution/network'; export const buildOverviewNetworkQuery = ({ diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts index c34ec2225ed9..4e5c3f4074b9 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { Direction, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/helpers.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/helpers.ts index 6b4fdd2827ae..cabaae2e54b7 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/helpers.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/helpers.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { NetworkTlsBuckets, NetworkTlsEdges, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/index.ts index 6a5e1e42abb9..39029089a430 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts index 490ade26ad2a..79ff8a74c220 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { Direction, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/helpers.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/helpers.ts index e96df32513a7..9540da3eb65f 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/helpers.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/helpers.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { NetworkTopCountriesBuckets, NetworkTopCountriesEdges, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/index.ts index 80c2050fd142..e65ff6e4d1ad 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts index fa759661772d..59150354613f 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { Direction, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/helpers.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/helpers.ts index f078c21a7d84..f50472781276 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/helpers.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/helpers.ts @@ -8,7 +8,7 @@ import { getOr } from 'lodash/fp'; import { assertUnreachable } from '../../../../../../common/utility_types'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { Direction, GeoItem, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/index.ts index 31529f677194..06fac027685b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts index acb98b7e347b..d36d38564392 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../../src/plugins/data/common'; import { Direction, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/helpers.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/helpers.ts index b67facab8f23..0e1286c8c2fc 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/helpers.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/helpers.ts @@ -6,7 +6,7 @@ */ import { get, getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { NetworkUsersBucketsItem, NetworkUsersEdges, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/index.ts index 5a7409200f9a..32778ba2bc66 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/types.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/types.ts index 4bdf97b48980..8fc1192fa95a 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/types.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/types.ts @@ -5,20 +5,20 @@ * 2.0. */ -import { +import type { IScopedClusterClient, SavedObjectsClientContract, } from '../../../../../../../src/core/server'; -import { +import type { IEsSearchResponse, ISearchRequestParams, } from '../../../../../../../src/plugins/data/common'; -import { +import type { FactoryQueryTypes, StrategyRequestType, StrategyResponseType, } from '../../../../common/search_strategy/security_solution'; -import { EndpointAppContext } from '../../../endpoint/types'; +import type { EndpointAppContext } from '../../../endpoint/types'; export interface SecuritySolutionFactory { buildDsl: (options: StrategyRequestType) => ISearchRequestParams; diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/index.ts index 39fa7193fd5d..78a1cfe20d21 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/index.ts @@ -15,7 +15,7 @@ import { } from '../../../../../../common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { buildHostRulesQuery } from './query.host_rules.dsl'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { formatHostRulesData } from './helpers'; import { inspectStringifyObject } from '../../../../../utils/build_query'; diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/index.ts index 0ba8cbef1d14..c90ad5a31179 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/index.ts @@ -15,7 +15,7 @@ import { } from '../../../../../../common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { buildHostTacticsQuery } from './query.host_tactics.dsl'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { formatHostTacticsData } from './helpers'; import { inspectStringifyObject } from '../../../../../utils/build_query'; diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/index.ts index 6b3a956c9c1b..8e65b53c3e68 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/index.ts @@ -15,7 +15,7 @@ import { } from '../../../../../../common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { buildRiskScoreQuery } from './query.risk_score.dsl'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { formatRiskScoreData } from './helpers'; import { inspectStringifyObject } from '../../../../../utils/build_query'; diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/index.ts index aa525f2c5b74..8a5099618d10 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/index.ts @@ -17,7 +17,7 @@ import { } from '../../../../../../common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; import { buildUserRulesQuery } from './query.user_rules.dsl'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { formatUserRulesData } from './helpers'; import { inspectStringifyObject } from '../../../../../utils/build_query'; diff --git a/x-pack/plugins/security_solution/server/usage/jest.config.js b/x-pack/plugins/security_solution/server/usage/jest.config.js index 82386fea363f..193590dbff54 100644 --- a/x-pack/plugins/security_solution/server/usage/jest.config.js +++ b/x-pack/plugins/security_solution/server/usage/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/usage', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/server/usage/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/security_solution/server/utils/jest.config.js b/x-pack/plugins/security_solution/server/utils/jest.config.js index d3a2e138b789..ceaa2d790da2 100644 --- a/x-pack/plugins/security_solution/server/utils/jest.config.js +++ b/x-pack/plugins/security_solution/server/utils/jest.config.js @@ -13,4 +13,12 @@ module.exports = { '/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/utils', coverageReporters: ['text', 'html'], collectCoverageFrom: ['/x-pack/plugins/security_solution/server/utils/**/*.{ts,tsx}'], + // See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core. + moduleNameMapper: { + 'core/server$': '/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts', + 'task_manager/server$': + '/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts', + 'alerting/server$': '/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts', + 'actions/server$': '/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts', + }, }; diff --git a/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx index aefff7fb3c76..2c64f559602c 100644 --- a/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx +++ b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx @@ -18,7 +18,7 @@ jest.mock('./edit_space', () => ({ }, })); -import { coreMock, scopedHistoryMock } from 'src/core/public/mocks'; +import { coreMock, scopedHistoryMock, themeServiceMock } from 'src/core/public/mocks'; import { featuresPluginMock } from '../../../features/public/mocks'; import type { PluginsStart } from '../plugin'; @@ -51,6 +51,7 @@ async function mountApp(basePath: string, pathname: string, spaceId?: string) { element: container, setBreadcrumbs, history: scopedHistoryMock.create({ pathname }), + theme$: themeServiceMock.createTheme$(), }); return { unmount, container, setBreadcrumbs, docTitle: coreStart.chrome.docTitle }; diff --git a/x-pack/plugins/timelines/common/search_strategy/index_fields/index.ts b/x-pack/plugins/timelines/common/search_strategy/index_fields/index.ts index 3579a45d2fcb..0b83cf28f9bb 100644 --- a/x-pack/plugins/timelines/common/search_strategy/index_fields/index.ts +++ b/x-pack/plugins/timelines/common/search_strategy/index_fields/index.ts @@ -10,9 +10,9 @@ import type { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesW import type { IEsSearchRequest, IEsSearchResponse, + FieldSpec, } from '../../../../../../src/plugins/data/common'; import type { DocValueFields, Maybe } from '../common'; -import { FieldSpec } from '../../../../../../src/plugins/data/common'; export type BeatFieldsFactoryQueryType = 'beatFields'; diff --git a/x-pack/plugins/timelines/common/search_strategy/timeline/events/details/index.ts b/x-pack/plugins/timelines/common/search_strategy/timeline/events/details/index.ts index f9f6a2ea5791..c8b1c8ef43ce 100644 --- a/x-pack/plugins/timelines/common/search_strategy/timeline/events/details/index.ts +++ b/x-pack/plugins/timelines/common/search_strategy/timeline/events/details/index.ts @@ -7,7 +7,7 @@ import { JsonObject } from '@kbn/utility-types'; -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe } from '../../../common'; import { TimelineRequestOptionsPaginated } from '../..'; diff --git a/x-pack/plugins/timelines/common/search_strategy/timeline/events/eql/index.ts b/x-pack/plugins/timelines/common/search_strategy/timeline/events/eql/index.ts index 1e5164684bf6..fee5014524fe 100644 --- a/x-pack/plugins/timelines/common/search_strategy/timeline/events/eql/index.ts +++ b/x-pack/plugins/timelines/common/search_strategy/timeline/events/eql/index.ts @@ -6,7 +6,7 @@ */ import { EuiComboBoxOptionOption } from '@elastic/eui'; -import { +import type { EqlSearchStrategyRequest, EqlSearchStrategyResponse, } from '../../../../../../../../src/plugins/data/common'; diff --git a/x-pack/plugins/timelines/common/search_strategy/timeline/events/last_event_time/index.ts b/x-pack/plugins/timelines/common/search_strategy/timeline/events/last_event_time/index.ts index 8673359d230b..95d82e605ef1 100644 --- a/x-pack/plugins/timelines/common/search_strategy/timeline/events/last_event_time/index.ts +++ b/x-pack/plugins/timelines/common/search_strategy/timeline/events/last_event_time/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe } from '../../../common'; import { TimelineRequestBasicOptions } from '../..'; diff --git a/x-pack/plugins/timelines/common/search_strategy/timeline/index.ts b/x-pack/plugins/timelines/common/search_strategy/timeline/index.ts index f57639291049..c328ba49493f 100644 --- a/x-pack/plugins/timelines/common/search_strategy/timeline/index.ts +++ b/x-pack/plugins/timelines/common/search_strategy/timeline/index.ts @@ -6,7 +6,7 @@ */ import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { IEsSearchRequest } from '../../../../../../src/plugins/data/common'; +import type { IEsSearchRequest } from '../../../../../../src/plugins/data/common'; import { ESQuery } from '../../typed_json'; import { TimelineEventsQueries, diff --git a/x-pack/plugins/timelines/common/types/timeline/cells/index.ts b/x-pack/plugins/timelines/common/types/timeline/cells/index.ts index e922fed97a4d..c2f785d54c5d 100644 --- a/x-pack/plugins/timelines/common/types/timeline/cells/index.ts +++ b/x-pack/plugins/timelines/common/types/timeline/cells/index.ts @@ -6,9 +6,8 @@ */ import { EuiDataGridCellValueElementProps } from '@elastic/eui'; +import type { Filter } from '@kbn/es-query'; import { RowRenderer } from '../../..'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Filter } from '../../../../../../../src/plugins/data/public'; import { Ecs } from '../../../ecs'; import { BrowserFields, TimelineNonEcsData } from '../../../search_strategy'; import { ColumnHeaderOptions } from '../columns'; diff --git a/x-pack/plugins/timelines/common/types/timeline/columns/index.tsx b/x-pack/plugins/timelines/common/types/timeline/columns/index.tsx index bd4cd2d7192d..88caa779d059 100644 --- a/x-pack/plugins/timelines/common/types/timeline/columns/index.tsx +++ b/x-pack/plugins/timelines/common/types/timeline/columns/index.tsx @@ -8,7 +8,7 @@ import { ReactNode } from 'react'; import { EuiDataGridColumn, EuiDataGridColumnCellActionProps } from '@elastic/eui'; -import { IFieldSubType } from '../../../../../../../src/plugins/data/common'; +import type { IFieldSubType } from '@kbn/es-query'; import { BrowserFields } from '../../../search_strategy/index_fields'; import { TimelineNonEcsData } from '../../../search_strategy/timeline'; import { Ecs } from '../../../ecs'; diff --git a/x-pack/plugins/timelines/common/types/timeline/store.ts b/x-pack/plugins/timelines/common/types/timeline/store.ts index 8e3a9fda9475..db2f09e4f74c 100644 --- a/x-pack/plugins/timelines/common/types/timeline/store.ts +++ b/x-pack/plugins/timelines/common/types/timeline/store.ts @@ -5,6 +5,7 @@ * 2.0. */ +import type { Filter } from '@kbn/es-query'; import { ColumnHeaderOptions, ColumnId, @@ -13,8 +14,6 @@ import { TimelineExpandedDetail, TimelineTypeLiteral, } from '.'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Filter } from '../../../../../../src/plugins/data/public'; import { Direction } from '../../search_strategy'; import { DataProvider } from './data_provider'; diff --git a/x-pack/plugins/timelines/public/components/hover_actions/actions/types.ts b/x-pack/plugins/timelines/public/components/hover_actions/actions/types.ts index b6c9e794625e..b24b1fdf8501 100644 --- a/x-pack/plugins/timelines/public/components/hover_actions/actions/types.ts +++ b/x-pack/plugins/timelines/public/components/hover_actions/actions/types.ts @@ -6,7 +6,7 @@ */ import { EuiButtonEmpty, EuiButtonIcon, EuiButtonIconPropsForButton } from '@elastic/eui'; -import { FilterManager } from '../../../../../../../src/plugins/data/public'; +import type { FilterManager } from '../../../../../../../src/plugins/data/public'; export interface FilterValueFnArgs { /** `Component` is only used with `EuiDataGrid`; the grid keeps a reference to `Component` for show / hide functionality */ diff --git a/x-pack/plugins/timelines/public/components/hover_actions/utils.ts b/x-pack/plugins/timelines/public/components/hover_actions/utils.ts index f34506eaa795..019253a280b6 100644 --- a/x-pack/plugins/timelines/public/components/hover_actions/utils.ts +++ b/x-pack/plugins/timelines/public/components/hover_actions/utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Filter } from '../../../../../../src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; export const getAdditionalScreenReaderOnlyContext = ({ field, diff --git a/x-pack/plugins/timelines/public/components/t_grid/body/index.tsx b/x-pack/plugins/timelines/public/components/t_grid/body/index.tsx index 6f4fc6217ecd..d69cd4bb42c6 100644 --- a/x-pack/plugins/timelines/public/components/t_grid/body/index.tsx +++ b/x-pack/plugins/timelines/public/components/t_grid/body/index.tsx @@ -36,6 +36,7 @@ import { ALERT_RULE_CONSUMER, ALERT_RULE_PRODUCER, } from '@kbn/rule-data-utils/technical_field_names'; +import { Filter } from '@kbn/es-query'; import { TGridCellAction, BulkActionsProp, @@ -77,7 +78,6 @@ import type { EuiTheme } from '../../../../../../../src/plugins/kibana_react/com import { ViewSelection } from '../event_rendered_view/selector'; import { EventRenderedView } from '../event_rendered_view'; import { useDataGridHeightHack } from './height_hack'; -import { Filter } from '../../../../../../../src/plugins/data/public'; import { REMOVE_COLUMN } from './column_headers/translations'; const StatefulAlertStatusBulkActions = lazy( diff --git a/x-pack/plugins/timelines/public/components/t_grid/helpers.test.tsx b/x-pack/plugins/timelines/public/components/t_grid/helpers.test.tsx index 1998bef23374..535c856d51e8 100644 --- a/x-pack/plugins/timelines/public/components/t_grid/helpers.test.tsx +++ b/x-pack/plugins/timelines/public/components/t_grid/helpers.test.tsx @@ -6,7 +6,7 @@ */ import { cloneDeep } from 'lodash/fp'; -import { esFilters, EsQueryConfig, Filter } from '../../../../../../src/plugins/data/public'; +import { Filter, EsQueryConfig, FilterStateStore } from '@kbn/es-query'; import { DataProviderType } from '../../../common/types/timeline'; import { mockBrowserFields, mockDataProviders, mockIndexPattern } from '../../mock'; @@ -267,7 +267,7 @@ describe('Combined Queries', () => { browserFields: mockBrowserFields, filters: [ { - $state: { store: esFilters.FilterStateStore.APP_STATE }, + $state: { store: FilterStateStore.APP_STATE }, meta: { alias: null, disabled: false, @@ -279,7 +279,7 @@ describe('Combined Queries', () => { query: { match_phrase: { 'event.category': 'file' } }, }, { - $state: { store: esFilters.FilterStateStore.APP_STATE }, + $state: { store: FilterStateStore.APP_STATE }, meta: { alias: null, disabled: false, @@ -495,7 +495,7 @@ describe('Combined Queries', () => { }, }, $state: { - store: esFilters.FilterStateStore.APP_STATE, + store: FilterStateStore.APP_STATE, }, } as Filter, ], @@ -517,7 +517,7 @@ describe('Combined Queries', () => { browserFields: mockBrowserFields, filters: [ { - $state: { store: esFilters.FilterStateStore.APP_STATE }, + $state: { store: FilterStateStore.APP_STATE }, meta: { alias: null, disabled: false, diff --git a/x-pack/plugins/timelines/public/components/t_grid/integrated/index.tsx b/x-pack/plugins/timelines/public/components/t_grid/integrated/index.tsx index b83c1570d907..462a4900dc55 100644 --- a/x-pack/plugins/timelines/public/components/t_grid/integrated/index.tsx +++ b/x-pack/plugins/timelines/public/components/t_grid/integrated/index.tsx @@ -35,7 +35,9 @@ import type { RowRenderer, AlertStatus, } from '../../../../common/types/timeline'; -import { esQuery, DataPublicPluginStart } from '../../../../../../../src/plugins/data/public'; + +import type { DataPublicPluginStart } from '../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common'; import { useDeepEqualSelector } from '../../../hooks/use_selector'; import { defaultHeaders } from '../body/column_headers/default_headers'; import { buildCombinedQuery, getCombinedFilterQuery, resolverIsShowing } from '../helpers'; @@ -190,7 +192,7 @@ const TGridIntegratedComponent: React.FC = ({ const justTitle = useMemo(() => {title}, [title]); const combinedQueries = buildCombinedQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), dataProviders, indexPattern, browserFields, @@ -247,7 +249,7 @@ const TGridIntegratedComponent: React.FC = ({ const filterQuery = useMemo( () => getCombinedFilterQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), browserFields, dataProviders, filters, diff --git a/x-pack/plugins/timelines/public/components/t_grid/standalone/index.tsx b/x-pack/plugins/timelines/public/components/t_grid/standalone/index.tsx index 1cb13a9d6cbb..3f9fa6765056 100644 --- a/x-pack/plugins/timelines/public/components/t_grid/standalone/index.tsx +++ b/x-pack/plugins/timelines/public/components/t_grid/standalone/index.tsx @@ -10,6 +10,7 @@ import React, { useEffect, useMemo, useState, useRef } from 'react'; import styled from 'styled-components'; import { useDispatch, useSelector } from 'react-redux'; import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type { Filter, Query } from '@kbn/es-query'; import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; import { Direction, EntityType } from '../../../../common/search_strategy'; import type { CoreStart } from '../../../../../../../src/core/public'; @@ -25,12 +26,8 @@ import type { BulkActionsProp, AlertStatus, } from '../../../../common/types/timeline'; -import { - esQuery, - Filter, - Query, - DataPublicPluginStart, -} from '../../../../../../../src/plugins/data/public'; +import type { DataPublicPluginStart } from '../../../../../../../src/plugins/data/public'; +import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common'; import { useDeepEqualSelector } from '../../../hooks/use_selector'; import { defaultHeaders } from '../body/column_headers/default_headers'; import { combineQueries, getCombinedFilterQuery } from '../helpers'; @@ -176,7 +173,7 @@ const TGridStandaloneComponent: React.FC = ({ const combinedQueries = useMemo( () => combineQueries({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), dataProviders: EMPTY_DATA_PROVIDERS, indexPattern: indexPatterns, browserFields, @@ -290,7 +287,7 @@ const TGridStandaloneComponent: React.FC = ({ const filterQuery = useMemo( () => getCombinedFilterQuery({ - config: esQuery.getEsQueryConfig(uiSettings), + config: getEsQueryConfig(uiSettings), dataProviders: EMPTY_DATA_PROVIDERS, indexPattern: indexPatterns, browserFields, diff --git a/x-pack/plugins/timelines/public/container/index.tsx b/x-pack/plugins/timelines/public/container/index.tsx index 8a6c4ac53faa..e43d9571f800 100644 --- a/x-pack/plugins/timelines/public/container/index.tsx +++ b/x-pack/plugins/timelines/public/container/index.tsx @@ -14,11 +14,8 @@ import { Subscription } from 'rxjs'; import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { tGridActions } from '..'; -import { - DataPublicPluginStart, - isCompleteResponse, - isErrorResponse, -} from '../../../../../src/plugins/data/public'; +import type { DataPublicPluginStart } from '../../../../../src/plugins/data/public'; +import { isCompleteResponse, isErrorResponse } from '../../../../../src/plugins/data/common'; import { Direction, TimelineFactoryQueryTypes, diff --git a/x-pack/plugins/timelines/public/container/source/index.tsx b/x-pack/plugins/timelines/public/container/source/index.tsx index f66eedb94f88..f13e48d82ac8 100644 --- a/x-pack/plugins/timelines/public/container/source/index.tsx +++ b/x-pack/plugins/timelines/public/container/source/index.tsx @@ -21,11 +21,9 @@ import { } from '../../../common'; import * as i18n from './translations'; -import { - DataPublicPluginStart, - isCompleteResponse, - isErrorResponse, -} from '../../../../../../src/plugins/data/public'; +import type { DataPublicPluginStart } from '../../../../../../src/plugins/data/public'; +import { isCompleteResponse, isErrorResponse } from '../../../../../../src/plugins/data/common'; + import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; import { useAppToasts } from '../../hooks/use_app_toasts'; diff --git a/x-pack/plugins/timelines/public/hooks/use_app_toasts.ts b/x-pack/plugins/timelines/public/hooks/use_app_toasts.ts index 8b4bf582e6d8..8b05aa6df27a 100644 --- a/x-pack/plugins/timelines/public/hooks/use_app_toasts.ts +++ b/x-pack/plugins/timelines/public/hooks/use_app_toasts.ts @@ -11,7 +11,7 @@ import { isAppError, isKibanaError, isSecurityAppError } from '@kbn/securitysolu import type { AppError } from '@kbn/securitysolution-t-grid'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; -import { +import type { ErrorToastOptions, ToastsStart, Toast, diff --git a/x-pack/plugins/timelines/public/store/t_grid/model.ts b/x-pack/plugins/timelines/public/store/t_grid/model.ts index 739bcbef3e20..bc44a5fc159c 100644 --- a/x-pack/plugins/timelines/public/store/t_grid/model.ts +++ b/x-pack/plugins/timelines/public/store/t_grid/model.ts @@ -6,7 +6,8 @@ */ import type { EuiDataGridColumn } from '@elastic/eui'; -import type { Filter, FilterManager } from '../../../../../../src/plugins/data/public'; +import type { Filter } from '@kbn/es-query'; +import type { FilterManager } from '../../../../../../src/plugins/data/public'; import type { TimelineNonEcsData } from '../../../common/search_strategy'; import type { ColumnHeaderOptions, diff --git a/x-pack/plugins/timelines/public/types.ts b/x-pack/plugins/timelines/public/types.ts index f81632e29ab1..9c42f941ee03 100644 --- a/x-pack/plugins/timelines/public/types.ts +++ b/x-pack/plugins/timelines/public/types.ts @@ -9,7 +9,7 @@ import { ReactElement } from 'react'; import type { SensorAPI } from 'react-beautiful-dnd'; import { Store } from 'redux'; import { CoreStart } from '../../../../src/core/public'; -import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; +import type { DataPublicPluginStart } from '../../../../src/plugins/data/public'; import { CasesUiStart } from '../../cases/public'; import type { LastUpdatedAtProps, diff --git a/x-pack/plugins/timelines/server/search_strategy/index_fields/index.ts b/x-pack/plugins/timelines/server/search_strategy/index_fields/index.ts index 2427ec8bb607..7e2c03486d89 100644 --- a/x-pack/plugins/timelines/server/search_strategy/index_fields/index.ts +++ b/x-pack/plugins/timelines/server/search_strategy/index_fields/index.ts @@ -24,7 +24,7 @@ import { DELETED_SECURITY_SOLUTION_DATA_VIEW, } from '../../../common'; import { StartPlugins } from '../../types'; -import { FieldSpec } from '../../../../../../src/plugins/data_views/common'; +import type { FieldSpec } from '../../../../../../src/plugins/data_views/common'; const apmIndexPattern = 'apm-*-transaction*'; const apmDataStreamsPattern = 'traces-apm*'; diff --git a/x-pack/plugins/timelines/server/search_strategy/index_fields/mock.ts b/x-pack/plugins/timelines/server/search_strategy/index_fields/mock.ts index f55cd069ecd5..6ec6ca86538b 100644 --- a/x-pack/plugins/timelines/server/search_strategy/index_fields/mock.ts +++ b/x-pack/plugins/timelines/server/search_strategy/index_fields/mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { FieldDescriptor } from '../../../../../../src/plugins/data/server'; +import type { FieldDescriptor } from '../../../../../../src/plugins/data/server'; export const mockAuditbeatIndexField: FieldDescriptor[] = [ { diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/eql/__mocks__/index.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/eql/__mocks__/index.ts index 9e950132b5b6..ea212f07f442 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/eql/__mocks__/index.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/eql/__mocks__/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { EqlSearchStrategyResponse } from '../../../../../../../../src/plugins/data/common'; +import type { EqlSearchStrategyResponse } from '../../../../../../../../src/plugins/data/common'; import { EqlSearchResponse } from '../../../../../common'; export const sequenceResponse = { diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/eql/helpers.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/eql/helpers.ts index 976185bb1b17..50ef2ccd0293 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/eql/helpers.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/eql/helpers.ts @@ -6,7 +6,7 @@ */ import { isEmpty } from 'lodash/fp'; -import { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; +import type { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../common/constants'; import { EqlSearchResponse, EqlSequence, EventHit } from '../../../../common'; import { TimelineEdges } from '../../../../common/search_strategy'; diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/index.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/index.ts index 3ab924440152..476ac196de81 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/index.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/index.ts @@ -7,7 +7,7 @@ import { cloneDeep, getOr } from 'lodash/fp'; import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../common/constants'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { EventHit, TimelineEventsQueries, diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/index.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/index.ts index e2491c403945..4e2876b4e19c 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/index.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/index.ts @@ -7,7 +7,7 @@ import { cloneDeep, merge, unionBy } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { EventHit, TimelineEventsQueries, diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/index.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/index.ts index 86a7819e6415..50484bbda0e6 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/index.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { TimelineEventsQueries, TimelineRequestBasicOptions, diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/index.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/index.ts index 9b96743ff850..528230d660a4 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/index.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/index.ts @@ -7,7 +7,7 @@ import { getOr } from 'lodash/fp'; -import { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; +import type { IEsSearchResponse } from '../../../../../../../../../src/plugins/data/common'; import { TimelineEventsQueries, TimelineEventsLastEventTimeStrategyResponse, diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts index 4ff86c9a9f29..54bd3ec522b8 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts @@ -6,7 +6,7 @@ */ import { isEmpty } from 'lodash/fp'; -import { ISearchRequestParams } from 'src/plugins/data/common'; +import type { ISearchRequestParams } from 'src/plugins/data/common'; import { TimelineEventsLastEventTimeRequestOptions, LastEventIndexKey, diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/types.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/types.ts index 831e3266ad8e..3eb35c88f8ea 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/types.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { +import type { IEsSearchResponse, ISearchRequestParams, } from '../../../../../../../src/plugins/data/common'; diff --git a/x-pack/plugins/timelines/server/types.ts b/x-pack/plugins/timelines/server/types.ts index f9a80908fbc7..436702257303 100644 --- a/x-pack/plugins/timelines/server/types.ts +++ b/x-pack/plugins/timelines/server/types.ts @@ -5,8 +5,7 @@ * 2.0. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { DataPluginSetup, DataPluginStart } from '../../../../src/plugins/data/server/plugin'; +import type { PluginSetup, PluginStart } from '../../../../src/plugins/data/server'; import { PluginStartContract as AlertingPluginStartContract } from '../../alerting/server'; import { SecurityPluginSetup } from '../../security/server'; @@ -16,11 +15,11 @@ export interface TimelinesPluginUI {} export interface TimelinesPluginStart {} export interface SetupPlugins { - data: DataPluginSetup; + data: PluginSetup; security?: SecurityPluginSetup; } export interface StartPlugins { - data: DataPluginStart; + data: PluginStart; alerting: AlertingPluginStartContract; } diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index bfea8ef7b547..84888f5ebf86 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -8111,7 +8111,6 @@ "xpack.canvas.workpadConfig.pageSizeBadgeOnClickAriaLabel": "ページサイズを {sizeName} に設定", "xpack.canvas.workpadConfig.swapDimensionsAriaLabel": "ページの幅と高さを入れ替えます", "xpack.canvas.workpadConfig.swapDimensionsTooltip": "ページの幅と高さを入れ替える", - "xpack.canvas.workpadConfig.title": "ワークパッドの設定", "xpack.canvas.workpadConfig.USLetterButtonLabel": "US レター", "xpack.canvas.workpadConfig.widthLabel": "幅", "xpack.canvas.workpadCreate.createButtonLabel": "ワークパッドを作成", @@ -19831,7 +19830,6 @@ "xpack.security.management.roleMappings.rolesColumnName": "ロール", "xpack.security.management.roleMappingsTitle": "ロールマッピング", "xpack.security.management.roles.actionsColumnName": "アクション", - "xpack.security.management.roles.cloneRoleActionName": "{roleName} を複製", "xpack.security.management.roles.confirmDelete.cancelButtonLabel": "キャンセル", "xpack.security.management.roles.confirmDelete.deleteButtonLabel": "削除", "xpack.security.management.roles.confirmDelete.removingRolesDescription": "これらのロールを削除しようとしています:", @@ -19842,7 +19840,6 @@ "xpack.security.management.roles.deleteSelectedRolesButtonLabel": "ロール {numSelected} {numSelected, plural, one { } other {}} を削除しました", "xpack.security.management.roles.deletingRolesWarningMessage": "この操作は元に戻すことができません。", "xpack.security.management.roles.deniedPermissionTitle": "ロールを管理するにはパーミッションが必要です", - "xpack.security.management.roles.editRoleActionName": "{roleName} を編集", "xpack.security.management.roles.fetchingRolesErrorMessage": "ロールの取得中にエラーが発生:{message}", "xpack.security.management.roles.nameColumnName": "ロール", "xpack.security.management.roles.noIndexPatternsPermission": "利用可能なインデックスパターンのリストへのアクセス権が必要です。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 0c115bc61b56..ef9fb023b15f 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -8174,7 +8174,6 @@ "xpack.canvas.workpadConfig.pageSizeBadgeOnClickAriaLabel": "将页面大小设置为 {sizeName}", "xpack.canvas.workpadConfig.swapDimensionsAriaLabel": "交换页面的宽和高", "xpack.canvas.workpadConfig.swapDimensionsTooltip": "交换宽高", - "xpack.canvas.workpadConfig.title": "Workpad 设置", "xpack.canvas.workpadConfig.USLetterButtonLabel": "美国信函", "xpack.canvas.workpadConfig.widthLabel": "宽", "xpack.canvas.workpadCreate.createButtonLabel": "创建 Workpad", @@ -20126,7 +20125,6 @@ "xpack.security.management.roleMappings.roleTemplates": "{templateCount, plural, other {# 个角色模板}}已定义", "xpack.security.management.roleMappingsTitle": "角色映射", "xpack.security.management.roles.actionsColumnName": "操作", - "xpack.security.management.roles.cloneRoleActionName": "克隆 {roleName}", "xpack.security.management.roles.confirmDelete.cancelButtonLabel": "取消", "xpack.security.management.roles.confirmDelete.deleteButtonLabel": "删除", "xpack.security.management.roles.confirmDelete.removingRolesDescription": "您即将删除以下角色:", @@ -20137,7 +20135,6 @@ "xpack.security.management.roles.deleteSelectedRolesButtonLabel": "删除 {numSelected} 个角色{numSelected, plural, other {}}", "xpack.security.management.roles.deletingRolesWarningMessage": "此操作无法撤消。", "xpack.security.management.roles.deniedPermissionTitle": "您需要用于管理角色的权限", - "xpack.security.management.roles.editRoleActionName": "编辑 {roleName}", "xpack.security.management.roles.fetchingRolesErrorMessage": "获取用户时出错:{message}", "xpack.security.management.roles.nameColumnName": "角色", "xpack.security.management.roles.noIndexPatternsPermission": "您需要访问可用索引模式列表的权限。", diff --git a/x-pack/plugins/uptime/public/components/fleet_package/synthetics_policy_edit_extension_wrapper.test.tsx b/x-pack/plugins/uptime/public/components/fleet_package/synthetics_policy_edit_extension_wrapper.test.tsx index c141e33ea159..51b7ddd90a05 100644 --- a/x-pack/plugins/uptime/public/components/fleet_package/synthetics_policy_edit_extension_wrapper.test.tsx +++ b/x-pack/plugins/uptime/public/components/fleet_package/synthetics_policy_edit_extension_wrapper.test.tsx @@ -573,16 +573,43 @@ describe('', () => { }); }); - it('shows tls fields when metadata.is_tls_enabled is true', async () => { - const { getByLabelText } = render(); - const verificationMode = getByLabelText('Verification mode') as HTMLInputElement; - const enableTLSConfig = getByLabelText('Enable TLS configuration') as HTMLInputElement; - expect(enableTLSConfig.getAttribute('aria-checked')).toEqual('true'); - expect(verificationMode).toBeInTheDocument(); - expect(verificationMode.value).toEqual( - `${defaultHTTPConfig[ConfigKeys.TLS_VERIFICATION_MODE]}` - ); - }); + it.each([[true], [false]])( + 'shows tls fields when metadata.is_tls_enabled is or verification mode is truthy true', + async (isTLSEnabledInUIMetadataKey) => { + const currentPolicy = { + ...defaultCurrentPolicy, + inputs: [ + { + ...defaultNewPolicy.inputs[0], + enabled: true, + streams: [ + { + ...defaultNewPolicy.inputs[0].streams[0], + vars: { + ...defaultNewPolicy.inputs[0].streams[0].vars, + __ui: { + type: 'yaml', + value: JSON.stringify({ + is_tls_enabled: isTLSEnabledInUIMetadataKey, + }), + }, + }, + }, + ], + }, + ], + }; + + const { getByLabelText } = render(); + const verificationMode = getByLabelText('Verification mode') as HTMLInputElement; + const enableTLSConfig = getByLabelText('Enable TLS configuration') as HTMLInputElement; + expect(enableTLSConfig.getAttribute('aria-checked')).toEqual('true'); + expect(verificationMode).toBeInTheDocument(); + expect(verificationMode.value).toEqual( + `${defaultHTTPConfig[ConfigKeys.TLS_VERIFICATION_MODE]}` + ); + } + ); it('handles browser validation', async () => { const currentPolicy = { @@ -1128,6 +1155,7 @@ describe('', () => { expect(getByText(text)).toBeInTheDocument(); } ); + it('hides tls fields when metadata.is_tls_enabled is false', async () => { const { getByLabelText, queryByLabelText } = render( = { [type]: formattedDefaultConfigForMonitorType, diff --git a/x-pack/test/apm_api_integration/tests/correlations/failed_transactions.spec.ts b/x-pack/test/apm_api_integration/tests/correlations/failed_transactions.spec.ts index 22909d5431b4..0a175762fe3e 100644 --- a/x-pack/test/apm_api_integration/tests/correlations/failed_transactions.spec.ts +++ b/x-pack/test/apm_api_integration/tests/correlations/failed_transactions.spec.ts @@ -201,7 +201,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { expect(finalRawResponse?.percentileThresholdValue).to.be(1309695.875); expect(finalRawResponse?.errorHistogram?.length).to.be(101); expect(finalRawResponse?.overallHistogram?.length).to.be(101); - expect(finalRawResponse?.fieldStats?.length).to.be(26); + expect(finalRawResponse?.fieldStats?.length).to.be(fieldsToSample.size); expect(finalRawResponse?.failedTransactionsCorrelations?.length).to.eql( 30, diff --git a/x-pack/test/apm_api_integration/tests/correlations/latency.spec.ts b/x-pack/test/apm_api_integration/tests/correlations/latency.spec.ts index 6be239972933..70a4071bfbb0 100644 --- a/x-pack/test/apm_api_integration/tests/correlations/latency.spec.ts +++ b/x-pack/test/apm_api_integration/tests/correlations/latency.spec.ts @@ -105,8 +105,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { { config: 'trial', archives: ['8.0.0'] }, () => { // putting this into a single `it` because the responses depend on each other - // FLAKY: https://github.com/elastic/kibana/issues/118023 - it.skip('runs queries and returns results', async () => { + it('runs queries and returns results', async () => { const overallDistributionResponse = await apmApiClient.readUser({ endpoint: 'POST /internal/apm/latency/overall_distribution', params: { @@ -210,7 +209,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { // Fetched 95th percentile value of 1309695.875 based on 1244 documents. expect(finalRawResponse?.percentileThresholdValue).to.be(1309695.875); expect(finalRawResponse?.overallHistogram?.length).to.be(101); - expect(finalRawResponse?.fieldStats?.length).to.be(12); + expect(finalRawResponse?.fieldStats?.length).to.be(fieldsToSample.size); // Identified 13 significant correlations out of 379 field/value pairs. expect(finalRawResponse?.latencyCorrelations?.length).to.eql( diff --git a/x-pack/test/apm_api_integration/tests/metrics_charts/metrics_charts.spec.ts b/x-pack/test/apm_api_integration/tests/metrics_charts/metrics_charts.spec.ts index d70ee347d4c2..beaaae24fb22 100644 --- a/x-pack/test/apm_api_integration/tests/metrics_charts/metrics_charts.spec.ts +++ b/x-pack/test/apm_api_integration/tests/metrics_charts/metrics_charts.spec.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { first } from 'lodash'; -import { GenericMetricsChart } from '../../../../plugins/apm/server/lib/metrics/fetch_and_transform_metrics'; +import { GenericMetricsChart } from '../../../../plugins/apm/server/routes/metrics/fetch_and_transform_metrics'; import { SupertestReturnType } from '../../common/apm_api_supertest'; import { FtrProviderContext } from '../../common/ftr_provider_context'; diff --git a/x-pack/test/apm_api_integration/tests/settings/agent_configuration.spec.ts b/x-pack/test/apm_api_integration/tests/settings/agent_configuration.spec.ts index df504ec7444d..cea718c2c69d 100644 --- a/x-pack/test/apm_api_integration/tests/settings/agent_configuration.spec.ts +++ b/x-pack/test/apm_api_integration/tests/settings/agent_configuration.spec.ts @@ -10,7 +10,7 @@ import { inspect } from 'util'; import expect from '@kbn/expect'; import { omit, orderBy } from 'lodash'; import { AgentConfigurationIntake } from '../../../../plugins/apm/common/agent_configuration/configuration_types'; -import { AgentConfigSearchParams } from '../../../../plugins/apm/server/routes/settings/agent_configuration'; +import { AgentConfigSearchParams } from '../../../../plugins/apm/server/routes/settings/agent_configuration/route'; import { FtrProviderContext } from '../../common/ftr_provider_context'; diff --git a/x-pack/test/examples/search_examples/search_session_example.ts b/x-pack/test/examples/search_examples/search_session_example.ts index ab96a7767baf..e6261f69e14f 100644 --- a/x-pack/test/examples/search_examples/search_session_example.ts +++ b/x-pack/test/examples/search_examples/search_session_example.ts @@ -15,7 +15,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const es = getService('es'); const searchSessions = getService('searchSessions'); - describe('Search session example', () => { + // FLAKY: https://github.com/elastic/kibana/issues/118921 + describe.skip('Search session example', () => { const appId = 'searchExamples'; before(async function () { diff --git a/x-pack/test/functional/apps/lens/heatmap.ts b/x-pack/test/functional/apps/lens/heatmap.ts index 3f8456e9d75f..e4f20d075541 100644 --- a/x-pack/test/functional/apps/lens/heatmap.ts +++ b/x-pack/test/functional/apps/lens/heatmap.ts @@ -130,10 +130,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // assert legend has changed expect(debugState.legend!.items).to.eql([ - { key: '0 - 8,529.22', name: '0 - 8,529.22', color: '#6092c0' }, - { key: '8,529.22 - 11,335.66', name: '8,529.22 - 11,335.66', color: '#a8bfda' }, - { key: '11,335.66 - 14,142.11', name: '11,335.66 - 14,142.11', color: '#ebeff5' }, - { key: '14,142.11 - 16,948.55', name: '14,142.11 - 16,948.55', color: '#ecb385' }, + { key: '0 - 8,529.21', name: '0 - 8,529.21', color: '#6092c0' }, + { key: '8,529.21 - 11,335.66', name: '8,529.21 - 11,335.66', color: '#a8bfda' }, + { key: '11,335.66 - 14,142.1', name: '11,335.66 - 14,142.1', color: '#ebeff5' }, + { key: '14,142.1 - 16,948.55', name: '14,142.1 - 16,948.55', color: '#ecb385' }, { key: '≥ 16,948.55', name: '≥ 16,948.55', color: '#e7664c' }, ]); }); diff --git a/x-pack/test/functional/apps/lens/index.ts b/x-pack/test/functional/apps/lens/index.ts index 26fb100adf13..72442be7645f 100644 --- a/x-pack/test/functional/apps/lens/index.ts +++ b/x-pack/test/functional/apps/lens/index.ts @@ -17,7 +17,7 @@ export default function ({ getService, loadTestFile, getPageObjects }: FtrProvid describe('lens app', () => { before(async () => { log.debug('Starting lens before method'); - await browser.setWindowSize(1280, 800); + await browser.setWindowSize(1280, 1200); await esArchiver.load('x-pack/test/functional/es_archives/logstash_functional'); // changing the timepicker default here saves us from having to set it in Discover (~8s) await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); @@ -57,6 +57,7 @@ export default function ({ getService, loadTestFile, getPageObjects }: FtrProvid loadTestFile(require.resolve('./geo_field')); loadTestFile(require.resolve('./formula')); loadTestFile(require.resolve('./heatmap')); + loadTestFile(require.resolve('./metrics')); loadTestFile(require.resolve('./reference_lines')); loadTestFile(require.resolve('./inspector')); loadTestFile(require.resolve('./error_handling')); diff --git a/x-pack/test/functional/apps/lens/metrics.ts b/x-pack/test/functional/apps/lens/metrics.ts new file mode 100644 index 000000000000..4bc589b1a3b8 --- /dev/null +++ b/x-pack/test/functional/apps/lens/metrics.ts @@ -0,0 +1,59 @@ +/* + * 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. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const listingTable = getService('listingTable'); + const testSubjects = getService('testSubjects'); + + describe('lens metrics', () => { + it('should render a numeric metric', async () => { + await PageObjects.visualize.gotoVisualizationLandingPage(); + await listingTable.searchForItemWithName('Artistpreviouslyknownaslens'); + await PageObjects.lens.clickVisualizeListItemTitle('Artistpreviouslyknownaslens'); + await PageObjects.lens.goToTimeRange(); + await PageObjects.lens.assertMetric('Maximum of bytes', '19,986'); + }); + + it('should color the metric text based on value', async () => { + await PageObjects.lens.openDimensionEditor('lns-dimensionTrigger'); + await PageObjects.lens.setMetricDynamicColoring('labels'); + await PageObjects.header.waitUntilLoadingHasFinished(); + const styleObj = await PageObjects.lens.getMetricStyle(); + expect(styleObj['background-color']).to.be(undefined); + expect(styleObj.color).to.be('rgb(214, 191, 87)'); + }); + + it('should change the color of the metric when tweaking the values in the panel', async () => { + await PageObjects.lens.openPalettePanel('lnsMetric'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await testSubjects.setValue('lnsPalettePanel_dynamicColoring_stop_value_1', '21000', { + clearWithKeyboard: true, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + const styleObj = await PageObjects.lens.getMetricStyle(); + expect(styleObj.color).to.be('rgb(32, 146, 128)'); + }); + + it('should change the color when reverting the palette', async () => { + await testSubjects.click('lnsPalettePanel_dynamicColoring_reverse'); + await PageObjects.header.waitUntilLoadingHasFinished(); + const styleObj = await PageObjects.lens.getMetricStyle(); + expect(styleObj.color).to.be('rgb(204, 86, 66)'); + }); + + it('should reset the color stops when changing palette to a predefined one', async () => { + await PageObjects.lens.changePaletteTo('temperature'); + await PageObjects.header.waitUntilLoadingHasFinished(); + const styleObj = await PageObjects.lens.getMetricStyle(); + expect(styleObj.color).to.be('rgb(235, 239, 245)'); + }); + }); +} diff --git a/x-pack/test/functional/apps/security/role_mappings.ts b/x-pack/test/functional/apps/security/role_mappings.ts index 190323b8aaf1..54c92c4815b5 100644 --- a/x-pack/test/functional/apps/security/role_mappings.ts +++ b/x-pack/test/functional/apps/security/role_mappings.ts @@ -81,7 +81,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); it('allows a role mapping to be deleted', async () => { - await testSubjects.click(`deleteRoleMappingButton-new_role_mapping`); + await testSubjects.click('euiCollapsedItemActionsButton'); + await testSubjects.click('deleteRoleMappingButton-new_role_mapping'); await testSubjects.click('confirmModalConfirmButton'); await testSubjects.existOrFail('deletedRoleMappingSuccessToast'); }); @@ -162,6 +163,15 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { } }); + it('allows a role mapping to be cloned', async () => { + await testSubjects.click('cloneRoleMappingButton-a_enabled_role_mapping'); + await testSubjects.setValue('roleMappingFormNameInput', 'cloned_role_mapping'); + await testSubjects.click('saveRoleMappingButton'); + await testSubjects.existOrFail('savedRoleMappingSuccessToast'); + const rows = await testSubjects.findAll('roleMappingRow'); + expect(rows.length).to.eql(mappings.length + 1); + }); + it('allows a role mapping to be edited', async () => { await testSubjects.click('roleMappingName'); await testSubjects.click('saveRoleMappingButton'); diff --git a/x-pack/test/functional/page_objects/lens_page.ts b/x-pack/test/functional/page_objects/lens_page.ts index ca097ffe757c..78b9762e3889 100644 --- a/x-pack/test/functional/page_objects/lens_page.ts +++ b/x-pack/test/functional/page_objects/lens_page.ts @@ -20,8 +20,6 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont const browser = getService('browser'); const dashboardAddPanel = getService('dashboardAddPanel'); - const FORMULA_TAB_HEIGHT = 40; - const PageObjects = getPageObjects([ 'common', 'header', @@ -133,7 +131,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont : `lns-indexPatternDimension-${opts.operation}`; async function getAriaPressed() { const operationSelectorContainer = await testSubjects.find(operationSelector); - await testSubjects.click(operationSelector, undefined, FORMULA_TAB_HEIGHT); + await testSubjects.click(operationSelector); const ariaPressed = await operationSelectorContainer.getAttribute('aria-pressed'); return ariaPressed; } @@ -872,7 +870,12 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont }, async openPalettePanel(chartType: string) { - await testSubjects.click(`${chartType}_dynamicColoring_trigger`); + await retry.try(async () => { + await testSubjects.click(`${chartType}_dynamicColoring_trigger`); + // wait for the UI to settle + await PageObjects.common.sleep(100); + await testSubjects.existOrFail('lns-indexPattern-PalettePanelContainer', { timeout: 2500 }); + }); }, async closePalettePanel() { @@ -944,6 +947,22 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await this.assertExactText('[data-test-subj="lns_metric_value"]', count); }, + async setMetricDynamicColoring(coloringType: 'none' | 'labels' | 'background') { + await testSubjects.click('lnsMetric_dynamicColoring_groups_' + coloringType); + }, + + async getMetricStyle() { + const el = await testSubjects.find('lns_metric_value'); + const styleString = await el.getAttribute('style'); + return styleString.split(';').reduce>((memo, cssLine) => { + const [prop, value] = cssLine.split(':'); + if (prop && value) { + memo[prop.trim()] = value.trim(); + } + return memo; + }, {}); + }, + async assertMissingValues(option: string) { await this.assertExactText('[data-test-subj="lnsMissingValuesSelect"]', option); }, diff --git a/yarn.lock b/yarn.lock index e2c8581d597c..c6279d6577e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -44,6 +44,11 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.16.0.tgz#ea269d7f78deb3a7826c39a4048eecda541ebdaa" integrity sha512-DGjt2QZse5SGd9nfOSqO4WLJ8NN/oHkijbXbPrxuoJO3oIPJL3TciZs9FX+cOHNiY9E9l0opL8g7BmLe3T+9ew== +"@babel/compat-data@^7.16.4": + version "7.16.4" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.16.4.tgz#081d6bbc336ec5c2435c6346b2ae1fb98b5ac68e" + integrity sha512-1o/jo7D+kC9ZjHX5v+EHrdjl3PhxMrLSOTGsOdHJ+KL8HCaEK6ehrVL2RS6oHDZp+L7xLirLrPmQtEng769J/Q== + "@babel/core@7.12.9": version "7.12.9" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.9.tgz#fd450c4ec10cdbb980e2928b7aa7a28484593fc8" @@ -147,7 +152,7 @@ "@babel/helper-explode-assignable-expression" "^7.16.0" "@babel/types" "^7.16.0" -"@babel/helper-compilation-targets@^7.13.0", "@babel/helper-compilation-targets@^7.16.0": +"@babel/helper-compilation-targets@^7.13.0", "@babel/helper-compilation-targets@^7.16.0", "@babel/helper-compilation-targets@^7.16.3": version "7.16.3" resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.3.tgz#5b480cd13f68363df6ec4dc8ac8e2da11363cbf0" integrity sha512-vKsoSQAyBmxS35JUOOt+07cLc6Nk/2ljLIHwmq2/NM6hdioUaqEXq/S+nXvbvXbZkNDlWOymPanJGOc4CBjSJA== @@ -191,6 +196,20 @@ resolve "^1.14.2" semver "^6.1.2" +"@babel/helper-define-polyfill-provider@^0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.0.tgz#c5b10cf4b324ff840140bb07e05b8564af2ae971" + integrity sha512-7hfT8lUljl/tM3h+izTX/pO3W3frz2ok6Pk+gzys8iJqDfZrZy2pXjRTZAvG2YmfHun1X4q8/UZRLatMfqc5Tg== + dependencies: + "@babel/helper-compilation-targets" "^7.13.0" + "@babel/helper-module-imports" "^7.12.13" + "@babel/helper-plugin-utils" "^7.13.0" + "@babel/traverse" "^7.13.0" + debug "^4.1.1" + lodash.debounce "^4.0.8" + resolve "^1.14.2" + semver "^6.1.2" + "@babel/helper-explode-assignable-expression@^7.16.0": version "7.16.0" resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.16.0.tgz#753017337a15f46f9c09f674cff10cee9b9d7778" @@ -275,6 +294,15 @@ "@babel/helper-wrap-function" "^7.16.0" "@babel/types" "^7.16.0" +"@babel/helper-remap-async-to-generator@^7.16.4": + version "7.16.4" + resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.16.4.tgz#5d7902f61349ff6b963e07f06a389ce139fbfe6e" + integrity sha512-vGERmmhR+s7eH5Y/cp8PCVzj4XEjerq8jooMfxFdA5xVtAk9Sh4AQsrWgiErUEBjtGrBtOFKDUcWQFW4/dFwMA== + dependencies: + "@babel/helper-annotate-as-pure" "^7.16.0" + "@babel/helper-wrap-function" "^7.16.0" + "@babel/types" "^7.16.0" + "@babel/helper-replace-supers@^7.16.0": version "7.16.0" resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.16.0.tgz#73055e8d3cf9bcba8ddb55cad93fedc860f68f17" @@ -349,7 +377,12 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.3.tgz#271bafcb811080905a119222edbc17909c82261d" integrity sha512-dcNwU1O4sx57ClvLBVFbEgx0UZWfd0JQX5X6fxFRCLHelFBGXFfSz6Y0FAq2PEwUqlqLkdVjVr4VASEOuUnLJw== -"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.0": +"@babel/parser@^7.16.4": + version "7.16.4" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.4.tgz#d5f92f57cf2c74ffe9b37981c0e72fee7311372e" + integrity sha512-6V0qdPUaiVHH3RtZeLIsc+6pDhbYzHR8ogA8w+f+Wc77DuXto19g2QUwveINoS34Uw+W8/hQDGJCx+i4n7xcng== + +"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.0", "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.2": version "7.16.2" resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.2.tgz#2977fca9b212db153c195674e57cfab807733183" integrity sha512-h37CvpLSf8gb2lIJ2CgC3t+EjFbi0t8qS7LCS1xcJIlEXE4czlofwaW7W1HA8zpgOCzI9C1nmoqNR1zWkk0pQg== @@ -374,6 +407,15 @@ "@babel/helper-remap-async-to-generator" "^7.16.0" "@babel/plugin-syntax-async-generators" "^7.8.4" +"@babel/plugin-proposal-async-generator-functions@^7.16.4": + version "7.16.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.4.tgz#e606eb6015fec6fa5978c940f315eae4e300b081" + integrity sha512-/CUekqaAaZCQHleSK/9HajvcD/zdnJiKRiuUFq8ITE+0HsPzquf53cpFiqAwl/UfmJbR6n5uGPQSPdrmKOvHHg== + dependencies: + "@babel/helper-plugin-utils" "^7.14.5" + "@babel/helper-remap-async-to-generator" "^7.16.4" + "@babel/plugin-syntax-async-generators" "^7.8.4" + "@babel/plugin-proposal-class-properties@7.3.0": version "7.3.0" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.3.0.tgz#272636bc0fa19a0bc46e601ec78136a173ea36cd" @@ -866,7 +908,7 @@ "@babel/helper-plugin-utils" "^7.14.5" "@babel/helper-replace-supers" "^7.16.0" -"@babel/plugin-transform-parameters@^7.12.1", "@babel/plugin-transform-parameters@^7.16.0", "@babel/plugin-transform-parameters@^7.4.4": +"@babel/plugin-transform-parameters@^7.12.1", "@babel/plugin-transform-parameters@^7.16.0", "@babel/plugin-transform-parameters@^7.16.3", "@babel/plugin-transform-parameters@^7.4.4": version "7.16.3" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.16.3.tgz#fa9e4c874ee5223f891ee6fa8d737f4766d31d15" integrity sha512-3MaDpJrOXT1MZ/WCmkOFo7EtmVVC8H4EUZVrHvFOsmwkk4lOjQj8rzv8JKUZV4YoQKeoIgk07GO+acPU9IMu/w== @@ -953,16 +995,16 @@ resolve "^1.8.1" semver "^5.5.1" -"@babel/plugin-transform-runtime@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.16.0.tgz#3fe0da36c2f0834bef7c4d3e7f2b2db0ee0c8909" - integrity sha512-zlPf1/XFn5+vWdve3AAhf+Sxl+MVa5VlwTwWgnLx23u4GlatSRQJ3Eoo9vllf0a9il3woQsT4SK+5Z7c06h8ag== +"@babel/plugin-transform-runtime@^7.16.4": + version "7.16.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.16.4.tgz#f9ba3c7034d429c581e1bd41b4952f3db3c2c7e8" + integrity sha512-pru6+yHANMTukMtEZGC4fs7XPwg35v8sj5CIEmE+gEkFljFiVJxEWxx/7ZDkTK+iZRYo1bFXBtfIN95+K3cJ5A== dependencies: "@babel/helper-module-imports" "^7.16.0" "@babel/helper-plugin-utils" "^7.14.5" - babel-plugin-polyfill-corejs2 "^0.2.3" - babel-plugin-polyfill-corejs3 "^0.3.0" - babel-plugin-polyfill-regenerator "^0.2.3" + babel-plugin-polyfill-corejs2 "^0.3.0" + babel-plugin-polyfill-corejs3 "^0.4.0" + babel-plugin-polyfill-regenerator "^0.3.0" semver "^6.3.0" "@babel/plugin-transform-shorthand-properties@^7.12.1", "@babel/plugin-transform-shorthand-properties@^7.16.0", "@babel/plugin-transform-shorthand-properties@^7.2.0": @@ -1079,7 +1121,7 @@ js-levenshtein "^1.1.3" semver "^5.5.0" -"@babel/preset-env@^7.12.1", "@babel/preset-env@^7.16.0": +"@babel/preset-env@^7.12.1": version "7.16.0" resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.16.0.tgz#97228393d217560d6a1c6c56f0adb9d12bca67f5" integrity sha512-cdTu/W0IrviamtnZiTfixPfIncr2M1VqRrkjzZWlr1B4TVYimCFK5jkyOdP4qw2MrlKHi+b3ORj6x8GoCew8Dg== @@ -1159,6 +1201,86 @@ core-js-compat "^3.19.0" semver "^6.3.0" +"@babel/preset-env@^7.16.4": + version "7.16.4" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.16.4.tgz#4f6ec33b2a3fe72d6bfdcdf3859500232563a2e3" + integrity sha512-v0QtNd81v/xKj4gNKeuAerQ/azeNn/G1B1qMLeXOcV8+4TWlD2j3NV1u8q29SDFBXx/NBq5kyEAO+0mpRgacjA== + dependencies: + "@babel/compat-data" "^7.16.4" + "@babel/helper-compilation-targets" "^7.16.3" + "@babel/helper-plugin-utils" "^7.14.5" + "@babel/helper-validator-option" "^7.14.5" + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.16.2" + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.16.0" + "@babel/plugin-proposal-async-generator-functions" "^7.16.4" + "@babel/plugin-proposal-class-properties" "^7.16.0" + "@babel/plugin-proposal-class-static-block" "^7.16.0" + "@babel/plugin-proposal-dynamic-import" "^7.16.0" + "@babel/plugin-proposal-export-namespace-from" "^7.16.0" + "@babel/plugin-proposal-json-strings" "^7.16.0" + "@babel/plugin-proposal-logical-assignment-operators" "^7.16.0" + "@babel/plugin-proposal-nullish-coalescing-operator" "^7.16.0" + "@babel/plugin-proposal-numeric-separator" "^7.16.0" + "@babel/plugin-proposal-object-rest-spread" "^7.16.0" + "@babel/plugin-proposal-optional-catch-binding" "^7.16.0" + "@babel/plugin-proposal-optional-chaining" "^7.16.0" + "@babel/plugin-proposal-private-methods" "^7.16.0" + "@babel/plugin-proposal-private-property-in-object" "^7.16.0" + "@babel/plugin-proposal-unicode-property-regex" "^7.16.0" + "@babel/plugin-syntax-async-generators" "^7.8.4" + "@babel/plugin-syntax-class-properties" "^7.12.13" + "@babel/plugin-syntax-class-static-block" "^7.14.5" + "@babel/plugin-syntax-dynamic-import" "^7.8.3" + "@babel/plugin-syntax-export-namespace-from" "^7.8.3" + "@babel/plugin-syntax-json-strings" "^7.8.3" + "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" + "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" + "@babel/plugin-syntax-numeric-separator" "^7.10.4" + "@babel/plugin-syntax-object-rest-spread" "^7.8.3" + "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" + "@babel/plugin-syntax-optional-chaining" "^7.8.3" + "@babel/plugin-syntax-private-property-in-object" "^7.14.5" + "@babel/plugin-syntax-top-level-await" "^7.14.5" + "@babel/plugin-transform-arrow-functions" "^7.16.0" + "@babel/plugin-transform-async-to-generator" "^7.16.0" + "@babel/plugin-transform-block-scoped-functions" "^7.16.0" + "@babel/plugin-transform-block-scoping" "^7.16.0" + "@babel/plugin-transform-classes" "^7.16.0" + "@babel/plugin-transform-computed-properties" "^7.16.0" + "@babel/plugin-transform-destructuring" "^7.16.0" + "@babel/plugin-transform-dotall-regex" "^7.16.0" + "@babel/plugin-transform-duplicate-keys" "^7.16.0" + "@babel/plugin-transform-exponentiation-operator" "^7.16.0" + "@babel/plugin-transform-for-of" "^7.16.0" + "@babel/plugin-transform-function-name" "^7.16.0" + "@babel/plugin-transform-literals" "^7.16.0" + "@babel/plugin-transform-member-expression-literals" "^7.16.0" + "@babel/plugin-transform-modules-amd" "^7.16.0" + "@babel/plugin-transform-modules-commonjs" "^7.16.0" + "@babel/plugin-transform-modules-systemjs" "^7.16.0" + "@babel/plugin-transform-modules-umd" "^7.16.0" + "@babel/plugin-transform-named-capturing-groups-regex" "^7.16.0" + "@babel/plugin-transform-new-target" "^7.16.0" + "@babel/plugin-transform-object-super" "^7.16.0" + "@babel/plugin-transform-parameters" "^7.16.3" + "@babel/plugin-transform-property-literals" "^7.16.0" + "@babel/plugin-transform-regenerator" "^7.16.0" + "@babel/plugin-transform-reserved-words" "^7.16.0" + "@babel/plugin-transform-shorthand-properties" "^7.16.0" + "@babel/plugin-transform-spread" "^7.16.0" + "@babel/plugin-transform-sticky-regex" "^7.16.0" + "@babel/plugin-transform-template-literals" "^7.16.0" + "@babel/plugin-transform-typeof-symbol" "^7.16.0" + "@babel/plugin-transform-unicode-escapes" "^7.16.0" + "@babel/plugin-transform-unicode-regex" "^7.16.0" + "@babel/preset-modules" "^0.1.5" + "@babel/types" "^7.16.0" + babel-plugin-polyfill-corejs2 "^0.3.0" + babel-plugin-polyfill-corejs3 "^0.4.0" + babel-plugin-polyfill-regenerator "^0.3.0" + core-js-compat "^3.19.1" + semver "^6.3.0" + "@babel/preset-flow@^7.12.1": version "7.12.13" resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.12.13.tgz#71ee7fe65a95b507ac12bcad65a4ced27d8dfc3e" @@ -1501,10 +1623,10 @@ dependencies: object-hash "^1.3.0" -"@elastic/charts@39.0.1": - version "39.0.1" - resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-39.0.1.tgz#7891d6efb3a12eb73fcb57d9a1f71565c22f4501" - integrity sha512-k64+vrfRkP7Gn8+T0Vtdev/DKpy6G+M9H6OFQcf1fgXAd7qOnTXVaN4Ru+BRTPylTFwxf9pqHraz8Ayi+3VpjA== +"@elastic/charts@39.0.2": + version "39.0.2" + resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-39.0.2.tgz#5533fc57c4ceed4c5ae826cd9a13c55cc03c55e5" + integrity sha512-jjdZSV6PGKsjA2qDAwEw+SjHWq5/Rm9FQk9lrmxrX+0rc7TlsPyr840RT1BAfkDDoo8+o3WWbfg+r61Y0FQ1Pg== dependencies: "@popperjs/core" "^2.4.0" chroma-js "^2.1.0" @@ -8215,6 +8337,15 @@ babel-plugin-polyfill-corejs2@^0.2.3: "@babel/helper-define-polyfill-provider" "^0.2.4" semver "^6.1.1" +babel-plugin-polyfill-corejs2@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.0.tgz#407082d0d355ba565af24126fb6cb8e9115251fd" + integrity sha512-wMDoBJ6uG4u4PNFh72Ty6t3EgfA91puCuAwKIazbQlci+ENb/UU9A3xG5lutjUIiXCIn1CY5L15r9LimiJyrSA== + dependencies: + "@babel/compat-data" "^7.13.11" + "@babel/helper-define-polyfill-provider" "^0.3.0" + semver "^6.1.1" + babel-plugin-polyfill-corejs3@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.3.0.tgz#fa7ca3d1ee9ddc6193600ffb632c9785d54918af" @@ -8223,6 +8354,14 @@ babel-plugin-polyfill-corejs3@^0.3.0: "@babel/helper-define-polyfill-provider" "^0.2.4" core-js-compat "^3.18.0" +babel-plugin-polyfill-corejs3@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.4.0.tgz#0b571f4cf3d67f911512f5c04842a7b8e8263087" + integrity sha512-YxFreYwUfglYKdLUGvIF2nJEsGwj+RhWSX/ije3D2vQPOXuyMLMtg/cCGMDpOA7Nd+MwlNdnGODbd2EwUZPlsw== + dependencies: + "@babel/helper-define-polyfill-provider" "^0.3.0" + core-js-compat "^3.18.0" + babel-plugin-polyfill-regenerator@^0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.2.3.tgz#2e9808f5027c4336c994992b48a4262580cb8d6d" @@ -8230,6 +8369,13 @@ babel-plugin-polyfill-regenerator@^0.2.3: dependencies: "@babel/helper-define-polyfill-provider" "^0.2.4" +babel-plugin-polyfill-regenerator@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.3.0.tgz#9ebbcd7186e1a33e21c5e20cae4e7983949533be" + integrity sha512-dhAPTDLGoMW5/84wkgwiLRwMnio2i1fUe53EuvtKMv0pn2p3S8OCoV1xAzfJPl0KOX7IB89s2ib85vbYiea3jg== + dependencies: + "@babel/helper-define-polyfill-provider" "^0.3.0" + babel-plugin-react-docgen@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/babel-plugin-react-docgen/-/babel-plugin-react-docgen-4.2.1.tgz#7cc8e2f94e8dc057a06e953162f0810e4e72257b" @@ -10430,7 +10576,7 @@ core-js-compat@^3.18.0: browserslist "^4.17.1" semver "7.0.0" -core-js-compat@^3.19.0: +core-js-compat@^3.19.0, core-js-compat@^3.19.1: version "3.19.1" resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.19.1.tgz#fe598f1a9bf37310d77c3813968e9f7c7bb99476" integrity sha512-Q/VJ7jAF/y68+aUsQJ/afPOewdsGkDtcMb40J8MbuWKlK3Y+wtHq8bTHKPj2WKWLIqmS5JhHs4CzHtz6pT2W6g==