Skip to content

Commit

Permalink
Merge branch 'elastic:master' into cleanup-package
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic authored Sep 23, 2021
2 parents ab6ac60 + 26d19e7 commit ba2d6e2
Show file tree
Hide file tree
Showing 1,167 changed files with 23,075 additions and 7,944 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipelines/es_snapshots/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ steps:
- command: .buildkite/scripts/steps/test/jest_integration.sh
label: 'Jest Integration Tests'
agents:
queue: jest
queue: n2-4
timeout_in_minutes: 120
key: jest-integration
retry:
Expand Down
6 changes: 4 additions & 2 deletions .buildkite/pipelines/hourly.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env:
REPORT_FAILED_TESTS_TO_GITHUB: 'true'
steps:
- command: .buildkite/scripts/lifecycle/pre_build.sh
label: Pre-Build
Expand Down Expand Up @@ -118,14 +120,14 @@ steps:
- command: .buildkite/scripts/steps/test/jest_integration.sh
label: 'Jest Integration Tests'
agents:
queue: jest
queue: n2-4
timeout_in_minutes: 120
key: jest-integration

- command: .buildkite/scripts/steps/test/api_integration.sh
label: 'API Integration Tests'
agents:
queue: jest
queue: n2-2
timeout_in_minutes: 120
key: api-integration

Expand Down
3 changes: 1 addition & 2 deletions .buildkite/scripts/lifecycle/post_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ if [[ "$IS_TEST_EXECUTION_STEP" == "true" ]]; then
buildkite-agent artifact upload 'x-pack/test/functional/failure_debug/html/*.html'
buildkite-agent artifact upload '.es/**/*.hprof'

