# Backport
This will backport the following commits from `main` to `8.14`:
- [[ES|QL] Add `date_diff`
(#182513)](https://github.com/elastic/kibana/pull/182513)
<!--- Backport version: 8.9.8 -->
### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)
<!--BACKPORT [{"author":{"name":"Drew
Tate","email":"drew.tate@elastic.co"},"sourceCommit":{"committedDate":"2024-05-03T14:29:36Z","message":"[ES|QL]
Add `date_diff` (#182513)\n\n## Summary\r\n\r\nAdds validation and
autocomplete support
for\r\n[`date_diff`](https://www.elastic.co/guide/en/elasticsearch/reference/8.14/esql-functions-operators.html#esql-date_diff).\r\nWhew
— just me or does this get trickier every time? 😅\r\n\r\n## First
param\r\n\r\n### We only suggest the main time unit options\r\n\r\n<img
width=\"910\" alt=\"Screenshot 2024-05-02 at 1 19
32 PM\"\r\nsrc=\"ecf7f602-0934-4f2c-8c38-df7cdbd9da28\">\r\n\r\n\r\n###
But the validator accepts all the options including
abbreviations\r\n\r\n<img width=\"897\" alt=\"Screenshot 2024-05-02 at 1
42
19 PM\"\r\nsrc=\"7a523a8e-a1a4-4abc-b318-a2d2a0ddf11c\">\r\n\r\n###
But still warns if it's a totally funky value\r\n\r\n<img width=\"782\"
alt=\"Screenshot 2024-05-02 at 1 19
17 PM\"\r\nsrc=\"ff8955d9-e7a2-4e7a-b64c-aad2ba2aee0e\">\r\n\r\n###
And it does accept string fields\r\n\r\n<img width=\"918\"
alt=\"Screenshot 2024-05-02 at 1 39
57 PM\"\r\nsrc=\"b76a4343-a88a-44e0-8324-54cad4d3b53d\">\r\n\r\n##
Second and third params\r\n\r\n### We suggest date-based fields and
functions\r\n \r\n<img width=\"955\" alt=\"Screenshot 2024-05-02 at 1 51
14 PM\"\r\nsrc=\"39927314-b93e-4289-9d14-aecbaab644d9\">\r\n\r\n###
But date strings are also 👍 because of auto-casting\r\n\r\n<img
width=\"844\" alt=\"Screenshot 2024-05-02 at 1 51
47 PM\"\r\nsrc=\"1d826fa4-5604-453f-95fe-a03612a9c4cf\">\r\n\r\n###
But string fields are 👎 \r\n\r\n<img width=\"872\" alt=\"Screenshot
2024-05-02 at 1 52
13 PM\"\r\nsrc=\"4f7f3220-ccd3-4592-b034-579a31f0c88c\">\r\n\r\n\r\n\r\n##
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"df0949469a4a4142692204153b69b728b6969ce5","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:prev-minor","Feature:ES|QL","v8.14.0","Team:ESQL","v8.15.0"],"number":182513,"url":"https://github.com/elastic/kibana/pull/182513","mergeCommit":{"message":"[ES|QL]
Add `date_diff` (#182513)\n\n## Summary\r\n\r\nAdds validation and
autocomplete support
for\r\n[`date_diff`](https://www.elastic.co/guide/en/elasticsearch/reference/8.14/esql-functions-operators.html#esql-date_diff).\r\nWhew
— just me or does this get trickier every time? 😅\r\n\r\n## First
param\r\n\r\n### We only suggest the main time unit options\r\n\r\n<img
width=\"910\" alt=\"Screenshot 2024-05-02 at 1 19
32 PM\"\r\nsrc=\"ecf7f602-0934-4f2c-8c38-df7cdbd9da28\">\r\n\r\n\r\n###
But the validator accepts all the options including
abbreviations\r\n\r\n<img width=\"897\" alt=\"Screenshot 2024-05-02 at 1
42
19 PM\"\r\nsrc=\"7a523a8e-a1a4-4abc-b318-a2d2a0ddf11c\">\r\n\r\n###
But still warns if it's a totally funky value\r\n\r\n<img width=\"782\"
alt=\"Screenshot 2024-05-02 at 1 19
17 PM\"\r\nsrc=\"ff8955d9-e7a2-4e7a-b64c-aad2ba2aee0e\">\r\n\r\n###
And it does accept string fields\r\n\r\n<img width=\"918\"
alt=\"Screenshot 2024-05-02 at 1 39
57 PM\"\r\nsrc=\"b76a4343-a88a-44e0-8324-54cad4d3b53d\">\r\n\r\n##
Second and third params\r\n\r\n### We suggest date-based fields and
functions\r\n \r\n<img width=\"955\" alt=\"Screenshot 2024-05-02 at 1 51
14 PM\"\r\nsrc=\"39927314-b93e-4289-9d14-aecbaab644d9\">\r\n\r\n###
But date strings are also 👍 because of auto-casting\r\n\r\n<img
width=\"844\" alt=\"Screenshot 2024-05-02 at 1 51
47 PM\"\r\nsrc=\"1d826fa4-5604-453f-95fe-a03612a9c4cf\">\r\n\r\n###
But string fields are 👎 \r\n\r\n<img width=\"872\" alt=\"Screenshot
2024-05-02 at 1 52
13 PM\"\r\nsrc=\"4f7f3220-ccd3-4592-b034-579a31f0c88c\">\r\n\r\n\r\n\r\n##
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"df0949469a4a4142692204153b69b728b6969ce5"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"8.14","label":"v8.14.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.15.0","labelRegex":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/182513","number":182513,"mergeCommit":{"message":"[ES|QL]
Add `date_diff` (#182513)\n\n## Summary\r\n\r\nAdds validation and
autocomplete support
for\r\n[`date_diff`](https://www.elastic.co/guide/en/elasticsearch/reference/8.14/esql-functions-operators.html#esql-date_diff).\r\nWhew
— just me or does this get trickier every time? 😅\r\n\r\n## First
param\r\n\r\n### We only suggest the main time unit options\r\n\r\n<img
width=\"910\" alt=\"Screenshot 2024-05-02 at 1 19
32 PM\"\r\nsrc=\"ecf7f602-0934-4f2c-8c38-df7cdbd9da28\">\r\n\r\n\r\n###
But the validator accepts all the options including
abbreviations\r\n\r\n<img width=\"897\" alt=\"Screenshot 2024-05-02 at 1
42
19 PM\"\r\nsrc=\"7a523a8e-a1a4-4abc-b318-a2d2a0ddf11c\">\r\n\r\n###
But still warns if it's a totally funky value\r\n\r\n<img width=\"782\"
alt=\"Screenshot 2024-05-02 at 1 19
17 PM\"\r\nsrc=\"ff8955d9-e7a2-4e7a-b64c-aad2ba2aee0e\">\r\n\r\n###
And it does accept string fields\r\n\r\n<img width=\"918\"
alt=\"Screenshot 2024-05-02 at 1 39
57 PM\"\r\nsrc=\"b76a4343-a88a-44e0-8324-54cad4d3b53d\">\r\n\r\n##
Second and third params\r\n\r\n### We suggest date-based fields and
functions\r\n \r\n<img width=\"955\" alt=\"Screenshot 2024-05-02 at 1 51
14 PM\"\r\nsrc=\"39927314-b93e-4289-9d14-aecbaab644d9\">\r\n\r\n###
But date strings are also 👍 because of auto-casting\r\n\r\n<img
width=\"844\" alt=\"Screenshot 2024-05-02 at 1 51
47 PM\"\r\nsrc=\"1d826fa4-5604-453f-95fe-a03612a9c4cf\">\r\n\r\n###
But string fields are 👎 \r\n\r\n<img width=\"872\" alt=\"Screenshot
2024-05-02 at 1 52
13 PM\"\r\nsrc=\"4f7f3220-ccd3-4592-b034-579a31f0c88c\">\r\n\r\n\r\n\r\n##
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"df0949469a4a4142692204153b69b728b6969ce5"}}]}]
BACKPORT-->
This folder contains packages that are intended for use in Kibana and Kibana
plugins.
tl;dr:
Don't publish to npm registry
Always use the @kbn namespace
Always set "private": true in package.json
Using these packages
We no longer publish these packages to the npm registry. Now, instead of
specifying a version when including these packages, we rely on yarn workspaces,
which sets up a symlink to the package.
For example if you want to use the @kbn/i18n package in Kibana itself, you
can specify the dependency like this:
"@kbn/i18n": "1.0.0"
However, if you want to use this from a Kibana plugin, you need to use a link:
dependency and account for the relative location of the Kibana repo, so it would
instead be:
Currently there is only one tool being used in order to test packages which is Jest. Below we will explain how it should be done.
Jest
A package should follow the pattern of having .test.js files as siblings of the source code files, and these run by Jest.
A package using the .test.js naming convention will have those tests automatically picked up by Jest and run by the unit test runner, currently mapped to the Kibana test script in the root package.json.
yarn test runs all unit tests.
yarn jest runs all Jest tests in Kibana.
In order for the plugin or package to use Jest, a jest.config.js file must be present in it's root. However, there are safeguards for this in CI should a test file be added without a corresponding config file.
Each package can also specify its own test script in the package's package.json, for cases where you'd prefer to run the tests from the local package directory.