Adds doc for API changes (#93544) (#94386)

* [DOCS] Adds doc for plugin API changes

* [DOCS] Edits doc

* [DOCS] Removes links to older docs

* [DOCS] Adds links to previous versions
This commit is contained in:
gchaps 2021-03-10 16:37:01 -08:00 committed by GitHub
parent cb620ac69c
commit 3e3b61b148
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 355 additions and 405 deletions

View file

@ -30,4 +30,4 @@ include::advanced/index.asciidoc[]
include::plugin-list.asciidoc[]
include::plugin-api-changes/index.asciidoc[]
include::plugin-api-changes/plugin-api-changes-7_12.asciidoc[]

View file

@ -1,14 +0,0 @@
[[plugin-api-changes]]
== Plugin API changes
This page discusses the plugin API changes that you need to be aware of when migrating
your application from one version of {kib} to another.
* <<plugin-api-changes-7-11, Changes in 7.11>>
* <<general-plugin-API-changes-7-10, Changes in 7.10>>
* <<general-plugin-API-changes-79, Changes in 7.9>>
* <<general-plugin-API-changes-78, Changes in 7.8>>
* <<general-plugin-API-changes-77, Changes in 7.7>>
* <<general-plugin-API-changes-76, Changes in 7.6>>
include::plugin-api-changes-7_11.asciidoc[leveloffset=+1]

View file

@ -1,390 +0,0 @@
[[plugin-api-changes-7-11]]
== Plugin API changes in 7.11
++++
<titleabbrev>7.11</titleabbrev>
++++
This page discusses the plugin API changes that you need to be aware of when migrating
your application to {kib} 7.11.
[[breaking_plugin_v7.11.0_85234]]
.Custom visualizations plugin need to build their own expression AST
[%collapsible]
====
In {kib} all visualizations underneath render using {kib} expressions (that you can see user facing inside Canvas expression editor).
Right now old custom visualization plugins are all using the same `visualizations` expression function underneath.
We're going to remove this function in one of the upcoming minors, meaning your custom visualization plugin will require to register
its own renderer and expression function and provide a `toExpressionAst` function.
You can check any of the https://github.com/elastic/kibana/issues/46801[PRs for core visualizations] as a reference how those migration need to look like.
*via https://github.com/elastic/kibana/pull/85234[#85234]*
====
[[breaking_plugin_v7.11.0_84973]]
.`esaggs` expression function changed
[%collapsible]
====
The `esaggs` expression function, which is the default method of requesting aggregations for visualizations,
has had some changes to the arguments it accepts.
```ts
// old
esaggs index="logstash-*" aggConfigs="[{ id: 1, enabled: true, type: "count", schema: "metric" }]"
// new
esaggs
// use indexPatternLoad and pass your ID instead of passing it as a string
index={indexPatternLoad id="logstash-*"}
// use aggType functions for each aggregation you need. the aggs argument
// can be passed multiple times. if you are using AggConfigs you can automatically
// generate the expression AST for these arguments with `aggConfig.toExpressionAst()`
aggs={aggCount id=1 enabled=true schema="metric"}
```
*via https://github.com/elastic/kibana/pull/84973[#84973]*
====
[[breaking_plugin_v7.11.0_84791]]
.`server.xsrf.whitelist` rename `server.xsrf.allowlist`
[%collapsible]
====
`server.xsrf.whitelist` was deprecated in favor of `server.xsrf.allowlist`.
*via https://github.com/elastic/kibana/pull/84791[#84791]*
====
[[breaking_plugin_v7.11.0_84326]]
.`SavedObjectsRepository.incrementCounter` supports array of fields
[%collapsible]
====
The `SavedObjectsRepository.incrementCounter` method no longer accepts a string field name.
An array of field names to increment must be provided.
*via https://github.com/elastic/kibana/pull/84326[#84326]*
====
[[breaking_plugin_v7.11.0_84224]]
.UI counters introduced
[%collapsible]
====
This change adds `incrementBy` to the config `SavedObjectsIncrementCounterOptions` for
`SavedObjectsRepository.incrementCounter()`.
The config `incrementBy` allows incrementing the counter by a custom number instead of
a hardcoded `1`. If no value is specified, the counter is incremented by `1`.
Example:
```js
await internalRepository.incrementCounter(type, id, counterFieldName, {
incrementBy: 5,
});
```
*via https://github.com/elastic/kibana/pull/84224[#84224]*
====
[[breaking_plugin_v7.11.0_83575]]
.Conflict checking is now disabled by default when copying saved objects
[%collapsible]
====
See the `createNewCopies` parameter in
the <<spaces-api-copy-saved-objects,Copy saved objects to space API documentation>> for more information.
*via https://github.com/elastic/kibana/pull/83575[#83575]*
====
[[breaking_plugin_v7.11.0_83482]]
.Predefined IDs allowed for encrypted saved objects
[%collapsible]
====
Task Manager now uses predefined IDs with encrypted saved objects.
{kib} previously generated the ID within the
`EncryptedSavedObjectsClientWrapper` in order to use a UUID v4.
This restriction was put in place because typically a saved object
has a reference to an "encrypted saved object" and we wanted to reduce the
likelihood of someone potentially guessing the reference ID. Instead of relaxing this constraint for
all saved object types used with the encrypted saved objects plugin,
this PR allows certain saved object types to opt-out of this protection.
*via https://github.com/elastic/kibana/pull/83482[#83482]*
====
[[breaking_plugin_v7.11.0_83037]]
.Schema for `UiSettings` is now required
[%collapsible]
====
`UiSettings` registration without a validation `schema` will throw an exception.
```js
uiSettings.register({ mySetting: { value: 42 } });
```
*via https://github.com/elastic/kibana/pull/83037[#83037]*
====
[[breaking_plugin_v7.11.0_82715]]
.User and alert comment types added
[%collapsible]
====
To create or update a comment, you must provide the type of comment and
the attributes of each type. Specifically:
[cols="3"]
|===
| *Property*
| *Description*
| *Type*
| type
| The type of the comment
| `user` or `alert`
| comment
| The comment. Valid only when type is `user`.
| string
| alertId
| The alert ID. Valid only when the type is `alert`.
| string
| index
| The index where the alert is saved. Valid only when the type is `alert`.
| strings
|===
*via https://github.com/elastic/kibana/pull/82715[#82715]*
====
[[breaking_plugin_v7.11.0_82383]]
.SearchSource updated to use fields API
[%collapsible]
====
**SearchSource now uses the search fields param by default**
The `data` plugin's high-level search API, `SearchSource`,
has migrated to use
the https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-fields.html#search-fields-param[Elasticsearch search fields param]
as the default when constructing a search request body with specific fields.
To make it as easy as possible for plugins to migrate to the new behavior,
we've preserved a way for plugins to use the legacy behavior of requesting fields from `_source`:
```ts
class MyPlugin {
start(core, { data }) {
const searchSource = data.search.searchSource.create();
// Deprecated. Legacy behavior from 'fields' has been moved to 'fieldsFromSource'.
// This is now the only way to search for fields directly from `_source`:
searchSource.setField('fieldsFromSource', ['fieldA', 'fieldB']);
// The old 'fields' syntax now uses the search fields API under the hood, and accepts
// an array of fields that are passed straight through to the fields API.
searchSource.setField('fields', ['fieldC', { field: 'fieldD', format: 'date_time' });
...etc
}
}
```
If your plugin calls `setField('fields', [...])`,
update it to use `fieldsFromSource`
until you are able to adapt your plugin to the new fields behavior.
**SearchSource has stopped using `docvalue_fields` by default**
Previously `SearchSource` would automatically request `docvalue_fields` for any date
fields in an index pattern to avoid a situation where {kib} might
receive a date field from {es}
https://github.com/elastic/kibana/issues/22897#issuecomment-604998405[that it doesn't know how to format].
With the introduction of the
https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-fields.html#search-fields-param[Elasticsearch search fields param],
which supports requesting fields in a particular format, we no longer need to rely
on `docvalue_fields` for this behavior.
`SearchSource` now automatically
requests any date fields via the fields API, unless you provide specific ones
via `setField('fields', [...])`, in which case only the relevant ones will be requested.
If you do not provide a `format` for the fields you are requesting, one will automatically be added for you.
*via https://github.com/elastic/kibana/pull/82383[#82383]*
====
[[breaking_plugin_v7.11.0_81739]]
.Global types removed
[%collapsible]
====
This requires the following changes:
* `PublicMethodsOf`, `MethodKeysOf`, and `Writable` should be imported from `@kbn/utility-types`.
* `DeeplyMockedKeys` bands `MockedKeys` should be imported from `@kbn/utility-types/jest`.
*via https://github.com/elastic/kibana/pull/81739[#81739]*
====
[[breaking_plugin_v7.11.0_81582]]
.Support for `SavedObjects` export API enhanced
[%collapsible]
====
The `SavedObjects` export API now supports the export of `SavedObjects` with circular references.
*via https://github.com/elastic/kibana/pull/81582[#81582]*
====
[[breaking_plugin_v7.11.0_80909]]
.Feature registration improved
[%collapsible]
====
The `icon` and `navLinkId` options were removed from Feature registration:
* `icon` was used on the Spaces and Role Management interfaces, but a recent redesign of these screens rendered the icon unnecessary.
* `navLinkId` was only required by the legacy platform, and is therefore no longer supported in versions >= 7.11.0.
The `validLicenses` property was renamed `minimumLicense`.
The existing property was unnecessarily configurable. This rename aligns the property with the `licensing` plugin's functionality, which has built-in support for checking a minimum license against the current license.
*via https://github.com/elastic/kibana/pull/80909[#80909]*
====
[[breaking_plugin_v7.11.0_80905]]
.`independent` sub-feature privileges can now be licensed
[%collapsible]
====
Features support defining a set of valid licenses for which they are available.
Although this works for conditionally supporting top-level features,
it doesn't scale to sub-feature privileges.
Currently, there is no way to define a sub-feature privilege that is only available at a certain license level.
This change introduces a `minimumLicense` property on each sub-feature privilege,
so that consumers can choose the set of valid licenses for their sub-feature privileges.
A concrete example is Reporting. There are different report types offered at different license levels.
PDF reports are a Platinum feature, so an administrator configuring roles in a Gold cluster
shouldn't be able to toggle the PDF report privilege.
Licensed sub-feature privileges will only be registered with {es}
when the `minimumLicense` is satisfied. Further, the sub-feature privilege will
only be included into the primary feature privileges when the `minimumLicense` is satisfied.
The privilege registration system is already configured to listen to license changes at runtime,
so the set of available/registered sub-feature privileges will always be kept in sync.
*via https://github.com/elastic/kibana/pull/80905[#80905]*
====
[[breaking_plugin_v7.11.0_80870]]
.A field for cases' comments was added
[%collapsible]
====
A new field was introduced to cases' comments. It must be provided when adding a
comment to a case. Specifically:
[cols="4"]
|===
| *Name*
| *Type*
| *Description*
| *Required*
| type
| `user` or `alert`
| The cases new comment type
| Yes
|===
*via https://github.com/elastic/kibana/pull/80870[#80870]*
====
[[breaking_plugin_v7.11.0_80810]]
.URL rewritten in `onPreRouting` interceptor now provided in setting
[%collapsible]
====
The original URL rewritten in the `onPreRouting` interceptor is now
provided in the `KibanaRequest.rewrittenUrl` property.
*via https://github.com/elastic/kibana/pull/80810[#80810]*
====
[[breaking_plugin_v7.11.0_78352]]
.API added for index pattern edit field formatter
[%collapsible]
====
These methods were added for setting field formatters: `indexPattern.setFieldFormat` and `indexPattern.deleteFieldFormat`.
`indexPattern.getFormatterForFieldNoDefault` was also added, which is used by the management interface.
*via https://github.com/elastic/kibana/pull/78352[#78352]*
====
[[breaking_plugin_v7.11.0_76889]]
.Client side session service introduced
[%collapsible]
====
This PR introduces the frontend session management service
and integrates it into Discover
by initializing a session before fetching fresh data from the server.
This PR also uses the session service to show the timeout
error once per session instead of using a debounce.
*via https://github.com/elastic/kibana/pull/76889[#76889]*
====
[[breaking_plugin_v7.11.0_74640]]
.New audit logging events and event filtering added
[%collapsible]
====
The following audit events are logged when enabled:
- `user_login`
- `http_request`
- `saved_object_create`
- `saved_object_get`
- `saved_object_update`
- `saved_object_delete`
- `saved_object_find`
- `saved_object_add_to_spaces`
- `saved_object_delete_from_spaces`
*via https://github.com/elastic/kibana/pull/74640[#74640]*
====

View file

@ -0,0 +1,354 @@
[[plugin-api-changes]]
== Plugin API changes in 7.12
++++
<titleabbrev>Plugin API changes</titleabbrev>
++++
This page discusses the plugin API changes that you need to be aware of when migrating
your application to {kib} 7.12.
Other versions: {kibana-ref-all}/7.11/plugin-api-changes-7-11.html[7.11] |
{kibana-ref-all}/7.10/breaking-changes-7.10.html#general-plugin-API-changes-7-10[7.10] |
{kibana-ref-all}/7.9/breaking-changes-7.9.html#general-plugin-API-changes-79[7.9] |
{kibana-ref-all}/7.8/breaking-changes-7.8.html#general-plugin-API-changes-78[7.8]
[[breaking_plugin_v7.12.0_90764]]
.{kib} and {es} logging config keys unified
[%collapsible]
====
The {kib} logging system uses a configuration schema inspired by `log4j` to
provide {es} compatible format. Several logging configuration keys were renamed
to align the naming schema with the {es} config:
* `*.kind` is renamed to ``*.type`
* `file-appender.path` to `file-appender.fileName`
* `logger.xxx.context` to `logger.xxx.name`
Refer to https://github.com/elastic/kibana/pull/90764[#90764]
====
[[breaking_plugin_v7.12.0_90752]]
.Camel case now enforced for plugin IDs
[%collapsible]
====
Plugin IDs in the `kibana.json` manifest must be camelCase.
This has always been a requirement in the {kib} Platform.
Previously, {kib} logged a deprecation warning. Now {kib} refuses to start.
Refer to https://github.com/elastic/kibana/pull/90752[#90752]
====
[[breaking_plugin_v7.12.0_90432]]
.Timeout added for "stop" lifecycle
[%collapsible]
====
The {kib} plugin system has a concept of
https://www.elastic.co/guide/en/kibana/current/kibana-platform-plugin-api.html#plugin-lifecycles[asynchronous lifecycles] for
all the {kib} plugins.
The new timeout (30 seconds by default) ensures that the `stop` lifecycle doesn't stop
the shutdown process for the {kib} server. If a plugin doesn't complete the `stop` lifecycle in 30 seconds,
{kib} moves to the next plugin.
Refer to https://github.com/elastic/kibana/pull/90432[#90432]
====
[[breaking_plugin_v7.12.0_89274]]
.`vis_type_timeseries_enhanced` plugin removed
[%collapsible]
====
All code from `x-pack/vis_type_timeseries_enhanced` was moved into `src/vis_type_timeseries`.
Refer to https://github.com/elastic/kibana/pull/89274[#89274]
====
[[breaking_plugin_v7.12.0_89259]]
.Field format editors moved from Index Pattern management
[%collapsible]
====
The `IndexPatternManagement.formatEditors` API moved to
`IndexPatternFieldEditor.formatEditors`. The functionality remains the same.
Refer to https://github.com/elastic/kibana/pull/89259[#89259]
====
[[breaking_plugin_v7.12.0_89211]]
.`fetch$` method added for partial search results
[%collapsible]
====
The data plugin search service `SearchSource` now provides a `fetch$`
method. In addition to the existing `fetch` method that returns an
`Observable`, an overall response is returned. This is useful when `_async_search`
is used, and the user needs to handle partial search responses.
Refer to https://github.com/elastic/kibana/pull/89211[#89211]
====
[[breaking_plugin_v7.12.0_88718]]
.Explicit typings for request handler context
[%collapsible]
====
Whenever {kib} needs access to data saved in {es}, it should check if
the user has access to the data.
On the server-side, APIs that require impersonation with an incoming request,
are exposed by the `context` argument of request handler:
```typescript
const router = core.http.createRouter();
router.get(
{ path: '/api/my-plugin/', validate: … },
async (context, req, res) => {}
)
```
Starting with the current version, your plugin should declare an interface of
the `context` parameter explicitly.
**Before**
```typescript
declare module 'src/core/server' {
interface RequestHandlerContext {
myPlugin?: MyPluginApi;
}
}
const router = http.createRouter();
http.registerRouteHandlerContext('my-plugin', async (context, req, res) => {...});
```
**After**
```typescript
export interface MyPluginRequestHandlerContext extends RequestHandlerContext {
myPlugin: MyPluginApi;
}
const router = http.createRouter<MyPluginRequestHandlerContext>();
http.registerRouteHandlerContext<MyPluginRequestHandlerContext, 'my-plugin'>(
'my-plugin',
async (context, req, res) => {...}
);
```
Refer to https://github.com/elastic/kibana/pull/88718[#88718]
====
[[breaking_plugin_v7.12.0_88317]]
.Support changed for custom visualizations
[%collapsible]
====
You can no longer use a common `visualization expression function`
and a common `visualization renderer` to retrieve data and render your custom visualization.
To register a custom visualization:
. Register a **visualization type** using the `visualizations.createBaseVisualization(config)`
function, where `config` is a type of `VisTypeDefinition`. Refer to the
https://github.com/elastic/kibana/blob/7.12/src/plugins/visualizations/public/vis_types/types.ts[`VisTypeDefinition` documentation].
. Register an **expression function definition** to handle your custom expression using
`expressions.registerFunction(functionDefinition)`, where `functionDefinition` describes your expression parameters.
. Register an **explicit renderer** for your visualization using `expressions.registerRenderer(rendererDefinition)`,
where the `rendererDefinition` is a type of `ExpressionRenderDefinition`.
Your visualization is ready to be rendered in {kib} applications,
such as *Lens*, *Dashboard*, *Canvas*, and more.
Refer to https://github.com/elastic/kibana/tree/7.12/test/plugin_functional/plugins/kbn_tp_custom_visualizations[custom visualizations].
Refer to https://github.com/elastic/kibana/pull/88317[#88317]
====
[[breaking_plugin_v7.12.0_88115]]
.Search response follows new hits format
[%collapsible]
====
When using the data plugin search service `search` method,
you can now provide an additional argument, `legacyHitsTotal`, in the `options`.
When set to `true` (the default), the `hits.total` is returned as a number.
When set to `false`, the `hits.total` format is returned as-is from the {es} response.
Refer to https://github.com/elastic/kibana/pull/88115[#88115]
====
[[breaking_plugin_v7.12.0_88070]]
.Ops logs added to the KP logging system
[%collapsible]
====
We are deprecating the legacy response logs, which were enabled
when `logging.verbose: true` or when using `logging.events.ops`.
The legacy response logs will be removed in 8.0, and replaced with new ops
logs that are provided under the `metrics.ops` context at the debug level.
**Before**
```yml
logging:
events:
ops: "*"
```
**After**
```yml
logging:
loggers:
- context: metrics.ops
appenders: [console]
level: debug
```
For more information, check out
https://github.com/elastic/kibana/blob/7.x/src/core/server/logging/README.mdx#logging-config-migration[logging config migration] in the logging README.
**How to test this:**
. Add the following logging configuration to your `kibana.yml` file:
+
```yml
**kibana.yml or kibana.dev.yml**
logging:
events:
log: ['debug']
json: false
verbose: true
appenders:
console:
kind: console
layout:
kind: pattern
highlight: true
root:
appenders: [default]
level: warn
loggers:
- context: metrics.metrics
appenders: [console]
level: debug
```
. Start {es} and {kib}.
. Observe that the ops metrics are logged out (`std out`). For example:
+
```ts
[2021-01-20T22:30:06.974Z][DEBUG][metrics.ops]{"ecs":{"version":"1.7.0"},"kind":"metric","category":["process","host"],"process":{"uptime":640,"memory":{"heap":{"usedInBytes":232472872}},"eventLoopDelay":0.25925004482269287},"host":{"os":{"load":{"1m":8.0625,"5m":7.07470703125,"15m":13.32568359375}}}} memory: 221.7MB uptime: 0:10:40 load: [8.06,7.07,13.33] delay: 0.259
```
Refer to https://github.com/elastic/kibana/pull/88070[#88070]
====
[[breaking_plugin_v7.12.0_87939]]
.Response logs added to the KP logging system
[%collapsible]
====
We are deprecating the legacy response logs, which were enabled when
`logging.verbose: true` or when using `logging.events.request` and `logging.events.response`.
They will be removed in `8.0`, and have been replaced with new response logs,
which are provided under the `http.server.response` context at the `debug` level.
**Before**
```yaml
logging:
events:
request: "*"
response: "*"
```
**After**
```yaml
logging:
loggers:
- context: http.server.response
appenders: [console]
level: debug
```
For more information, check out
https://github.com/elastic/kibana/blob/7.x/src/core/server/logging/README.mdx#logging-config-migration[logging config migration] in the logging README.
Refer to https://github.com/elastic/kibana/pull/87939[#87939]
====
[[breaking_plugin_v7.12.0_87356]]
.Telemetry plugins {es} client migrated to the new client
[%collapsible]
====
Support for the legacy {es} client was removed from the `usage collector`'s `fetch` context.
Refer to https://github.com/elastic/kibana/pull/87356[#87356]
====
[[breaking_plugin_v7.12.0_86988]]
.Dependences between `src/plugins/vis_default_editor` and `src/plugins/visualizations` removed
[%collapsible]
====
In this change:
* The `ISchemas` and `Schema` interfaces moved from `vis_default_editor` to the `visualizations` plugin.
* The `Schemas` class moved from `vis_default_editor` to the `visualizations`
plugin. It's now a private class, and should not be used outside of the `visualizations` plugin.
* The type definition object for visualizations changed.
**Before:**
```yaml
{
editorConfig: {
schemas: new Schemas([{schemaObject1, schemasObject2}])
}
}
```
**After:**
```yaml
{
editorConfig: {
schemas: [{schemaObject1, schemasObject2}]
}
}
```
Refer to https://github.com/elastic/kibana/pull/86988[#86988]
====
[[breaking_plugin_v7.12.0_86474]]
.`services.callCluster` deprecated in alerts and actions executors
[%collapsible]
====
Usage of `services.callCluster` in the alert and action
type executors is deprecated. Use the new `services.scopedClusterClient` instead.
Refer to https://github.com/elastic/kibana/pull/86474[#86474]
====