Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into pr/42858
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Aug 20, 2019
2 parents a35649f + aa55a32 commit 83dc5aa
Show file tree
Hide file tree
Showing 2,411 changed files with 79,334 additions and 25,613 deletions.
4 changes: 2 additions & 2 deletions .ci/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ JOB:
- kibana-ciGroup10
- kibana-ciGroup11
- kibana-ciGroup12
# - kibana-visualRegression
- kibana-visualRegression

# make sure all x-pack-ciGroups are listed in test/scripts/jenkins_xpack_ci_group.sh
- x-pack-firefoxSmoke
Expand All @@ -28,7 +28,7 @@ JOB:
- x-pack-ciGroup8
- x-pack-ciGroup9
- x-pack-ciGroup10
# - x-pack-visualRegression
- x-pack-visualRegression

# `~` is yaml for `null`
exclude: ~
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ELASTIC_LICENSE_HEADER = `
`;

module.exports = {
extends: ['@elastic/eslint-config-kibana'],
extends: ['@elastic/eslint-config-kibana', 'plugin:@elastic/eui/recommended'],

overrides: [
/**
Expand All @@ -40,6 +40,7 @@ module.exports = {
{
files: [
'.eslintrc.js',
'packages/kbn-utility-types/**/*',
'packages/kbn-eslint-plugin-eslint/**/*',
'packages/kbn-config-schema/**/*',
'packages/kbn-pm/**/*',
Expand Down
12 changes: 12 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'Team:AppArch':
- src/plugins/data/**/*
- src/plugins/embeddable/**/*
- src/plugins/kibana_react/**/*
- src/plugins/kibana_utils/**/*
- src/legacy/core_plugins/dashboard_embeddable_container/**/*
- src/legacy/core_plugins/data/**/*
- src/legacy/core_plugins/embeddable_api/**/*
- src/legacy/core_plugins/interpreter/**/*
- src/legacy/ui/public/index_patterns/**/*
- src/legacy/ui/public/indexed_array/**/*
- src/legacy/ui/public/new_platform/**/*
1 change: 1 addition & 0 deletions .sass-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ files:
- 'src/legacy/ui/public/vislib/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/rollup/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/security/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/canvas/**/*.s+(a|c)ss'
rules:
quotes:
- 2
Expand Down
2 changes: 1 addition & 1 deletion bin/kibana
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ if [ ! -x "$NODE" ]; then
exit 1
fi

NODE_ENV=production exec "${NODE}" --no-warnings --max-http-header-size=65536 $NODE_OPTIONS "${DIR}/src/cli" ${@}
NODE_OPTIONS="--no-warnings --max-http-header-size=65536 ${NODE_OPTIONS}" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli" ${@}
2 changes: 1 addition & 1 deletion bin/kibana-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ if [ ! -x "$NODE" ]; then
exit 1
fi

NODE_ENV=production exec "${NODE}" $NODE_OPTIONS --no-warnings "${DIR}/src/cli_plugin" "$@"
NODE_OPTIONS="--no-warnings ${NODE_OPTIONS}" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli_plugin" "$@"
3 changes: 2 additions & 1 deletion bin/kibana-plugin.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ If Not Exist "%NODE%" (
)

TITLE Kibana Server
"%NODE%" %NODE_OPTIONS% --no-warnings "%DIR%\src\cli_plugin" %*

set "NODE_OPTIONS=--no-warnings %NODE_OPTIONS%" && "%NODE%" "%DIR%\src\cli_plugin" %*

:finally

Expand Down
2 changes: 1 addition & 1 deletion bin/kibana.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If Not Exist "%NODE%" (
Exit /B 1
)

"%NODE%" --no-warnings --max-http-header-size=65536 %NODE_OPTIONS% "%DIR%\src\cli" %*
set "NODE_OPTIONS=--no-warnings --max-http-header-size=65536 %NODE_OPTIONS%" && "%NODE%" "%DIR%\src\cli" %*

:finally

Expand Down
5 changes: 5 additions & 0 deletions docs/apm/agent-configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ Adjusting the sampling rate controls what percent of requests are traced.
`1.0` means _all_ requests are traced. If you set the `TRANSACTION_SAMPLE_RATE` to a value below `1.0`,
the agent will randomly sample only a subset of transactions.
Unsampled transactions only record the name of the transaction, the overall transaction time, and the result.

IMPORTANT: In a distributed trace, the sampling decision is propagated by the initializing Agent.
This means if you're using multiple agents, only the originating service's sampling rate will be used.
Be sure to set sensible defaults in _all_ of your agents, especially the
{apm-rum-ref}/configuration.html#transaction-sample-rate[JavaScript RUM Agent].
4 changes: 3 additions & 1 deletion docs/code/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
[partintro]
--

beta[] Interaction with source code is pervasive and essential for any technology company. Speed of innovation is limited by how easy it is to search, navigate, and gain insight into your source code. Elastic *Code* provides an easy-to-use code search solution that scales with your organization. *Code* empowers your team to ship awesome products and provide the best services. *Code* offers the following functions:
beta[]

Interaction with source code is pervasive and essential for any technology company. Speed of innovation is limited by how easy it is to search, navigate, and gain insight into your source code. Elastic *Code* provides an easy-to-use code search solution that scales with your organization. *Code* empowers your team to ship awesome products and provide the best services. *Code* offers the following functions:

* Jump to definition and find references for a symbol
* Typeahead search for symbol definition, file, and repo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Create a new handler function pre-wired to context for the plugin.
<b>Signature:</b>

```typescript
createHandler(pluginOpaqueId: PluginOpaqueId, handler: IContextHandler<TContext, THandlerReturn, THandlerParameters>): (...rest: THandlerParameters) => Promisify<THandlerReturn>;
createHandler(pluginOpaqueId: PluginOpaqueId, handler: IContextHandler<TContext, THandlerReturn, THandlerParameters>): (...rest: THandlerParameters) => THandlerReturn extends Promise<any> ? THandlerReturn : Promise<THandlerReturn>;
```

## Parameters
Expand All @@ -21,7 +21,7 @@ createHandler(pluginOpaqueId: PluginOpaqueId, handler: IContextHandler<TContext,

<b>Returns:</b>

`(...rest: THandlerParameters) => Promisify<THandlerReturn>`
`(...rest: THandlerParameters) => THandlerReturn extends Promise<any> ? THandlerReturn : Promise<THandlerReturn>`

A function that takes `THandlerParameters`<!-- -->, calls `handler` with a new context, and returns a Promise of the `handler` return value.

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Search for objects
<b>Signature:</b>

```typescript
find: <T extends SavedObjectAttributes>(options?: Pick<SavedObjectFindOptionsServer, "search" | "type" | "defaultSearchOperator" | "searchFields" | "sortField" | "hasReference" | "page" | "perPage" | "fields">) => Promise<SavedObjectsFindResponsePublic<T>>;
find: <T extends SavedObjectAttributes>(options: Pick<SavedObjectFindOptionsServer, "search" | "type" | "defaultSearchOperator" | "searchFields" | "sortField" | "hasReference" | "page" | "perPage" | "fields">) => Promise<SavedObjectsFindResponsePublic<T>>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export declare class SavedObjectsClient
| [bulkGet](./kibana-plugin-public.savedobjectsclient.bulkget.md) | | <code>(objects?: {</code><br/><code> id: string;</code><br/><code> type: string;</code><br/><code> }[]) =&gt; Promise&lt;SavedObjectsBatchResponse&lt;SavedObjectAttributes&gt;&gt;</code> | Returns an array of objects by id |
| [create](./kibana-plugin-public.savedobjectsclient.create.md) | | <code>&lt;T extends SavedObjectAttributes&gt;(type: string, attributes: T, options?: SavedObjectsCreateOptions) =&gt; Promise&lt;SimpleSavedObject&lt;T&gt;&gt;</code> | Persists an object |
| [delete](./kibana-plugin-public.savedobjectsclient.delete.md) | | <code>(type: string, id: string) =&gt; Promise&lt;{}&gt;</code> | Deletes an object |
| [find](./kibana-plugin-public.savedobjectsclient.find.md) | | <code>&lt;T extends SavedObjectAttributes&gt;(options?: Pick&lt;SavedObjectFindOptionsServer, &quot;search&quot; &#124; &quot;type&quot; &#124; &quot;defaultSearchOperator&quot; &#124; &quot;searchFields&quot; &#124; &quot;sortField&quot; &#124; &quot;hasReference&quot; &#124; &quot;page&quot; &#124; &quot;perPage&quot; &#124; &quot;fields&quot;&gt;) =&gt; Promise&lt;SavedObjectsFindResponsePublic&lt;T&gt;&gt;</code> | Search for objects |
| [find](./kibana-plugin-public.savedobjectsclient.find.md) | | <code>&lt;T extends SavedObjectAttributes&gt;(options: Pick&lt;SavedObjectFindOptionsServer, &quot;search&quot; &#124; &quot;type&quot; &#124; &quot;defaultSearchOperator&quot; &#124; &quot;searchFields&quot; &#124; &quot;sortField&quot; &#124; &quot;hasReference&quot; &#124; &quot;page&quot; &#124; &quot;perPage&quot; &#124; &quot;fields&quot;&gt;) =&gt; Promise&lt;SavedObjectsFindResponsePublic&lt;T&gt;&gt;</code> | Search for objects |
| [get](./kibana-plugin-public.savedobjectsclient.get.md) | | <code>&lt;T extends SavedObjectAttributes&gt;(type: string, id: string) =&gt; Promise&lt;SimpleSavedObject&lt;T&gt;&gt;</code> | Fetches a single object |

## Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
type?: string | string[];
type: string | string[];
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## ContextSetup.createContextContainer() method

Creates a new for a service owner.
Creates a new [IContextContainer](./kibana-plugin-server.icontextcontainer.md) for a service owner.

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## ContextSetup interface

An object that handles registration of context providers and configuring handlers with context.

<b>Signature:</b>

```typescript
Expand All @@ -14,7 +16,66 @@ export interface ContextSetup

| Method | Description |
| --- | --- |
| [createContextContainer()](./kibana-plugin-server.contextsetup.createcontextcontainer.md) | Creates a new for a service owner. |
| [createContextContainer()](./kibana-plugin-server.contextsetup.createcontextcontainer.md) | Creates a new [IContextContainer](./kibana-plugin-server.icontextcontainer.md) for a service owner. |

## Remarks

A [IContextContainer](./kibana-plugin-server.icontextcontainer.md) can be used by any Core service or plugin (known as the "service owner") which wishes to expose APIs in a handler function. The container object will manage registering context providers and configuring a handler with all of the contexts that should be exposed to the handler's plugin. This is dependent on the dependencies that the handler's plugin declares.

Contexts providers are executed in the order they were registered. Each provider gets access to context values provided by any plugins that it depends on.

In order to configure a handler with context, you must call the [IContextContainer.createHandler()](./kibana-plugin-server.icontextcontainer.createhandler.md) function and use the returned handler which will automatically build a context object when called.

When registering context or creating handlers, the \_calling plugin's opaque id\_ must be provided. This id is passed in via the plugin's initializer and can be accessed from the [PluginInitializerContext.opaqueId](./kibana-plugin-server.plugininitializercontext.opaqueid.md) Note this should NOT be the context service owner's id, but the plugin that is actually registering the context or handler.

```ts
// Correct
class MyPlugin {
private readonly handlers = new Map();

setup(core) {
this.contextContainer = core.context.createContextContainer();
return {
registerContext(pluginOpaqueId, contextName, provider) {
this.contextContainer.registerContext(pluginOpaqueId, contextName, provider);
},
registerRoute(pluginOpaqueId, path, handler) {
this.handlers.set(
path,
this.contextContainer.createHandler(pluginOpaqueId, handler)
);
}
}
}
}

// Incorrect
class MyPlugin {
private readonly handlers = new Map();

constructor(private readonly initContext: PluginInitializerContext) {}

setup(core) {
this.contextContainer = core.context.createContextContainer();
return {
registerContext(contextName, provider) {
// BUG!
// This would leak this context to all handlers rather that only plugins that depend on the calling plugin.
this.contextContainer.registerContext(this.initContext.opaqueId, contextName, provider);
},
registerRoute(path, handler) {
this.handlers.set(
path,
// BUG!
// This handler will not receive any contexts provided by other dependencies of the calling plugin.
this.contextContainer.createHandler(this.initContext.opaqueId, handler)
);
}
}
}
}

```

## Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ http: {
registerOnPostAuth: HttpServiceSetup['registerOnPostAuth'];
basePath: HttpServiceSetup['basePath'];
isTlsEnabled: HttpServiceSetup['isTlsEnabled'];
registerRouteHandlerContext: <T extends keyof RequestHandlerContext>(name: T, provider: RequestHandlerContextProvider<RequestHandlerContext>) => RequestHandlerContextContainer<RequestHandlerContext>;
createRouter: () => IRouter;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export interface CoreSetup
| --- | --- | --- |
| [context](./kibana-plugin-server.coresetup.context.md) | <code>{</code><br/><code> createContextContainer: ContextSetup['createContextContainer'];</code><br/><code> }</code> | |
| [elasticsearch](./kibana-plugin-server.coresetup.elasticsearch.md) | <code>{</code><br/><code> adminClient$: Observable&lt;ClusterClient&gt;;</code><br/><code> dataClient$: Observable&lt;ClusterClient&gt;;</code><br/><code> createClient: (type: string, clientConfig?: Partial&lt;ElasticsearchClientConfig&gt;) =&gt; ClusterClient;</code><br/><code> }</code> | |
| [http](./kibana-plugin-server.coresetup.http.md) | <code>{</code><br/><code> createCookieSessionStorageFactory: HttpServiceSetup['createCookieSessionStorageFactory'];</code><br/><code> registerOnPreAuth: HttpServiceSetup['registerOnPreAuth'];</code><br/><code> registerAuth: HttpServiceSetup['registerAuth'];</code><br/><code> registerOnPostAuth: HttpServiceSetup['registerOnPostAuth'];</code><br/><code> basePath: HttpServiceSetup['basePath'];</code><br/><code> isTlsEnabled: HttpServiceSetup['isTlsEnabled'];</code><br/><code> }</code> | |
| [http](./kibana-plugin-server.coresetup.http.md) | <code>{</code><br/><code> createCookieSessionStorageFactory: HttpServiceSetup['createCookieSessionStorageFactory'];</code><br/><code> registerOnPreAuth: HttpServiceSetup['registerOnPreAuth'];</code><br/><code> registerAuth: HttpServiceSetup['registerAuth'];</code><br/><code> registerOnPostAuth: HttpServiceSetup['registerOnPostAuth'];</code><br/><code> basePath: HttpServiceSetup['basePath'];</code><br/><code> isTlsEnabled: HttpServiceSetup['isTlsEnabled'];</code><br/><code> registerRouteHandlerContext: &lt;T extends keyof RequestHandlerContext&gt;(name: T, provider: RequestHandlerContextProvider&lt;RequestHandlerContext&gt;) =&gt; RequestHandlerContextContainer&lt;RequestHandlerContext&gt;;</code><br/><code> createRouter: () =&gt; IRouter;</code><br/><code> }</code> | |

Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ export interface HttpServerSetup
| [registerAuth](./kibana-plugin-server.httpserversetup.registerauth.md) | <code>(handler: AuthenticationHandler) =&gt; void</code> | To define custom authentication and/or authorization mechanism for incoming requests. A handler should return a state to associate with the incoming request. The state can be retrieved later via http.auth.get(..) Only one AuthenticationHandler can be registered. |
| [registerOnPostAuth](./kibana-plugin-server.httpserversetup.registeronpostauth.md) | <code>(handler: OnPostAuthHandler) =&gt; void</code> | To define custom logic to perform for incoming requests. Runs the handler after Auth interceptor did make sure a user has access to the requested resource. The auth state is available at stage via http.auth.get(..) Can register any number of registerOnPreAuth, which are called in sequence (from the first registered to the last). |
| [registerOnPreAuth](./kibana-plugin-server.httpserversetup.registeronpreauth.md) | <code>(handler: OnPreAuthHandler) =&gt; void</code> | To define custom logic to perform for incoming requests. Runs the handler before Auth interceptor performs a check that user has access to requested resources, so it's the only place when you can forward a request to another URL right on the server. Can register any number of registerOnPostAuth, which are called in sequence (from the first registered to the last). |
| [registerRouter](./kibana-plugin-server.httpserversetup.registerrouter.md) | <code>(router: Router) =&gt; void</code> | Add all the routes registered with <code>router</code> to HTTP server request listeners. |
| [registerRouter](./kibana-plugin-server.httpserversetup.registerrouter.md) | <code>(router: IRouter) =&gt; void</code> | Add all the routes registered with <code>router</code> to HTTP server request listeners. |
| [server](./kibana-plugin-server.httpserversetup.server.md) | <code>Server</code> | |

## Example

To handle an incoming request in your plugin you should: - Create a `Router` instance. Use `plugin-id` as a prefix path segment for your routes.
To handle an incoming request in your plugin you should: - Create a `Router` instance. Router is already configured to use `plugin-id` to prefix path segment for your routes.

```ts
import { Router } from 'src/core/server';
const router = new Router('my-app');
const router = httpSetup.createRouter();

```
- Use `@kbn/config-schema` package to create a schema to validate the request `params`<!-- -->, `query`<!-- -->, and `body`<!-- -->. Every incoming request will be validated against the created schema. If validation failed, the request is rejected with `400` status and `Bad request` error without calling the route's handler. To opt out of validating the request, specify `false`<!-- -->.
Expand Down Expand Up @@ -66,8 +65,7 @@ const handler = async (request: KibanaRequest, response: ResponseFactory) => {
```ts
import { schema, TypeOf } from '@kbn/config-schema';
import { Router } from 'src/core/server';
const router = new Router('my-app');
const router = httpSetup.createRouter();

const validate = {
params: schema.object({
Expand All @@ -79,7 +77,7 @@ router.get({
path: 'path/{id}',
validate
},
async (request, response) => {
async (context, request, response) => {
const data = await findObject(request.params.id);
if (!data) return response.notFound();
return response.ok(data, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Add all the routes registered with `router` to HTTP server request listeners.
<b>Signature:</b>

```typescript
registerRouter: (router: Router) => void;
registerRouter: (router: IRouter) => void;
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
<b>Signature:</b>

```typescript
export declare type HttpServiceSetup = HttpServerSetup;
export declare type HttpServiceSetup = Omit<HttpServerSetup, 'registerRouter'> & {
createRouter: (path: string, plugin?: PluginOpaqueId) => IRouter;
registerRouteHandlerContext: <T extends keyof RequestHandlerContext>(pluginOpaqueId: PluginOpaqueId, contextName: T, provider: RequestHandlerContextProvider<RequestHandlerContext>) => RequestHandlerContextContainer<RequestHandlerContext>;
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [IContextContainer](./kibana-plugin-server.icontextcontainer.md) &gt; [createHandler](./kibana-plugin-server.icontextcontainer.createhandler.md)

## IContextContainer.createHandler() method

Create a new handler function pre-wired to context for the plugin.

<b>Signature:</b>

```typescript
createHandler(pluginOpaqueId: PluginOpaqueId, handler: IContextHandler<TContext, THandlerReturn, THandlerParameters>): (...rest: THandlerParameters) => THandlerReturn extends Promise<any> ? THandlerReturn : Promise<THandlerReturn>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| pluginOpaqueId | <code>PluginOpaqueId</code> | The plugin opaque ID for the plugin that registers this handler. |
| handler | <code>IContextHandler&lt;TContext, THandlerReturn, THandlerParameters&gt;</code> | Handler function to pass context object to. |

<b>Returns:</b>

`(...rest: THandlerParameters) => THandlerReturn extends Promise<any> ? THandlerReturn : Promise<THandlerReturn>`

A function that takes `THandlerParameters`<!-- -->, calls `handler` with a new context, and returns a Promise of the `handler` return value.

Loading

0 comments on commit 83dc5aa

Please sign in to comment.