# TODO - re-enable when Jenkins is disabled
# node scripts/report_failed_tests --build-url="${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}" 'target/junit/**/*.xml'
node scripts/report_failed_tests --build-url="${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}" 'target/junit/**/*.xml'
fi
1 change: 1 addition & 0 deletions .buildkite/scripts/steps/storybooks/build_and_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const STORYBOOKS = [
'dashboard_enhanced',
'data_enhanced',
'embeddable',
'fleet',
'infra',
'security_solution',
'ui_actions_enhanced',
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ module.exports = {
* TSVB overrides
*/
{
files: ['src/plugins/vis_type_timeseries/**/*.{js,mjs,ts,tsx}'],
files: ['src/plugins/vis_types/timeseries/**/*.{js,mjs,ts,tsx}'],
rules: {
'import/no-default-export': 'error',
},
Expand Down
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/src/plugins/vis_types/table/ @elastic/kibana-vis-editors
/src/plugins/vis_types/tagcloud/ @elastic/kibana-vis-editors
/src/plugins/vis_types/timelion/ @elastic/kibana-vis-editors
/src/plugins/vis_type_timeseries/ @elastic/kibana-vis-editors
/src/plugins/vis_types/timeseries/ @elastic/kibana-vis-editors
/src/plugins/vis_types/vega/ @elastic/kibana-vis-editors
/src/plugins/vis_types/vislib/ @elastic/kibana-vis-editors
/src/plugins/vis_types/xy/ @elastic/kibana-vis-editors
Expand Down Expand Up @@ -381,9 +381,9 @@
#CC# /x-pack/plugins/security_solution/ @elastic/security-solution

# Security Solution sub teams
/x-pack/plugins/cases @elastic/security-threat-hunting
/x-pack/plugins/cases @elastic/security-threat-hunting-cases
/x-pack/plugins/timelines @elastic/security-threat-hunting
/x-pack/test/case_api_integration @elastic/security-threat-hunting
/x-pack/test/case_api_integration @elastic/security-threat-hunting-cases
/x-pack/plugins/lists @elastic/security-detections-response

## Security Solution sub teams - security-onboarding-and-lifecycle-mgt
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"visTypeMetric": "src/plugins/vis_types/metric",
"visTypeTable": "src/plugins/vis_types/table",
"visTypeTagCloud": "src/plugins/vis_types/tagcloud",
"visTypeTimeseries": "src/plugins/vis_type_timeseries",
"visTypeTimeseries": "src/plugins/vis_types/timeseries",
"visTypeVega": "src/plugins/vis_types/vega",
"visTypeVislib": "src/plugins/vis_types/vislib",
"visTypeXy": "src/plugins/vis_types/xy",
Expand Down
5 changes: 5 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/groovy

if (!env.ghprbPullId) {
print "Non-PR builds are now in Buildkite."
return
}

library 'kibana-pipeline-library'
kibanaLibrary.load()

Expand Down
320 changes: 160 additions & 160 deletions api_docs/data.json

Large diffs are not rendered by default.

116 changes: 58 additions & 58 deletions api_docs/data_index_patterns.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions api_docs/deprecations_by_plugin.mdx

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions api_docs/vis_type_timeseries.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
") => data is ",
"SeriesData"
],
"path": "src/plugins/vis_type_timeseries/common/vis_data_utils.ts",
"path": "src/plugins/vis_types/timeseries/common/vis_data_utils.ts",
"deprecated": false,
"children": [
{
Expand All @@ -37,7 +37,7 @@
"signature": [
"TimeseriesVisData"
],
"path": "src/plugins/vis_type_timeseries/common/vis_data_utils.ts",
"path": "src/plugins/vis_types/timeseries/common/vis_data_utils.ts",
"deprecated": false,
"isRequired": true
}
Expand All @@ -58,7 +58,7 @@
") => data is ",
"TableData"
],
"path": "src/plugins/vis_type_timeseries/common/vis_data_utils.ts",
"path": "src/plugins/vis_types/timeseries/common/vis_data_utils.ts",
"deprecated": false,
"children": [
{
Expand All @@ -71,7 +71,7 @@
"signature": [
"TimeseriesVisData"
],
"path": "src/plugins/vis_type_timeseries/common/vis_data_utils.ts",
"path": "src/plugins/vis_types/timeseries/common/vis_data_utils.ts",
"deprecated": false,
"isRequired": true
}
Expand All @@ -95,7 +95,7 @@
" | ",
"TableData"
],
"path": "src/plugins/vis_type_timeseries/common/types/vis_data.ts",
"path": "src/plugins/vis_types/timeseries/common/types/vis_data.ts",
"deprecated": false,
"initialIsOpen": false
}
Expand All @@ -108,7 +108,7 @@
"tags": [],
"label": "VisTypeTimeseriesSetup",
"description": [],
"path": "src/plugins/vis_type_timeseries/server/plugin.ts",
"path": "src/plugins/vis_types/timeseries/server/plugin.ts",
"deprecated": false,
"children": [
{
Expand All @@ -133,7 +133,7 @@
"TimeseriesVisData",
">"
],
"path": "src/plugins/vis_type_timeseries/server/plugin.ts",
"path": "src/plugins/vis_types/timeseries/server/plugin.ts",
"deprecated": false,
"children": [
{
Expand All @@ -146,7 +146,7 @@
"signature": [
"DataRequestHandlerContext"
],
"path": "src/plugins/vis_type_timeseries/server/plugin.ts",
"path": "src/plugins/vis_types/timeseries/server/plugin.ts",
"deprecated": false,
"isRequired": true
},
Expand All @@ -167,7 +167,7 @@
},
"<unknown, unknown, unknown, any>"
],
"path": "src/plugins/vis_type_timeseries/server/plugin.ts",
"path": "src/plugins/vis_types/timeseries/server/plugin.ts",
"deprecated": false,
"isRequired": true
},
Expand All @@ -181,7 +181,7 @@
"signature": [
"any"
],
"path": "src/plugins/vis_type_timeseries/server/plugin.ts",
"path": "src/plugins/vis_types/timeseries/server/plugin.ts",
"deprecated": false,
"isRequired": true
}
Expand Down
83 changes: 83 additions & 0 deletions dev_docs/key_concepts/persistable_state.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
id: kibDevDocsPersistableStateIntro
slug: /kibana-dev-docs/persistable-state-intro
title: Persistable State
summary: Persitable state is a key concept to understand when building a Kibana plugin.
date: 2021-02-02
tags: ['kibana','dev', 'contributor', 'api docs']
---

“Persistable state” is developer-defined state that supports being persisted by a plugin other than the one defining it. Persistable State needs to be serializable and the owner can/should provide utilities to migrate it, extract and inject any <DocLink id="kibDevDocsSavedObjectsIntro" section="references" text="references to Saved Objects"/> it may contain, as well as telemetry collection utilities.

## Exposing state that can be persisted

Any plugin that exposes state that another plugin might persist should implement <DocLink id="kibKibanaUtilsPluginApi" section="def-common.PersistableStateService" text="`PersistableStateService`"/> interface on their `setup` contract. This will allow plugins persisting the state to easily access migrations and other utilities.

Example: Data plugin allows you to generate filters. Those filters can be persisted by applications in their saved
objects or in the URL. In order to allow apps to migrate the filters in case the structure changes in the future, the Data plugin implements `PersistableStateService` on <DocLink id="kibDataQueryPluginApi" section="def-public.FilterManager" text="`data.query.filterManager`"/>.

note: There is currently no obvious way for a plugin to know which state is safe to persist. The developer must manually look for a matching `PersistableStateService`, or ad-hoc provided migration utilities (as is the case with Rule Type Parameters).
In the future, we hope to make it easier for producers of state to understand when they need to write a migration with changes, and also make it easier for consumers of such state, to understand whether it is safe to persist.

## Exposing state that can be persisted but is not owned by plugin exposing it (registry)

