Skip to content

Commit

Permalink
Merge branch 'master' into runtime-fields-in-mappings-2
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine committed Dec 2, 2020
2 parents 8a65bc8 + 90a18cc commit 5f1fb37
Show file tree
Hide file tree
Showing 1,049 changed files with 468,646 additions and 9,211 deletions.
28 changes: 27 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -187,6 +187,9 @@
/x-pack/test/saved_object_tagging/ @elastic/kibana-core
/packages/kbn-config-schema/ @elastic/kibana-core
/packages/kbn-std/ @elastic/kibana-core
/packages/kbn-config/ @elastic/kibana-core
/packages/kbn-logging/ @elastic/kibana-core
/packages/kbn-legacy-logging/ @elastic/kibana-core
/src/legacy/server/config/ @elastic/kibana-core
/src/legacy/server/http/ @elastic/kibana-core
/src/legacy/server/logging/ @elastic/kibana-core
Expand Down Expand Up @@ -259,8 +262,31 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib

# Enterprise Search
# Shared
/x-pack/plugins/enterprise_search/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/* @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/common/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/public/* @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/public/applications/* @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/public/applications/enterprise_search/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/public/applications/shared/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/public/applications/__mocks__/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/* @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/lib/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/__mocks__/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/collectors/enterprise_search/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/collectors/lib/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/routes/enterprise_search/ @elastic/enterprise-search-frontend
/x-pack/plugins/enterprise_search/server/saved_objects/enterprise_search/ @elastic/enterprise-search-frontend
/x-pack/test/functional_enterprise_search/ @elastic/enterprise-search-frontend
# App Search
/x-pack/plugins/enterprise_search/public/applications/app_search/ @elastic/app-search-frontend
/x-pack/plugins/enterprise_search/server/routes/app_search/ @elastic/app-search-frontend
/x-pack/plugins/enterprise_search/server/collectors/app_search/ @elastic/app-search-frontend
/x-pack/plugins/enterprise_search/server/saved_objects/app_search/ @elastic/app-search-frontend
# Workplace Search
/x-pack/plugins/enterprise_search/public/applications/workplace_search/ @elastic/workplace-search-frontend
/x-pack/plugins/enterprise_search/server/routes/workplace_search/ @elastic/workplace-search-frontend
/x-pack/plugins/enterprise_search/server/collectors/workplace_search/ @elastic/workplace-search-frontend
/x-pack/plugins/enterprise_search/server/saved_objects/workplace_search/ @elastic/workplace-search-frontend

# Elasticsearch UI
/src/plugins/dev_tools/ @elastic/es-ui
Expand Down
1 change: 1 addition & 0 deletions .i18nrc.json
Expand Up @@ -27,6 +27,7 @@
"src/plugins/management"
],
"maps_legacy": "src/plugins/maps_legacy",
"monaco": "packages/kbn-monaco/src",
"indexPatternManagement": "src/plugins/index_pattern_management",
"advancedSettings": "src/plugins/advanced_settings",
"kibana_legacy": "src/plugins/kibana_legacy",
Expand Down
18 changes: 18 additions & 0 deletions STYLEGUIDE.md
Expand Up @@ -589,6 +589,24 @@ Do not use setters, they cause more problems than they can solve.
[sideeffect]: http://en.wikipedia.org/wiki/Side_effect_(computer_science)
### Avoid circular dependencies
As part of a future effort to use correct and idempotent build tools we need our code to be
able to be represented as a directed acyclic graph. We must avoid having circular dependencies
both on code and type imports to achieve that. One of the most critical parts is the plugins
code. We've developed a tool to identify plugins with circular dependencies which
has allowed us to build a list of plugins who have circular dependencies
between each other.
When building plugins we should avoid importing from plugins
who are known to have circular dependencies at the moment as well as introducing
new circular dependencies. You can run the same tool we use on our CI locally by
typing `node scripts/find_plugins_with_circular_deps --debug`. It will error out in
case new circular dependencies has been added with your changes
(which will also happen in the CI) as well as print out the current list of
the known circular dependencies which, as mentioned before, should not be imported
by your code until the circular dependencies on these have been solved.
## SASS files
When writing a new component, create a sibling SASS file of the same name and import directly into the **top** of the JS/TS component file. Doing so ensures the styles are never separated or lost on import and allows for better modularization (smaller individual plugin asset footprint).
Expand Down
6 changes: 4 additions & 2 deletions docs/api/saved-objects/create.asciidoc
Expand Up @@ -9,11 +9,13 @@ experimental[] Create {kib} saved objects.
[[saved-objects-api-create-request]]
==== Request

`POST <kibana host>:<port>/api/saved_objects/<type>` +
`POST <kibana host>:<port>/api/saved_objects/<type>`

`POST <kibana host>:<port>/api/saved_objects/<type>/<id>`

`POST <kibana host>:<port>/s/<space_id>/saved_objects/<type>`
`POST <kibana host>:<port>/s/<space_id>/api/saved_objects/<type>`

`POST <kibana host>:<port>/s/<space_id>/api/saved_objects/<type>/<id>`

[[saved-objects-api-create-path-params]]
==== Path parameters
Expand Down
1 change: 0 additions & 1 deletion docs/apm/apm-alerts.asciidoc
Expand Up @@ -6,7 +6,6 @@
<titleabbrev>Create an alert</titleabbrev>
++++

beta::[]

The APM app integrates with Kibana's {kibana-ref}/alerting-getting-started.html[alerting and actions] feature.
It provides a set of built-in **actions** and APM specific threshold **alerts** for you to use
Expand Down
4 changes: 3 additions & 1 deletion docs/developer/best-practices/typescript.asciidoc
Expand Up @@ -19,7 +19,7 @@ More details are available in the https://www.typescriptlang.org/docs/handbook/p
==== Caveats
This architecture imposes several limitations to which we must comply:

- Projects cannot have circular dependencies. Even though the Kibana platform doesn't support circular dependencies between Kibana plugins, TypeScript (and ES6 modules) does allow circular imports between files. So in theory, you may face a problem when migrating to the TS project references and you will have to resolve this circular dependency. https://github.com/elastic/kibana/issues/78162 is going to provide a tool to find such problem places.
- Projects cannot have circular dependencies. Even though the Kibana platform doesn't support circular dependencies between Kibana plugins, TypeScript (and ES6 modules) does allow circular imports between files. So in theory, you may face a problem when migrating to the TS project references and you will have to resolve this circular dependency. We've built a tool that can be used to find such problems. Please read the prerequisites section below to know how to use it.
- A project must emit its type declaration. It's not always possible to generate a type declaration if the compiler cannot infer a type. There are two basic cases:

1. Your plugin exports a type inferring an internal type declared in Kibana codebase. In this case, you'll have to either export an internal type or to declare an exported type explicitly.
Expand All @@ -30,6 +30,8 @@ This architecture imposes several limitations to which we must comply:
Since project refs rely on generated `d.ts` files, the migration order does matter. You can migrate your plugin only when all the plugin dependencies already have migrated. It creates a situation where commonly used plugins (such as `data` or `kibana_react`) have to migrate first.
Run `node scripts/find_plugins_without_ts_refs.js --id your_plugin_id` to get a list of plugins that should be switched to TS project refs to unblock your plugin migration.

Additionally, in order to migrate into project refs, you also need to make sure your plugin doesn't have circular dependencies with other plugins both on code and type imports. We run a job in the CI for each PR trying to find if new circular dependencies are being added which runs our tool with `node scripts/find_plugins_with_circular_deps`. However there are also a couple of circular dependencies already identified and that are in an allowed list to be solved. You also need to make sure your plugin don't rely in any other plugin into that allowed list. For a complete overview of the circular dependencies both found and in the allowed list as well as the complete circular dependencies path please run the following script locally with the debug flag `node scripts/find_plugins_with_circular_deps --debug` .

[discrete]
==== Implementation
- Make sure all the plugins listed as dependencies in *requiredPlugins*, *optionalPlugins* & *requiredBundles* properties of `kibana.json` manifest file have migrated to TS project references.
Expand Down
71 changes: 71 additions & 0 deletions docs/developer/plugin/migrating-legacy-plugins-examples.asciidoc
Expand Up @@ -1143,6 +1143,77 @@ router.get(
);
----

==== Accessing the client from a collector's `fetch` method

At the moment, the `fetch` method's context receives preconfigured
<<scoped-services, scoped clients>> for Elasticsearch and SavedObjects.
To help in the transition, both, the legacy (`callCluster`) and new clients are provided,
but we strongly discourage using the deprecated legacy ones for any new implementation.

[source,typescript]
----
usageCollection.makeUsageCollector<MyUsage>({
type: 'my-collector',
isReady: async () => true, // Logic to confirm the `fetch` method is ready to be called
schema: {...},
async fetch(context) {
const { callCluster, esClient, soClient } = context;
// Before:
const result = callCluster('search', options)
// After:
const { body: result } = esClient.search(options);
return result;
}
});
----

Regarding the `soClient`, it is encouraged to use it instead of the plugin's owned SavedObject's repository
as we used to do in the past.

Before:

[source,typescript]
----
function getUsageCollector(
usageCollection: UsageCollectionSetup,
getSavedObjectsRepository: () => ISavedObjectsRepository | undefined
) {
usageCollection.makeUsageCollector<MyUsage>({
type: 'my-collector',
isReady: () => typeof getSavedObjectsRepository() !== 'undefined',
schema: {...},
async fetch() {
const savedObjectsRepository = getSavedObjectsRepository();
const { attributes: result } = await savedObjectsRepository.get('my-so-type', 'my-so-id');
return result;
}
});
}
----

After:

[source,typescript]
----
function getUsageCollector(usageCollection: UsageCollectionSetup) {
usageCollection.makeUsageCollector<MyUsage>({
type: 'my-collector',
isReady: () => true,
schema: {...},
async fetch({ soClient }) {
const { attributes: result } = await soClient.get('my-so-type', 'my-so-id');
return result;
}
});
}
----

==== Creating a custom client

Note that the `plugins` option is no longer available on the new
Expand Down
Expand Up @@ -18,7 +18,7 @@ exactRoute?: boolean;
```ts
core.application.register({
id: 'my_app',
title: 'My App'
title: 'My App',
exactRoute: true,
mount: () => { ... },
})
Expand Down
Expand Up @@ -27,6 +27,7 @@ export interface App<HistoryLocationState = unknown>
| [mount](./kibana-plugin-core-public.app.mount.md) | <code>AppMount&lt;HistoryLocationState&gt; &#124; AppMountDeprecated&lt;HistoryLocationState&gt;</code> | A mount function called when the user navigates to this app's route. May have signature of [AppMount](./kibana-plugin-core-public.appmount.md) or [AppMountDeprecated](./kibana-plugin-core-public.appmountdeprecated.md)<!-- -->. |
| [navLinkStatus](./kibana-plugin-core-public.app.navlinkstatus.md) | <code>AppNavLinkStatus</code> | The initial status of the application's navLink. Defaulting to <code>visible</code> if <code>status</code> is <code>accessible</code> and <code>hidden</code> if status is <code>inaccessible</code> See [AppNavLinkStatus](./kibana-plugin-core-public.appnavlinkstatus.md) |
| [order](./kibana-plugin-core-public.app.order.md) | <code>number</code> | An ordinal used to sort nav links relative to one another for display. |
| [searchDeepLinks](./kibana-plugin-core-public.app.searchdeeplinks.md) | <code>AppSearchDeepLink[]</code> | Array of links that represent secondary in-app locations for the app. |
| [status](./kibana-plugin-core-public.app.status.md) | <code>AppStatus</code> | The initial status of the application. Defaulting to <code>accessible</code> |
| [title](./kibana-plugin-core-public.app.title.md) | <code>string</code> | The title of the application. |
| [tooltip](./kibana-plugin-core-public.app.tooltip.md) | <code>string</code> | A tooltip shown when hovering over app link. |
Expand Down
@@ -0,0 +1,42 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [App](./kibana-plugin-core-public.app.md) &gt; [searchDeepLinks](./kibana-plugin-core-public.app.searchdeeplinks.md)

## App.searchDeepLinks property

Array of links that represent secondary in-app locations for the app.

<b>Signature:</b>

```typescript
searchDeepLinks?: AppSearchDeepLink[];
```

## Remarks

Used to populate navigational search results (where available). Can be updated using the [App.updater$](./kibana-plugin-core-public.app.updater_.md) observable. See for more details.

## Example

The `path` property on deep links should not include the application's `appRoute`<!-- -->:

```ts
core.application.register({
id: 'my_app',
title: 'My App',
searchDeepLinks: [
{ id: 'sub1', title: 'Sub1', path: '/sub1' },
{
id: 'sub2',
title: 'Sub2',
searchDeepLinks: [
{ id: 'subsub', title: 'SubSub', path: '/sub2/sub' }
]
}
],
mount: () => { ... },
})

```
Will produce deep links on these paths: - `/app/my_app/sub1` - `/app/my_app/sub2/sub`

@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [AppSearchDeepLink](./kibana-plugin-core-public.appsearchdeeplink.md)

## AppSearchDeepLink type

Input type for registering secondary in-app locations for an application.

Deep links must include at least one of `path` or `searchDeepLinks`<!-- -->. A deep link that does not have a `path` represents a topological level in the application's hierarchy, but does not have a destination URL that is user-accessible.

<b>Signature:</b>

```typescript
export declare type AppSearchDeepLink = {
id: string;
title: string;
} & ({
path: string;
searchDeepLinks?: AppSearchDeepLink[];
} | {
path?: string;
searchDeepLinks: AppSearchDeepLink[];
});
```
Expand Up @@ -9,5 +9,5 @@ Defines the list of fields that can be updated via an [AppUpdater](./kibana-plug
<b>Signature:</b>

```typescript
export declare type AppUpdatableFields = Pick<App, 'status' | 'navLinkStatus' | 'tooltip' | 'defaultPath'>;
export declare type AppUpdatableFields = Pick<App, 'status' | 'navLinkStatus' | 'tooltip' | 'defaultPath' | 'searchDeepLinks'>;
```
2 changes: 2 additions & 0 deletions docs/development/core/public/kibana-plugin-core-public.md
Expand Up @@ -138,6 +138,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [AppLeaveHandler](./kibana-plugin-core-public.appleavehandler.md) | A handler that will be executed before leaving the application, either when going to another application or when closing the browser tab or manually changing the url. Should return <code>confirm</code> to to prompt a message to the user before leaving the page, or <code>default</code> to keep the default behavior (doing nothing).<!-- -->See [AppMountParameters](./kibana-plugin-core-public.appmountparameters.md) for detailed usage examples. |
| [AppMount](./kibana-plugin-core-public.appmount.md) | A mount function called when the user navigates to this app's route. |
| [AppMountDeprecated](./kibana-plugin-core-public.appmountdeprecated.md) | A mount function called when the user navigates to this app's route. |
| [AppSearchDeepLink](./kibana-plugin-core-public.appsearchdeeplink.md) | Input type for registering secondary in-app locations for an application.<!-- -->Deep links must include at least one of <code>path</code> or <code>searchDeepLinks</code>. A deep link that does not have a <code>path</code> represents a topological level in the application's hierarchy, but does not have a destination URL that is user-accessible. |
| [AppUnmount](./kibana-plugin-core-public.appunmount.md) | A function called when an application should be unmounted from the page. This function should be synchronous. |
| [AppUpdatableFields](./kibana-plugin-core-public.appupdatablefields.md) | Defines the list of fields that can be updated via an [AppUpdater](./kibana-plugin-core-public.appupdater.md)<!-- -->. |
| [AppUpdater](./kibana-plugin-core-public.appupdater.md) | Updater for applications. see [ApplicationSetup](./kibana-plugin-core-public.applicationsetup.md) |
Expand All @@ -160,6 +161,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [PluginInitializer](./kibana-plugin-core-public.plugininitializer.md) | The <code>plugin</code> export at the root of a plugin's <code>public</code> directory should conform to this interface. |
| [PluginOpaqueId](./kibana-plugin-core-public.pluginopaqueid.md) | |
| [PublicAppInfo](./kibana-plugin-core-public.publicappinfo.md) | Public information about a registered [application](./kibana-plugin-core-public.app.md) |
| [PublicAppSearchDeepLinkInfo](./kibana-plugin-core-public.publicappsearchdeeplinkinfo.md) | Public information about a registered app's [searchDeepLinks](./kibana-plugin-core-public.appsearchdeeplink.md) |
| [PublicUiSettingsParams](./kibana-plugin-core-public.publicuisettingsparams.md) | A sub-set of [UiSettingsParams](./kibana-plugin-core-public.uisettingsparams.md) exposed to the client-side. |
| [SavedObjectAttribute](./kibana-plugin-core-public.savedobjectattribute.md) | Type definition for a Saved Object attribute value |
| [SavedObjectAttributeSingle](./kibana-plugin-core-public.savedobjectattributesingle.md) | Don't use this type, it's simply a helper type for [SavedObjectAttribute](./kibana-plugin-core-public.savedobjectattribute.md) |
Expand Down
Expand Up @@ -9,9 +9,10 @@ Public information about a registered [application](./kibana-plugin-core-public.
<b>Signature:</b>

```typescript
export declare type PublicAppInfo = Omit<App, 'mount' | 'updater$'> & {
export declare type PublicAppInfo = Omit<App, 'mount' | 'updater$' | 'searchDeepLinks'> & {
status: AppStatus;
navLinkStatus: AppNavLinkStatus;
appRoute: string;
searchDeepLinks: PublicAppSearchDeepLinkInfo[];
};
```
@@ -0,0 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [PublicAppSearchDeepLinkInfo](./kibana-plugin-core-public.publicappsearchdeeplinkinfo.md)

## PublicAppSearchDeepLinkInfo type

Public information about a registered app's [searchDeepLinks](./kibana-plugin-core-public.appsearchdeeplink.md)

<b>Signature:</b>

```typescript
export declare type PublicAppSearchDeepLinkInfo = Omit<AppSearchDeepLink, 'searchDeepLinks'> & {
searchDeepLinks: PublicAppSearchDeepLinkInfo[];
};
```
Expand Up @@ -4,6 +4,11 @@

## LegacyClusterClient.callAsInternalUser property

> Warning: This API is now obsolete.
>
> Use [IClusterClient.asInternalUser](./kibana-plugin-core-server.iclusterclient.asinternaluser.md)<!-- -->.
>
Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. See [LegacyAPICaller](./kibana-plugin-core-server.legacyapicaller.md)<!-- -->.

<b>Signature:</b>
Expand Down
Expand Up @@ -4,6 +4,11 @@

## LegacyScopedClusterClient.callAsCurrentUser() method

> Warning: This API is now obsolete.
>
> Use [IScopedClusterClient.asCurrentUser](./kibana-plugin-core-server.iscopedclusterclient.ascurrentuser.md)<!-- -->.
>
Calls specified `endpoint` with provided `clientParams` on behalf of the user initiated request to the Kibana server (via HTTP request headers). See [LegacyAPICaller](./kibana-plugin-core-server.legacyapicaller.md)<!-- -->.

<b>Signature:</b>
Expand Down

0 comments on commit 5f1fb37

Please sign in to comment.