Any plugin that owns collection of items (registry) whose state/configuration can be persisted should implement `PersistableStateService`
interface on their `setup` contract and each item in the collection should implement <DocLink id="kibKibanaUtilsPluginApi" section="def-common.PersistableStateDefinition" text="`PersistableStateDefinition`"/> interface.

Example: Embeddable plugin owns the registry of embeddable factories to which other plugins can register new embeddable factories. Dashboard plugin
stores a bunch of embeddable panels input in its saved object and URL. Embeddable plugin setup contract implements `PersistableStateService`
interface and each `EmbeddableFactory` needs to implement `PersistableStateDefinition` interface.

Embeddable plugin exposes this interfaces:
```
// EmbeddableInput implements Serializable
export interface EmbeddableRegistryDefinition extends PersistableStateDefinition<EmbeddableInput> {
id: string;
...
}
export interface EmbeddableSetup extends PersistableStateService<EmbeddableInput>;
```

Note: if your plugin doesn't expose the state (it is the only one storing state), the plugin doesn't need to implement the `PersistableStateService` interface.
If the state your plugin is storing can be provided by other plugins (your plugin owns a registry) items in that registry still need to implement `PersistableStateDefinition` interface.

## Storing persistable state as part of saved object

Any plugin that stores any persistable state as part of their saved object should make sure that its saved object migration
and reference extraction and injection methods correctly use the matching `PersistableStateService` implementation for the state they are storing.

Take a look at [example saved object](https://github.com/elastic/kibana/blob/master/examples/embeddable_examples/server/searchable_list_saved_object.ts#L32) which stores an embeddable state. Note how the `migrations`, `extractReferences` and `injectReferences` are defined.

## Storing persistable state as part of URL

When storing persistable state as part of URL you must make sure your URL is versioned. When loading the state `migrateToLatest` method
of `PersistableStateService` should be called, which will migrate the state from its original version to latest.

note: Currently there is no recommended way on how to store version in url and its up to every application to decide on how to implement that.

## Available state operations

### Extraction/Injection of References

In order to support import and export, and space-sharing capabilities, Saved Objects need to explicitly list any references they contain to other Saved Objects.
To support persisting your state in saved objects owned by another plugin, the <DocLink id="kibKibanaUtilsPluginApi" section="def-common.PersistableState.extract" text="`extract`"/> and <DocLink id="kibKibanaUtilsPluginApi" section="def-common.PersistableState.inject" text="`inject`"/> methods of Persistable State interface should be implemented.

<DocLink id="kibDevTutorialSavedObject" section="references" text="Learn how to define Saved Object references"/>

[See example embeddable providing extract/inject functions](https://github.com/elastic/kibana/blob/master/examples/embeddable_examples/public/migrations/migrations_embeddable_factory.ts)

### Migrations and Backward compatibility

As your plugin evolves, you may need to change your state in a breaking way. If that happens, you should write a migration to upgrade the state that existed prior to the change.

<DocLink id="kibDevTutorialSavedObject" section="migrations" text="How to write a migration"/>.

[See an example saved object storing embeddable state implementing saved object migration function](https://github.com/elastic/kibana/blob/master/examples/embeddable_examples/server/searchable_list_saved_object.ts)

[See example embeddable providing migration functions](https://github.com/elastic/kibana/blob/master/examples/embeddable_examples/public/migrations/migrations_embeddable_factory.ts)

## Telemetry

You might want to collect statistics about how your state is used. If that is the case you should implement the telemetry method of Persistable State interface.
11 changes: 11 additions & 0 deletions docs/api/machine-learning.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[machine-learning-api]]
== {ml-cap} APIs

//Manage {kib} saved objects, including dashboards, visualizations, and more.

The following {ml} API is available:

* <<machine-learning-api-sync, Sync API>>
//to retrieve a single {kib} saved object by ID

include::machine-learning/sync.asciidoc[]
79 changes: 79 additions & 0 deletions docs/api/machine-learning/sync.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[[machine-learning-api-sync]]
=== Sync {ml} saved objects API
++++
<titleabbrev>Sync {ml} saved objects</titleabbrev>
++++

Synchronizes {kib} saved objects for {ml} jobs.

[[machine-learning-api-sync-request]]
==== Request

`GET <kibana host>:<port>/api/ml/saved_objects/sync`

`GET <kibana host>:<port>/s/<space_id>/api/ml/saved_objects/sync`


[[machine-learning-api-sync-path-params]]
==== Path parameters

`space_id`::
(Optional, string) An identifier for the space. If `space_id` is not provided in
the URL the default space is used.

[[machine-learning-api-sync-query-params]]
==== Query parameters

`simulate`::
(Optional, boolean) When `true`, simulates the synchronization by only returning
the list actions that _would_ be performed.

[[machine-learning-api-sync-response-body]]
==== Response body

`datafeedsAdded`::
(array) If a saved object for an {anomaly-job} is missing a {dfeed} identifier,
it is added. This list contains the {dfeed} identifiers and indicates whether
the synchronization was successful.

`datafeedsRemoved`::
(array) If saved objects exist for {dfeeds} that no longer exist, they are
deleted. This list contains the {dfeed} identifiers and indicates whether the
synchronization was successful.

`savedObjectsCreated`::
(array) If saved objects are missing for {ml} jobs, they are created. This
list contains the job identifiers and indicates whether the synchronization was
successful.

`savedObjectsDeleted`::
(array) If saved objects exist for jobs that no longer exist, they are deleted.
This list contains the job identifiers and indicates whether the synchronization
was successful.

[[machine-learning-api-sync-codes]]
==== Response code

`200`::
Indicates a successful call.

[[machine-learning-api-sync-example]]
==== Example

Retrieve the list of {ml} saved objects that require synchronization:

[source,sh]
--------------------------------------------------
$ curl -X GET api/ml/saved_objects/sync?simulate=true
--------------------------------------------------
// KIBANA

If there are two jobs and a {dfeed} that need to be synchronized, for example,
the API returns the following:

[source,sh]
--------------------------------------------------
{{"savedObjectsCreated":{"myjob1":{"success":true},"myjob2":{"success":true}},"savedObjectsDeleted":{},"datafeedsAdded":{},"datafeedsRemoved":{"myfeed3":{"success":true}}}
--------------------------------------------------

To perform the synchronization, re-run the API and omit the `simulate` parameter.
1 change: 1 addition & 0 deletions docs/dev-tools/console/console.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ shortcuts, click *Help*.
[[console-settings]]
=== Disable Console

deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
If you don’t want to use *Console*, you can disable it by setting `console.enabled`
to `false` in your `kibana.yml` configuration file. Changing this setting
causes the server to regenerate assets on the next startup,
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ The plugin exposes the static DefaultEditorController class to consume.
|Contains the timelion visualization and the timelion backend.
|{kib-repo}blob/{branch}/src/plugins/vis_type_timeseries[visTypeTimeseries]
|{kib-repo}blob/{branch}/src/plugins/vis_types/timeseries[visTypeTimeseries]
|WARNING: Missing README.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ async function getDeprecations({ esClient, savedObjectsClient }: GetDeprecations
const deprecations: DeprecationsDetails[] = [];
const count = await getFooCount(savedObjectsClient);
if (count > 0) {
// Example of a manual correctiveAction
deprecations.push({
title: i18n.translate('xpack.foo.deprecations.title', {
defaultMessage: `Foo's are deprecated`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ export interface SavedObjectsTypeManagementDefinition<Attributes = any>
| [isExportable](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.isexportable.md) | <code>SavedObjectsExportablePredicate&lt;Attributes&gt;</code> | Optional hook to specify whether an object should be exportable.<!-- -->If specified, <code>isExportable</code> will be called during export for each of this type's objects in the export, and the ones not matching the predicate will be excluded from the export.<!-- -->When implementing both <code>isExportable</code> and <code>onExport</code>, it is mandatory that <code>isExportable</code> returns the same value for an object before and after going though the export transform. E.g <code>isExportable(objectBeforeTransform) === isExportable(objectAfterTransform)</code> |
| [onExport](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.onexport.md) | <code>SavedObjectsExportTransform&lt;Attributes&gt;</code> | An optional export transform function that can be used transform the objects of the registered type during the export process.<!-- -->It can be used to either mutate the exported objects, or add additional objects (of any type) to the export list.<!-- -->See [the transform type documentation](./kibana-plugin-core-server.savedobjectsexporttransform.md) for more info and examples.<!-- -->When implementing both <code>isExportable</code> and <code>onExport</code>, it is mandatory that <code>isExportable</code> returns the same value for an object before and after going though the export transform. E.g <code>isExportable(objectBeforeTransform) === isExportable(objectAfterTransform)</code> |
| [onImport](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.onimport.md) | <code>SavedObjectsImportHook&lt;Attributes&gt;</code> | An optional [import hook](./kibana-plugin-core-server.savedobjectsimporthook.md) to use when importing given type.<!-- -->Import hooks are executed during the savedObjects import process and allow to interact with the imported objects. See the [hook documentation](./kibana-plugin-core-server.savedobjectsimporthook.md) for more info. |
| [visibleInManagement](./kibana-plugin-core-server.savedobjectstypemanagementdefinition.visibleinmanagement.md) | <code>boolean</code> | When set to false, the type will not be listed or searchable in the SO management section. Main usage of setting this property to false for a type is when objects from the type should be included in the export via references or export hooks, but should not directly appear in the SOM. Defaults to <code>true</code>. |

Loading

0 comments on commit ba2d6e2

Please sign in to comment.