From 7fbd1f1425a1161ee8e1c5330778f68387e00ede Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Tue, 1 Oct 2019 13:44:19 -0500 Subject: [PATCH 1/5] Make generated type docs more explorable --- ...a-plugin-public.httperrorresponse.error.md | 2 +- .../kibana-plugin-public.httperrorresponse.md | 2 +- ...-plugin-public.httpfetchoptions.headers.md | 2 + .../kibana-plugin-public.httpfetchoptions.md | 7 +- ...public.httpfetchoptions.prependbasepath.md | 2 + ...na-plugin-public.httpfetchoptions.query.md | 2 + .../kibana-plugin-public.httphandler.md | 1 + ...gin-public.httpinterceptcontroller.halt.md | 15 -- ...n-public.httpinterceptcontroller.halted.md | 11 - ...a-plugin-public.httpinterceptcontroller.md | 24 -- .../kibana-plugin-public.httpinterceptor.md | 9 +- ...a-plugin-public.httpinterceptor.request.md | 6 +- ...gin-public.httpinterceptor.requesterror.md | 6 +- ...-plugin-public.httpinterceptor.response.md | 6 +- ...in-public.httpinterceptor.responseerror.md | 6 +- ...bana-plugin-public.httprequestinit.body.md | 1 + ...ana-plugin-public.httprequestinit.cache.md | 2 + ...ugin-public.httprequestinit.credentials.md | 2 + ...a-plugin-public.httprequestinit.headers.md | 2 + ...plugin-public.httprequestinit.integrity.md | 2 + ...plugin-public.httprequestinit.keepalive.md | 2 + .../kibana-plugin-public.httprequestinit.md | 25 +- ...na-plugin-public.httprequestinit.method.md | 2 + ...bana-plugin-public.httprequestinit.mode.md | 2 + ...-plugin-public.httprequestinit.redirect.md | 2 + ...-plugin-public.httprequestinit.referrer.md | 2 + ...n-public.httprequestinit.referrerpolicy.md | 2 + ...na-plugin-public.httprequestinit.signal.md | 2 + ...na-plugin-public.httprequestinit.window.md | 4 +- ...-public.httpservicebase.addloadingcount.md | 6 +- ...-plugin-public.httpservicebase.basepath.md | 8 +- ...na-plugin-public.httpservicebase.delete.md | 2 + ...ana-plugin-public.httpservicebase.fetch.md | 2 + ...ibana-plugin-public.httpservicebase.get.md | 2 + ...public.httpservicebase.getloadingcount_.md | 2 + ...bana-plugin-public.httpservicebase.head.md | 2 + ...plugin-public.httpservicebase.intercept.md | 4 + .../kibana-plugin-public.httpservicebase.md | 27 +- ...a-plugin-public.httpservicebase.options.md | 2 + ...ana-plugin-public.httpservicebase.patch.md | 2 + ...bana-plugin-public.httpservicebase.post.md | 2 + ...ibana-plugin-public.httpservicebase.put.md | 2 + ...c.httpservicebase.removeallinterceptors.md | 2 + ...bana-plugin-public.httpservicebase.stop.md | 15 -- .../public/kibana-plugin-public.httpsetup.md | 1 + .../public/kibana-plugin-public.httpstart.md | 1 + ...bana-plugin-public.ihttpfetcherror.body.md | 11 + .../kibana-plugin-public.ihttpfetcherror.md | 21 ++ ...a-plugin-public.ihttpfetcherror.request.md | 11 + ...-plugin-public.ihttpfetcherror.response.md | 11 + ...in-public.ihttpinterceptcontroller.halt.md | 17 ++ ...-public.ihttpinterceptcontroller.halted.md | 13 + ...-plugin-public.ihttpinterceptcontroller.md | 26 ++ ...md => kibana-plugin-public.itoasts.add.md} | 10 +- .../kibana-plugin-public.itoasts.adddanger.md | 26 ++ .../kibana-plugin-public.itoasts.adderror.md | 27 ++ ...kibana-plugin-public.itoasts.addsuccess.md | 26 ++ ...kibana-plugin-public.itoasts.addwarning.md | 26 ++ ...d => kibana-plugin-public.itoasts.get_.md} | 6 +- .../public/kibana-plugin-public.itoasts.md | 25 ++ .../kibana-plugin-public.itoasts.remove.md | 24 ++ .../core/public/kibana-plugin-public.md | 19 +- ...kibana-plugin-public.notificationssetup.md | 2 +- ...plugin-public.notificationssetup.toasts.md | 2 + ...kibana-plugin-public.notificationsstart.md | 2 +- ...plugin-public.notificationsstart.toasts.md | 2 + ...a-plugin-public.toastsapi._constructor_.md | 22 -- ...ibana-plugin-public.toastsapi.adddanger.md | 22 -- ...kibana-plugin-public.toastsapi.adderror.md | 23 -- ...bana-plugin-public.toastsapi.addsuccess.md | 22 -- ...bana-plugin-public.toastsapi.addwarning.md | 22 -- .../public/kibana-plugin-public.toastsapi.md | 32 --- ...lugin-public.toastsapi.registeroverlays.md | 22 -- .../kibana-plugin-public.toastsapi.remove.md | 22 -- .../kibana-plugin-public.toastssetup.md | 13 + .../kibana-plugin-public.toastsstart.md | 13 + ...ana-plugin-server.authenticationhandler.md | 1 + .../server/kibana-plugin-server.basepath.md | 4 +- .../kibana-plugin-server.basepath.prepend.md | 2 +- .../kibana-plugin-server.basepath.remove.md | 2 +- ...na-plugin-server.clusterclient.asscoped.md | 4 +- ...server.clusterclient.callasinternaluser.md | 2 +- .../kibana-plugin-server.clusterclient.md | 4 +- .../kibana-plugin-server.coresetup.context.md | 6 +- ...a-plugin-server.coresetup.elasticsearch.md | 8 +- .../kibana-plugin-server.coresetup.http.md | 13 +- .../server/kibana-plugin-server.coresetup.md | 6 +- ....elasticsearchservicesetup.adminclient_.md | 8 + ....elasticsearchservicesetup.createclient.md | 2 +- ...r.elasticsearchservicesetup.dataclient_.md | 8 + ...server.elasticsearchservicesetup.legacy.md | 13 - ...plugin-server.elasticsearchservicesetup.md | 17 +- ...bana-plugin-server.httpserversetup.auth.md | 15 -- ...-plugin-server.httpserversetup.basepath.md | 13 - .../kibana-plugin-server.httpserversetup.md | 93 ------- ...gin-server.httpserversetup.registerauth.md | 13 - ...rver.httpserversetup.registeronpostauth.md | 13 - ...erver.httpserversetup.registeronpreauth.md | 13 - ...n-server.httpserversetup.registerrouter.md | 13 - ...na-plugin-server.httpserversetup.server.md | 11 - ...plugin-server.httpservicesetup.basepath.md | 13 + ...etup.createcookiesessionstoragefactory.md} | 4 +- ...in-server.httpservicesetup.createrouter.md | 28 +++ ...n-server.httpservicesetup.istlsenabled.md} | 4 +- .../kibana-plugin-server.httpservicesetup.md | 85 ++++++- ...in-server.httpservicesetup.registerauth.md | 18 ++ ...ver.httpservicesetup.registeronpostauth.md | 18 ++ ...rver.httpservicesetup.registeronpreauth.md | 18 ++ ...ervicesetup.registerroutehandlercontext.md | 37 +++ .../server/kibana-plugin-server.irouter.md | 2 +- .../core/server/kibana-plugin-server.md | 11 +- .../kibana-plugin-server.onpostauthhandler.md | 1 + .../kibana-plugin-server.onpreauthhandler.md | 1 + .../kibana-plugin-server.routeconfig.md | 4 +- .../kibana-plugin-server.routeconfig.path.md | 7 +- ...bana-plugin-server.routeconfig.validate.md | 6 +- ...r.scopedclusterclient.callascurrentuser.md | 2 +- ....scopedclusterclient.callasinternaluser.md | 2 +- ...ibana-plugin-server.scopedclusterclient.md | 4 +- src/core/public/http/http_fetch_error.ts | 5 +- .../public/http/http_intercept_controller.ts | 7 +- .../public/http/http_intercept_halt_error.ts | 1 + src/core/public/http/http_service.ts | 9 +- src/core/public/http/index.ts | 3 - src/core/public/http/types.ts | 234 ++++++++++++++++-- src/core/public/index.ts | 25 +- src/core/public/notifications/index.ts | 2 +- .../notifications/notifications_service.ts | 2 + src/core/public/notifications/toasts/index.ts | 2 +- .../notifications/toasts/toasts_api.tsx | 55 +++- .../toasts/toasts_service.mock.ts | 2 +- .../notifications/toasts/toasts_service.tsx | 16 +- src/core/public/public.api.md | 145 +++++------ .../server/elasticsearch/cluster_client.ts | 9 +- .../elasticsearch_service.mock.ts | 5 +- .../elasticsearch/elasticsearch_service.ts | 42 +--- src/core/server/elasticsearch/index.ts | 3 +- .../elasticsearch/scoped_cluster_client.ts | 4 + src/core/server/elasticsearch/types.ts | 80 ++++++ src/core/server/http/base_path_service.ts | 4 +- src/core/server/http/http_server.ts | 124 +--------- src/core/server/http/http_service.mock.ts | 9 +- src/core/server/http/http_service.ts | 66 +---- src/core/server/http/index.ts | 3 +- src/core/server/http/lifecycle/auth.ts | 9 +- .../server/http/lifecycle/on_post_auth.ts | 5 +- src/core/server/http/lifecycle/on_pre_auth.ts | 5 +- src/core/server/http/router/route.ts | 11 +- src/core/server/http/router/router.ts | 2 + src/core/server/http/types.ts | 209 +++++++++++++++- src/core/server/index.ts | 61 ++--- src/core/server/legacy/legacy_service.test.ts | 4 +- src/core/server/plugins/plugins_service.ts | 8 +- src/core/server/server.api.md | 61 ++--- src/core/server/server.ts | 4 +- .../notify/toasts/toast_notifications.test.ts | 114 ++------- .../on_post_auth_interceptor.test.ts | 27 +- .../on_request_interceptor.test.ts | 25 +- 158 files changed, 1548 insertions(+), 1158 deletions(-) delete mode 100644 docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.halt.md delete mode 100644 docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.halted.md delete mode 100644 docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.md delete mode 100644 docs/development/core/public/kibana-plugin-public.httpservicebase.stop.md create mode 100644 docs/development/core/public/kibana-plugin-public.ihttpfetcherror.body.md create mode 100644 docs/development/core/public/kibana-plugin-public.ihttpfetcherror.md create mode 100644 docs/development/core/public/kibana-plugin-public.ihttpfetcherror.request.md create mode 100644 docs/development/core/public/kibana-plugin-public.ihttpfetcherror.response.md create mode 100644 docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.halt.md create mode 100644 docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.halted.md create mode 100644 docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.md rename docs/development/core/public/{kibana-plugin-public.toastsapi.add.md => kibana-plugin-public.itoasts.add.md} (51%) create mode 100644 docs/development/core/public/kibana-plugin-public.itoasts.adddanger.md create mode 100644 docs/development/core/public/kibana-plugin-public.itoasts.adderror.md create mode 100644 docs/development/core/public/kibana-plugin-public.itoasts.addsuccess.md create mode 100644 docs/development/core/public/kibana-plugin-public.itoasts.addwarning.md rename docs/development/core/public/{kibana-plugin-public.toastsapi.get_.md => kibana-plugin-public.itoasts.get_.md} (56%) create mode 100644 docs/development/core/public/kibana-plugin-public.itoasts.md create mode 100644 docs/development/core/public/kibana-plugin-public.itoasts.remove.md delete mode 100644 docs/development/core/public/kibana-plugin-public.toastsapi._constructor_.md delete mode 100644 docs/development/core/public/kibana-plugin-public.toastsapi.adddanger.md delete mode 100644 docs/development/core/public/kibana-plugin-public.toastsapi.adderror.md delete mode 100644 docs/development/core/public/kibana-plugin-public.toastsapi.addsuccess.md delete mode 100644 docs/development/core/public/kibana-plugin-public.toastsapi.addwarning.md delete mode 100644 docs/development/core/public/kibana-plugin-public.toastsapi.md delete mode 100644 docs/development/core/public/kibana-plugin-public.toastsapi.registeroverlays.md delete mode 100644 docs/development/core/public/kibana-plugin-public.toastsapi.remove.md create mode 100644 docs/development/core/public/kibana-plugin-public.toastssetup.md create mode 100644 docs/development/core/public/kibana-plugin-public.toastsstart.md delete mode 100644 docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.legacy.md delete mode 100644 docs/development/core/server/kibana-plugin-server.httpserversetup.auth.md delete mode 100644 docs/development/core/server/kibana-plugin-server.httpserversetup.basepath.md delete mode 100644 docs/development/core/server/kibana-plugin-server.httpserversetup.md delete mode 100644 docs/development/core/server/kibana-plugin-server.httpserversetup.registerauth.md delete mode 100644 docs/development/core/server/kibana-plugin-server.httpserversetup.registeronpostauth.md delete mode 100644 docs/development/core/server/kibana-plugin-server.httpserversetup.registeronpreauth.md delete mode 100644 docs/development/core/server/kibana-plugin-server.httpserversetup.registerrouter.md delete mode 100644 docs/development/core/server/kibana-plugin-server.httpserversetup.server.md create mode 100644 docs/development/core/server/kibana-plugin-server.httpservicesetup.basepath.md rename docs/development/core/server/{kibana-plugin-server.httpserversetup.createcookiesessionstoragefactory.md => kibana-plugin-server.httpservicesetup.createcookiesessionstoragefactory.md} (61%) create mode 100644 docs/development/core/server/kibana-plugin-server.httpservicesetup.createrouter.md rename docs/development/core/server/{kibana-plugin-server.httpserversetup.istlsenabled.md => kibana-plugin-server.httpservicesetup.istlsenabled.md} (56%) create mode 100644 docs/development/core/server/kibana-plugin-server.httpservicesetup.registerauth.md create mode 100644 docs/development/core/server/kibana-plugin-server.httpservicesetup.registeronpostauth.md create mode 100644 docs/development/core/server/kibana-plugin-server.httpservicesetup.registeronpreauth.md create mode 100644 docs/development/core/server/kibana-plugin-server.httpservicesetup.registerroutehandlercontext.md create mode 100644 src/core/server/elasticsearch/types.ts diff --git a/docs/development/core/public/kibana-plugin-public.httperrorresponse.error.md b/docs/development/core/public/kibana-plugin-public.httperrorresponse.error.md index cb82a1f37f84e..59eee87cb70ba 100644 --- a/docs/development/core/public/kibana-plugin-public.httperrorresponse.error.md +++ b/docs/development/core/public/kibana-plugin-public.httperrorresponse.error.md @@ -7,5 +7,5 @@ Signature: ```typescript -error: Error | HttpFetchError; +error: Error | IHttpFetchError; ``` diff --git a/docs/development/core/public/kibana-plugin-public.httperrorresponse.md b/docs/development/core/public/kibana-plugin-public.httperrorresponse.md index 0495195328fa2..1955bb57c50bf 100644 --- a/docs/development/core/public/kibana-plugin-public.httperrorresponse.md +++ b/docs/development/core/public/kibana-plugin-public.httperrorresponse.md @@ -16,7 +16,7 @@ export interface HttpErrorResponse | Property | Type | Description | | --- | --- | --- | | [body](./kibana-plugin-public.httperrorresponse.body.md) | HttpBody | | -| [error](./kibana-plugin-public.httperrorresponse.error.md) | Error | HttpFetchError | | +| [error](./kibana-plugin-public.httperrorresponse.error.md) | Error | IHttpFetchError | | | [request](./kibana-plugin-public.httperrorresponse.request.md) | Request | | | [response](./kibana-plugin-public.httperrorresponse.response.md) | Response | | diff --git a/docs/development/core/public/kibana-plugin-public.httpfetchoptions.headers.md b/docs/development/core/public/kibana-plugin-public.httpfetchoptions.headers.md index 2fb4c448fe237..232b7d3da3af4 100644 --- a/docs/development/core/public/kibana-plugin-public.httpfetchoptions.headers.md +++ b/docs/development/core/public/kibana-plugin-public.httpfetchoptions.headers.md @@ -4,6 +4,8 @@ ## HttpFetchOptions.headers property +Headers to send with the request. See [HttpHeadersInit](./kibana-plugin-public.httpheadersinit.md). + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpfetchoptions.md b/docs/development/core/public/kibana-plugin-public.httpfetchoptions.md index 93fabb053871a..eca29b37425e9 100644 --- a/docs/development/core/public/kibana-plugin-public.httpfetchoptions.md +++ b/docs/development/core/public/kibana-plugin-public.httpfetchoptions.md @@ -4,6 +4,7 @@ ## HttpFetchOptions interface +All options that may be used with a [HttpHandler](./kibana-plugin-public.httphandler.md). Signature: @@ -15,7 +16,7 @@ export interface HttpFetchOptions extends HttpRequestInit | Property | Type | Description | | --- | --- | --- | -| [headers](./kibana-plugin-public.httpfetchoptions.headers.md) | HttpHeadersInit | | -| [prependBasePath](./kibana-plugin-public.httpfetchoptions.prependbasepath.md) | boolean | | -| [query](./kibana-plugin-public.httpfetchoptions.query.md) | HttpFetchQuery | | +| [headers](./kibana-plugin-public.httpfetchoptions.headers.md) | HttpHeadersInit | Headers to send with the request. See [HttpHeadersInit](./kibana-plugin-public.httpheadersinit.md). | +| [prependBasePath](./kibana-plugin-public.httpfetchoptions.prependbasepath.md) | boolean | Whether or not the request should automatically prepend the basePath. Defaults to true. | +| [query](./kibana-plugin-public.httpfetchoptions.query.md) | HttpFetchQuery | The query string for an HTTP request. See [HttpFetchQuery](./kibana-plugin-public.httpfetchquery.md). | diff --git a/docs/development/core/public/kibana-plugin-public.httpfetchoptions.prependbasepath.md b/docs/development/core/public/kibana-plugin-public.httpfetchoptions.prependbasepath.md index 5fff6c3518b56..0a6a8e195e565 100644 --- a/docs/development/core/public/kibana-plugin-public.httpfetchoptions.prependbasepath.md +++ b/docs/development/core/public/kibana-plugin-public.httpfetchoptions.prependbasepath.md @@ -4,6 +4,8 @@ ## HttpFetchOptions.prependBasePath property +Whether or not the request should automatically prepend the basePath. Defaults to `true`. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpfetchoptions.query.md b/docs/development/core/public/kibana-plugin-public.httpfetchoptions.query.md index 2c24a3a3a548d..0f8d6ba83e772 100644 --- a/docs/development/core/public/kibana-plugin-public.httpfetchoptions.query.md +++ b/docs/development/core/public/kibana-plugin-public.httpfetchoptions.query.md @@ -4,6 +4,8 @@ ## HttpFetchOptions.query property +The query string for an HTTP request. See [HttpFetchQuery](./kibana-plugin-public.httpfetchquery.md). + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httphandler.md b/docs/development/core/public/kibana-plugin-public.httphandler.md index 8bc9c3302252f..80fd1ea2e5761 100644 --- a/docs/development/core/public/kibana-plugin-public.httphandler.md +++ b/docs/development/core/public/kibana-plugin-public.httphandler.md @@ -4,6 +4,7 @@ ## HttpHandler type +A function for making an HTTP requests to Kibana's backend. See [HttpFetchOptions](./kibana-plugin-public.httpfetchoptions.md) for options and [HttpBody](./kibana-plugin-public.httpbody.md) for the response. Signature: diff --git a/docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.halt.md b/docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.halt.md deleted file mode 100644 index 36983d90cf8f4..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.halt.md +++ /dev/null @@ -1,15 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [HttpInterceptController](./kibana-plugin-public.httpinterceptcontroller.md) > [halt](./kibana-plugin-public.httpinterceptcontroller.halt.md) - -## HttpInterceptController.halt() method - -Signature: - -```typescript -halt(): void; -``` -Returns: - -`void` - diff --git a/docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.halted.md b/docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.halted.md deleted file mode 100644 index 18e380c0786bf..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.halted.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [HttpInterceptController](./kibana-plugin-public.httpinterceptcontroller.md) > [halted](./kibana-plugin-public.httpinterceptcontroller.halted.md) - -## HttpInterceptController.halted property - -Signature: - -```typescript -readonly halted: boolean; -``` diff --git a/docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.md b/docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.md deleted file mode 100644 index 03b91fde69cc3..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.httpinterceptcontroller.md +++ /dev/null @@ -1,24 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [HttpInterceptController](./kibana-plugin-public.httpinterceptcontroller.md) - -## HttpInterceptController class - -Signature: - -```typescript -export declare class HttpInterceptController -``` - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [halted](./kibana-plugin-public.httpinterceptcontroller.halted.md) | | boolean | | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [halt()](./kibana-plugin-public.httpinterceptcontroller.halt.md) | | | - diff --git a/docs/development/core/public/kibana-plugin-public.httpinterceptor.md b/docs/development/core/public/kibana-plugin-public.httpinterceptor.md index c694151701ffb..cf7288a492ebb 100644 --- a/docs/development/core/public/kibana-plugin-public.httpinterceptor.md +++ b/docs/development/core/public/kibana-plugin-public.httpinterceptor.md @@ -4,6 +4,7 @@ ## HttpInterceptor interface +An object that may define global interceptor functions for different parts of the request and response lifecycle. See [IHttpInterceptController](./kibana-plugin-public.ihttpinterceptcontroller.md). Signature: @@ -15,8 +16,8 @@ export interface HttpInterceptor | Method | Description | | --- | --- | -| [request(request, controller)](./kibana-plugin-public.httpinterceptor.request.md) | | -| [requestError(httpErrorRequest, controller)](./kibana-plugin-public.httpinterceptor.requesterror.md) | | -| [response(httpResponse, controller)](./kibana-plugin-public.httpinterceptor.response.md) | | -| [responseError(httpErrorResponse, controller)](./kibana-plugin-public.httpinterceptor.responseerror.md) | | +| [request(request, controller)](./kibana-plugin-public.httpinterceptor.request.md) | Define an interceptor to be executed before a request is sent. | +| [requestError(httpErrorRequest, controller)](./kibana-plugin-public.httpinterceptor.requesterror.md) | Define an interceptor to be executed if a request interceptor throws an error or returns a rejected Promise. | +| [response(httpResponse, controller)](./kibana-plugin-public.httpinterceptor.response.md) | Define an interceptor to be executed after a response is received. | +| [responseError(httpErrorResponse, controller)](./kibana-plugin-public.httpinterceptor.responseerror.md) | Define an interceptor to be executed if a response interceptor throws an error or returns a rejected Promise. | diff --git a/docs/development/core/public/kibana-plugin-public.httpinterceptor.request.md b/docs/development/core/public/kibana-plugin-public.httpinterceptor.request.md index 0e57cf8dc51f9..4254e4aa8950c 100644 --- a/docs/development/core/public/kibana-plugin-public.httpinterceptor.request.md +++ b/docs/development/core/public/kibana-plugin-public.httpinterceptor.request.md @@ -4,10 +4,12 @@ ## HttpInterceptor.request() method +Define an interceptor to be executed before a request is sent. + Signature: ```typescript -request?(request: Request, controller: HttpInterceptController): Promise | Request | void; +request?(request: Request, controller: IHttpInterceptController): Promise | Request | void; ``` ## Parameters @@ -15,7 +17,7 @@ request?(request: Request, controller: HttpInterceptController): PromiseRequest | | -| controller | HttpInterceptController | | +| controller | IHttpInterceptController | | Returns: diff --git a/docs/development/core/public/kibana-plugin-public.httpinterceptor.requesterror.md b/docs/development/core/public/kibana-plugin-public.httpinterceptor.requesterror.md index 5c95e15697c35..af9b8641e7473 100644 --- a/docs/development/core/public/kibana-plugin-public.httpinterceptor.requesterror.md +++ b/docs/development/core/public/kibana-plugin-public.httpinterceptor.requesterror.md @@ -4,10 +4,12 @@ ## HttpInterceptor.requestError() method +Define an interceptor to be executed if a request interceptor throws an error or returns a rejected Promise. + Signature: ```typescript -requestError?(httpErrorRequest: HttpErrorRequest, controller: HttpInterceptController): Promise | Request | void; +requestError?(httpErrorRequest: HttpErrorRequest, controller: IHttpInterceptController): Promise | Request | void; ``` ## Parameters @@ -15,7 +17,7 @@ requestError?(httpErrorRequest: HttpErrorRequest, controller: HttpInterceptContr | Parameter | Type | Description | | --- | --- | --- | | httpErrorRequest | HttpErrorRequest | | -| controller | HttpInterceptController | | +| controller | IHttpInterceptController | | Returns: diff --git a/docs/development/core/public/kibana-plugin-public.httpinterceptor.response.md b/docs/development/core/public/kibana-plugin-public.httpinterceptor.response.md index 01609eb2bbac7..6f4205f3362fe 100644 --- a/docs/development/core/public/kibana-plugin-public.httpinterceptor.response.md +++ b/docs/development/core/public/kibana-plugin-public.httpinterceptor.response.md @@ -4,10 +4,12 @@ ## HttpInterceptor.response() method +Define an interceptor to be executed after a response is received. + Signature: ```typescript -response?(httpResponse: HttpResponse, controller: HttpInterceptController): Promise | HttpResponse | void; +response?(httpResponse: HttpResponse, controller: IHttpInterceptController): Promise | HttpResponse | void; ``` ## Parameters @@ -15,7 +17,7 @@ response?(httpResponse: HttpResponse, controller: HttpInterceptController): Prom | Parameter | Type | Description | | --- | --- | --- | | httpResponse | HttpResponse | | -| controller | HttpInterceptController | | +| controller | IHttpInterceptController | | Returns: diff --git a/docs/development/core/public/kibana-plugin-public.httpinterceptor.responseerror.md b/docs/development/core/public/kibana-plugin-public.httpinterceptor.responseerror.md index 71e0f11205d7b..1e7cd5e61186e 100644 --- a/docs/development/core/public/kibana-plugin-public.httpinterceptor.responseerror.md +++ b/docs/development/core/public/kibana-plugin-public.httpinterceptor.responseerror.md @@ -4,10 +4,12 @@ ## HttpInterceptor.responseError() method +Define an interceptor to be executed if a response interceptor throws an error or returns a rejected Promise. + Signature: ```typescript -responseError?(httpErrorResponse: HttpErrorResponse, controller: HttpInterceptController): Promise | HttpResponse | void; +responseError?(httpErrorResponse: HttpErrorResponse, controller: IHttpInterceptController): Promise | HttpResponse | void; ``` ## Parameters @@ -15,7 +17,7 @@ responseError?(httpErrorResponse: HttpErrorResponse, controller: HttpInterceptCo | Parameter | Type | Description | | --- | --- | --- | | httpErrorResponse | HttpErrorResponse | | -| controller | HttpInterceptController | | +| controller | IHttpInterceptController | | Returns: diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.body.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.body.md index ecf8343ab529c..997bbf624ff03 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.body.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.body.md @@ -4,6 +4,7 @@ ## HttpRequestInit.body property + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.cache.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.cache.md index 813639b51f814..0f9dff3887ccf 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.cache.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.cache.md @@ -4,6 +4,8 @@ ## HttpRequestInit.cache property +The cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.credentials.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.credentials.md index 26e86722a8219..93c624cd1980c 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.credentials.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.credentials.md @@ -4,6 +4,8 @@ ## HttpRequestInit.credentials property +The credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.headers.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.headers.md index 2e5f86ebe38ef..0f885ed0df1a3 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.headers.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.headers.md @@ -4,6 +4,8 @@ ## HttpRequestInit.headers property +[HttpHeadersInit](./kibana-plugin-public.httpheadersinit.md) + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.integrity.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.integrity.md index 9d8b3644aa9d7..7bb1665fdfcbe 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.integrity.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.integrity.md @@ -4,6 +4,8 @@ ## HttpRequestInit.integrity property +Subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.keepalive.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.keepalive.md index bb1a50c280dce..ba256188ce338 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.keepalive.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.keepalive.md @@ -4,6 +4,8 @@ ## HttpRequestInit.keepalive property +Whether or not request can outlive the global in which it was created. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.md index 89fa6d5379581..ac0d896b3d0c0 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.md @@ -4,6 +4,7 @@ ## HttpRequestInit interface +Fetch API options available to [HttpHandler](./kibana-plugin-public.httphandler.md)s. Signature: @@ -16,16 +17,16 @@ export interface HttpRequestInit | Property | Type | Description | | --- | --- | --- | | [body](./kibana-plugin-public.httprequestinit.body.md) | BodyInit | null | | -| [cache](./kibana-plugin-public.httprequestinit.cache.md) | RequestCache | | -| [credentials](./kibana-plugin-public.httprequestinit.credentials.md) | RequestCredentials | | -| [headers](./kibana-plugin-public.httprequestinit.headers.md) | HttpHeadersInit | | -| [integrity](./kibana-plugin-public.httprequestinit.integrity.md) | string | | -| [keepalive](./kibana-plugin-public.httprequestinit.keepalive.md) | boolean | | -| [method](./kibana-plugin-public.httprequestinit.method.md) | string | | -| [mode](./kibana-plugin-public.httprequestinit.mode.md) | RequestMode | | -| [redirect](./kibana-plugin-public.httprequestinit.redirect.md) | RequestRedirect | | -| [referrer](./kibana-plugin-public.httprequestinit.referrer.md) | string | | -| [referrerPolicy](./kibana-plugin-public.httprequestinit.referrerpolicy.md) | ReferrerPolicy | | -| [signal](./kibana-plugin-public.httprequestinit.signal.md) | AbortSignal | null | | -| [window](./kibana-plugin-public.httprequestinit.window.md) | any | | +| [cache](./kibana-plugin-public.httprequestinit.cache.md) | RequestCache | The cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. | +| [credentials](./kibana-plugin-public.httprequestinit.credentials.md) | RequestCredentials | The credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. | +| [headers](./kibana-plugin-public.httprequestinit.headers.md) | HttpHeadersInit | [HttpHeadersInit](./kibana-plugin-public.httpheadersinit.md) | +| [integrity](./kibana-plugin-public.httprequestinit.integrity.md) | string | Subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. | +| [keepalive](./kibana-plugin-public.httprequestinit.keepalive.md) | boolean | Whether or not request can outlive the global in which it was created. | +| [method](./kibana-plugin-public.httprequestinit.method.md) | string | HTTP method, which is "GET" by default. | +| [mode](./kibana-plugin-public.httprequestinit.mode.md) | RequestMode | The mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs. | +| [redirect](./kibana-plugin-public.httprequestinit.redirect.md) | RequestRedirect | The redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. | +| [referrer](./kibana-plugin-public.httprequestinit.referrer.md) | string | The referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the Referer header of the request being made. | +| [referrerPolicy](./kibana-plugin-public.httprequestinit.referrerpolicy.md) | ReferrerPolicy | The referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. | +| [signal](./kibana-plugin-public.httprequestinit.signal.md) | AbortSignal | null | Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. | +| [window](./kibana-plugin-public.httprequestinit.window.md) | null | Can only be null. Used to disassociate request from any Window. | diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.method.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.method.md index 2aab899405576..c3465ae75521d 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.method.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.method.md @@ -4,6 +4,8 @@ ## HttpRequestInit.method property +HTTP method, which is "GET" by default. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.mode.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.mode.md index 611671331ee58..5ba625318eb27 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.mode.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.mode.md @@ -4,6 +4,8 @@ ## HttpRequestInit.mode property +The mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.redirect.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.redirect.md index 6795e99d370f3..b2554812fadf9 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.redirect.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.redirect.md @@ -4,6 +4,8 @@ ## HttpRequestInit.redirect property +The redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.referrer.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.referrer.md index 60e249cc9cf1d..56c9bcb4afaa9 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.referrer.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.referrer.md @@ -4,6 +4,8 @@ ## HttpRequestInit.referrer property +The referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.referrerpolicy.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.referrerpolicy.md index 3f92ee021f9cc..07231203c0030 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.referrerpolicy.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.referrerpolicy.md @@ -4,6 +4,8 @@ ## HttpRequestInit.referrerPolicy property +The referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.signal.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.signal.md index 8657c6b7a1242..b0e863eaa804f 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.signal.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.signal.md @@ -4,6 +4,8 @@ ## HttpRequestInit.signal property +Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.window.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.window.md index aec7fad7e3927..1a6d740065423 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.window.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.window.md @@ -4,8 +4,10 @@ ## HttpRequestInit.window property +Can only be null. Used to disassociate request from any Window. + Signature: ```typescript -window?: any; +window?: null; ``` diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.addloadingcount.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.addloadingcount.md index 0dc64a3f75443..e984fea48625d 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.addloadingcount.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.addloadingcount.md @@ -4,17 +4,19 @@ ## HttpServiceBase.addLoadingCount() method +Adds a new source of loading counts. Used to show the global loading indicator when sum of all observed counts are more than 0. + Signature: ```typescript -addLoadingCount(count$: Observable): void; +addLoadingCount(countSource$: Observable): void; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| count$ | Observable<number> | | +| countSource$ | Observable<number> | | Returns: diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.basepath.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.basepath.md index 6794199dc9dbd..6c5f690a5c607 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.basepath.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.basepath.md @@ -4,12 +4,10 @@ ## HttpServiceBase.basePath property +APIs for manipulating the basePath on URL segments. + Signature: ```typescript -basePath: { - get: () => string; - prepend: (url: string) => string; - remove: (url: string) => string; - }; +basePath: IBasePath; ``` diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.delete.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.delete.md index 55e67a50b156f..73022ef4f2946 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.delete.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.delete.md @@ -4,6 +4,8 @@ ## HttpServiceBase.delete property +Makes an HTTP request with the DELETE method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.fetch.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.fetch.md index 92936230149b6..3a1ae4892a3dd 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.fetch.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.fetch.md @@ -4,6 +4,8 @@ ## HttpServiceBase.fetch property +Makes an HTTP request. Defaults to a GET request unless overriden. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.get.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.get.md index d4b9a3810a497..a61b3dd140e50 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.get.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.get.md @@ -4,6 +4,8 @@ ## HttpServiceBase.get property +Makes an HTTP request with the GET method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.getloadingcount_.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.getloadingcount_.md index 5b04c3327fd49..0b2129330cd01 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.getloadingcount_.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.getloadingcount_.md @@ -4,6 +4,8 @@ ## HttpServiceBase.getLoadingCount$() method +Get the sum of all loading count sources as a single Observable. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.head.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.head.md index 78546d0fbb4f3..4624d95f03bf3 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.head.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.head.md @@ -4,6 +4,8 @@ ## HttpServiceBase.head property +Makes an HTTP request with the HEAD method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.intercept.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.intercept.md index 805884a21d18f..06aae54d8ee9d 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.intercept.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.intercept.md @@ -4,6 +4,8 @@ ## HttpServiceBase.intercept() method +Adds a new to the global HTTP client. + Signature: ```typescript @@ -20,3 +22,5 @@ intercept(interceptor: HttpInterceptor): () => void; `() => void` +a function for removing the attached interceptor. + diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.md index 71ddb6dee20a8..87be9db3a113e 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.md @@ -15,23 +15,22 @@ export interface HttpServiceBase | Property | Type | Description | | --- | --- | --- | -| [basePath](./kibana-plugin-public.httpservicebase.basepath.md) | {
get: () => string;
prepend: (url: string) => string;
remove: (url: string) => string;
} | | -| [delete](./kibana-plugin-public.httpservicebase.delete.md) | HttpHandler | | -| [fetch](./kibana-plugin-public.httpservicebase.fetch.md) | HttpHandler | | -| [get](./kibana-plugin-public.httpservicebase.get.md) | HttpHandler | | -| [head](./kibana-plugin-public.httpservicebase.head.md) | HttpHandler | | -| [options](./kibana-plugin-public.httpservicebase.options.md) | HttpHandler | | -| [patch](./kibana-plugin-public.httpservicebase.patch.md) | HttpHandler | | -| [post](./kibana-plugin-public.httpservicebase.post.md) | HttpHandler | | -| [put](./kibana-plugin-public.httpservicebase.put.md) | HttpHandler | | +| [basePath](./kibana-plugin-public.httpservicebase.basepath.md) | IBasePath | APIs for manipulating the basePath on URL segments. | +| [delete](./kibana-plugin-public.httpservicebase.delete.md) | HttpHandler | Makes an HTTP request with the DELETE method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. | +| [fetch](./kibana-plugin-public.httpservicebase.fetch.md) | HttpHandler | Makes an HTTP request. Defaults to a GET request unless overriden. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. | +| [get](./kibana-plugin-public.httpservicebase.get.md) | HttpHandler | Makes an HTTP request with the GET method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. | +| [head](./kibana-plugin-public.httpservicebase.head.md) | HttpHandler | Makes an HTTP request with the HEAD method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. | +| [options](./kibana-plugin-public.httpservicebase.options.md) | HttpHandler | Makes an HTTP request with the OPTIONS method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. | +| [patch](./kibana-plugin-public.httpservicebase.patch.md) | HttpHandler | Makes an HTTP request with the PATCH method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. | +| [post](./kibana-plugin-public.httpservicebase.post.md) | HttpHandler | Makes an HTTP request with the POST method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. | +| [put](./kibana-plugin-public.httpservicebase.put.md) | HttpHandler | Makes an HTTP request with the PUT method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. | ## Methods | Method | Description | | --- | --- | -| [addLoadingCount(count$)](./kibana-plugin-public.httpservicebase.addloadingcount.md) | | -| [getLoadingCount$()](./kibana-plugin-public.httpservicebase.getloadingcount_.md) | | -| [intercept(interceptor)](./kibana-plugin-public.httpservicebase.intercept.md) | | -| [removeAllInterceptors()](./kibana-plugin-public.httpservicebase.removeallinterceptors.md) | | -| [stop()](./kibana-plugin-public.httpservicebase.stop.md) | | +| [addLoadingCount(countSource$)](./kibana-plugin-public.httpservicebase.addloadingcount.md) | Adds a new source of loading counts. Used to show the global loading indicator when sum of all observed counts are more than 0. | +| [getLoadingCount$()](./kibana-plugin-public.httpservicebase.getloadingcount_.md) | Get the sum of all loading count sources as a single Observable. | +| [intercept(interceptor)](./kibana-plugin-public.httpservicebase.intercept.md) | Adds a new to the global HTTP client. | +| [removeAllInterceptors()](./kibana-plugin-public.httpservicebase.removeallinterceptors.md) | Removes all configured interceptors. | diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.options.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.options.md index 6579a92f695a4..0820beb2752f2 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.options.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.options.md @@ -4,6 +4,8 @@ ## HttpServiceBase.options property +Makes an HTTP request with the OPTIONS method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.patch.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.patch.md index 3b81f2f863376..00e1ffc0e16bf 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.patch.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.patch.md @@ -4,6 +4,8 @@ ## HttpServiceBase.patch property +Makes an HTTP request with the PATCH method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.post.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.post.md index b990fd1458c33..3771a7c910895 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.post.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.post.md @@ -4,6 +4,8 @@ ## HttpServiceBase.post property +Makes an HTTP request with the POST method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.put.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.put.md index 3f41c6c21fec6..6e43aafa916bc 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.put.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.put.md @@ -4,6 +4,8 @@ ## HttpServiceBase.put property +Makes an HTTP request with the PUT method. See [HttpHandler](./kibana-plugin-public.httphandler.md) for options. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.removeallinterceptors.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.removeallinterceptors.md index 405baf458e516..0432ec29a22b6 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.removeallinterceptors.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.removeallinterceptors.md @@ -4,6 +4,8 @@ ## HttpServiceBase.removeAllInterceptors() method +Removes all configured interceptors. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.stop.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.stop.md deleted file mode 100644 index 2a2323dbdda16..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.stop.md +++ /dev/null @@ -1,15 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [HttpServiceBase](./kibana-plugin-public.httpservicebase.md) > [stop](./kibana-plugin-public.httpservicebase.stop.md) - -## HttpServiceBase.stop() method - -Signature: - -```typescript -stop(): void; -``` -Returns: - -`void` - diff --git a/docs/development/core/public/kibana-plugin-public.httpsetup.md b/docs/development/core/public/kibana-plugin-public.httpsetup.md index cc8ae6ab6aac1..7ef037ea7abd1 100644 --- a/docs/development/core/public/kibana-plugin-public.httpsetup.md +++ b/docs/development/core/public/kibana-plugin-public.httpsetup.md @@ -4,6 +4,7 @@ ## HttpSetup type +See [HttpServiceBase](./kibana-plugin-public.httpservicebase.md) Signature: diff --git a/docs/development/core/public/kibana-plugin-public.httpstart.md b/docs/development/core/public/kibana-plugin-public.httpstart.md index f70c08a1bde50..bb9247c63897a 100644 --- a/docs/development/core/public/kibana-plugin-public.httpstart.md +++ b/docs/development/core/public/kibana-plugin-public.httpstart.md @@ -4,6 +4,7 @@ ## HttpStart type +See [HttpServiceBase](./kibana-plugin-public.httpservicebase.md) Signature: diff --git a/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.body.md b/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.body.md new file mode 100644 index 0000000000000..2a5f3a68635b8 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.body.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IHttpFetchError](./kibana-plugin-public.ihttpfetcherror.md) > [body](./kibana-plugin-public.ihttpfetcherror.body.md) + +## IHttpFetchError.body property + +Signature: + +```typescript +readonly body?: any; +``` diff --git a/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.md b/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.md new file mode 100644 index 0000000000000..f33688affe8d5 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IHttpFetchError](./kibana-plugin-public.ihttpfetcherror.md) + +## IHttpFetchError interface + + +Signature: + +```typescript +export interface IHttpFetchError extends Error +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [body](./kibana-plugin-public.ihttpfetcherror.body.md) | any | | +| [request](./kibana-plugin-public.ihttpfetcherror.request.md) | Request | | +| [response](./kibana-plugin-public.ihttpfetcherror.response.md) | Response | | + diff --git a/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.request.md b/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.request.md new file mode 100644 index 0000000000000..bbb1432f13bfb --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.request.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IHttpFetchError](./kibana-plugin-public.ihttpfetcherror.md) > [request](./kibana-plugin-public.ihttpfetcherror.request.md) + +## IHttpFetchError.request property + +Signature: + +```typescript +readonly request: Request; +``` diff --git a/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.response.md b/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.response.md new file mode 100644 index 0000000000000..c5efc1cc3858c --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.ihttpfetcherror.response.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IHttpFetchError](./kibana-plugin-public.ihttpfetcherror.md) > [response](./kibana-plugin-public.ihttpfetcherror.response.md) + +## IHttpFetchError.response property + +Signature: + +```typescript +readonly response?: Response; +``` diff --git a/docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.halt.md b/docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.halt.md new file mode 100644 index 0000000000000..6bd3e2e397b91 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.halt.md @@ -0,0 +1,17 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IHttpInterceptController](./kibana-plugin-public.ihttpinterceptcontroller.md) > [halt](./kibana-plugin-public.ihttpinterceptcontroller.halt.md) + +## IHttpInterceptController.halt() method + +Halt the request Promise chain and do not process further interceptors or response handlers. + +Signature: + +```typescript +halt(): void; +``` +Returns: + +`void` + diff --git a/docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.halted.md b/docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.halted.md new file mode 100644 index 0000000000000..2e61e8da56e6f --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.halted.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IHttpInterceptController](./kibana-plugin-public.ihttpinterceptcontroller.md) > [halted](./kibana-plugin-public.ihttpinterceptcontroller.halted.md) + +## IHttpInterceptController.halted property + +Whether or not this chain has been halted. + +Signature: + +```typescript +halted: boolean; +``` diff --git a/docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.md b/docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.md new file mode 100644 index 0000000000000..b07d9fceb91f0 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.ihttpinterceptcontroller.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IHttpInterceptController](./kibana-plugin-public.ihttpinterceptcontroller.md) + +## IHttpInterceptController interface + +Used to halt a request Promise chain in a [HttpInterceptor](./kibana-plugin-public.httpinterceptor.md). + +Signature: + +```typescript +export interface IHttpInterceptController +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [halted](./kibana-plugin-public.ihttpinterceptcontroller.halted.md) | boolean | Whether or not this chain has been halted. | + +## Methods + +| Method | Description | +| --- | --- | +| [halt()](./kibana-plugin-public.ihttpinterceptcontroller.halt.md) | Halt the request Promise chain and do not process further interceptors or response handlers. | + diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi.add.md b/docs/development/core/public/kibana-plugin-public.itoasts.add.md similarity index 51% rename from docs/development/core/public/kibana-plugin-public.toastsapi.add.md rename to docs/development/core/public/kibana-plugin-public.itoasts.add.md index a59c11d0d5f53..541b26837aeea 100644 --- a/docs/development/core/public/kibana-plugin-public.toastsapi.add.md +++ b/docs/development/core/public/kibana-plugin-public.itoasts.add.md @@ -1,8 +1,10 @@ -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [add](./kibana-plugin-public.toastsapi.add.md) +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [add](./kibana-plugin-public.itoasts.add.md) -## ToastsApi.add() method +## IToasts.add() method + +Adds a new toast to current array of toast. Signature: @@ -14,9 +16,11 @@ add(toastOrTitle: ToastInput): Toast; | Parameter | Type | Description | | --- | --- | --- | -| toastOrTitle | ToastInput | | +| toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-public.toastinput.md) | Returns: `Toast` +a + diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.adddanger.md b/docs/development/core/public/kibana-plugin-public.itoasts.adddanger.md new file mode 100644 index 0000000000000..cd8610e0f5d0c --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.itoasts.adddanger.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [addDanger](./kibana-plugin-public.itoasts.adddanger.md) + +## IToasts.addDanger() method + +Adds a new toast pre-configured with the danger color and alert icon. + +Signature: + +```typescript +addDanger(toastOrTitle: ToastInput): Toast; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-public.toastinput.md) | + +Returns: + +`Toast` + +a + diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.adderror.md b/docs/development/core/public/kibana-plugin-public.itoasts.adderror.md new file mode 100644 index 0000000000000..b1c0598f9c38f --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.itoasts.adderror.md @@ -0,0 +1,27 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [addError](./kibana-plugin-public.itoasts.adderror.md) + +## IToasts.addError() method + +Adds a new toast that displays an exception message with a button to open the full stacktrace in a modal. + +Signature: + +```typescript +addError(error: Error, options: ErrorToastOptions): Toast; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| error | Error | an Error instance. | +| options | ErrorToastOptions | [ErrorToastOptions](./kibana-plugin-public.errortoastoptions.md) | + +Returns: + +`Toast` + +a + diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.addsuccess.md b/docs/development/core/public/kibana-plugin-public.itoasts.addsuccess.md new file mode 100644 index 0000000000000..9e355c6c5492f --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.itoasts.addsuccess.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [addSuccess](./kibana-plugin-public.itoasts.addsuccess.md) + +## IToasts.addSuccess() method + +Adds a new toast pre-configured with the success color and check icon. + +Signature: + +```typescript +addSuccess(toastOrTitle: ToastInput): Toast; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-public.toastinput.md) | + +Returns: + +`Toast` + +a + diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.addwarning.md b/docs/development/core/public/kibana-plugin-public.itoasts.addwarning.md new file mode 100644 index 0000000000000..06efc2c94cf06 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.itoasts.addwarning.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [addWarning](./kibana-plugin-public.itoasts.addwarning.md) + +## IToasts.addWarning() method + +Adds a new toast pre-configured with the warning color and help icon. + +Signature: + +```typescript +addWarning(toastOrTitle: ToastInput): Toast; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-public.toastinput.md) | + +Returns: + +`Toast` + +a + diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi.get_.md b/docs/development/core/public/kibana-plugin-public.itoasts.get_.md similarity index 56% rename from docs/development/core/public/kibana-plugin-public.toastsapi.get_.md rename to docs/development/core/public/kibana-plugin-public.itoasts.get_.md index 1761fa21b70e8..f5d00f4c10341 100644 --- a/docs/development/core/public/kibana-plugin-public.toastsapi.get_.md +++ b/docs/development/core/public/kibana-plugin-public.itoasts.get_.md @@ -1,8 +1,10 @@ -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [get$](./kibana-plugin-public.toastsapi.get_.md) +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [get$](./kibana-plugin-public.itoasts.get_.md) -## ToastsApi.get$() method +## IToasts.get$() method + +Current array of toast messages to show to user. Signature: diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.md b/docs/development/core/public/kibana-plugin-public.itoasts.md new file mode 100644 index 0000000000000..045574eb1d490 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.itoasts.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) + +## IToasts interface + + +Signature: + +```typescript +export interface IToasts +``` + +## Methods + +| Method | Description | +| --- | --- | +| [add(toastOrTitle)](./kibana-plugin-public.itoasts.add.md) | Adds a new toast to current array of toast. | +| [addDanger(toastOrTitle)](./kibana-plugin-public.itoasts.adddanger.md) | Adds a new toast pre-configured with the danger color and alert icon. | +| [addError(error, options)](./kibana-plugin-public.itoasts.adderror.md) | Adds a new toast that displays an exception message with a button to open the full stacktrace in a modal. | +| [addSuccess(toastOrTitle)](./kibana-plugin-public.itoasts.addsuccess.md) | Adds a new toast pre-configured with the success color and check icon. | +| [addWarning(toastOrTitle)](./kibana-plugin-public.itoasts.addwarning.md) | Adds a new toast pre-configured with the warning color and help icon. | +| [get$()](./kibana-plugin-public.itoasts.get_.md) | Current array of toast messages to show to user. | +| [remove(toasts)](./kibana-plugin-public.itoasts.remove.md) | Removes a toast from the current array of toasts if present. | + diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.remove.md b/docs/development/core/public/kibana-plugin-public.itoasts.remove.md new file mode 100644 index 0000000000000..cebb38c0fcc6f --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.itoasts.remove.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [remove](./kibana-plugin-public.itoasts.remove.md) + +## IToasts.remove() method + +Removes a toast from the current array of toasts if present. + +Signature: + +```typescript +remove(toasts: Toast): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| toasts | Toast | | + +Returns: + +`void` + diff --git a/docs/development/core/public/kibana-plugin-public.md b/docs/development/core/public/kibana-plugin-public.md index 3c7943ba29388..d577ac2eafdd6 100644 --- a/docs/development/core/public/kibana-plugin-public.md +++ b/docs/development/core/public/kibana-plugin-public.md @@ -14,10 +14,8 @@ The plugin integrates with the core system via lifecycle events: `setup` | Class | Description | | --- | --- | -| [HttpInterceptController](./kibana-plugin-public.httpinterceptcontroller.md) | | | [SavedObjectsClient](./kibana-plugin-public.savedobjectsclient.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing plugin state. The client-side SavedObjectsClient is a thin convenience library around the SavedObjects HTTP API for interacting with Saved Objects. | | [SimpleSavedObject](./kibana-plugin-public.simplesavedobject.md) | This class is a very simple wrapper for SavedObjects loaded from the server with the [SavedObjectsClient](./kibana-plugin-public.savedobjectsclient.md).It provides basic functionality for creating/saving/deleting saved objects, but doesn't include any type-specific implementations. | -| [ToastsApi](./kibana-plugin-public.toastsapi.md) | | | [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) | | ## Interfaces @@ -50,15 +48,18 @@ The plugin integrates with the core system via lifecycle events: `setup` | [FatalErrorsSetup](./kibana-plugin-public.fatalerrorssetup.md) | FatalErrors stop the Kibana Public Core and displays a fatal error screen with details about the Kibana build and the error. | | [HttpErrorRequest](./kibana-plugin-public.httperrorrequest.md) | | | [HttpErrorResponse](./kibana-plugin-public.httperrorresponse.md) | | -| [HttpFetchOptions](./kibana-plugin-public.httpfetchoptions.md) | | +| [HttpFetchOptions](./kibana-plugin-public.httpfetchoptions.md) | All options that may be used with a [HttpHandler](./kibana-plugin-public.httphandler.md). | | [HttpFetchQuery](./kibana-plugin-public.httpfetchquery.md) | | | [HttpHeadersInit](./kibana-plugin-public.httpheadersinit.md) | | -| [HttpInterceptor](./kibana-plugin-public.httpinterceptor.md) | | -| [HttpRequestInit](./kibana-plugin-public.httprequestinit.md) | | +| [HttpInterceptor](./kibana-plugin-public.httpinterceptor.md) | An object that may define global interceptor functions for different parts of the request and response lifecycle. See [IHttpInterceptController](./kibana-plugin-public.ihttpinterceptcontroller.md). | +| [HttpRequestInit](./kibana-plugin-public.httprequestinit.md) | Fetch API options available to [HttpHandler](./kibana-plugin-public.httphandler.md)s. | | [HttpResponse](./kibana-plugin-public.httpresponse.md) | | | [HttpServiceBase](./kibana-plugin-public.httpservicebase.md) | | | [I18nStart](./kibana-plugin-public.i18nstart.md) | I18nStart.Context is required by any localizable React component from @kbn/i18n and @elastic/eui packages and is supposed to be used as the topmost component for any i18n-compatible React tree. | | [IContextContainer](./kibana-plugin-public.icontextcontainer.md) | An object that handles registration of context providers and configuring handlers with context. | +| [IHttpFetchError](./kibana-plugin-public.ihttpfetcherror.md) | | +| [IHttpInterceptController](./kibana-plugin-public.ihttpinterceptcontroller.md) | Used to halt a request Promise chain in a [HttpInterceptor](./kibana-plugin-public.httpinterceptor.md). | +| [IToasts](./kibana-plugin-public.itoasts.md) | | | [LegacyCoreSetup](./kibana-plugin-public.legacycoresetup.md) | Setup interface exposed to the legacy platform via the ui/new_platform module. | | [LegacyCoreStart](./kibana-plugin-public.legacycorestart.md) | Start interface exposed to the legacy platform via the ui/new_platform module. | | [LegacyNavLink](./kibana-plugin-public.legacynavlink.md) | | @@ -95,9 +96,9 @@ The plugin integrates with the core system via lifecycle events: `setup` | [HandlerFunction](./kibana-plugin-public.handlerfunction.md) | A function that accepts a context object and an optional number of additional arguments. Used for the generic types in [IContextContainer](./kibana-plugin-public.icontextcontainer.md) | | [HandlerParameters](./kibana-plugin-public.handlerparameters.md) | Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-public.handlerfunction.md), excluding the [HandlerContextType](./kibana-plugin-public.handlercontexttype.md). | | [HttpBody](./kibana-plugin-public.httpbody.md) | | -| [HttpHandler](./kibana-plugin-public.httphandler.md) | | -| [HttpSetup](./kibana-plugin-public.httpsetup.md) | | -| [HttpStart](./kibana-plugin-public.httpstart.md) | | +| [HttpHandler](./kibana-plugin-public.httphandler.md) | A function for making an HTTP requests to Kibana's backend. See [HttpFetchOptions](./kibana-plugin-public.httpfetchoptions.md) for options and [HttpBody](./kibana-plugin-public.httpbody.md) for the response. | +| [HttpSetup](./kibana-plugin-public.httpsetup.md) | See [HttpServiceBase](./kibana-plugin-public.httpservicebase.md) | +| [HttpStart](./kibana-plugin-public.httpstart.md) | See [HttpServiceBase](./kibana-plugin-public.httpservicebase.md) | | [IContextProvider](./kibana-plugin-public.icontextprovider.md) | A function that returns a context value for a specific key of given context type. | | [OverlayBannerMount](./kibana-plugin-public.overlaybannermount.md) | A function that will mount the banner inside the provided element. | | [OverlayBannerUnmount](./kibana-plugin-public.overlaybannerunmount.md) | A function that will unmount the banner from the element. | @@ -108,5 +109,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [SavedObjectAttributeSingle](./kibana-plugin-public.savedobjectattributesingle.md) | Don't use this type, it's simply a helper type for [SavedObjectAttribute](./kibana-plugin-public.savedobjectattribute.md) | | [SavedObjectsClientContract](./kibana-plugin-public.savedobjectsclientcontract.md) | SavedObjectsClientContract as implemented by the [SavedObjectsClient](./kibana-plugin-public.savedobjectsclient.md) | | [ToastInput](./kibana-plugin-public.toastinput.md) | | +| [ToastsSetup](./kibana-plugin-public.toastssetup.md) | [IToasts](./kibana-plugin-public.itoasts.md) | +| [ToastsStart](./kibana-plugin-public.toastsstart.md) | [IToasts](./kibana-plugin-public.itoasts.md) | | [UiSettingsClientContract](./kibana-plugin-public.uisettingsclientcontract.md) | [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) | diff --git a/docs/development/core/public/kibana-plugin-public.notificationssetup.md b/docs/development/core/public/kibana-plugin-public.notificationssetup.md index 7d9dd2e89f851..c03abf9d01dca 100644 --- a/docs/development/core/public/kibana-plugin-public.notificationssetup.md +++ b/docs/development/core/public/kibana-plugin-public.notificationssetup.md @@ -15,5 +15,5 @@ export interface NotificationsSetup | Property | Type | Description | | --- | --- | --- | -| [toasts](./kibana-plugin-public.notificationssetup.toasts.md) | ToastsSetup | | +| [toasts](./kibana-plugin-public.notificationssetup.toasts.md) | ToastsSetup | [ToastsSetup](./kibana-plugin-public.toastssetup.md) | diff --git a/docs/development/core/public/kibana-plugin-public.notificationssetup.toasts.md b/docs/development/core/public/kibana-plugin-public.notificationssetup.toasts.md index c44ec9ca93e65..dd613a959061e 100644 --- a/docs/development/core/public/kibana-plugin-public.notificationssetup.toasts.md +++ b/docs/development/core/public/kibana-plugin-public.notificationssetup.toasts.md @@ -4,6 +4,8 @@ ## NotificationsSetup.toasts property +[ToastsSetup](./kibana-plugin-public.toastssetup.md) + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.notificationsstart.md b/docs/development/core/public/kibana-plugin-public.notificationsstart.md index acab2d6884418..56a1ce2095742 100644 --- a/docs/development/core/public/kibana-plugin-public.notificationsstart.md +++ b/docs/development/core/public/kibana-plugin-public.notificationsstart.md @@ -15,5 +15,5 @@ export interface NotificationsStart | Property | Type | Description | | --- | --- | --- | -| [toasts](./kibana-plugin-public.notificationsstart.toasts.md) | ToastsStart | | +| [toasts](./kibana-plugin-public.notificationsstart.toasts.md) | ToastsStart | [ToastsStart](./kibana-plugin-public.toastsstart.md) | diff --git a/docs/development/core/public/kibana-plugin-public.notificationsstart.toasts.md b/docs/development/core/public/kibana-plugin-public.notificationsstart.toasts.md index db2be3dad8351..9d2c685946fda 100644 --- a/docs/development/core/public/kibana-plugin-public.notificationsstart.toasts.md +++ b/docs/development/core/public/kibana-plugin-public.notificationsstart.toasts.md @@ -4,6 +4,8 @@ ## NotificationsStart.toasts property +[ToastsStart](./kibana-plugin-public.toastsstart.md) + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi._constructor_.md b/docs/development/core/public/kibana-plugin-public.toastsapi._constructor_.md deleted file mode 100644 index 31a16403a41a1..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.toastsapi._constructor_.md +++ /dev/null @@ -1,22 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [(constructor)](./kibana-plugin-public.toastsapi._constructor_.md) - -## ToastsApi.(constructor) - -Constructs a new instance of the `ToastsApi` class - -Signature: - -```typescript -constructor(deps: { - uiSettings: UiSettingsClientContract; - }); -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| deps | {
uiSettings: UiSettingsClientContract;
} | | - diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi.adddanger.md b/docs/development/core/public/kibana-plugin-public.toastsapi.adddanger.md deleted file mode 100644 index 3f9e6b1c389da..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.toastsapi.adddanger.md +++ /dev/null @@ -1,22 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [addDanger](./kibana-plugin-public.toastsapi.adddanger.md) - -## ToastsApi.addDanger() method - -Signature: - -```typescript -addDanger(toastOrTitle: ToastInput): Toast; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| toastOrTitle | ToastInput | | - -Returns: - -`Toast` - diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi.adderror.md b/docs/development/core/public/kibana-plugin-public.toastsapi.adderror.md deleted file mode 100644 index 10aaf50ebab4d..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.toastsapi.adderror.md +++ /dev/null @@ -1,23 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [addError](./kibana-plugin-public.toastsapi.adderror.md) - -## ToastsApi.addError() method - -Signature: - -```typescript -addError(error: Error, options: ErrorToastOptions): Toast; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| error | Error | | -| options | ErrorToastOptions | | - -Returns: - -`Toast` - diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi.addsuccess.md b/docs/development/core/public/kibana-plugin-public.toastsapi.addsuccess.md deleted file mode 100644 index 5aff3229b3c81..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.toastsapi.addsuccess.md +++ /dev/null @@ -1,22 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [addSuccess](./kibana-plugin-public.toastsapi.addsuccess.md) - -## ToastsApi.addSuccess() method - -Signature: - -```typescript -addSuccess(toastOrTitle: ToastInput): Toast; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| toastOrTitle | ToastInput | | - -Returns: - -`Toast` - diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi.addwarning.md b/docs/development/core/public/kibana-plugin-public.toastsapi.addwarning.md deleted file mode 100644 index 3b68f0b7fe22a..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.toastsapi.addwarning.md +++ /dev/null @@ -1,22 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [addWarning](./kibana-plugin-public.toastsapi.addwarning.md) - -## ToastsApi.addWarning() method - -Signature: - -```typescript -addWarning(toastOrTitle: ToastInput): Toast; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| toastOrTitle | ToastInput | | - -Returns: - -`Toast` - diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi.md b/docs/development/core/public/kibana-plugin-public.toastsapi.md deleted file mode 100644 index 1d5e0382d9465..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.toastsapi.md +++ /dev/null @@ -1,32 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) - -## ToastsApi class - - -Signature: - -```typescript -export declare class ToastsApi -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(deps)](./kibana-plugin-public.toastsapi._constructor_.md) | | Constructs a new instance of the ToastsApi class | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [add(toastOrTitle)](./kibana-plugin-public.toastsapi.add.md) | | | -| [addDanger(toastOrTitle)](./kibana-plugin-public.toastsapi.adddanger.md) | | | -| [addError(error, options)](./kibana-plugin-public.toastsapi.adderror.md) | | | -| [addSuccess(toastOrTitle)](./kibana-plugin-public.toastsapi.addsuccess.md) | | | -| [addWarning(toastOrTitle)](./kibana-plugin-public.toastsapi.addwarning.md) | | | -| [get$()](./kibana-plugin-public.toastsapi.get_.md) | | | -| [registerOverlays(overlays)](./kibana-plugin-public.toastsapi.registeroverlays.md) | | | -| [remove(toast)](./kibana-plugin-public.toastsapi.remove.md) | | | - diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi.registeroverlays.md b/docs/development/core/public/kibana-plugin-public.toastsapi.registeroverlays.md deleted file mode 100644 index 31601e9b215bc..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.toastsapi.registeroverlays.md +++ /dev/null @@ -1,22 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [registerOverlays](./kibana-plugin-public.toastsapi.registeroverlays.md) - -## ToastsApi.registerOverlays() method - -Signature: - -```typescript -registerOverlays(overlays: OverlayStart): void; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| overlays | OverlayStart | | - -Returns: - -`void` - diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi.remove.md b/docs/development/core/public/kibana-plugin-public.toastsapi.remove.md deleted file mode 100644 index 822677a42b630..0000000000000 --- a/docs/development/core/public/kibana-plugin-public.toastsapi.remove.md +++ /dev/null @@ -1,22 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [remove](./kibana-plugin-public.toastsapi.remove.md) - -## ToastsApi.remove() method - -Signature: - -```typescript -remove(toast: Toast): void; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| toast | Toast | | - -Returns: - -`void` - diff --git a/docs/development/core/public/kibana-plugin-public.toastssetup.md b/docs/development/core/public/kibana-plugin-public.toastssetup.md new file mode 100644 index 0000000000000..e06dd7f7093bb --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.toastssetup.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsSetup](./kibana-plugin-public.toastssetup.md) + +## ToastsSetup type + +[IToasts](./kibana-plugin-public.itoasts.md) + +Signature: + +```typescript +export declare type ToastsSetup = IToasts; +``` diff --git a/docs/development/core/public/kibana-plugin-public.toastsstart.md b/docs/development/core/public/kibana-plugin-public.toastsstart.md new file mode 100644 index 0000000000000..6e090dcdc64fb --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.toastsstart.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsStart](./kibana-plugin-public.toastsstart.md) + +## ToastsStart type + +[IToasts](./kibana-plugin-public.itoasts.md) + +Signature: + +```typescript +export declare type ToastsStart = IToasts; +``` diff --git a/docs/development/core/server/kibana-plugin-server.authenticationhandler.md b/docs/development/core/server/kibana-plugin-server.authenticationhandler.md index ced5cfd9413ec..7b845b49eab59 100644 --- a/docs/development/core/server/kibana-plugin-server.authenticationhandler.md +++ b/docs/development/core/server/kibana-plugin-server.authenticationhandler.md @@ -4,6 +4,7 @@ ## AuthenticationHandler type +See [AuthToolkit](./kibana-plugin-server.authtoolkit.md). Signature: diff --git a/docs/development/core/server/kibana-plugin-server.basepath.md b/docs/development/core/server/kibana-plugin-server.basepath.md index bfa1ea02aec17..da833c71bf93b 100644 --- a/docs/development/core/server/kibana-plugin-server.basepath.md +++ b/docs/development/core/server/kibana-plugin-server.basepath.md @@ -17,8 +17,8 @@ export declare class BasePath | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [get](./kibana-plugin-server.basepath.get.md) | | (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>) => string | returns basePath value, specific for an incoming request. | -| [prepend](./kibana-plugin-server.basepath.prepend.md) | | (path: string) => string | returns a new basePath value, prefixed with passed url. | -| [remove](./kibana-plugin-server.basepath.remove.md) | | (path: string) => string | returns a new basePath value, cleaned up from passed url. | +| [prepend](./kibana-plugin-server.basepath.prepend.md) | | (path: string) => string | Prepends path with the basePath. | +| [remove](./kibana-plugin-server.basepath.remove.md) | | (path: string) => string | Removes the prepended basePath from the path. | | [serverBasePath](./kibana-plugin-server.basepath.serverbasepath.md) | | string | returns the server's basePathSee [BasePath.get](./kibana-plugin-server.basepath.get.md) for getting the basePath value for a specific request | | [set](./kibana-plugin-server.basepath.set.md) | | (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>, requestSpecificBasePath: string) => void | sets basePath value, specific for an incoming request. | diff --git a/docs/development/core/server/kibana-plugin-server.basepath.prepend.md b/docs/development/core/server/kibana-plugin-server.basepath.prepend.md index 113e8d9bf4880..9a615dfe80f32 100644 --- a/docs/development/core/server/kibana-plugin-server.basepath.prepend.md +++ b/docs/development/core/server/kibana-plugin-server.basepath.prepend.md @@ -4,7 +4,7 @@ ## BasePath.prepend property -returns a new `basePath` value, prefixed with passed `url`. +Prepends `path` with the basePath. Signature: diff --git a/docs/development/core/server/kibana-plugin-server.basepath.remove.md b/docs/development/core/server/kibana-plugin-server.basepath.remove.md index c5f1092d2969d..8fcfbc2b921d3 100644 --- a/docs/development/core/server/kibana-plugin-server.basepath.remove.md +++ b/docs/development/core/server/kibana-plugin-server.basepath.remove.md @@ -4,7 +4,7 @@ ## BasePath.remove property -returns a new `basePath` value, cleaned up from passed `url`. +Removes the prepended basePath from the `path`. Signature: diff --git a/docs/development/core/server/kibana-plugin-server.clusterclient.asscoped.md b/docs/development/core/server/kibana-plugin-server.clusterclient.asscoped.md index f87fc34bdc45f..ed7d028a1ec8a 100644 --- a/docs/development/core/server/kibana-plugin-server.clusterclient.asscoped.md +++ b/docs/development/core/server/kibana-plugin-server.clusterclient.asscoped.md @@ -4,7 +4,7 @@ ## ClusterClient.asScoped() method -Creates an instance of `ScopedClusterClient` based on the configuration the current cluster client that exposes additional `callAsCurrentUser` method scoped to the provided req. Consumers shouldn't worry about closing scoped client instances, these will be automatically closed as soon as the original cluster client isn't needed anymore and closed. +Creates an instance of [IScopedClusterClient](./kibana-plugin-server.iscopedclusterclient.md) based on the configuration the current cluster client that exposes additional `callAsCurrentUser` method scoped to the provided req. Consumers shouldn't worry about closing scoped client instances, these will be automatically closed as soon as the original cluster client isn't needed anymore and closed. Signature: @@ -16,7 +16,7 @@ asScoped(request?: KibanaRequest | LegacyRequest | FakeRequest): IScopedClusterC | Parameter | Type | Description | | --- | --- | --- | -| request | KibanaRequest | LegacyRequest | FakeRequest | Request the ScopedClusterClient instance will be scoped to. Supports request optionality, Legacy.Request & FakeRequest for BWC with LegacyPlatform | +| request | KibanaRequest | LegacyRequest | FakeRequest | Request the IScopedClusterClient instance will be scoped to. Supports request optionality, Legacy.Request & FakeRequest for BWC with LegacyPlatform | Returns: diff --git a/docs/development/core/server/kibana-plugin-server.clusterclient.callasinternaluser.md b/docs/development/core/server/kibana-plugin-server.clusterclient.callasinternaluser.md index 74003189c765d..7afb6afa4bc3b 100644 --- a/docs/development/core/server/kibana-plugin-server.clusterclient.callasinternaluser.md +++ b/docs/development/core/server/kibana-plugin-server.clusterclient.callasinternaluser.md @@ -4,7 +4,7 @@ ## ClusterClient.callAsInternalUser property -Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. +Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. See [APICaller](./kibana-plugin-server.apicaller.md). Signature: diff --git a/docs/development/core/server/kibana-plugin-server.clusterclient.md b/docs/development/core/server/kibana-plugin-server.clusterclient.md index 6288bc0a07c11..5fdda7ef3e499 100644 --- a/docs/development/core/server/kibana-plugin-server.clusterclient.md +++ b/docs/development/core/server/kibana-plugin-server.clusterclient.md @@ -24,12 +24,12 @@ export declare class ClusterClient implements IClusterClient | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [callAsInternalUser](./kibana-plugin-server.clusterclient.callasinternaluser.md) | | APICaller | Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. | +| [callAsInternalUser](./kibana-plugin-server.clusterclient.callasinternaluser.md) | | APICaller | Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. See [APICaller](./kibana-plugin-server.apicaller.md). | ## Methods | Method | Modifiers | Description | | --- | --- | --- | -| [asScoped(request)](./kibana-plugin-server.clusterclient.asscoped.md) | | Creates an instance of ScopedClusterClient based on the configuration the current cluster client that exposes additional callAsCurrentUser method scoped to the provided req. Consumers shouldn't worry about closing scoped client instances, these will be automatically closed as soon as the original cluster client isn't needed anymore and closed. | +| [asScoped(request)](./kibana-plugin-server.clusterclient.asscoped.md) | | Creates an instance of [IScopedClusterClient](./kibana-plugin-server.iscopedclusterclient.md) based on the configuration the current cluster client that exposes additional callAsCurrentUser method scoped to the provided req. Consumers shouldn't worry about closing scoped client instances, these will be automatically closed as soon as the original cluster client isn't needed anymore and closed. | | [close()](./kibana-plugin-server.clusterclient.close.md) | | Closes the cluster client. After that client cannot be used and one should create a new client instance to be able to interact with Elasticsearch API. | diff --git a/docs/development/core/server/kibana-plugin-server.coresetup.context.md b/docs/development/core/server/kibana-plugin-server.coresetup.context.md index e98cd6a0d04e1..63c37eec70b05 100644 --- a/docs/development/core/server/kibana-plugin-server.coresetup.context.md +++ b/docs/development/core/server/kibana-plugin-server.coresetup.context.md @@ -4,10 +4,10 @@ ## CoreSetup.context property +[ContextSetup](./kibana-plugin-server.contextsetup.md) + Signature: ```typescript -context: { - createContextContainer: ContextSetup['createContextContainer']; - }; +context: ContextSetup; ``` diff --git a/docs/development/core/server/kibana-plugin-server.coresetup.elasticsearch.md b/docs/development/core/server/kibana-plugin-server.coresetup.elasticsearch.md index dfe1839babdad..9498e0223350d 100644 --- a/docs/development/core/server/kibana-plugin-server.coresetup.elasticsearch.md +++ b/docs/development/core/server/kibana-plugin-server.coresetup.elasticsearch.md @@ -4,12 +4,10 @@ ## CoreSetup.elasticsearch property +[ElasticsearchServiceSetup](./kibana-plugin-server.elasticsearchservicesetup.md) + Signature: ```typescript -elasticsearch: { - adminClient$: Observable; - dataClient$: Observable; - createClient: (type: string, clientConfig?: Partial) => IClusterClient; - }; +elasticsearch: ElasticsearchServiceSetup; ``` diff --git a/docs/development/core/server/kibana-plugin-server.coresetup.http.md b/docs/development/core/server/kibana-plugin-server.coresetup.http.md index 8474f4ef940dc..09b12bca7b275 100644 --- a/docs/development/core/server/kibana-plugin-server.coresetup.http.md +++ b/docs/development/core/server/kibana-plugin-server.coresetup.http.md @@ -4,17 +4,10 @@ ## CoreSetup.http property +[HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) + Signature: ```typescript -http: { - createCookieSessionStorageFactory: HttpServiceSetup['createCookieSessionStorageFactory']; - registerOnPreAuth: HttpServiceSetup['registerOnPreAuth']; - registerAuth: HttpServiceSetup['registerAuth']; - registerOnPostAuth: HttpServiceSetup['registerOnPostAuth']; - basePath: HttpServiceSetup['basePath']; - isTlsEnabled: HttpServiceSetup['isTlsEnabled']; - registerRouteHandlerContext: (name: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer; - createRouter: () => IRouter; - }; +http: HttpServiceSetup; ``` diff --git a/docs/development/core/server/kibana-plugin-server.coresetup.md b/docs/development/core/server/kibana-plugin-server.coresetup.md index a53f807d001bd..a6dda69fd154e 100644 --- a/docs/development/core/server/kibana-plugin-server.coresetup.md +++ b/docs/development/core/server/kibana-plugin-server.coresetup.md @@ -16,7 +16,7 @@ export interface CoreSetup | Property | Type | Description | | --- | --- | --- | -| [context](./kibana-plugin-server.coresetup.context.md) | {
createContextContainer: ContextSetup['createContextContainer'];
} | | -| [elasticsearch](./kibana-plugin-server.coresetup.elasticsearch.md) | {
adminClient$: Observable<IClusterClient>;
dataClient$: Observable<IClusterClient>;
createClient: (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => IClusterClient;
} | | -| [http](./kibana-plugin-server.coresetup.http.md) | {
createCookieSessionStorageFactory: HttpServiceSetup['createCookieSessionStorageFactory'];
registerOnPreAuth: HttpServiceSetup['registerOnPreAuth'];
registerAuth: HttpServiceSetup['registerAuth'];
registerOnPostAuth: HttpServiceSetup['registerOnPostAuth'];
basePath: HttpServiceSetup['basePath'];
isTlsEnabled: HttpServiceSetup['isTlsEnabled'];
registerRouteHandlerContext: <T extends keyof RequestHandlerContext>(name: T, provider: RequestHandlerContextProvider<T>) => RequestHandlerContextContainer;
createRouter: () => IRouter;
} | | +| [context](./kibana-plugin-server.coresetup.context.md) | ContextSetup | [ContextSetup](./kibana-plugin-server.contextsetup.md) | +| [elasticsearch](./kibana-plugin-server.coresetup.elasticsearch.md) | ElasticsearchServiceSetup | [ElasticsearchServiceSetup](./kibana-plugin-server.elasticsearchservicesetup.md) | +| [http](./kibana-plugin-server.coresetup.http.md) | HttpServiceSetup | [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | diff --git a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.adminclient_.md b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.adminclient_.md index 31cf07ac66a46..4c3de56938d2d 100644 --- a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.adminclient_.md +++ b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.adminclient_.md @@ -4,6 +4,14 @@ ## ElasticsearchServiceSetup.adminClient$ property +Observable of clients for the `admin` cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md) + + +```js +const client = await elasticsearch.adminClient$.pipe(take(1)).toPromise(); + +``` + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.createclient.md b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.createclient.md index 34d04d26e9654..3d26f2d4cec88 100644 --- a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.createclient.md +++ b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.createclient.md @@ -4,7 +4,7 @@ ## ElasticsearchServiceSetup.createClient property -Create application specific Elasticsearch cluster API client with customized config. +Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-server.iclusterclient.md). Signature: diff --git a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.dataclient_.md b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.dataclient_.md index 240dff2e53635..eafc0f3929374 100644 --- a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.dataclient_.md +++ b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.dataclient_.md @@ -4,6 +4,14 @@ ## ElasticsearchServiceSetup.dataClient$ property +Observable of clients for the `data` cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md) + + +```js +const client = await elasticsearch.dataClient$.pipe(take(1)).toPromise(); + +``` + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.legacy.md b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.legacy.md deleted file mode 100644 index 6040b407dd415..0000000000000 --- a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.legacy.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [ElasticsearchServiceSetup](./kibana-plugin-server.elasticsearchservicesetup.md) > [legacy](./kibana-plugin-server.elasticsearchservicesetup.legacy.md) - -## ElasticsearchServiceSetup.legacy property - -Signature: - -```typescript -readonly legacy: { - readonly config$: Observable; - }; -``` diff --git a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md index 9c3b92a88fe07..4690033be6e2d 100644 --- a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md +++ b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md @@ -15,8 +15,17 @@ export interface ElasticsearchServiceSetup | Property | Type | Description | | --- | --- | --- | -| [adminClient$](./kibana-plugin-server.elasticsearchservicesetup.adminclient_.md) | Observable<IClusterClient> | | -| [createClient](./kibana-plugin-server.elasticsearchservicesetup.createclient.md) | (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => IClusterClient | Create application specific Elasticsearch cluster API client with customized config. | -| [dataClient$](./kibana-plugin-server.elasticsearchservicesetup.dataclient_.md) | Observable<IClusterClient> | | -| [legacy](./kibana-plugin-server.elasticsearchservicesetup.legacy.md) | {
readonly config$: Observable<ElasticsearchConfig>;
} | | +| [adminClient$](./kibana-plugin-server.elasticsearchservicesetup.adminclient_.md) | Observable<IClusterClient> | Observable of clients for the admin cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md) +```js +const client = await elasticsearch.adminClient$.pipe(take(1)).toPromise(); + +``` + | +| [createClient](./kibana-plugin-server.elasticsearchservicesetup.createclient.md) | (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => IClusterClient | Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-server.iclusterclient.md). | +| [dataClient$](./kibana-plugin-server.elasticsearchservicesetup.dataclient_.md) | Observable<IClusterClient> | Observable of clients for the data cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md) +```js +const client = await elasticsearch.dataClient$.pipe(take(1)).toPromise(); + +``` + | diff --git a/docs/development/core/server/kibana-plugin-server.httpserversetup.auth.md b/docs/development/core/server/kibana-plugin-server.httpserversetup.auth.md deleted file mode 100644 index e39c3c6316768..0000000000000 --- a/docs/development/core/server/kibana-plugin-server.httpserversetup.auth.md +++ /dev/null @@ -1,15 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServerSetup](./kibana-plugin-server.httpserversetup.md) > [auth](./kibana-plugin-server.httpserversetup.auth.md) - -## HttpServerSetup.auth property - -Signature: - -```typescript -auth: { - get: GetAuthState; - isAuthenticated: IsAuthenticated; - getAuthHeaders: GetAuthHeaders; - }; -``` diff --git a/docs/development/core/server/kibana-plugin-server.httpserversetup.basepath.md b/docs/development/core/server/kibana-plugin-server.httpserversetup.basepath.md deleted file mode 100644 index 173262de10494..0000000000000 --- a/docs/development/core/server/kibana-plugin-server.httpserversetup.basepath.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServerSetup](./kibana-plugin-server.httpserversetup.md) > [basePath](./kibana-plugin-server.httpserversetup.basepath.md) - -## HttpServerSetup.basePath property - -[BasePath](./kibana-plugin-server.basepath.md) - -Signature: - -```typescript -basePath: IBasePath; -``` diff --git a/docs/development/core/server/kibana-plugin-server.httpserversetup.md b/docs/development/core/server/kibana-plugin-server.httpserversetup.md deleted file mode 100644 index 7a126383116e7..0000000000000 --- a/docs/development/core/server/kibana-plugin-server.httpserversetup.md +++ /dev/null @@ -1,93 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServerSetup](./kibana-plugin-server.httpserversetup.md) - -## HttpServerSetup interface - -Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to `hapi` server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. - -Signature: - -```typescript -export interface HttpServerSetup -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [auth](./kibana-plugin-server.httpserversetup.auth.md) | {
get: GetAuthState;
isAuthenticated: IsAuthenticated;
getAuthHeaders: GetAuthHeaders;
} | | -| [basePath](./kibana-plugin-server.httpserversetup.basepath.md) | IBasePath | [BasePath](./kibana-plugin-server.basepath.md) | -| [createCookieSessionStorageFactory](./kibana-plugin-server.httpserversetup.createcookiesessionstoragefactory.md) | <T>(cookieOptions: SessionStorageCookieOptions<T>) => Promise<SessionStorageFactory<T>> | Creates cookie based session storage factory [SessionStorageFactory](./kibana-plugin-server.sessionstoragefactory.md) | -| [isTlsEnabled](./kibana-plugin-server.httpserversetup.istlsenabled.md) | boolean | Flag showing whether a server was configured to use TLS connection. | -| [registerAuth](./kibana-plugin-server.httpserversetup.registerauth.md) | (handler: AuthenticationHandler) => void | 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) | (handler: OnPostAuthHandler) => void | 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) | (handler: OnPreAuthHandler) => void | 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) | (router: IRouter) => void | Add all the routes registered with router to HTTP server request listeners. | -| [server](./kibana-plugin-server.httpserversetup.server.md) | Server | | - -## Example - -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 -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`. - -```ts -import { schema, TypeOf } from '@kbn/config-schema'; -const validate = { - params: schema.object({ - id: schema.string(), - }), -}; - -``` -- Declare a function to respond to incoming request. The function will receive `request` object containing request details: url, headers, matched route, as well as validated `params`, `query`, `body`. And `response` object instructing HTTP server to create HTTP response with information sent back to the client as the response body, headers, and HTTP status. Unlike, `hapi` route handler in the Legacy platform, any exception raised during the handler call will generate `500 Server error` response and log error details for further investigation. See below for returning custom error responses. - -```ts -const handler = async (context: RequestHandlerContext, request: KibanaRequest, response: ResponseFactory) => { - const data = await findObject(request.params.id); - // creates a command to respond with 'not found' error - if (!data) return response.notFound(); - // creates a command to send found data to the client and set response headers - return response.ok({ - body: data, - headers: { - 'content-type': 'application/json' - } - }); -} - -``` -- Register route handler for GET request to 'my-app/path/{id}' path - -```ts -import { schema, TypeOf } from '@kbn/config-schema'; -const router = httpSetup.createRouter(); - -const validate = { - params: schema.object({ - id: schema.string(), - }), -}; - -router.get({ - path: 'path/{id}', - validate -}, -async (context, request, response) => { - const data = await findObject(request.params.id); - if (!data) return response.notFound(); - return response.ok({ - body: data, - headers: { - 'content-type': 'application/json' - } - }); -}); - -``` - diff --git a/docs/development/core/server/kibana-plugin-server.httpserversetup.registerauth.md b/docs/development/core/server/kibana-plugin-server.httpserversetup.registerauth.md deleted file mode 100644 index 6e63e0996a63a..0000000000000 --- a/docs/development/core/server/kibana-plugin-server.httpserversetup.registerauth.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServerSetup](./kibana-plugin-server.httpserversetup.md) > [registerAuth](./kibana-plugin-server.httpserversetup.registerauth.md) - -## HttpServerSetup.registerAuth property - -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. - -Signature: - -```typescript -registerAuth: (handler: AuthenticationHandler) => void; -``` diff --git a/docs/development/core/server/kibana-plugin-server.httpserversetup.registeronpostauth.md b/docs/development/core/server/kibana-plugin-server.httpserversetup.registeronpostauth.md deleted file mode 100644 index c74a67da350ec..0000000000000 --- a/docs/development/core/server/kibana-plugin-server.httpserversetup.registeronpostauth.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServerSetup](./kibana-plugin-server.httpserversetup.md) > [registerOnPostAuth](./kibana-plugin-server.httpserversetup.registeronpostauth.md) - -## HttpServerSetup.registerOnPostAuth property - -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). - -Signature: - -```typescript -registerOnPostAuth: (handler: OnPostAuthHandler) => void; -``` diff --git a/docs/development/core/server/kibana-plugin-server.httpserversetup.registeronpreauth.md b/docs/development/core/server/kibana-plugin-server.httpserversetup.registeronpreauth.md deleted file mode 100644 index f6efa1c1dd73c..0000000000000 --- a/docs/development/core/server/kibana-plugin-server.httpserversetup.registeronpreauth.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServerSetup](./kibana-plugin-server.httpserversetup.md) > [registerOnPreAuth](./kibana-plugin-server.httpserversetup.registeronpreauth.md) - -## HttpServerSetup.registerOnPreAuth property - -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). - -Signature: - -```typescript -registerOnPreAuth: (handler: OnPreAuthHandler) => void; -``` diff --git a/docs/development/core/server/kibana-plugin-server.httpserversetup.registerrouter.md b/docs/development/core/server/kibana-plugin-server.httpserversetup.registerrouter.md deleted file mode 100644 index 32daa650f8d5d..0000000000000 --- a/docs/development/core/server/kibana-plugin-server.httpserversetup.registerrouter.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServerSetup](./kibana-plugin-server.httpserversetup.md) > [registerRouter](./kibana-plugin-server.httpserversetup.registerrouter.md) - -## HttpServerSetup.registerRouter property - -Add all the routes registered with `router` to HTTP server request listeners. - -Signature: - -```typescript -registerRouter: (router: IRouter) => void; -``` diff --git a/docs/development/core/server/kibana-plugin-server.httpserversetup.server.md b/docs/development/core/server/kibana-plugin-server.httpserversetup.server.md deleted file mode 100644 index a137eba7c8a5a..0000000000000 --- a/docs/development/core/server/kibana-plugin-server.httpserversetup.server.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServerSetup](./kibana-plugin-server.httpserversetup.md) > [server](./kibana-plugin-server.httpserversetup.server.md) - -## HttpServerSetup.server property - -Signature: - -```typescript -server: Server; -``` diff --git a/docs/development/core/server/kibana-plugin-server.httpservicesetup.basepath.md b/docs/development/core/server/kibana-plugin-server.httpservicesetup.basepath.md new file mode 100644 index 0000000000000..61390773bd726 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.httpservicesetup.basepath.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) > [basePath](./kibana-plugin-server.httpservicesetup.basepath.md) + +## HttpServiceSetup.basePath property + +Access or manipulate the Kibana base path See [IBasePath](./kibana-plugin-server.ibasepath.md). + +Signature: + +```typescript +basePath: IBasePath; +``` diff --git a/docs/development/core/server/kibana-plugin-server.httpserversetup.createcookiesessionstoragefactory.md b/docs/development/core/server/kibana-plugin-server.httpservicesetup.createcookiesessionstoragefactory.md similarity index 61% rename from docs/development/core/server/kibana-plugin-server.httpserversetup.createcookiesessionstoragefactory.md rename to docs/development/core/server/kibana-plugin-server.httpservicesetup.createcookiesessionstoragefactory.md index 3dc01a52a2f58..4771836bea477 100644 --- a/docs/development/core/server/kibana-plugin-server.httpserversetup.createcookiesessionstoragefactory.md +++ b/docs/development/core/server/kibana-plugin-server.httpservicesetup.createcookiesessionstoragefactory.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServerSetup](./kibana-plugin-server.httpserversetup.md) > [createCookieSessionStorageFactory](./kibana-plugin-server.httpserversetup.createcookiesessionstoragefactory.md) +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) > [createCookieSessionStorageFactory](./kibana-plugin-server.httpservicesetup.createcookiesessionstoragefactory.md) -## HttpServerSetup.createCookieSessionStorageFactory property +## HttpServiceSetup.createCookieSessionStorageFactory property Creates cookie based session storage factory [SessionStorageFactory](./kibana-plugin-server.sessionstoragefactory.md) diff --git a/docs/development/core/server/kibana-plugin-server.httpservicesetup.createrouter.md b/docs/development/core/server/kibana-plugin-server.httpservicesetup.createrouter.md new file mode 100644 index 0000000000000..826136853fd6a --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.httpservicesetup.createrouter.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) > [createRouter](./kibana-plugin-server.httpservicesetup.createrouter.md) + +## HttpServiceSetup.createRouter property + +Provides ability to declare a handler function for a particular path and HTTP request method. + +Signature: + +```typescript +createRouter: () => IRouter; +``` + +## Remarks + +Each route can have only one handler functions, which is executed when the route is matched. All routes are prefixed with plugin name as a first segment of URL path. See the [IRouter](./kibana-plugin-server.irouter.md) documentation for more information. + +## Example + + +```ts +const router = createRouter(); +// handler is called when '${my-plugin-id}/path' resource is requested with `GET` method +router.get({ path: '/path', validate: false }, (context, req, res) => res.ok({ content: 'ok' })); + +``` + diff --git a/docs/development/core/server/kibana-plugin-server.httpserversetup.istlsenabled.md b/docs/development/core/server/kibana-plugin-server.httpservicesetup.istlsenabled.md similarity index 56% rename from docs/development/core/server/kibana-plugin-server.httpserversetup.istlsenabled.md rename to docs/development/core/server/kibana-plugin-server.httpservicesetup.istlsenabled.md index 6961d4feeb7c7..06a99e8bf3013 100644 --- a/docs/development/core/server/kibana-plugin-server.httpserversetup.istlsenabled.md +++ b/docs/development/core/server/kibana-plugin-server.httpservicesetup.istlsenabled.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServerSetup](./kibana-plugin-server.httpserversetup.md) > [isTlsEnabled](./kibana-plugin-server.httpserversetup.istlsenabled.md) +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) > [isTlsEnabled](./kibana-plugin-server.httpservicesetup.istlsenabled.md) -## HttpServerSetup.isTlsEnabled property +## HttpServiceSetup.isTlsEnabled property Flag showing whether a server was configured to use TLS connection. diff --git a/docs/development/core/server/kibana-plugin-server.httpservicesetup.md b/docs/development/core/server/kibana-plugin-server.httpservicesetup.md index eec63cf5c8093..d943ad53af843 100644 --- a/docs/development/core/server/kibana-plugin-server.httpservicesetup.md +++ b/docs/development/core/server/kibana-plugin-server.httpservicesetup.md @@ -2,14 +2,91 @@ [Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) -## HttpServiceSetup type +## HttpServiceSetup interface +Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to `hapi` server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. Signature: ```typescript -export declare type HttpServiceSetup = Omit & { - createRouter: (path: string, plugin?: PluginOpaqueId) => IRouter; - registerRouteHandlerContext: (pluginOpaqueId: PluginOpaqueId, contextName: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer; +export interface HttpServiceSetup +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [basePath](./kibana-plugin-server.httpservicesetup.basepath.md) | IBasePath | Access or manipulate the Kibana base path See [IBasePath](./kibana-plugin-server.ibasepath.md). | +| [createCookieSessionStorageFactory](./kibana-plugin-server.httpservicesetup.createcookiesessionstoragefactory.md) | <T>(cookieOptions: SessionStorageCookieOptions<T>) => Promise<SessionStorageFactory<T>> | Creates cookie based session storage factory [SessionStorageFactory](./kibana-plugin-server.sessionstoragefactory.md) | +| [createRouter](./kibana-plugin-server.httpservicesetup.createrouter.md) | () => IRouter | Provides ability to declare a handler function for a particular path and HTTP request method. | +| [isTlsEnabled](./kibana-plugin-server.httpservicesetup.istlsenabled.md) | boolean | Flag showing whether a server was configured to use TLS connection. | +| [registerAuth](./kibana-plugin-server.httpservicesetup.registerauth.md) | (handler: AuthenticationHandler) => void | To define custom authentication and/or authorization mechanism for incoming requests. | +| [registerOnPostAuth](./kibana-plugin-server.httpservicesetup.registeronpostauth.md) | (handler: OnPostAuthHandler) => void | To define custom logic to perform for incoming requests. | +| [registerOnPreAuth](./kibana-plugin-server.httpservicesetup.registeronpreauth.md) | (handler: OnPreAuthHandler) => void | To define custom logic to perform for incoming requests. | +| [registerRouteHandlerContext](./kibana-plugin-server.httpservicesetup.registerroutehandlercontext.md) | <T extends keyof RequestHandlerContext>(contextName: T, provider: RequestHandlerContextProvider<T>) => RequestHandlerContextContainer | Register a context provider for a route handler. | + +## Example + +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 +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`. + +```ts +import { schema, TypeOf } from '@kbn/config-schema'; +const validate = { + params: schema.object({ + id: schema.string(), + }), +}; + +``` +- Declare a function to respond to incoming request. The function will receive `request` object containing request details: url, headers, matched route, as well as validated `params`, `query`, `body`. And `response` object instructing HTTP server to create HTTP response with information sent back to the client as the response body, headers, and HTTP status. Unlike, `hapi` route handler in the Legacy platform, any exception raised during the handler call will generate `500 Server error` response and log error details for further investigation. See below for returning custom error responses. + +```ts +const handler = async (context: RequestHandlerContext, request: KibanaRequest, response: ResponseFactory) => { + const data = await findObject(request.params.id); + // creates a command to respond with 'not found' error + if (!data) return response.notFound(); + // creates a command to send found data to the client and set response headers + return response.ok({ + body: data, + headers: { + 'content-type': 'application/json' + } + }); +} + +``` +- Register route handler for GET request to 'my-app/path/{id}' path + +```ts +import { schema, TypeOf } from '@kbn/config-schema'; +const router = httpSetup.createRouter(); + +const validate = { + params: schema.object({ + id: schema.string(), + }), }; + +router.get({ + path: 'path/{id}', + validate +}, +async (context, request, response) => { + const data = await findObject(request.params.id); + if (!data) return response.notFound(); + return response.ok({ + body: data, + headers: { + 'content-type': 'application/json' + } + }); +}); + ``` + diff --git a/docs/development/core/server/kibana-plugin-server.httpservicesetup.registerauth.md b/docs/development/core/server/kibana-plugin-server.httpservicesetup.registerauth.md new file mode 100644 index 0000000000000..be3da1ca1131f --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.httpservicesetup.registerauth.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) > [registerAuth](./kibana-plugin-server.httpservicesetup.registerauth.md) + +## HttpServiceSetup.registerAuth property + +To define custom authentication and/or authorization mechanism for incoming requests. + +Signature: + +```typescript +registerAuth: (handler: AuthenticationHandler) => void; +``` + +## Remarks + +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. See [AuthenticationHandler](./kibana-plugin-server.authenticationhandler.md). + diff --git a/docs/development/core/server/kibana-plugin-server.httpservicesetup.registeronpostauth.md b/docs/development/core/server/kibana-plugin-server.httpservicesetup.registeronpostauth.md new file mode 100644 index 0000000000000..a3f875c999af1 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.httpservicesetup.registeronpostauth.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) > [registerOnPostAuth](./kibana-plugin-server.httpservicesetup.registeronpostauth.md) + +## HttpServiceSetup.registerOnPostAuth property + +To define custom logic to perform for incoming requests. + +Signature: + +```typescript +registerOnPostAuth: (handler: OnPostAuthHandler) => void; +``` + +## Remarks + +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). See [OnPostAuthHandler](./kibana-plugin-server.onpostauthhandler.md). + diff --git a/docs/development/core/server/kibana-plugin-server.httpservicesetup.registeronpreauth.md b/docs/development/core/server/kibana-plugin-server.httpservicesetup.registeronpreauth.md new file mode 100644 index 0000000000000..4c7b688619319 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.httpservicesetup.registeronpreauth.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) > [registerOnPreAuth](./kibana-plugin-server.httpservicesetup.registeronpreauth.md) + +## HttpServiceSetup.registerOnPreAuth property + +To define custom logic to perform for incoming requests. + +Signature: + +```typescript +registerOnPreAuth: (handler: OnPreAuthHandler) => void; +``` + +## Remarks + +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). See [OnPreAuthHandler](./kibana-plugin-server.onpreauthhandler.md). + diff --git a/docs/development/core/server/kibana-plugin-server.httpservicesetup.registerroutehandlercontext.md b/docs/development/core/server/kibana-plugin-server.httpservicesetup.registerroutehandlercontext.md new file mode 100644 index 0000000000000..339f2eb329c7b --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.httpservicesetup.registerroutehandlercontext.md @@ -0,0 +1,37 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) > [registerRouteHandlerContext](./kibana-plugin-server.httpservicesetup.registerroutehandlercontext.md) + +## HttpServiceSetup.registerRouteHandlerContext property + +Register a context provider for a route handler. + +Signature: + +```typescript +registerRouteHandlerContext: (contextName: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer; +``` + +## Example + + +```ts + // my-plugin.ts + deps.http.registerRouteHandlerContext( + 'myApp', + (context, req) => { + async function search (id: string) { + return await context.elasticsearch.adminClient.callAsInternalUser('endpoint', id); + } + return { search }; + } + ); + +// my-route-handler.ts + router.get({ path: '/', validate: false }, async (context, req, res) => { + const response = await context.myApp.search(...); + return res.ok(response); + }); + +``` + diff --git a/docs/development/core/server/kibana-plugin-server.irouter.md b/docs/development/core/server/kibana-plugin-server.irouter.md index 2fb2d30eb31d7..bbffe1e42f229 100644 --- a/docs/development/core/server/kibana-plugin-server.irouter.md +++ b/docs/development/core/server/kibana-plugin-server.irouter.md @@ -4,7 +4,7 @@ ## IRouter interface -Registers route handlers for specified resource path and method. +Registers route handlers for specified resource path and method. See [RouteConfig](./kibana-plugin-server.routeconfig.md) and [RequestHandler](./kibana-plugin-server.requesthandler.md) for more information about arguments to route registrations. Signature: diff --git a/docs/development/core/server/kibana-plugin-server.md b/docs/development/core/server/kibana-plugin-server.md index 02bbd028ac419..5e22b7908bddc 100644 --- a/docs/development/core/server/kibana-plugin-server.md +++ b/docs/development/core/server/kibana-plugin-server.md @@ -52,12 +52,12 @@ The plugin integrates with the core system via lifecycle events: `setup` | [ErrorHttpResponseOptions](./kibana-plugin-server.errorhttpresponseoptions.md) | HTTP response parameters | | [FakeRequest](./kibana-plugin-server.fakerequest.md) | Fake request object created manually by Kibana plugins. | | [HttpResponseOptions](./kibana-plugin-server.httpresponseoptions.md) | HTTP response parameters | -| [HttpServerSetup](./kibana-plugin-server.httpserversetup.md) | Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to hapi server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. | +| [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to hapi server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. | | [HttpServiceStart](./kibana-plugin-server.httpservicestart.md) | | | [IContextContainer](./kibana-plugin-server.icontextcontainer.md) | An object that handles registration of context providers and configuring handlers with context. | | [IKibanaSocket](./kibana-plugin-server.ikibanasocket.md) | A tiny abstraction for TCP socket. | | [IndexSettingsDeprecationInfo](./kibana-plugin-server.indexsettingsdeprecationinfo.md) | | -| [IRouter](./kibana-plugin-server.irouter.md) | Registers route handlers for specified resource path and method. | +| [IRouter](./kibana-plugin-server.irouter.md) | Registers route handlers for specified resource path and method. See [RouteConfig](./kibana-plugin-server.routeconfig.md) and [RequestHandler](./kibana-plugin-server.requesthandler.md) for more information about arguments to route registrations. | | [KibanaRequestRoute](./kibana-plugin-server.kibanarequestroute.md) | Request specific route information exposed to a handler. | | [LegacyRequest](./kibana-plugin-server.legacyrequest.md) | | | [LegacyServiceSetupDeps](./kibana-plugin-server.legacyservicesetupdeps.md) | | @@ -116,7 +116,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | Type Alias | Description | | --- | --- | -| [AuthenticationHandler](./kibana-plugin-server.authenticationhandler.md) | | +| [AuthenticationHandler](./kibana-plugin-server.authenticationhandler.md) | See [AuthToolkit](./kibana-plugin-server.authtoolkit.md). | | [AuthHeaders](./kibana-plugin-server.authheaders.md) | Auth Headers map | | [ConfigPath](./kibana-plugin-server.configpath.md) | | | [ElasticsearchClientConfig](./kibana-plugin-server.elasticsearchclientconfig.md) | | @@ -127,7 +127,6 @@ The plugin integrates with the core system via lifecycle events: `setup` | [HandlerParameters](./kibana-plugin-server.handlerparameters.md) | Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md), excluding the [HandlerContextType](./kibana-plugin-server.handlercontexttype.md). | | [Headers](./kibana-plugin-server.headers.md) | Http request headers to read. | | [HttpResponsePayload](./kibana-plugin-server.httpresponsepayload.md) | Data send to the client as a response payload. | -| [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | | | [IBasePath](./kibana-plugin-server.ibasepath.md) | Access or manipulate the Kibana base path[BasePath](./kibana-plugin-server.basepath.md) | | [IClusterClient](./kibana-plugin-server.iclusterclient.md) | Represents an Elasticsearch cluster API client and allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via asScoped(...)).See [ClusterClient](./kibana-plugin-server.clusterclient.md). | | [IContextProvider](./kibana-plugin-server.icontextprovider.md) | A function that returns a context value for a specific key of given context type. | @@ -138,8 +137,8 @@ The plugin integrates with the core system via lifecycle events: `setup` | [LifecycleResponseFactory](./kibana-plugin-server.lifecycleresponsefactory.md) | Creates an object containing redirection or error response with error details, HTTP headers, and other data transmitted to the client. | | [MIGRATION\_ASSISTANCE\_INDEX\_ACTION](./kibana-plugin-server.migration_assistance_index_action.md) | | | [MIGRATION\_DEPRECATION\_LEVEL](./kibana-plugin-server.migration_deprecation_level.md) | | -| [OnPostAuthHandler](./kibana-plugin-server.onpostauthhandler.md) | | -| [OnPreAuthHandler](./kibana-plugin-server.onpreauthhandler.md) | | +| [OnPostAuthHandler](./kibana-plugin-server.onpostauthhandler.md) | See [OnPostAuthToolkit](./kibana-plugin-server.onpostauthtoolkit.md). | +| [OnPreAuthHandler](./kibana-plugin-server.onpreauthhandler.md) | See [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md). | | [PluginInitializer](./kibana-plugin-server.plugininitializer.md) | The plugin export at the root of a plugin's server directory should conform to this interface. | | [PluginName](./kibana-plugin-server.pluginname.md) | Dedicated type for plugin name/id that is supposed to make Map/Set/Arrays that use it as a key or value more obvious. | | [PluginOpaqueId](./kibana-plugin-server.pluginopaqueid.md) | | diff --git a/docs/development/core/server/kibana-plugin-server.onpostauthhandler.md b/docs/development/core/server/kibana-plugin-server.onpostauthhandler.md index 884eb3e6346bd..a887dea26e3bc 100644 --- a/docs/development/core/server/kibana-plugin-server.onpostauthhandler.md +++ b/docs/development/core/server/kibana-plugin-server.onpostauthhandler.md @@ -4,6 +4,7 @@ ## OnPostAuthHandler type +See [OnPostAuthToolkit](./kibana-plugin-server.onpostauthtoolkit.md). Signature: diff --git a/docs/development/core/server/kibana-plugin-server.onpreauthhandler.md b/docs/development/core/server/kibana-plugin-server.onpreauthhandler.md index 5eca904227bb9..003bd4b19eadf 100644 --- a/docs/development/core/server/kibana-plugin-server.onpreauthhandler.md +++ b/docs/development/core/server/kibana-plugin-server.onpreauthhandler.md @@ -4,6 +4,7 @@ ## OnPreAuthHandler type +See [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md). Signature: diff --git a/docs/development/core/server/kibana-plugin-server.routeconfig.md b/docs/development/core/server/kibana-plugin-server.routeconfig.md index 87ec365dc2510..769d0dda42644 100644 --- a/docs/development/core/server/kibana-plugin-server.routeconfig.md +++ b/docs/development/core/server/kibana-plugin-server.routeconfig.md @@ -17,6 +17,6 @@ export interface RouteConfig

RouteConfigOptions | Additional route options [RouteConfigOptions](./kibana-plugin-server.routeconfigoptions.md). | -| [path](./kibana-plugin-server.routeconfig.path.md) | string | The endpoint \_within\_ the router path to register the route. E.g. if the router is registered at /elasticsearch and the route path is /search, the full path for the route is /elasticsearch/search. Supports: - named path segments path/{name}. - optional path segments path/{position?}. - multi-segments path/{coordinates*2}. Segments are accessible within a handler function as params property of [KibanaRequest](./kibana-plugin-server.kibanarequest.md) object. To have read access to params you \*must\* specify validation schema with [RouteConfig.validate](./kibana-plugin-server.routeconfig.validate.md). | -| [validate](./kibana-plugin-server.routeconfig.validate.md) | RouteSchemas<P, Q, B> | false | A schema created with @kbn/config-schema that every request will be validated against. You \*must\* specify a validation schema to be able to read: - url path segments - request query - request body To opt out of validating the request, specify false. | +| [path](./kibana-plugin-server.routeconfig.path.md) | string | The endpoint \_within\_ the router path to register the route. | +| [validate](./kibana-plugin-server.routeconfig.validate.md) | RouteSchemas<P, Q, B> | false | A schema created with @kbn/config-schema that every request will be validated against. | diff --git a/docs/development/core/server/kibana-plugin-server.routeconfig.path.md b/docs/development/core/server/kibana-plugin-server.routeconfig.path.md index 3437f0e0fe064..0e6fa19f98ace 100644 --- a/docs/development/core/server/kibana-plugin-server.routeconfig.path.md +++ b/docs/development/core/server/kibana-plugin-server.routeconfig.path.md @@ -4,10 +4,15 @@ ## RouteConfig.path property -The endpoint \_within\_ the router path to register the route. E.g. if the router is registered at `/elasticsearch` and the route path is `/search`, the full path for the route is `/elasticsearch/search`. Supports: - named path segments `path/{name}`. - optional path segments `path/{position?}`. - multi-segments `path/{coordinates*2}`. Segments are accessible within a handler function as `params` property of [KibanaRequest](./kibana-plugin-server.kibanarequest.md) object. To have read access to `params` you \*must\* specify validation schema with [RouteConfig.validate](./kibana-plugin-server.routeconfig.validate.md). +The endpoint \_within\_ the router path to register the route. Signature: ```typescript path: string; ``` + +## Remarks + +E.g. if the router is registered at `/elasticsearch` and the route path is `/search`, the full path for the route is `/elasticsearch/search`. Supports: - named path segments `path/{name}`. - optional path segments `path/{position?}`. - multi-segments `path/{coordinates*2}`. Segments are accessible within a handler function as `params` property of [KibanaRequest](./kibana-plugin-server.kibanarequest.md) object. To have read access to `params` you \*must\* specify validation schema with [RouteConfig.validate](./kibana-plugin-server.routeconfig.validate.md). + diff --git a/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md b/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md index f7177485f5fb6..cffc4389becdf 100644 --- a/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md +++ b/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md @@ -4,7 +4,7 @@ ## RouteConfig.validate property -A schema created with `@kbn/config-schema` that every request will be validated against. You \*must\* specify a validation schema to be able to read: - url path segments - request query - request body To opt out of validating the request, specify `false`. +A schema created with `@kbn/config-schema` that every request will be validated against. Signature: @@ -12,6 +12,10 @@ A schema created with `@kbn/config-schema` that every request will be validated validate: RouteSchemas | false; ``` +## Remarks + +You \*must\* specify a validation schema to be able to read: - url path segments - request query - request body To opt out of validating the request, specify `false`. + ## Example diff --git a/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callascurrentuser.md b/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callascurrentuser.md index ce0c51be08698..1f53270042185 100644 --- a/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callascurrentuser.md +++ b/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callascurrentuser.md @@ -4,7 +4,7 @@ ## ScopedClusterClient.callAsCurrentUser() method -Calls specified `endpoint` with provided `clientParams` on behalf of the user initiated request to the Kibana server (via HTTP request headers). +Calls specified `endpoint` with provided `clientParams` on behalf of the user initiated request to the Kibana server (via HTTP request headers). See [APICaller](./kibana-plugin-server.apicaller.md). Signature: diff --git a/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callasinternaluser.md b/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callasinternaluser.md index 59811de18d926..7249af7b429e4 100644 --- a/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callasinternaluser.md +++ b/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callasinternaluser.md @@ -4,7 +4,7 @@ ## ScopedClusterClient.callAsInternalUser() method -Calls specified `endpoint` with provided `clientParams` on behalf of the Kibana internal user. +Calls specified `endpoint` with provided `clientParams` on behalf of the Kibana internal user. See [APICaller](./kibana-plugin-server.apicaller.md). Signature: diff --git a/docs/development/core/server/kibana-plugin-server.scopedclusterclient.md b/docs/development/core/server/kibana-plugin-server.scopedclusterclient.md index 7833f698d486d..dcbf869bc9360 100644 --- a/docs/development/core/server/kibana-plugin-server.scopedclusterclient.md +++ b/docs/development/core/server/kibana-plugin-server.scopedclusterclient.md @@ -24,6 +24,6 @@ export declare class ScopedClusterClient implements IScopedClusterClient | Method | Modifiers | Description | | --- | --- | --- | -| [callAsCurrentUser(endpoint, clientParams, options)](./kibana-plugin-server.scopedclusterclient.callascurrentuser.md) | | Calls specified endpoint with provided clientParams on behalf of the user initiated request to the Kibana server (via HTTP request headers). | -| [callAsInternalUser(endpoint, clientParams, options)](./kibana-plugin-server.scopedclusterclient.callasinternaluser.md) | | Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. | +| [callAsCurrentUser(endpoint, clientParams, options)](./kibana-plugin-server.scopedclusterclient.callascurrentuser.md) | | Calls specified endpoint with provided clientParams on behalf of the user initiated request to the Kibana server (via HTTP request headers). See [APICaller](./kibana-plugin-server.apicaller.md). | +| [callAsInternalUser(endpoint, clientParams, options)](./kibana-plugin-server.scopedclusterclient.callasinternaluser.md) | | Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. See [APICaller](./kibana-plugin-server.apicaller.md). | diff --git a/src/core/public/http/http_fetch_error.ts b/src/core/public/http/http_fetch_error.ts index 410369583b3a6..5292afdd56d77 100644 --- a/src/core/public/http/http_fetch_error.ts +++ b/src/core/public/http/http_fetch_error.ts @@ -17,7 +17,10 @@ * under the License. */ -export class HttpFetchError extends Error { +import { IHttpFetchError } from './types'; + +/** @internal */ +export class HttpFetchError extends Error implements IHttpFetchError { constructor( message: string, public readonly request: Request, diff --git a/src/core/public/http/http_intercept_controller.ts b/src/core/public/http/http_intercept_controller.ts index 9934cd8568797..e2ac0335ca548 100644 --- a/src/core/public/http/http_intercept_controller.ts +++ b/src/core/public/http/http_intercept_controller.ts @@ -17,14 +17,17 @@ * under the License. */ -export class HttpInterceptController { +import { IHttpInterceptController } from './types'; + +/** @internal */ +export class HttpInterceptController implements IHttpInterceptController { private _halted = false; public get halted() { return this._halted; } - halt() { + public halt() { this._halted = true; } } diff --git a/src/core/public/http/http_intercept_halt_error.ts b/src/core/public/http/http_intercept_halt_error.ts index 856a912f63c82..65d328f35a42d 100644 --- a/src/core/public/http/http_intercept_halt_error.ts +++ b/src/core/public/http/http_intercept_halt_error.ts @@ -17,6 +17,7 @@ * under the License. */ +/** @internal */ export class HttpInterceptHaltError extends Error { constructor() { super('HTTP Intercept Halt'); diff --git a/src/core/public/http/http_service.ts b/src/core/public/http/http_service.ts index 3bff861441fca..477bcd6152d44 100644 --- a/src/core/public/http/http_service.ts +++ b/src/core/public/http/http_service.ts @@ -17,8 +17,15 @@ * under the License. */ -import { HttpDeps, HttpSetup, HttpStart, HttpServiceBase } from './types'; +import { HttpSetup, HttpStart, HttpServiceBase } from './types'; import { setup } from './http_setup'; +import { InjectedMetadataSetup } from '../injected_metadata'; +import { FatalErrorsSetup } from '../fatal_errors'; + +interface HttpDeps { + injectedMetadata: InjectedMetadataSetup; + fatalErrors: FatalErrorsSetup | null; +} /** @internal */ export class HttpService { diff --git a/src/core/public/http/index.ts b/src/core/public/http/index.ts index 3edbbc2e362a4..d4aced6894526 100644 --- a/src/core/public/http/index.ts +++ b/src/core/public/http/index.ts @@ -18,7 +18,4 @@ */ export { HttpService } from './http_service'; -export { HttpFetchError } from './http_fetch_error'; -export { HttpInterceptHaltError } from './http_intercept_halt_error'; -export { HttpInterceptController } from './http_intercept_controller'; export * from './types'; diff --git a/src/core/public/http/types.ts b/src/core/public/http/types.ts index 293c125f9ad83..4aa872ca59fb6 100644 --- a/src/core/public/http/types.ts +++ b/src/core/public/http/types.ts @@ -18,84 +18,224 @@ */ import { Observable } from 'rxjs'; -import { InjectedMetadataSetup } from '../injected_metadata'; -import { FatalErrorsSetup } from '../fatal_errors'; -import { HttpInterceptController } from './http_intercept_controller'; -import { HttpFetchError } from './http_fetch_error'; /** @public */ export interface HttpServiceBase { + /** @internal */ stop(): void; - basePath: { - get: () => string; - prepend: (url: string) => string; - remove: (url: string) => string; - }; + + /** + * APIs for manipulating the basePath on URL segments. + */ + basePath: IBasePath; + + /** + * Adds a new {@link HTTPInterceptor} to the global HTTP client. + * @param interceptor a {@link HTTPInterceptor} + * @returns a function for removing the attached interceptor. + */ intercept(interceptor: HttpInterceptor): () => void; + + /** + * Removes all configured interceptors. + */ removeAllInterceptors(): void; + + /** Makes an HTTP request. Defaults to a GET request unless overriden. See {@link HttpHandler} for options. */ fetch: HttpHandler; + /** Makes an HTTP request with the DELETE method. See {@link HttpHandler} for options. */ delete: HttpHandler; + /** Makes an HTTP request with the GET method. See {@link HttpHandler} for options. */ get: HttpHandler; + /** Makes an HTTP request with the HEAD method. See {@link HttpHandler} for options. */ head: HttpHandler; + /** Makes an HTTP request with the OPTIONS method. See {@link HttpHandler} for options. */ options: HttpHandler; + /** Makes an HTTP request with the PATCH method. See {@link HttpHandler} for options. */ patch: HttpHandler; + /** Makes an HTTP request with the POST method. See {@link HttpHandler} for options. */ post: HttpHandler; + /** Makes an HTTP request with the PUT method. See {@link HttpHandler} for options. */ put: HttpHandler; - addLoadingCount(count$: Observable): void; + + /** + * Adds a new source of loading counts. Used to show the global loading indicator when sum of all observed counts are + * more than 0. + * @param countSource$ an Observable to subscribe to for loading count updates. + */ + addLoadingCount(countSource$: Observable): void; + + /** + * Get the sum of all loading count sources as a single Observable. + */ getLoadingCount$(): Observable; } -/** @public */ + +export interface IBasePath { + /** + * Gets the `basePath` string. + */ + get: () => string; + + /** + * Prepends `path` with the basePath. + */ + prepend: (url: string) => string; + + /** + * Removes the prepended basePath from the `path`. + */ + remove: (url: string) => string; +} + +/** + * See {@link HttpServiceBase} + * @public + */ export type HttpSetup = HttpServiceBase; -/** @public */ + +/** + * See {@link HttpServiceBase} + * @public + */ export type HttpStart = HttpServiceBase; + /** @public */ export interface HttpHeadersInit { [name: string]: any; } -/** @public */ + +/** + * Fetch API options available to {@link HttpHandler}s. + * + * @internalRemarks these docs are largely copied from TypeScript's included dom types. + * @public + */ export interface HttpRequestInit { + /** {@inheritdoc RequestInit.body} */ body?: BodyInit | null; + + /** + * The cache mode associated with request, which is a string indicating how the request will interact with the + * browser's cache when fetching. + */ cache?: RequestCache; + + /** + * The credentials mode associated with request, which is a string indicating whether credentials will be sent with + * the request always, never, or only when sent to a same-origin URL. + */ credentials?: RequestCredentials; + + /** {@link HttpHeadersInit} */ headers?: HttpHeadersInit; + + /** + * Subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of + * multiple hashes separated by whitespace. + */ integrity?: string; + + /** Whether or not request can outlive the global in which it was created. */ keepalive?: boolean; + + /** HTTP method, which is "GET" by default. */ method?: string; + + /** + * The mode associated with request, which is a string indicating whether the request will use CORS, or will be + * restricted to same-origin URLs. + */ mode?: RequestMode; + + /** + * The redirect mode associated with request, which is a string indicating how redirects for the request will be + * handled during fetching. A request will follow redirects by default. + */ redirect?: RequestRedirect; + + /** + * The referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to + * indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to + * determine the value of the `Referer` header of the request being made. + */ referrer?: string; + + /** + * The referrer policy associated with request. This is used during fetching to compute the value of the request's + * referrer. + */ referrerPolicy?: ReferrerPolicy; + + /** + * Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has + * been aborted, and its abort event handler. + */ signal?: AbortSignal | null; - window?: any; -} -/** @public */ -export interface HttpDeps { - injectedMetadata: InjectedMetadataSetup; - fatalErrors: FatalErrorsSetup | null; + + /** + * Can only be null. Used to disassociate request from any Window. + */ + window?: null; } + /** @public */ export interface HttpFetchQuery { [key: string]: string | number | boolean | undefined; } -/** @public */ + +/** + * All options that may be used with a {@link HttpHandler}. + * @public + */ export interface HttpFetchOptions extends HttpRequestInit { + /** + * The query string for an HTTP request. See {@link HttpFetchQuery}. + */ query?: HttpFetchQuery; + + /** + * Whether or not the request should automatically prepend the basePath. Defaults to `true`. + */ prependBasePath?: boolean; + + /** + * Headers to send with the request. See {@link HttpHeadersInit}. + */ headers?: HttpHeadersInit; } -/** @public */ + +/** + * A function for making an HTTP requests to Kibana's backend. See {@link HttpFetchOptions} for options and + * {@link HttpBody} for the response. + * + * @param path the path on the Kibana server to send the request to. Should not include the basePath. + * @param options {@link HttpFetchOptions} + * @returns a Promise that resolves to a {@link HttpBody} + * @public + */ export type HttpHandler = (path: string, options?: HttpFetchOptions) => Promise; + /** @public */ export type HttpBody = BodyInit | null | any; + /** @public */ export interface HttpResponse { request?: Request; response?: Response; body?: HttpBody; } + +/** @public */ +export interface IHttpFetchError extends Error { + readonly request: Request; + readonly response?: Response; + readonly body?: any; +} + /** @public */ export interface HttpErrorResponse { - error: Error | HttpFetchError; + error: Error | IHttpFetchError; request?: Request; response?: Response; body?: HttpBody; @@ -105,22 +245,62 @@ export interface HttpErrorRequest { request: Request; error: Error; } -/** @public */ + +/** + * An object that may define global interceptor functions for different parts of the request and response lifecycle. + * See {@link IHttpInterceptController}. + * + * @public + */ export interface HttpInterceptor { + /** + * Define an interceptor to be executed before a request is sent. + * @param request + * @param controller {@link IHttpInterceptController} + */ request?( request: Request, - controller: HttpInterceptController + controller: IHttpInterceptController ): Promise | Request | void; + + /** + * Define an interceptor to be executed if a request interceptor throws an error or returns a rejected Promise. + * @param httpErrorRequest {@link HttpErrorRequest} + * @param controller {@link IHttpInterceptController} + */ requestError?( httpErrorRequest: HttpErrorRequest, - controller: HttpInterceptController + controller: IHttpInterceptController ): Promise | Request | void; + + /** + * Define an interceptor to be executed after a response is received. + * @param httpResponse {@link HttpResponse} + * @param controller {@link IHttpInterceptController} + */ response?( httpResponse: HttpResponse, - controller: HttpInterceptController + controller: IHttpInterceptController ): Promise | HttpResponse | void; + + /** + * Define an interceptor to be executed if a response interceptor throws an error or returns a rejected Promise. + * @param httpErrorResponse {@link HttpErrorResponse} + * @param controller {@link IHttpInterceptController} + */ responseError?( httpErrorResponse: HttpErrorResponse, - controller: HttpInterceptController + controller: IHttpInterceptController ): Promise | HttpResponse | void; } + +/** + * Used to halt a request Promise chain in a {@link HttpInterceptor}. + * @public + */ +export interface IHttpInterceptController { + /** Whether or not this chain has been halted. */ + halted: boolean; + /** Halt the request Promise chain and do not process further interceptors or response handlers. */ + halt(): void; +} diff --git a/src/core/public/index.ts b/src/core/public/index.ts index 91f65a14986e9..381d8e6e1f0b0 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -53,14 +53,7 @@ import { FatalErrorsSetup, FatalErrorInfo } from './fatal_errors'; import { HttpSetup, HttpStart } from './http'; import { I18nStart } from './i18n'; import { InjectedMetadataSetup, InjectedMetadataStart, LegacyNavLink } from './injected_metadata'; -import { - ErrorToastOptions, - NotificationsSetup, - NotificationsStart, - Toast, - ToastInput, - ToastsApi, -} from './notifications'; +import { NotificationsSetup, NotificationsStart } from './notifications'; import { OverlayStart } from './overlays'; import { Plugin, PluginInitializer, PluginInitializerContext, PluginOpaqueId } from './plugins'; import { UiSettingsClient, UiSettingsState, UiSettingsClientContract } from './ui_settings'; @@ -113,7 +106,8 @@ export { HttpResponse, HttpHandler, HttpBody, - HttpInterceptController, + IHttpInterceptController, + IHttpFetchError, } from './http'; export { @@ -124,6 +118,15 @@ export { OverlayRef, } from './overlays'; +export { + Toast, + ToastInput, + IToasts, + ToastsSetup, + ToastsStart, + ErrorToastOptions, +} from './notifications'; + /** * Core services exposed to the `Plugin` setup lifecycle * @@ -249,7 +252,6 @@ export { IContextProvider, ContextSetup, DocLinksStart, - ErrorToastOptions, FatalErrorInfo, FatalErrorsSetup, HttpSetup, @@ -263,9 +265,6 @@ export { PluginInitializerContext, SavedObjectsStart, PluginOpaqueId, - Toast, - ToastInput, - ToastsApi, UiSettingsClient, UiSettingsClientContract, UiSettingsState, diff --git a/src/core/public/notifications/index.ts b/src/core/public/notifications/index.ts index e85db3772f019..f67c34709ea52 100644 --- a/src/core/public/notifications/index.ts +++ b/src/core/public/notifications/index.ts @@ -17,7 +17,7 @@ * under the License. */ -export { ErrorToastOptions, Toast, ToastInput, ToastsApi } from './toasts'; +export { ErrorToastOptions, Toast, ToastInput, IToasts, ToastsSetup, ToastsStart } from './toasts'; export { NotificationsService, NotificationsSetup, diff --git a/src/core/public/notifications/notifications_service.ts b/src/core/public/notifications/notifications_service.ts index 33221522fa83c..2c14f2f650078 100644 --- a/src/core/public/notifications/notifications_service.ts +++ b/src/core/public/notifications/notifications_service.ts @@ -85,10 +85,12 @@ export class NotificationsService { /** @public */ export interface NotificationsSetup { + /** {@link ToastsSetup} */ toasts: ToastsSetup; } /** @public */ export interface NotificationsStart { + /** {@link ToastsStart} */ toasts: ToastsStart; } diff --git a/src/core/public/notifications/toasts/index.ts b/src/core/public/notifications/toasts/index.ts index c047ac71f7adc..57901747eca9d 100644 --- a/src/core/public/notifications/toasts/index.ts +++ b/src/core/public/notifications/toasts/index.ts @@ -18,5 +18,5 @@ */ export { ToastsService, ToastsSetup, ToastsStart } from './toasts_service'; -export { ErrorToastOptions, ToastsApi, ToastInput } from './toasts_api'; +export { ErrorToastOptions, ToastsApi, ToastInput, IToasts } from './toasts_api'; export { EuiGlobalToastListToast as Toast } from '@elastic/eui'; diff --git a/src/core/public/notifications/toasts/toasts_api.tsx b/src/core/public/notifications/toasts/toasts_api.tsx index 9ecbc87f15b45..5cc5b46ab458a 100644 --- a/src/core/public/notifications/toasts/toasts_api.tsx +++ b/src/core/public/notifications/toasts/toasts_api.tsx @@ -55,7 +55,60 @@ const normalizeToast = (toastOrTitle: ToastInput) => { }; /** @public */ -export class ToastsApi { +export interface IToasts { + /** Current array of toast messages to show to user. */ + get$(): Rx.Observable; + + /** + * Adds a new toast to current array of toast. + * + * @param toastOrTitle - a {@link ToastInput} + * @returns a {@link Toast} + */ + add(toastOrTitle: ToastInput): Toast; + + /** + * Removes a toast from the current array of toasts if present. + * @param toast - a {@link Toast} returned by {@link IToast.add} + */ + remove(toasts: Toast): void; + + /** + * Adds a new toast pre-configured with the success color and check icon. + * + * @param toastOrTitle - a {@link ToastInput} + * @returns a {@link Toast} + */ + addSuccess(toastOrTitle: ToastInput): Toast; + + /** + * Adds a new toast pre-configured with the warning color and help icon. + * + * @param toastOrTitle - a {@link ToastInput} + * @returns a {@link Toast} + */ + addWarning(toastOrTitle: ToastInput): Toast; + + /** + * Adds a new toast pre-configured with the danger color and alert icon. + * + * @param toastOrTitle - a {@link ToastInput} + * @returns a {@link Toast} + */ + addDanger(toastOrTitle: ToastInput): Toast; + + /** + * Adds a new toast that displays an exception message with a button to open the full stacktrace in a modal. + * + * @param error - an `Error` instance. + * @param options - {@link ErrorToastOptions} + * @returns a {@link Toast} + */ + addError(error: Error, options: ErrorToastOptions): Toast; +} + +/** @internal */ +export class ToastsApi implements IToasts { private toasts$ = new Rx.BehaviorSubject([]); private idCounter = 0; private uiSettings: UiSettingsClientContract; diff --git a/src/core/public/notifications/toasts/toasts_service.mock.ts b/src/core/public/notifications/toasts/toasts_service.mock.ts index 06a30f458c162..37c4ae99c2bb1 100644 --- a/src/core/public/notifications/toasts/toasts_service.mock.ts +++ b/src/core/public/notifications/toasts/toasts_service.mock.ts @@ -21,7 +21,7 @@ import { Observable } from 'rxjs'; import { ToastsSetup } from './toasts_service'; const createToastsApiMock = () => { - const api: jest.Mocked> = { + const api: jest.Mocked = { get$: jest.fn(() => new Observable()), add: jest.fn(), remove: jest.fn(), diff --git a/src/core/public/notifications/toasts/toasts_service.tsx b/src/core/public/notifications/toasts/toasts_service.tsx index 022d57d155b6b..6a5fd8c576557 100644 --- a/src/core/public/notifications/toasts/toasts_service.tsx +++ b/src/core/public/notifications/toasts/toasts_service.tsx @@ -24,7 +24,7 @@ import { EuiGlobalToastListToast as Toast } from '@elastic/eui'; import { I18nStart } from '../../i18n'; import { UiSettingsClientContract } from '../../ui_settings'; import { GlobalToastList } from './global_toast_list'; -import { ToastsApi } from './toasts_api'; +import { ToastsApi, IToasts } from './toasts_api'; import { OverlayStart } from '../../overlays'; interface SetupDeps { @@ -37,11 +37,17 @@ interface StartDeps { targetDomElement: HTMLElement; } -/** @public */ -export type ToastsSetup = Pick>; +/** + * {@link IToasts} + * @public + */ +export type ToastsSetup = IToasts; -/** @public */ -export type ToastsStart = ToastsSetup; +/** + * {@link IToasts} + * @public + */ +export type ToastsStart = IToasts; export class ToastsService { private api?: ToastsApi; diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index 51a993ee5a5bb..e765304192018 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -425,23 +425,18 @@ export interface HttpErrorRequest { export interface HttpErrorResponse { // (undocumented) body?: HttpBody; - // Warning: (ae-forgotten-export) The symbol "HttpFetchError" needs to be exported by the entry point index.d.ts - // // (undocumented) - error: Error | HttpFetchError; + error: Error | IHttpFetchError; // (undocumented) request?: Request; // (undocumented) response?: Response; } -// @public (undocumented) +// @public export interface HttpFetchOptions extends HttpRequestInit { - // (undocumented) headers?: HttpHeadersInit; - // (undocumented) prependBasePath?: boolean; - // (undocumented) query?: HttpFetchQuery; } @@ -451,7 +446,7 @@ export interface HttpFetchQuery { [key: string]: string | number | boolean | undefined; } -// @public (undocumented) +// @public export type HttpHandler = (path: string, options?: HttpFetchOptions) => Promise; // @public (undocumented) @@ -460,56 +455,33 @@ export interface HttpHeadersInit { [name: string]: any; } -// Warning: (ae-missing-release-tag) "HttpInterceptController" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export class HttpInterceptController { - // (undocumented) - halt(): void; - // (undocumented) - readonly halted: boolean; - } - -// @public (undocumented) +// @public export interface HttpInterceptor { - // (undocumented) - request?(request: Request, controller: HttpInterceptController): Promise | Request | void; - // (undocumented) - requestError?(httpErrorRequest: HttpErrorRequest, controller: HttpInterceptController): Promise | Request | void; - // (undocumented) - response?(httpResponse: HttpResponse, controller: HttpInterceptController): Promise | HttpResponse | void; - // (undocumented) - responseError?(httpErrorResponse: HttpErrorResponse, controller: HttpInterceptController): Promise | HttpResponse | void; + request?(request: Request, controller: IHttpInterceptController): Promise | Request | void; + requestError?(httpErrorRequest: HttpErrorRequest, controller: IHttpInterceptController): Promise | Request | void; + response?(httpResponse: HttpResponse, controller: IHttpInterceptController): Promise | HttpResponse | void; + responseError?(httpErrorResponse: HttpErrorResponse, controller: IHttpInterceptController): Promise | HttpResponse | void; } -// @public (undocumented) +// @public export interface HttpRequestInit { + // Warning: (ae-unresolved-inheritdoc-reference) The @inheritDoc reference could not be resolved: The package "kibana" does not have an export "RequestInit" + // // (undocumented) body?: BodyInit | null; - // (undocumented) cache?: RequestCache; - // (undocumented) credentials?: RequestCredentials; // (undocumented) headers?: HttpHeadersInit; - // (undocumented) integrity?: string; - // (undocumented) keepalive?: boolean; - // (undocumented) method?: string; - // (undocumented) mode?: RequestMode; - // (undocumented) redirect?: RequestRedirect; - // (undocumented) referrer?: string; - // (undocumented) referrerPolicy?: ReferrerPolicy; - // (undocumented) signal?: AbortSignal | null; - // (undocumented) - window?: any; + window?: null; } // @public (undocumented) @@ -524,44 +496,30 @@ export interface HttpResponse { // @public (undocumented) export interface HttpServiceBase { - // (undocumented) - addLoadingCount(count$: Observable): void; - // (undocumented) - basePath: { - get: () => string; - prepend: (url: string) => string; - remove: (url: string) => string; - }; - // (undocumented) + addLoadingCount(countSource$: Observable): void; + // Warning: (ae-forgotten-export) The symbol "IBasePath" needs to be exported by the entry point index.d.ts + basePath: IBasePath; delete: HttpHandler; - // (undocumented) fetch: HttpHandler; - // (undocumented) get: HttpHandler; - // (undocumented) getLoadingCount$(): Observable; - // (undocumented) head: HttpHandler; - // (undocumented) + // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "HTTPInterceptor" + // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "HTTPInterceptor" intercept(interceptor: HttpInterceptor): () => void; - // (undocumented) options: HttpHandler; - // (undocumented) patch: HttpHandler; - // (undocumented) post: HttpHandler; - // (undocumented) put: HttpHandler; - // (undocumented) removeAllInterceptors(): void; - // (undocumented) + // @internal (undocumented) stop(): void; } -// @public (undocumented) +// @public export type HttpSetup = HttpServiceBase; -// @public (undocumented) +// @public export type HttpStart = HttpServiceBase; // @public @@ -580,6 +538,40 @@ export interface IContextContainer> { // @public export type IContextProvider, TContextName extends keyof HandlerContextType> = (context: Partial>, ...rest: HandlerParameters) => Promise[TContextName]> | HandlerContextType[TContextName]; +// @public (undocumented) +export interface IHttpFetchError extends Error { + // (undocumented) + readonly body?: any; + // (undocumented) + readonly request: Request; + // (undocumented) + readonly response?: Response; +} + +// @public +export interface IHttpInterceptController { + halt(): void; + halted: boolean; +} + +// @public (undocumented) +export interface IToasts { + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + add(toastOrTitle: ToastInput): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + addDanger(toastOrTitle: ToastInput): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + addError(error: Error, options: ErrorToastOptions): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + addSuccess(toastOrTitle: ToastInput): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + addWarning(toastOrTitle: ToastInput): Toast; + get$(): Rx.Observable; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "IToast" + remove(toasts: Toast): void; +} + // @public @deprecated export interface LegacyCoreSetup extends CoreSetup { // Warning: (ae-forgotten-export) The symbol "InjectedMetadataSetup" needs to be exported by the entry point index.d.ts @@ -614,16 +606,12 @@ export interface LegacyNavLink { // @public (undocumented) export interface NotificationsSetup { - // Warning: (ae-forgotten-export) The symbol "ToastsSetup" needs to be exported by the entry point index.d.ts - // // (undocumented) toasts: ToastsSetup; } // @public (undocumented) export interface NotificationsStart { - // Warning: (ae-forgotten-export) The symbol "ToastsStart" needs to be exported by the entry point index.d.ts - // // (undocumented) toasts: ToastsStart; } @@ -884,27 +872,10 @@ export { Toast } export type ToastInput = string | ToastInputFields | Promise; // @public (undocumented) -export class ToastsApi { - constructor(deps: { - uiSettings: UiSettingsClientContract; - }); - // (undocumented) - add(toastOrTitle: ToastInput): Toast; - // (undocumented) - addDanger(toastOrTitle: ToastInput): Toast; - // (undocumented) - addError(error: Error, options: ErrorToastOptions): Toast; - // (undocumented) - addSuccess(toastOrTitle: ToastInput): Toast; - // (undocumented) - addWarning(toastOrTitle: ToastInput): Toast; - // (undocumented) - get$(): Rx.Observable; - // (undocumented) - registerOverlays(overlays: OverlayStart): void; - // (undocumented) - remove(toast: Toast): void; - } +export type ToastsSetup = IToasts; + +// @public (undocumented) +export type ToastsStart = IToasts; // @public (undocumented) export class UiSettingsClient { diff --git a/src/core/server/elasticsearch/cluster_client.ts b/src/core/server/elasticsearch/cluster_client.ts index cd581013e7957..d43ab9d546ed2 100644 --- a/src/core/server/elasticsearch/cluster_client.ts +++ b/src/core/server/elasticsearch/cluster_client.ts @@ -131,6 +131,8 @@ export class ClusterClient implements IClusterClient { /** * Calls specified endpoint with provided clientParams on behalf of the * Kibana internal user. + * See {@link APICaller}. + * * @param endpoint - String descriptor of the endpoint e.g. `cluster.getSettings` or `ping`. * @param clientParams - A dictionary of parameters that will be passed directly to the Elasticsearch JS client. * @param options - Options that affect the way we call the API and process the result. @@ -163,12 +165,13 @@ export class ClusterClient implements IClusterClient { } /** - * Creates an instance of `ScopedClusterClient` based on the configuration the + * Creates an instance of {@link IScopedClusterClient} based on the configuration the * current cluster client that exposes additional `callAsCurrentUser` method * scoped to the provided req. Consumers shouldn't worry about closing * scoped client instances, these will be automatically closed as soon as the * original cluster client isn't needed anymore and closed. - * @param request - Request the `ScopedClusterClient` instance will be scoped to. + * + * @param request - Request the `IScopedClusterClient` instance will be scoped to. * Supports request optionality, Legacy.Request & FakeRequest for BWC with LegacyPlatform */ public asScoped(request?: KibanaRequest | LegacyRequest | FakeRequest): IScopedClusterClient { @@ -197,6 +200,8 @@ export class ClusterClient implements IClusterClient { /** * Calls specified endpoint with provided clientParams on behalf of the * user initiated request to the Kibana server (via HTTP request headers). + * See {@link APICaller}. + * * @param endpoint - String descriptor of the endpoint e.g. `cluster.getSettings` or `ping`. * @param clientParams - A dictionary of parameters that will be passed directly to the Elasticsearch JS client. * @param options - Options that affect the way we call the API and process the result. diff --git a/src/core/server/elasticsearch/elasticsearch_service.mock.ts b/src/core/server/elasticsearch/elasticsearch_service.mock.ts index 6cf759b73c656..d935d1a66eccf 100644 --- a/src/core/server/elasticsearch/elasticsearch_service.mock.ts +++ b/src/core/server/elasticsearch/elasticsearch_service.mock.ts @@ -21,7 +21,8 @@ import { BehaviorSubject } from 'rxjs'; import { IClusterClient } from './cluster_client'; import { IScopedClusterClient } from './scoped_cluster_client'; import { ElasticsearchConfig } from './elasticsearch_config'; -import { ElasticsearchService, ElasticsearchServiceSetup } from './elasticsearch_service'; +import { ElasticsearchService } from './elasticsearch_service'; +import { InternalElasticsearchServiceSetup } from './types'; const createScopedClusterClientMock = (): jest.Mocked => ({ callAsInternalUser: jest.fn(), @@ -35,7 +36,7 @@ const createClusterClientMock = (): jest.Mocked => ({ }); const createSetupContractMock = () => { - const setupContract: jest.Mocked = { + const setupContract: jest.Mocked = { legacy: { config$: new BehaviorSubject({} as ElasticsearchConfig), }, diff --git a/src/core/server/elasticsearch/elasticsearch_service.ts b/src/core/server/elasticsearch/elasticsearch_service.ts index 9bec697825346..ed1f2a276ebc8 100644 --- a/src/core/server/elasticsearch/elasticsearch_service.ts +++ b/src/core/server/elasticsearch/elasticsearch_service.ts @@ -23,10 +23,11 @@ import { merge } from 'lodash'; import { CoreService } from '../../types'; import { CoreContext } from '../core_context'; import { Logger } from '../logging'; -import { ClusterClient, IClusterClient } from './cluster_client'; +import { ClusterClient } from './cluster_client'; import { ElasticsearchClientConfig } from './elasticsearch_client_config'; import { ElasticsearchConfig, ElasticsearchConfigType } from './elasticsearch_config'; -import { HttpServiceSetup, GetAuthHeaders } from '../http/'; +import { InternalHttpServiceSetup, GetAuthHeaders } from '../http/'; +import { InternalElasticsearchServiceSetup } from './types'; /** @internal */ interface CoreClusterClients { @@ -36,42 +37,11 @@ interface CoreClusterClients { } interface SetupDeps { - http: HttpServiceSetup; -} - -/** @public */ -export interface ElasticsearchServiceSetup { - // Required for the BWC with the legacy Kibana only. - readonly legacy: { - readonly config$: Observable; - }; - /** - * Create application specific Elasticsearch cluster API client with customized config. - * - * @param type Unique identifier of the client - * @param clientConfig A config consists of Elasticsearch JS client options and - * valid sub-set of Elasticsearch service config. - * We fill all the missing properties in the `clientConfig` using the default - * Elasticsearch config so that we don't depend on default values set and - * controlled by underlying Elasticsearch JS client. - * We don't run validation against passed config expect it to be valid. - * - * @example - * ```js - * const client = elasticsearch.createCluster('my-app-name', config); - * const data = await client.callAsInternalUser(); - * ``` - */ - readonly createClient: ( - type: string, - clientConfig?: Partial - ) => IClusterClient; - readonly adminClient$: Observable; - readonly dataClient$: Observable; + http: InternalHttpServiceSetup; } /** @internal */ -export class ElasticsearchService implements CoreService { +export class ElasticsearchService implements CoreService { private readonly log: Logger; private readonly config$: Observable; private subscription?: Subscription; @@ -83,7 +53,7 @@ export class ElasticsearchService implements CoreService new ElasticsearchConfig(rawConfig))); } - public async setup(deps: SetupDeps): Promise { + public async setup(deps: SetupDeps): Promise { this.log.debug('Setting up elasticsearch service'); const clients$ = this.config$.pipe( diff --git a/src/core/server/elasticsearch/index.ts b/src/core/server/elasticsearch/index.ts index 7b496b738182b..1f99f86d9887b 100644 --- a/src/core/server/elasticsearch/index.ts +++ b/src/core/server/elasticsearch/index.ts @@ -17,10 +17,11 @@ * under the License. */ -export { ElasticsearchServiceSetup, ElasticsearchService } from './elasticsearch_service'; +export { ElasticsearchService } from './elasticsearch_service'; export { IClusterClient, ClusterClient, FakeRequest } from './cluster_client'; export { IScopedClusterClient, ScopedClusterClient, Headers } from './scoped_cluster_client'; export { ElasticsearchClientConfig } from './elasticsearch_client_config'; export { config } from './elasticsearch_config'; export { ElasticsearchError, ElasticsearchErrorHelpers } from './errors'; export * from './api_types'; +export * from './types'; diff --git a/src/core/server/elasticsearch/scoped_cluster_client.ts b/src/core/server/elasticsearch/scoped_cluster_client.ts index 02a37e1e3567f..920d236935261 100644 --- a/src/core/server/elasticsearch/scoped_cluster_client.ts +++ b/src/core/server/elasticsearch/scoped_cluster_client.ts @@ -56,6 +56,8 @@ export class ScopedClusterClient implements IScopedClusterClient { /** * Calls specified `endpoint` with provided `clientParams` on behalf of the * Kibana internal user. + * See {@link APICaller}. + * * @param endpoint - String descriptor of the endpoint e.g. `cluster.getSettings` or `ping`. * @param clientParams - A dictionary of parameters that will be passed directly to the Elasticsearch JS client. * @param options - Options that affect the way we call the API and process the result. @@ -71,6 +73,8 @@ export class ScopedClusterClient implements IScopedClusterClient { /** * Calls specified `endpoint` with provided `clientParams` on behalf of the * user initiated request to the Kibana server (via HTTP request headers). + * See {@link APICaller}. + * * @param endpoint - String descriptor of the endpoint e.g. `cluster.getSettings` or `ping`. * @param clientParams - A dictionary of parameters that will be passed directly to the Elasticsearch JS client. * @param options - Options that affect the way we call the API and process the result. diff --git a/src/core/server/elasticsearch/types.ts b/src/core/server/elasticsearch/types.ts new file mode 100644 index 0000000000000..234d7e13e3ac4 --- /dev/null +++ b/src/core/server/elasticsearch/types.ts @@ -0,0 +1,80 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Observable } from 'rxjs'; +import { ElasticsearchConfig } from './elasticsearch_config'; +import { ElasticsearchClientConfig } from './elasticsearch_client_config'; +import { IClusterClient } from './cluster_client'; + +/** + * @public + */ +export interface ElasticsearchServiceSetup { + /** + * Create application specific Elasticsearch cluster API client with customized config. See {@link IClusterClient}. + * + * @param type Unique identifier of the client + * @param clientConfig A config consists of Elasticsearch JS client options and + * valid sub-set of Elasticsearch service config. + * We fill all the missing properties in the `clientConfig` using the default + * Elasticsearch config so that we don't depend on default values set and + * controlled by underlying Elasticsearch JS client. + * We don't run validation against passed config expect it to be valid. + * + * @example + * ```js + * const client = elasticsearch.createCluster('my-app-name', config); + * const data = await client.callAsInternalUser(); + * ``` + */ + readonly createClient: ( + type: string, + clientConfig?: Partial + ) => IClusterClient; + + /** + * Observable of clients for the `admin` cluster. Observable emits when Elasticsearch config changes on the Kibana + * server. See {@link IClusterClient} + * + * @exmaple + * ```js + * const client = await elasticsearch.adminClient$.pipe(take(1)).toPromise(); + * ``` + */ + readonly adminClient$: Observable; + + /** + * Observable of clients for the `data` cluster. Observable emits when Elasticsearch config changes on the Kibana + * server. See {@link IClusterClient} + * + * @exmaple + * ```js + * const client = await elasticsearch.dataClient$.pipe(take(1)).toPromise(); + * ``` + */ + readonly dataClient$: Observable; +} + +/** @internal */ +export interface InternalElasticsearchServiceSetup extends ElasticsearchServiceSetup { + // Required for the BWC with the legacy Kibana only. + readonly legacy: { + readonly config$: Observable; + }; +} diff --git a/src/core/server/http/base_path_service.ts b/src/core/server/http/base_path_service.ts index 916419cac212a..5b5901b0ad6fb 100644 --- a/src/core/server/http/base_path_service.ts +++ b/src/core/server/http/base_path_service.ts @@ -65,7 +65,7 @@ export class BasePath { }; /** - * returns a new `basePath` value, prefixed with passed `url`. + * Prepends `path` with the basePath. */ public prepend = (path: string): string => { if (this.serverBasePath === '') return path; @@ -77,7 +77,7 @@ export class BasePath { }; /** - * returns a new `basePath` value, cleaned up from passed `url`. + * Removes the prepended basePath from the `path`. */ public remove = (path: string): string => { if (this.serverBasePath === '') { diff --git a/src/core/server/http/http_server.ts b/src/core/server/http/http_server.ts index b56fef5f65c2a..3354324c12407 100644 --- a/src/core/server/http/http_server.ts +++ b/src/core/server/http/http_server.ts @@ -31,83 +31,12 @@ import { SessionStorageCookieOptions, createCookieSessionStorageFactory, } from './cookie_session_storage'; -import { SessionStorageFactory } from './session_storage'; import { AuthStateStorage, GetAuthState, IsAuthenticated } from './auth_state_storage'; import { AuthHeadersStorage, GetAuthHeaders } from './auth_headers_storage'; -import { BasePath, IBasePath } from './base_path_service'; - -/** - * Kibana HTTP Service provides own abstraction for work with HTTP stack. - * Plugins don't have direct access to `hapi` server and its primitives anymore. Moreover, - * plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. - * This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. - * If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. - * - * @example - * 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 - * 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`. - * ```ts - * import { schema, TypeOf } from '@kbn/config-schema'; - * const validate = { - * params: schema.object({ - * id: schema.string(), - * }), - * }; - * ``` - * - * - Declare a function to respond to incoming request. - * The function will receive `request` object containing request details: url, headers, matched route, as well as validated `params`, `query`, `body`. - * And `response` object instructing HTTP server to create HTTP response with information sent back to the client as the response body, headers, and HTTP status. - * Unlike, `hapi` route handler in the Legacy platform, any exception raised during the handler call will generate `500 Server error` response and log error details for further investigation. See below for returning custom error responses. - * ```ts - * const handler = async (context: RequestHandlerContext, request: KibanaRequest, response: ResponseFactory) => { - * const data = await findObject(request.params.id); - * // creates a command to respond with 'not found' error - * if (!data) return response.notFound(); - * // creates a command to send found data to the client and set response headers - * return response.ok({ - * body: data, - * headers: { - * 'content-type': 'application/json' - * } - * }); - * } - * ``` - * - * - Register route handler for GET request to 'my-app/path/{id}' path - * ```ts - * import { schema, TypeOf } from '@kbn/config-schema'; - * const router = httpSetup.createRouter(); - * - * const validate = { - * params: schema.object({ - * id: schema.string(), - * }), - * }; - * - * router.get({ - * path: 'path/{id}', - * validate - * }, - * async (context, request, response) => { - * const data = await findObject(request.params.id); - * if (!data) return response.notFound(); - * return response.ok({ - * body: data, - * headers: { - * 'content-type': 'application/json' - * } - * }); - * }); - * ``` - * @public - */ +import { BasePath } from './base_path_service'; +import { HttpServiceSetup } from './types'; + +/** @internal */ export interface HttpServerSetup { server: Server; /** @@ -115,50 +44,17 @@ export interface HttpServerSetup { * @param router {@link IRouter} - a router with registered route handlers. */ registerRouter: (router: IRouter) => void; - /** - * Creates cookie based session storage factory {@link SessionStorageFactory} - * @param cookieOptions {@link SessionStorageCookieOptions} - options to configure created cookie session storage. - */ - createCookieSessionStorageFactory: ( - cookieOptions: SessionStorageCookieOptions - ) => Promise>; - /** - * 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. - * @param handler {@link AuthenticationHandler} - function to perform authentication. - */ - registerAuth: (handler: AuthenticationHandler) => void; - /** - * 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). - * @param handler {@link OnPreAuthHandler} - function to call. - */ - registerOnPreAuth: (handler: OnPreAuthHandler) => void; - /** - * 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). - * @param handler {@link OnPostAuthHandler} - function to call. - */ - registerOnPostAuth: (handler: OnPostAuthHandler) => void; - /** {@link BasePath} */ - basePath: IBasePath; + basePath: HttpServiceSetup['basePath']; + createCookieSessionStorageFactory: HttpServiceSetup['createCookieSessionStorageFactory']; + registerAuth: HttpServiceSetup['registerAuth']; + registerOnPreAuth: HttpServiceSetup['registerOnPreAuth']; + registerOnPostAuth: HttpServiceSetup['registerOnPostAuth']; + isTlsEnabled: HttpServiceSetup['isTlsEnabled']; auth: { get: GetAuthState; isAuthenticated: IsAuthenticated; getAuthHeaders: GetAuthHeaders; }; - /** - * Flag showing whether a server was configured to use TLS connection. - */ - isTlsEnabled: boolean; } export class HttpServer { diff --git a/src/core/server/http/http_service.mock.ts b/src/core/server/http/http_service.mock.ts index c0658ae8d1e5c..40a140f154a6e 100644 --- a/src/core/server/http/http_service.mock.ts +++ b/src/core/server/http/http_service.mock.ts @@ -18,18 +18,19 @@ */ import { Server } from 'hapi'; -import { HttpService, HttpServiceSetup } from './http_service'; +import { InternalHttpServiceSetup } from './types'; +import { HttpService } from './http_service'; import { OnPreAuthToolkit } from './lifecycle/on_pre_auth'; import { AuthToolkit } from './lifecycle/auth'; import { sessionStorageMock } from './cookie_session_storage.mocks'; import { IRouter } from './router'; import { OnPostAuthToolkit } from './lifecycle/on_post_auth'; -type ServiceSetupMockType = jest.Mocked & { - basePath: jest.Mocked; +type ServiceSetupMockType = jest.Mocked & { + basePath: jest.Mocked; }; -const createBasePathMock = (): jest.Mocked => ({ +const createBasePathMock = (): jest.Mocked => ({ serverBasePath: '/mock-server-basepath', get: jest.fn(), set: jest.fn(), diff --git a/src/core/server/http/http_service.ts b/src/core/server/http/http_service.ts index 0ac5ad9276353..c720d2fea4fc6 100644 --- a/src/core/server/http/http_service.ts +++ b/src/core/server/http/http_service.ts @@ -29,12 +29,17 @@ import { ContextSetup } from '../context'; import { CoreContext } from '../core_context'; import { PluginOpaqueId } from '../plugins'; -import { Router, IRouter } from './router'; +import { Router } from './router'; import { HttpConfig, HttpConfigType } from './http_config'; -import { HttpServer, HttpServerSetup } from './http_server'; +import { HttpServer } from './http_server'; import { HttpsRedirectServer } from './https_redirect_server'; -import { RequestHandlerContextContainer, RequestHandlerContextProvider } from './types'; +import { + RequestHandlerContextContainer, + RequestHandlerContextProvider, + InternalHttpServiceSetup, + HttpServiceStart, +} from './types'; import { RequestHandlerContext } from '../../server'; @@ -42,59 +47,8 @@ interface SetupDeps { context: ContextSetup; } -/** @public */ -export type HttpServiceSetup = Omit & { - /** - * Provides ability to declare a handler function for a particular path and HTTP request method. - * Each route can have only one handler functions, which is executed when the route is matched. - * All routes are prefixed with plugin name as a first segment of URL path. - * @example - * ```ts - * const router = createRouter(); - * // handler is called when '${my-plugin-id}/path' resource is requested with `GET` method - * router.get({ path: '/path', validate: false }, (context, req, res) => res.ok({ content: 'ok' })); - * ``` - * @public - */ - createRouter: (path: string, plugin?: PluginOpaqueId) => IRouter; - /** - * Register a context provider for a route handler. - * @example - * ```ts - * // my-plugin.ts - * deps.http.registerRouteHandlerContext( - * 'myApp', - * (context, req) => { - * async function search (id: string) { - * return await context.elasticsearch.adminClient.callAsInternalUser('endpoint', id); - * } - * return { search }; - * } - * ); - * - * // my-route-handler.ts - * router.get({ path: '/', validate: false }, async (context, req, res) => { - * const response = await context.myApp.search(...); - * return res.ok(response); - * }); - * ``` - * @public - */ - registerRouteHandlerContext: ( - pluginOpaqueId: PluginOpaqueId, - contextName: T, - provider: RequestHandlerContextProvider - ) => RequestHandlerContextContainer; -}; - -/** @public */ -export interface HttpServiceStart { - /** Indicates if http server is listening on a given port */ - isListening: (port: number) => boolean; -} - /** @internal */ -export class HttpService implements CoreService { +export class HttpService implements CoreService { private readonly httpServer: HttpServer; private readonly httpsRedirectServer: HttpsRedirectServer; private readonly config$: Observable; @@ -137,7 +91,7 @@ export class HttpService implements CoreService { diff --git a/src/core/server/http/index.ts b/src/core/server/http/index.ts index 4f83cd996deba..20cfe8a27843a 100644 --- a/src/core/server/http/index.ts +++ b/src/core/server/http/index.ts @@ -18,8 +18,7 @@ */ export { config, HttpConfig, HttpConfigType } from './http_config'; -export { HttpService, HttpServiceSetup, HttpServiceStart } from './http_service'; -export { HttpServerSetup } from './http_server'; +export { HttpService } from './http_service'; export { GetAuthHeaders } from './auth_headers_storage'; export { AuthStatus, GetAuthState, IsAuthenticated } from './auth_state_storage'; export { diff --git a/src/core/server/http/lifecycle/auth.ts b/src/core/server/http/lifecycle/auth.ts index a89c17a0340be..72acbff8cfb38 100644 --- a/src/core/server/http/lifecycle/auth.ts +++ b/src/core/server/http/lifecycle/auth.ts @@ -53,14 +53,14 @@ const authResult = { /** * Auth Headers map * @public - * */ + */ export type AuthHeaders = Record; /** * Result of an incoming request authentication. * @public - * */ + */ export interface AuthResultParams { /** * Data to associate with an incoming request. Any downstream plugin may get access to the data. @@ -91,7 +91,10 @@ const toolkit: AuthToolkit = { authenticated: authResult.authenticated, }; -/** @public */ +/** + * See {@link AuthToolkit}. + * @public + */ export type AuthenticationHandler = ( request: KibanaRequest, response: LifecycleResponseFactory, diff --git a/src/core/server/http/lifecycle/on_post_auth.ts b/src/core/server/http/lifecycle/on_post_auth.ts index a7f4eb57c2694..6ce70af2082c1 100644 --- a/src/core/server/http/lifecycle/on_post_auth.ts +++ b/src/core/server/http/lifecycle/on_post_auth.ts @@ -55,7 +55,10 @@ export interface OnPostAuthToolkit { next: () => OnPostAuthResult; } -/** @public */ +/** + * See {@link OnPostAuthToolkit}. + * @public + */ export type OnPostAuthHandler = ( request: KibanaRequest, response: LifecycleResponseFactory, diff --git a/src/core/server/http/lifecycle/on_pre_auth.ts b/src/core/server/http/lifecycle/on_pre_auth.ts index ad204044ec34d..dc2ae6922fb94 100644 --- a/src/core/server/http/lifecycle/on_pre_auth.ts +++ b/src/core/server/http/lifecycle/on_pre_auth.ts @@ -74,7 +74,10 @@ const toolkit: OnPreAuthToolkit = { rewriteUrl: preAuthResult.rewriteUrl, }; -/** @public */ +/** + * See {@link OnPreAuthToolkit}. + * @public + */ export type OnPreAuthHandler = ( request: KibanaRequest, response: LifecycleResponseFactory, diff --git a/src/core/server/http/router/route.ts b/src/core/server/http/router/route.ts index e805356014829..3beb2d17f7b60 100644 --- a/src/core/server/http/router/route.ts +++ b/src/core/server/http/router/route.ts @@ -50,9 +50,11 @@ export interface RouteConfigOptions { */ export interface RouteConfig

{ /** - * The endpoint _within_ the router path to register the route. E.g. if the - * router is registered at `/elasticsearch` and the route path is `/search`, - * the full path for the route is `/elasticsearch/search`. + * The endpoint _within_ the router path to register the route. + * + * @remarks + * E.g. if the router is registered at `/elasticsearch` and the route path is + * `/search`, the full path for the route is `/elasticsearch/search`. * Supports: * - named path segments `path/{name}`. * - optional path segments `path/{position?}`. @@ -64,11 +66,14 @@ export interface RouteConfig

= IContextProvider, TContextName>; + +/** + * Kibana HTTP Service provides own abstraction for work with HTTP stack. + * Plugins don't have direct access to `hapi` server and its primitives anymore. Moreover, + * plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. + * This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. + * If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. + * + * @example + * 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 + * 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`. + * ```ts + * import { schema, TypeOf } from '@kbn/config-schema'; + * const validate = { + * params: schema.object({ + * id: schema.string(), + * }), + * }; + * ``` + * + * - Declare a function to respond to incoming request. + * The function will receive `request` object containing request details: url, headers, matched route, as well as validated `params`, `query`, `body`. + * And `response` object instructing HTTP server to create HTTP response with information sent back to the client as the response body, headers, and HTTP status. + * Unlike, `hapi` route handler in the Legacy platform, any exception raised during the handler call will generate `500 Server error` response and log error details for further investigation. See below for returning custom error responses. + * ```ts + * const handler = async (context: RequestHandlerContext, request: KibanaRequest, response: ResponseFactory) => { + * const data = await findObject(request.params.id); + * // creates a command to respond with 'not found' error + * if (!data) return response.notFound(); + * // creates a command to send found data to the client and set response headers + * return response.ok({ + * body: data, + * headers: { + * 'content-type': 'application/json' + * } + * }); + * } + * ``` + * + * - Register route handler for GET request to 'my-app/path/{id}' path + * ```ts + * import { schema, TypeOf } from '@kbn/config-schema'; + * const router = httpSetup.createRouter(); + * + * const validate = { + * params: schema.object({ + * id: schema.string(), + * }), + * }; + * + * router.get({ + * path: 'path/{id}', + * validate + * }, + * async (context, request, response) => { + * const data = await findObject(request.params.id); + * if (!data) return response.notFound(); + * return response.ok({ + * body: data, + * headers: { + * 'content-type': 'application/json' + * } + * }); + * }); + * ``` + * @public + */ +export interface HttpServiceSetup { + /** + * Creates cookie based session storage factory {@link SessionStorageFactory} + * @param cookieOptions {@link SessionStorageCookieOptions} - options to configure created cookie session storage. + */ + createCookieSessionStorageFactory: ( + cookieOptions: SessionStorageCookieOptions + ) => Promise>; + + /** + * To define custom logic to perform for incoming requests. + * + * @remarks + * 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). See {@link OnPreAuthHandler}. + * + * @param handler {@link OnPreAuthHandler} - function to call. + */ + registerOnPreAuth: (handler: OnPreAuthHandler) => void; + + /** + * To define custom authentication and/or authorization mechanism for incoming requests. + * + * @remarks + * 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. See {@link AuthenticationHandler}. + * + * @param handler {@link AuthenticationHandler} - function to perform authentication. + */ + registerAuth: (handler: AuthenticationHandler) => void; + + /** + * To define custom logic to perform for incoming requests. + * + * @remarks + * 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). See {@link OnPostAuthHandler}. + * + * @param handler {@link OnPostAuthHandler} - function to call. + */ + registerOnPostAuth: (handler: OnPostAuthHandler) => void; + + /** + * Access or manipulate the Kibana base path + * See {@link IBasePath}. + */ + basePath: IBasePath; + + /** + * Flag showing whether a server was configured to use TLS connection. + */ + isTlsEnabled: boolean; + + /** + * Provides ability to declare a handler function for a particular path and HTTP request method. + * + * @remarks + * Each route can have only one handler functions, which is executed when the route is matched. + * All routes are prefixed with plugin name as a first segment of URL path. + * See the {@link IRouter} documentation for more information. + * + * @example + * ```ts + * const router = createRouter(); + * // handler is called when '${my-plugin-id}/path' resource is requested with `GET` method + * router.get({ path: '/path', validate: false }, (context, req, res) => res.ok({ content: 'ok' })); + * ``` + * @public + */ + createRouter: () => IRouter; + + /** + * Register a context provider for a route handler. + * @example + * ```ts + * // my-plugin.ts + * deps.http.registerRouteHandlerContext( + * 'myApp', + * (context, req) => { + * async function search (id: string) { + * return await context.elasticsearch.adminClient.callAsInternalUser('endpoint', id); + * } + * return { search }; + * } + * ); + * + * // my-route-handler.ts + * router.get({ path: '/', validate: false }, async (context, req, res) => { + * const response = await context.myApp.search(...); + * return res.ok(response); + * }); + * ``` + * @public + */ + registerRouteHandlerContext: ( + contextName: T, + provider: RequestHandlerContextProvider + ) => RequestHandlerContextContainer; +} + +/** @internal */ +export interface InternalHttpServiceSetup + extends Omit { + auth: HttpServerSetup['auth']; + server: HttpServerSetup['server']; + createRouter: (path: string, plugin?: PluginOpaqueId) => IRouter; + registerRouteHandlerContext: ( + pluginOpaqueId: PluginOpaqueId, + contextName: T, + provider: RequestHandlerContextProvider + ) => RequestHandlerContextContainer; +} + +/** @public */ +export interface HttpServiceStart { + /** Indicates if http server is listening on a given port */ + isListening: (port: number) => boolean; +} diff --git a/src/core/server/index.ts b/src/core/server/index.ts index 027c82e419b5c..82e95ff559e40 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -39,20 +39,12 @@ * @packageDocumentation */ -import { Observable } from 'rxjs'; import { - IClusterClient, - ElasticsearchClientConfig, ElasticsearchServiceSetup, + InternalElasticsearchServiceSetup, IScopedClusterClient, } from './elasticsearch'; -import { - HttpServiceSetup, - HttpServiceStart, - IRouter, - RequestHandlerContextContainer, - RequestHandlerContextProvider, -} from './http'; +import { InternalHttpServiceSetup, HttpServiceSetup } from './http'; import { PluginsServiceSetup, PluginsServiceStart, PluginOpaqueId } from './plugins'; import { ContextSetup } from './context'; import { SavedObjectsServiceStart } from './saved_objects'; @@ -76,6 +68,8 @@ export { ElasticsearchClientConfig, ElasticsearchError, ElasticsearchErrorHelpers, + ElasticsearchServiceSetup, + APICaller, FakeRequest, } from './elasticsearch'; export * from './elasticsearch/api_types'; @@ -92,7 +86,8 @@ export { GetAuthState, HttpResponseOptions, HttpResponsePayload, - HttpServerSetup, + HttpServiceSetup, + HttpServiceStart, ErrorHttpResponseOptions, IKibanaSocket, IsAuthenticated, @@ -198,30 +193,12 @@ export interface RequestHandlerContext { * @public */ export interface CoreSetup { - context: { - createContextContainer: ContextSetup['createContextContainer']; - }; - elasticsearch: { - adminClient$: Observable; - dataClient$: Observable; - createClient: ( - type: string, - clientConfig?: Partial - ) => IClusterClient; - }; - http: { - createCookieSessionStorageFactory: HttpServiceSetup['createCookieSessionStorageFactory']; - registerOnPreAuth: HttpServiceSetup['registerOnPreAuth']; - registerAuth: HttpServiceSetup['registerAuth']; - registerOnPostAuth: HttpServiceSetup['registerOnPostAuth']; - basePath: HttpServiceSetup['basePath']; - isTlsEnabled: HttpServiceSetup['isTlsEnabled']; - registerRouteHandlerContext: ( - name: T, - provider: RequestHandlerContextProvider - ) => RequestHandlerContextContainer; - createRouter: () => IRouter; - }; + /** {@link ContextSetup} */ + context: ContextSetup; + /** {@link ElasticsearchServiceSetup} */ + elasticsearch: ElasticsearchServiceSetup; + /** {@link HttpServiceSetup} */ + http: HttpServiceSetup; } /** @@ -234,8 +211,8 @@ export interface CoreStart {} // eslint-disable-line @typescript-eslint/no-empty /** @internal */ export interface InternalCoreSetup { context: ContextSetup; - http: HttpServiceSetup; - elasticsearch: ElasticsearchServiceSetup; + http: InternalHttpServiceSetup; + elasticsearch: InternalElasticsearchServiceSetup; } /** @@ -245,12 +222,4 @@ export interface InternalCoreStart { savedObjects: SavedObjectsServiceStart; } -export { - ContextSetup, - HttpServiceSetup, - HttpServiceStart, - ElasticsearchServiceSetup, - PluginsServiceSetup, - PluginsServiceStart, - PluginOpaqueId, -}; +export { ContextSetup, PluginsServiceSetup, PluginsServiceStart, PluginOpaqueId }; diff --git a/src/core/server/legacy/legacy_service.test.ts b/src/core/server/legacy/legacy_service.test.ts index b5153847e2d0f..9b64d7c811aa7 100644 --- a/src/core/server/legacy/legacy_service.test.ts +++ b/src/core/server/legacy/legacy_service.test.ts @@ -39,7 +39,7 @@ import { ContextSetup } from '../context'; import { contextServiceMock } from '../context/context_service.mock'; import { getEnvOptions } from '../config/__mocks__/env'; import { configServiceMock } from '../config/config_service.mock'; -import { ElasticsearchServiceSetup } from '../elasticsearch'; +import { InternalElasticsearchServiceSetup } from '../elasticsearch'; import { HttpServiceStart, BasePathProxyServer } from '../http'; import { loggingServiceMock } from '../logging/logging_service.mock'; import { DiscoveredPlugin, DiscoveredPluginInternal } from '../plugins'; @@ -56,7 +56,7 @@ let config$: BehaviorSubject; let setupDeps: { core: { context: ContextSetup; - elasticsearch: ElasticsearchServiceSetup; + elasticsearch: InternalElasticsearchServiceSetup; http: any; plugins: PluginsServiceSetup; }; diff --git a/src/core/server/plugins/plugins_service.ts b/src/core/server/plugins/plugins_service.ts index 0fe20e7e59c31..781b3ad309ba1 100644 --- a/src/core/server/plugins/plugins_service.ts +++ b/src/core/server/plugins/plugins_service.ts @@ -21,8 +21,8 @@ import { Observable } from 'rxjs'; import { filter, first, map, mergeMap, tap, toArray } from 'rxjs/operators'; import { CoreService } from '../../types'; import { CoreContext } from '../core_context'; -import { ElasticsearchServiceSetup } from '../elasticsearch/elasticsearch_service'; -import { HttpServiceSetup } from '../http/http_service'; +import { InternalElasticsearchServiceSetup } from '../elasticsearch'; +import { InternalHttpServiceSetup } from '../http'; import { Logger } from '../logging'; import { discover, PluginDiscoveryError, PluginDiscoveryErrorType } from './discovery'; import { PluginWrapper } from './plugin'; @@ -48,8 +48,8 @@ export interface PluginsServiceStart { /** @internal */ export interface PluginsServiceSetupDeps { context: ContextSetup; - elasticsearch: ElasticsearchServiceSetup; - http: HttpServiceSetup; + elasticsearch: InternalElasticsearchServiceSetup; + http: InternalHttpServiceSetup; } /** @internal */ diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index 01e6b63ee433a..e3fdef708f03a 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -413,7 +413,7 @@ export interface AssistantAPIClientParams extends GenericParams { // Warning: (ae-forgotten-export) The symbol "AuthResult" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "KibanaResponse" needs to be exported by the entry point index.d.ts // -// @public (undocumented) +// @public export type AuthenticationHandler = (request: KibanaRequest, response: LifecycleResponseFactory, toolkit: AuthToolkit) => AuthResult | KibanaResponse | Promise; // @public @@ -499,26 +499,11 @@ export type CoreId = symbol; // @public export interface CoreSetup { // (undocumented) - context: { - createContextContainer: ContextSetup['createContextContainer']; - }; + context: ContextSetup; // (undocumented) - elasticsearch: { - adminClient$: Observable; - dataClient$: Observable; - createClient: (type: string, clientConfig?: Partial) => IClusterClient; - }; + elasticsearch: ElasticsearchServiceSetup; // (undocumented) - http: { - createCookieSessionStorageFactory: HttpServiceSetup['createCookieSessionStorageFactory']; - registerOnPreAuth: HttpServiceSetup['registerOnPreAuth']; - registerAuth: HttpServiceSetup['registerAuth']; - registerOnPostAuth: HttpServiceSetup['registerOnPostAuth']; - basePath: HttpServiceSetup['basePath']; - isTlsEnabled: HttpServiceSetup['isTlsEnabled']; - registerRouteHandlerContext: (name: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer; - createRouter: () => IRouter; - }; + http: HttpServiceSetup; } // @public @@ -607,15 +592,9 @@ export class ElasticsearchErrorHelpers { // @public (undocumented) export interface ElasticsearchServiceSetup { - // (undocumented) readonly adminClient$: Observable; readonly createClient: (type: string, clientConfig?: Partial) => IClusterClient; - // (undocumented) readonly dataClient$: Observable; - // (undocumented) - readonly legacy: { - readonly config$: Observable; - }; } // @public @@ -664,31 +643,17 @@ export interface HttpResponseOptions { export type HttpResponsePayload = undefined | string | Record | Buffer | Stream; // @public -export interface HttpServerSetup { - // (undocumented) - auth: { - get: GetAuthState; - isAuthenticated: IsAuthenticated; - getAuthHeaders: GetAuthHeaders; - }; - // (undocumented) +export interface HttpServiceSetup { basePath: IBasePath; createCookieSessionStorageFactory: (cookieOptions: SessionStorageCookieOptions) => Promise>; + createRouter: () => IRouter; isTlsEnabled: boolean; registerAuth: (handler: AuthenticationHandler) => void; registerOnPostAuth: (handler: OnPostAuthHandler) => void; registerOnPreAuth: (handler: OnPreAuthHandler) => void; - registerRouter: (router: IRouter) => void; - // (undocumented) - server: Server; + registerRouteHandlerContext: (contextName: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer; } -// @public (undocumented) -export type HttpServiceSetup = Omit & { - createRouter: (path: string, plugin?: PluginOpaqueId) => IRouter; - registerRouteHandlerContext: (pluginOpaqueId: PluginOpaqueId, contextName: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer; -}; - // @public (undocumented) export interface HttpServiceStart { isListening: (port: number) => boolean; @@ -732,10 +697,14 @@ export interface IndexSettingsDeprecationInfo { export interface InternalCoreSetup { // (undocumented) context: ContextSetup; + // Warning: (ae-forgotten-export) The symbol "InternalElasticsearchServiceSetup" needs to be exported by the entry point index.d.ts + // // (undocumented) - elasticsearch: ElasticsearchServiceSetup; + elasticsearch: InternalElasticsearchServiceSetup; + // Warning: (ae-forgotten-export) The symbol "InternalHttpServiceSetup" needs to be exported by the entry point index.d.ts + // // (undocumented) - http: HttpServiceSetup; + http: InternalHttpServiceSetup; } // @internal (undocumented) @@ -938,7 +907,7 @@ export type MIGRATION_DEPRECATION_LEVEL = 'none' | 'info' | 'warning' | 'critica // Warning: (ae-forgotten-export) The symbol "OnPostAuthResult" needs to be exported by the entry point index.d.ts // -// @public (undocumented) +// @public export type OnPostAuthHandler = (request: KibanaRequest, response: LifecycleResponseFactory, toolkit: OnPostAuthToolkit) => OnPostAuthResult | KibanaResponse | Promise; // @public @@ -948,7 +917,7 @@ export interface OnPostAuthToolkit { // Warning: (ae-forgotten-export) The symbol "OnPreAuthResult" needs to be exported by the entry point index.d.ts // -// @public (undocumented) +// @public export type OnPreAuthHandler = (request: KibanaRequest, response: LifecycleResponseFactory, toolkit: OnPreAuthToolkit) => OnPreAuthResult | KibanaResponse | Promise; // @public diff --git a/src/core/server/server.ts b/src/core/server/server.ts index 29c9a3cd09275..81d30a367261d 100644 --- a/src/core/server/server.ts +++ b/src/core/server/server.ts @@ -22,7 +22,7 @@ import { Type } from '@kbn/config-schema'; import { ConfigService, Env, Config, ConfigPath } from './config'; import { ElasticsearchService } from './elasticsearch'; -import { HttpService, HttpServiceSetup } from './http'; +import { HttpService, InternalHttpServiceSetup } from './http'; import { LegacyService } from './legacy'; import { Logger, LoggerFactory } from './logging'; import { PluginsService, config as pluginsConfig } from './plugins'; @@ -140,7 +140,7 @@ export class Server { await this.http.stop(); } - private registerDefaultRoute(httpSetup: HttpServiceSetup) { + private registerDefaultRoute(httpSetup: InternalHttpServiceSetup) { const router = httpSetup.createRouter('/core'); router.get({ path: '/', validate: false }, async (context, req, res) => res.ok({ body: { version: '0.0.1' } }) diff --git a/src/legacy/ui/public/notify/toasts/toast_notifications.test.ts b/src/legacy/ui/public/notify/toasts/toast_notifications.test.ts index 61660812de1b7..ba39ee59e388c 100644 --- a/src/legacy/ui/public/notify/toasts/toast_notifications.test.ts +++ b/src/legacy/ui/public/notify/toasts/toast_notifications.test.ts @@ -17,130 +17,70 @@ * under the License. */ -import sinon from 'sinon'; -import { ToastsApi } from '../../../../../core/public'; -import { uiSettingsServiceMock, i18nServiceMock } from '../../../../../core/public/mocks'; +import { notificationServiceMock } from '../../../../../core/public/mocks'; import { ToastNotifications } from './toast_notifications'; - -function toastDeps() { - const uiSettingsMock = uiSettingsServiceMock.createSetupContract(); - uiSettingsMock.get.mockImplementation(() => (config: string) => { - switch (config) { - case 'notifications:lifetime:info': - return 5000; - case 'notifications:lifetime:warning': - return 10000; - case 'notification:lifetime:error': - return 30000; - default: - throw new Error(`Accessing ${config} is not supported in the mock.`); - } - }); - return { - uiSettings: uiSettingsMock, - i18n: i18nServiceMock.createStartContract(), - }; -} +import { Toast } from '../../../../../core/public'; +import { BehaviorSubject } from 'rxjs'; describe('ToastNotifications', () => { describe('interface', () => { function setup() { - return { toastNotifications: new ToastNotifications(new ToastsApi(toastDeps())) }; + const toastsMock = notificationServiceMock.createStartContract().toasts; + return { toastNotifications: new ToastNotifications(toastsMock), toastsMock }; } describe('add method', () => { test('adds a toast', () => { - const { toastNotifications } = setup(); - toastNotifications.add({}); - expect(toastNotifications.list).toHaveLength(1); - }); - - test('adds a toast with an ID property', () => { - const { toastNotifications } = setup(); + const { toastNotifications, toastsMock } = setup(); toastNotifications.add({}); - expect(toastNotifications.list[0]).toHaveProperty('id', '0'); - }); - - test('increments the toast ID', () => { - const { toastNotifications } = setup(); - toastNotifications.add({}); - toastNotifications.add({}); - expect(toastNotifications.list[1]).toHaveProperty('id', '1'); - }); - - test('accepts a string', () => { - const { toastNotifications } = setup(); - toastNotifications.add('New toast'); - expect(toastNotifications.list[0]).toHaveProperty('title', 'New toast'); + expect(toastsMock.add).toHaveBeenCalled(); }); }); describe('remove method', () => { test('removes a toast', () => { - const { toastNotifications } = setup(); - const toast = toastNotifications.add('Test'); - toastNotifications.remove(toast); - expect(toastNotifications.list).toHaveLength(0); - }); - - test('ignores unknown toast', () => { - const { toastNotifications } = setup(); - const toast = toastNotifications.add('Test'); - toastNotifications.remove({ - id: `not ${toast.id}`, - }); - expect(toastNotifications.list).toHaveLength(1); + const { toastNotifications, toastsMock } = setup(); + const fakeToast = {} as Toast; + toastNotifications.remove(fakeToast); + expect(toastsMock.remove).toHaveBeenCalledWith(fakeToast); }); }); describe('onChange method', () => { - test('callback is called when a toast is added', () => { - const { toastNotifications } = setup(); - const onChangeSpy = sinon.spy(); + test('callback is called when observable changes', () => { + const toastsMock = notificationServiceMock.createStartContract().toasts; + const toasts$ = new BehaviorSubject([]); + toastsMock.get$.mockReturnValue(toasts$); + const toastNotifications = new ToastNotifications(toastsMock); + const onChangeSpy = jest.fn(); toastNotifications.onChange(onChangeSpy); - toastNotifications.add({}); - sinon.assert.calledOnce(onChangeSpy); - }); - - test('callback is called when a toast is removed', () => { - const { toastNotifications } = setup(); - const onChangeSpy = sinon.spy(); - toastNotifications.onChange(onChangeSpy); - const toast = toastNotifications.add({}); - toastNotifications.remove(toast); - sinon.assert.calledTwice(onChangeSpy); - }); - - test('callback is not called when remove is ignored', () => { - const { toastNotifications } = setup(); - const onChangeSpy = sinon.spy(); - toastNotifications.onChange(onChangeSpy); - toastNotifications.remove({ id: 'foo' }); - sinon.assert.notCalled(onChangeSpy); + toasts$.next([{ id: 'toast1' }]); + toasts$.next([]); + expect(onChangeSpy).toHaveBeenCalledTimes(2); }); }); describe('addSuccess method', () => { test('adds a success toast', () => { - const { toastNotifications } = setup(); + const { toastNotifications, toastsMock } = setup(); toastNotifications.addSuccess({}); - expect(toastNotifications.list[0]).toHaveProperty('color', 'success'); + expect(toastsMock.addSuccess).toHaveBeenCalled(); }); }); describe('addWarning method', () => { test('adds a warning toast', () => { - const { toastNotifications } = setup(); + const { toastNotifications, toastsMock } = setup(); toastNotifications.addWarning({}); - expect(toastNotifications.list[0]).toHaveProperty('color', 'warning'); + expect(toastsMock.addWarning).toHaveBeenCalled(); }); }); describe('addDanger method', () => { test('adds a danger toast', () => { - const { toastNotifications } = setup(); - toastNotifications.addDanger({}); - expect(toastNotifications.list[0]).toHaveProperty('color', 'danger'); + const { toastNotifications, toastsMock } = setup(); + toastNotifications.addWarning({}); + expect(toastsMock.addWarning).toHaveBeenCalled(); }); }); }); diff --git a/x-pack/legacy/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.test.ts b/x-pack/legacy/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.test.ts index 511af53c13ab4..7500c8acadb7e 100644 --- a/x-pack/legacy/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.test.ts +++ b/x-pack/legacy/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.test.ts @@ -10,10 +10,11 @@ import { Legacy } from 'kibana'; import { kibanaTestUser } from '@kbn/test'; import { initSpacesOnRequestInterceptor } from './on_request_interceptor'; import { - HttpServiceSetup, CoreSetup, SavedObjectsLegacyService, SavedObjectsErrorHelpers, + IBasePath, + IRouter, } from '../../../../../../../src/core/server'; import { elasticsearchServiceMock, @@ -46,7 +47,7 @@ describe('onPostAuthInterceptor', () => { afterEach(async () => await root.shutdown()); - function initKbnServer(http: HttpServiceSetup, routes: 'legacy' | 'new-platform') { + function initKbnServer(router: IRouter, basePath: IBasePath, routes: 'legacy' | 'new-platform') { const kbnServer = kbnTestServer.getKbnServer(root); if (routes === 'legacy') { @@ -55,52 +56,50 @@ describe('onPostAuthInterceptor', () => { method: 'GET', path: '/foo', handler: (req: Legacy.Request, h: Legacy.ResponseToolkit) => { - return h.response({ path: req.path, basePath: http.basePath.get(req) }); + return h.response({ path: req.path, basePath: basePath.get(req) }); }, }, { method: 'GET', path: '/app/kibana', handler: (req: Legacy.Request, h: Legacy.ResponseToolkit) => { - return h.response({ path: req.path, basePath: http.basePath.get(req) }); + return h.response({ path: req.path, basePath: basePath.get(req) }); }, }, { method: 'GET', path: '/app/app-1', handler: (req: Legacy.Request, h: Legacy.ResponseToolkit) => { - return h.response({ path: req.path, basePath: http.basePath.get(req) }); + return h.response({ path: req.path, basePath: basePath.get(req) }); }, }, { method: 'GET', path: '/app/app-2', handler: (req: Legacy.Request, h: Legacy.ResponseToolkit) => { - return h.response({ path: req.path, basePath: http.basePath.get(req) }); + return h.response({ path: req.path, basePath: basePath.get(req) }); }, }, { method: 'GET', path: '/api/test/foo', handler: (req: Legacy.Request) => { - return { path: req.path, basePath: http.basePath.get(req) }; + return { path: req.path, basePath: basePath.get(req) }; }, }, { method: 'GET', path: '/some/path/s/foo/bar', handler: (req: Legacy.Request, h: Legacy.ResponseToolkit) => { - return h.response({ path: req.path, basePath: http.basePath.get(req) }); + return h.response({ path: req.path, basePath: basePath.get(req) }); }, }, ]); } if (routes === 'new-platform') { - const router = http.createRouter('/'); - router.get({ path: '/api/np_test/foo', validate: false }, (context, req, h) => { - return h.ok({ body: { path: req.url.pathname, basePath: http.basePath.get(req) } }); + return h.ok({ body: { path: req.url.pathname, basePath: basePath.get(req) } }); }); } } @@ -216,11 +215,13 @@ describe('onPostAuthInterceptor', () => { spacesService, }); - initKbnServer(http, 'new-platform'); + const router = http.createRouter('/'); + + initKbnServer(router, http.basePath, 'new-platform'); await root.start(); - initKbnServer(http, 'legacy'); + initKbnServer(router, http.basePath, 'legacy'); const response = await kbnTestServer.request.get(root, path); diff --git a/x-pack/legacy/plugins/spaces/server/lib/request_interceptors/on_request_interceptor.test.ts b/x-pack/legacy/plugins/spaces/server/lib/request_interceptors/on_request_interceptor.test.ts index e8bfab9fb1df0..fcfa80838efba 100644 --- a/x-pack/legacy/plugins/spaces/server/lib/request_interceptors/on_request_interceptor.test.ts +++ b/x-pack/legacy/plugins/spaces/server/lib/request_interceptors/on_request_interceptor.test.ts @@ -8,10 +8,11 @@ import { Legacy } from 'kibana'; import { schema } from '@kbn/config-schema'; import { initSpacesOnRequestInterceptor } from './on_request_interceptor'; import { - HttpServiceSetup, KibanaRequest, KibanaResponseFactory, CoreSetup, + IBasePath, + IRouter, } from '../../../../../../../src/core/server'; import * as kbnTestServer from '../../../../../../../src/test_utils/kbn_server'; @@ -26,7 +27,7 @@ describe('onRequestInterceptor', () => { afterEach(async () => await root.shutdown()); - function initKbnServer(http: HttpServiceSetup, routes: 'legacy' | 'new-platform') { + function initKbnServer(router: IRouter, basePath: IBasePath, routes: 'legacy' | 'new-platform') { const kbnServer = kbnTestServer.getKbnServer(root); if (routes === 'legacy') { @@ -35,14 +36,14 @@ describe('onRequestInterceptor', () => { method: 'GET', path: '/foo', handler: (req: Legacy.Request, h: Legacy.ResponseToolkit) => { - return h.response({ path: req.path, basePath: http.basePath.get(req) }); + return h.response({ path: req.path, basePath: basePath.get(req) }); }, }, { method: 'GET', path: '/some/path/s/foo/bar', handler: (req: Legacy.Request, h: Legacy.ResponseToolkit) => { - return h.response({ path: req.path, basePath: http.basePath.get(req) }); + return h.response({ path: req.path, basePath: basePath.get(req) }); }, }, { @@ -51,7 +52,7 @@ describe('onRequestInterceptor', () => { handler: (req: Legacy.Request, h: Legacy.ResponseToolkit) => { return h.response({ path: req.path, - basePath: http.basePath.get(req), + basePath: basePath.get(req), query: req.query, }); }, @@ -60,19 +61,17 @@ describe('onRequestInterceptor', () => { } if (routes === 'new-platform') { - const router = http.createRouter('/'); - router.get( { path: '/np_foo', validate: false }, (context: unknown, req: KibanaRequest, h: KibanaResponseFactory) => { - return h.ok({ body: { path: req.url.pathname, basePath: http.basePath.get(req) } }); + return h.ok({ body: { path: req.url.pathname, basePath: basePath.get(req) } }); } ); router.get( { path: '/some/path/s/np_foo/bar', validate: false }, (context: unknown, req: KibanaRequest, h: KibanaResponseFactory) => { - return h.ok({ body: { path: req.url.pathname, basePath: http.basePath.get(req) } }); + return h.ok({ body: { path: req.url.pathname, basePath: basePath.get(req) } }); } ); @@ -91,7 +90,7 @@ describe('onRequestInterceptor', () => { return h.ok({ body: { path: req.url.pathname, - basePath: http.basePath.get(req), + basePath: basePath.get(req), query: req.query, }, }); @@ -117,11 +116,13 @@ describe('onRequestInterceptor', () => { http: (http as unknown) as CoreSetup['http'], }); - initKbnServer(http, 'new-platform'); + const router = http.createRouter('/'); + + initKbnServer(router, http.basePath, 'new-platform'); await root.start(); - initKbnServer(http, 'legacy'); + initKbnServer(router, http.basePath, 'legacy'); return { http, From 4f77267c08e3b6b30adacce6a6cfacadd53d38a2 Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Tue, 8 Oct 2019 11:38:32 -0500 Subject: [PATCH 2/5] PR comments + a few more exports --- .../kibana-plugin-public.errortoastoptions.md | 2 + ...bana-plugin-public.httprequestinit.body.md | 1 + .../kibana-plugin-public.httprequestinit.md | 2 +- ...plugin-public.httpservicebase.intercept.md | 2 +- .../kibana-plugin-public.httpservicebase.md | 2 +- .../kibana-plugin-public.ibasepath.get.md | 13 ++ .../public/kibana-plugin-public.ibasepath.md | 22 ++++ .../kibana-plugin-public.ibasepath.prepend.md | 13 ++ .../kibana-plugin-public.ibasepath.remove.md | 13 ++ .../public/kibana-plugin-public.itoasts.md | 18 +-- .../core/public/kibana-plugin-public.md | 11 +- .../public/kibana-plugin-public.overlayref.md | 2 + .../public/kibana-plugin-public.toastinput.md | 1 + .../kibana-plugin-public.toastinputfields.md | 18 +++ ...a-plugin-public.toastsapi._constructor_.md | 22 ++++ ... => kibana-plugin-public.toastsapi.add.md} | 4 +- ...bana-plugin-public.toastsapi.adddanger.md} | 4 +- ...ibana-plugin-public.toastsapi.adderror.md} | 4 +- ...ana-plugin-public.toastsapi.addsuccess.md} | 4 +- ...ana-plugin-public.toastsapi.addwarning.md} | 4 +- ...=> kibana-plugin-public.toastsapi.get_.md} | 4 +- .../public/kibana-plugin-public.toastsapi.md | 32 +++++ ... kibana-plugin-public.toastsapi.remove.md} | 8 +- ...ana-plugin-server.assistanceapiresponse.md | 1 + ...-plugin-server.assistantapiclientparams.md | 1 + .../kibana-plugin-server.authenticated.md | 19 +++ ...kibana-plugin-server.authenticated.type.md | 11 ++ ...ana-plugin-server.authenticationhandler.md | 2 +- .../server/kibana-plugin-server.authresult.md | 12 ++ .../kibana-plugin-server.authresulttype.md | 19 +++ ...lugin-server.deprecationapiclientparams.md | 1 + ...na-plugin-server.deprecationapiresponse.md | 1 + .../kibana-plugin-server.deprecationinfo.md | 1 + ...kibana-plugin-server.elasticsearcherror.md | 1 + ....elasticsearchservicesetup.adminclient_.md | 2 +- ...r.elasticsearchservicesetup.dataclient_.md | 2 +- ...plugin-server.elasticsearchservicesetup.md | 4 +- ...in-server.httpservicesetup.createrouter.md | 2 +- .../kibana-plugin-server.ikibanaresponse.md | 22 ++++ ...a-plugin-server.ikibanaresponse.options.md | 11 ++ ...a-plugin-server.ikibanaresponse.payload.md | 11 ++ ...na-plugin-server.ikibanaresponse.status.md | 11 ++ ...gin-server.indexsettingsdeprecationinfo.md | 1 + .../core/server/kibana-plugin-server.md | 4 + ...erver.migration_assistance_index_action.md | 1 + ...ugin-server.migration_deprecation_level.md | 1 + .../kibana-plugin-server.requesthandler.md | 2 +- src/core/public/http/types.ts | 12 +- src/core/public/index.ts | 3 + src/core/public/notifications/index.ts | 11 +- src/core/public/notifications/toasts/index.ts | 2 +- .../notifications/toasts/toasts_api.tsx | 123 ++++++++++-------- src/core/public/overlays/overlay_service.ts | 4 + src/core/public/public.api.md | 70 +++++----- src/core/server/elasticsearch/api_types.ts | 8 ++ src/core/server/elasticsearch/errors.ts | 1 + src/core/server/elasticsearch/types.ts | 6 +- src/core/server/http/index.ts | 4 + src/core/server/http/lifecycle/auth.ts | 22 ++-- src/core/server/http/router/index.ts | 2 + src/core/server/http/router/response.ts | 17 ++- src/core/server/http/router/router.ts | 4 +- src/core/server/http/types.ts | 3 +- src/core/server/index.ts | 4 + .../service/saved_objects_client.ts | 2 - src/core/server/server.api.md | 53 ++++---- 66 files changed, 519 insertions(+), 181 deletions(-) create mode 100644 docs/development/core/public/kibana-plugin-public.ibasepath.get.md create mode 100644 docs/development/core/public/kibana-plugin-public.ibasepath.md create mode 100644 docs/development/core/public/kibana-plugin-public.ibasepath.prepend.md create mode 100644 docs/development/core/public/kibana-plugin-public.ibasepath.remove.md create mode 100644 docs/development/core/public/kibana-plugin-public.toastinputfields.md create mode 100644 docs/development/core/public/kibana-plugin-public.toastsapi._constructor_.md rename docs/development/core/public/{kibana-plugin-public.itoasts.add.md => kibana-plugin-public.toastsapi.add.md} (73%) rename docs/development/core/public/{kibana-plugin-public.itoasts.adddanger.md => kibana-plugin-public.toastsapi.adddanger.md} (73%) rename docs/development/core/public/{kibana-plugin-public.itoasts.adderror.md => kibana-plugin-public.toastsapi.adderror.md} (77%) rename docs/development/core/public/{kibana-plugin-public.itoasts.addsuccess.md => kibana-plugin-public.toastsapi.addsuccess.md} (72%) rename docs/development/core/public/{kibana-plugin-public.itoasts.addwarning.md => kibana-plugin-public.toastsapi.addwarning.md} (72%) rename docs/development/core/public/{kibana-plugin-public.itoasts.get_.md => kibana-plugin-public.toastsapi.get_.md} (65%) create mode 100644 docs/development/core/public/kibana-plugin-public.toastsapi.md rename docs/development/core/public/{kibana-plugin-public.itoasts.remove.md => kibana-plugin-public.toastsapi.remove.md} (57%) create mode 100644 docs/development/core/server/kibana-plugin-server.authenticated.md create mode 100644 docs/development/core/server/kibana-plugin-server.authenticated.type.md create mode 100644 docs/development/core/server/kibana-plugin-server.authresult.md create mode 100644 docs/development/core/server/kibana-plugin-server.authresulttype.md create mode 100644 docs/development/core/server/kibana-plugin-server.ikibanaresponse.md create mode 100644 docs/development/core/server/kibana-plugin-server.ikibanaresponse.options.md create mode 100644 docs/development/core/server/kibana-plugin-server.ikibanaresponse.payload.md create mode 100644 docs/development/core/server/kibana-plugin-server.ikibanaresponse.status.md diff --git a/docs/development/core/public/kibana-plugin-public.errortoastoptions.md b/docs/development/core/public/kibana-plugin-public.errortoastoptions.md index 135418632ac98..30fc044ff93e6 100644 --- a/docs/development/core/public/kibana-plugin-public.errortoastoptions.md +++ b/docs/development/core/public/kibana-plugin-public.errortoastoptions.md @@ -4,6 +4,8 @@ ## ErrorToastOptions interface +Options available for APIs. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.body.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.body.md index 997bbf624ff03..44b33c9917543 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.body.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.body.md @@ -4,6 +4,7 @@ ## HttpRequestInit.body property +A BodyInit object or null to set request's body. Signature: diff --git a/docs/development/core/public/kibana-plugin-public.httprequestinit.md b/docs/development/core/public/kibana-plugin-public.httprequestinit.md index ac0d896b3d0c0..1271e039b0713 100644 --- a/docs/development/core/public/kibana-plugin-public.httprequestinit.md +++ b/docs/development/core/public/kibana-plugin-public.httprequestinit.md @@ -16,7 +16,7 @@ export interface HttpRequestInit | Property | Type | Description | | --- | --- | --- | -| [body](./kibana-plugin-public.httprequestinit.body.md) | BodyInit | null | | +| [body](./kibana-plugin-public.httprequestinit.body.md) | BodyInit | null | A BodyInit object or null to set request's body. | | [cache](./kibana-plugin-public.httprequestinit.cache.md) | RequestCache | The cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. | | [credentials](./kibana-plugin-public.httprequestinit.credentials.md) | RequestCredentials | The credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. | | [headers](./kibana-plugin-public.httprequestinit.headers.md) | HttpHeadersInit | [HttpHeadersInit](./kibana-plugin-public.httpheadersinit.md) | diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.intercept.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.intercept.md index 06aae54d8ee9d..8cf5bf813df09 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.intercept.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.intercept.md @@ -4,7 +4,7 @@ ## HttpServiceBase.intercept() method -Adds a new to the global HTTP client. +Adds a new [HttpInterceptor](./kibana-plugin-public.httpinterceptor.md) to the global HTTP client. Signature: diff --git a/docs/development/core/public/kibana-plugin-public.httpservicebase.md b/docs/development/core/public/kibana-plugin-public.httpservicebase.md index 87be9db3a113e..a1eef3db42b7d 100644 --- a/docs/development/core/public/kibana-plugin-public.httpservicebase.md +++ b/docs/development/core/public/kibana-plugin-public.httpservicebase.md @@ -31,6 +31,6 @@ export interface HttpServiceBase | --- | --- | | [addLoadingCount(countSource$)](./kibana-plugin-public.httpservicebase.addloadingcount.md) | Adds a new source of loading counts. Used to show the global loading indicator when sum of all observed counts are more than 0. | | [getLoadingCount$()](./kibana-plugin-public.httpservicebase.getloadingcount_.md) | Get the sum of all loading count sources as a single Observable. | -| [intercept(interceptor)](./kibana-plugin-public.httpservicebase.intercept.md) | Adds a new to the global HTTP client. | +| [intercept(interceptor)](./kibana-plugin-public.httpservicebase.intercept.md) | Adds a new [HttpInterceptor](./kibana-plugin-public.httpinterceptor.md) to the global HTTP client. | | [removeAllInterceptors()](./kibana-plugin-public.httpservicebase.removeallinterceptors.md) | Removes all configured interceptors. | diff --git a/docs/development/core/public/kibana-plugin-public.ibasepath.get.md b/docs/development/core/public/kibana-plugin-public.ibasepath.get.md new file mode 100644 index 0000000000000..08ca3afee11f7 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.ibasepath.get.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IBasePath](./kibana-plugin-public.ibasepath.md) > [get](./kibana-plugin-public.ibasepath.get.md) + +## IBasePath.get property + +Gets the `basePath` string. + +Signature: + +```typescript +get: () => string; +``` diff --git a/docs/development/core/public/kibana-plugin-public.ibasepath.md b/docs/development/core/public/kibana-plugin-public.ibasepath.md new file mode 100644 index 0000000000000..de392d45c4493 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.ibasepath.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IBasePath](./kibana-plugin-public.ibasepath.md) + +## IBasePath interface + +APIs for manipulating the basePath on URL segments. + +Signature: + +```typescript +export interface IBasePath +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [get](./kibana-plugin-public.ibasepath.get.md) | () => string | Gets the basePath string. | +| [prepend](./kibana-plugin-public.ibasepath.prepend.md) | (url: string) => string | Prepends path with the basePath. | +| [remove](./kibana-plugin-public.ibasepath.remove.md) | (url: string) => string | Removes the prepended basePath from the path. | + diff --git a/docs/development/core/public/kibana-plugin-public.ibasepath.prepend.md b/docs/development/core/public/kibana-plugin-public.ibasepath.prepend.md new file mode 100644 index 0000000000000..48b909aa2f7a8 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.ibasepath.prepend.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IBasePath](./kibana-plugin-public.ibasepath.md) > [prepend](./kibana-plugin-public.ibasepath.prepend.md) + +## IBasePath.prepend property + +Prepends `path` with the basePath. + +Signature: + +```typescript +prepend: (url: string) => string; +``` diff --git a/docs/development/core/public/kibana-plugin-public.ibasepath.remove.md b/docs/development/core/public/kibana-plugin-public.ibasepath.remove.md new file mode 100644 index 0000000000000..6af8564420830 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.ibasepath.remove.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IBasePath](./kibana-plugin-public.ibasepath.md) > [remove](./kibana-plugin-public.ibasepath.remove.md) + +## IBasePath.remove property + +Removes the prepended basePath from the `path`. + +Signature: + +```typescript +remove: (url: string) => string; +``` diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.md b/docs/development/core/public/kibana-plugin-public.itoasts.md index 045574eb1d490..2a6d454e2194a 100644 --- a/docs/development/core/public/kibana-plugin-public.itoasts.md +++ b/docs/development/core/public/kibana-plugin-public.itoasts.md @@ -2,24 +2,12 @@ [Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) -## IToasts interface +## IToasts type +Methods for adding and removing global toast messages. See [ToastsApi](./kibana-plugin-public.toastsapi.md). Signature: ```typescript -export interface IToasts +export declare type IToasts = Pick; ``` - -## Methods - -| Method | Description | -| --- | --- | -| [add(toastOrTitle)](./kibana-plugin-public.itoasts.add.md) | Adds a new toast to current array of toast. | -| [addDanger(toastOrTitle)](./kibana-plugin-public.itoasts.adddanger.md) | Adds a new toast pre-configured with the danger color and alert icon. | -| [addError(error, options)](./kibana-plugin-public.itoasts.adderror.md) | Adds a new toast that displays an exception message with a button to open the full stacktrace in a modal. | -| [addSuccess(toastOrTitle)](./kibana-plugin-public.itoasts.addsuccess.md) | Adds a new toast pre-configured with the success color and check icon. | -| [addWarning(toastOrTitle)](./kibana-plugin-public.itoasts.addwarning.md) | Adds a new toast pre-configured with the warning color and help icon. | -| [get$()](./kibana-plugin-public.itoasts.get_.md) | Current array of toast messages to show to user. | -| [remove(toasts)](./kibana-plugin-public.itoasts.remove.md) | Removes a toast from the current array of toasts if present. | - diff --git a/docs/development/core/public/kibana-plugin-public.md b/docs/development/core/public/kibana-plugin-public.md index d577ac2eafdd6..4df9a10a3e65c 100644 --- a/docs/development/core/public/kibana-plugin-public.md +++ b/docs/development/core/public/kibana-plugin-public.md @@ -16,6 +16,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | --- | --- | | [SavedObjectsClient](./kibana-plugin-public.savedobjectsclient.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing plugin state. The client-side SavedObjectsClient is a thin convenience library around the SavedObjects HTTP API for interacting with Saved Objects. | | [SimpleSavedObject](./kibana-plugin-public.simplesavedobject.md) | This class is a very simple wrapper for SavedObjects loaded from the server with the [SavedObjectsClient](./kibana-plugin-public.savedobjectsclient.md).It provides basic functionality for creating/saving/deleting saved objects, but doesn't include any type-specific implementations. | +| [ToastsApi](./kibana-plugin-public.toastsapi.md) | Methods for adding and removing global toast messages. | | [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) | | ## Interfaces @@ -43,7 +44,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [CoreSetup](./kibana-plugin-public.coresetup.md) | Core services exposed to the Plugin setup lifecycle | | [CoreStart](./kibana-plugin-public.corestart.md) | Core services exposed to the Plugin start lifecycle | | [DocLinksStart](./kibana-plugin-public.doclinksstart.md) | | -| [ErrorToastOptions](./kibana-plugin-public.errortoastoptions.md) | | +| [ErrorToastOptions](./kibana-plugin-public.errortoastoptions.md) | Options available for APIs. | | [FatalErrorInfo](./kibana-plugin-public.fatalerrorinfo.md) | Represents the message and stack of a fatal Error | | [FatalErrorsSetup](./kibana-plugin-public.fatalerrorssetup.md) | FatalErrors stop the Kibana Public Core and displays a fatal error screen with details about the Kibana build and the error. | | [HttpErrorRequest](./kibana-plugin-public.httperrorrequest.md) | | @@ -56,17 +57,17 @@ The plugin integrates with the core system via lifecycle events: `setup` | [HttpResponse](./kibana-plugin-public.httpresponse.md) | | | [HttpServiceBase](./kibana-plugin-public.httpservicebase.md) | | | [I18nStart](./kibana-plugin-public.i18nstart.md) | I18nStart.Context is required by any localizable React component from @kbn/i18n and @elastic/eui packages and is supposed to be used as the topmost component for any i18n-compatible React tree. | +| [IBasePath](./kibana-plugin-public.ibasepath.md) | APIs for manipulating the basePath on URL segments. | | [IContextContainer](./kibana-plugin-public.icontextcontainer.md) | An object that handles registration of context providers and configuring handlers with context. | | [IHttpFetchError](./kibana-plugin-public.ihttpfetcherror.md) | | | [IHttpInterceptController](./kibana-plugin-public.ihttpinterceptcontroller.md) | Used to halt a request Promise chain in a [HttpInterceptor](./kibana-plugin-public.httpinterceptor.md). | -| [IToasts](./kibana-plugin-public.itoasts.md) | | | [LegacyCoreSetup](./kibana-plugin-public.legacycoresetup.md) | Setup interface exposed to the legacy platform via the ui/new_platform module. | | [LegacyCoreStart](./kibana-plugin-public.legacycorestart.md) | Start interface exposed to the legacy platform via the ui/new_platform module. | | [LegacyNavLink](./kibana-plugin-public.legacynavlink.md) | | | [NotificationsSetup](./kibana-plugin-public.notificationssetup.md) | | | [NotificationsStart](./kibana-plugin-public.notificationsstart.md) | | | [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) | | -| [OverlayRef](./kibana-plugin-public.overlayref.md) | | +| [OverlayRef](./kibana-plugin-public.overlayref.md) | Returned by [OverlayStart](./kibana-plugin-public.overlaystart.md) methods for closing a mounted overlay. | | [OverlayStart](./kibana-plugin-public.overlaystart.md) | | | [Plugin](./kibana-plugin-public.plugin.md) | The interface that should be returned by a PluginInitializer. | | [PluginInitializerContext](./kibana-plugin-public.plugininitializercontext.md) | The available core services passed to a PluginInitializer | @@ -100,6 +101,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [HttpSetup](./kibana-plugin-public.httpsetup.md) | See [HttpServiceBase](./kibana-plugin-public.httpservicebase.md) | | [HttpStart](./kibana-plugin-public.httpstart.md) | See [HttpServiceBase](./kibana-plugin-public.httpservicebase.md) | | [IContextProvider](./kibana-plugin-public.icontextprovider.md) | A function that returns a context value for a specific key of given context type. | +| [IToasts](./kibana-plugin-public.itoasts.md) | Methods for adding and removing global toast messages. See [ToastsApi](./kibana-plugin-public.toastsapi.md). | | [OverlayBannerMount](./kibana-plugin-public.overlaybannermount.md) | A function that will mount the banner inside the provided element. | | [OverlayBannerUnmount](./kibana-plugin-public.overlaybannerunmount.md) | A function that will unmount the banner from the element. | | [PluginInitializer](./kibana-plugin-public.plugininitializer.md) | The plugin export at the root of a plugin's public directory should conform to this interface. | @@ -108,7 +110,8 @@ The plugin integrates with the core system via lifecycle events: `setup` | [SavedObjectAttribute](./kibana-plugin-public.savedobjectattribute.md) | Type definition for a Saved Object attribute value | | [SavedObjectAttributeSingle](./kibana-plugin-public.savedobjectattributesingle.md) | Don't use this type, it's simply a helper type for [SavedObjectAttribute](./kibana-plugin-public.savedobjectattribute.md) | | [SavedObjectsClientContract](./kibana-plugin-public.savedobjectsclientcontract.md) | SavedObjectsClientContract as implemented by the [SavedObjectsClient](./kibana-plugin-public.savedobjectsclient.md) | -| [ToastInput](./kibana-plugin-public.toastinput.md) | | +| [ToastInput](./kibana-plugin-public.toastinput.md) | Inputs for [IToasts](./kibana-plugin-public.itoasts.md) APIs. | +| [ToastInputFields](./kibana-plugin-public.toastinputfields.md) | Allowed fields for [ToastInput](./kibana-plugin-public.toastinput.md). | | [ToastsSetup](./kibana-plugin-public.toastssetup.md) | [IToasts](./kibana-plugin-public.itoasts.md) | | [ToastsStart](./kibana-plugin-public.toastsstart.md) | [IToasts](./kibana-plugin-public.itoasts.md) | | [UiSettingsClientContract](./kibana-plugin-public.uisettingsclientcontract.md) | [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) | diff --git a/docs/development/core/public/kibana-plugin-public.overlayref.md b/docs/development/core/public/kibana-plugin-public.overlayref.md index ba573ccf10bbe..e71415280e4d2 100644 --- a/docs/development/core/public/kibana-plugin-public.overlayref.md +++ b/docs/development/core/public/kibana-plugin-public.overlayref.md @@ -4,6 +4,8 @@ ## OverlayRef interface +Returned by [OverlayStart](./kibana-plugin-public.overlaystart.md) methods for closing a mounted overlay. + Signature: ```typescript diff --git a/docs/development/core/public/kibana-plugin-public.toastinput.md b/docs/development/core/public/kibana-plugin-public.toastinput.md index 8e798697fa6c0..75f12b3d94561 100644 --- a/docs/development/core/public/kibana-plugin-public.toastinput.md +++ b/docs/development/core/public/kibana-plugin-public.toastinput.md @@ -4,6 +4,7 @@ ## ToastInput type +Inputs for [IToasts](./kibana-plugin-public.itoasts.md) APIs. Signature: diff --git a/docs/development/core/public/kibana-plugin-public.toastinputfields.md b/docs/development/core/public/kibana-plugin-public.toastinputfields.md new file mode 100644 index 0000000000000..ffcf9e5c6dea2 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.toastinputfields.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastInputFields](./kibana-plugin-public.toastinputfields.md) + +## ToastInputFields type + +Allowed fields for [ToastInput](./kibana-plugin-public.toastinput.md). + +Signature: + +```typescript +export declare type ToastInputFields = Pick>; +``` + +## Remarks + +`id` cannot be specified. + diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi._constructor_.md b/docs/development/core/public/kibana-plugin-public.toastsapi._constructor_.md new file mode 100644 index 0000000000000..31a16403a41a1 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.toastsapi._constructor_.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [(constructor)](./kibana-plugin-public.toastsapi._constructor_.md) + +## ToastsApi.(constructor) + +Constructs a new instance of the `ToastsApi` class + +Signature: + +```typescript +constructor(deps: { + uiSettings: UiSettingsClientContract; + }); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| deps | {
uiSettings: UiSettingsClientContract;
} | | + diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.add.md b/docs/development/core/public/kibana-plugin-public.toastsapi.add.md similarity index 73% rename from docs/development/core/public/kibana-plugin-public.itoasts.add.md rename to docs/development/core/public/kibana-plugin-public.toastsapi.add.md index 541b26837aeea..8e9648031f0e2 100644 --- a/docs/development/core/public/kibana-plugin-public.itoasts.add.md +++ b/docs/development/core/public/kibana-plugin-public.toastsapi.add.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [add](./kibana-plugin-public.itoasts.add.md) +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [add](./kibana-plugin-public.toastsapi.add.md) -## IToasts.add() method +## ToastsApi.add() method Adds a new toast to current array of toast. diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.adddanger.md b/docs/development/core/public/kibana-plugin-public.toastsapi.adddanger.md similarity index 73% rename from docs/development/core/public/kibana-plugin-public.itoasts.adddanger.md rename to docs/development/core/public/kibana-plugin-public.toastsapi.adddanger.md index cd8610e0f5d0c..28e596f0c09e3 100644 --- a/docs/development/core/public/kibana-plugin-public.itoasts.adddanger.md +++ b/docs/development/core/public/kibana-plugin-public.toastsapi.adddanger.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [addDanger](./kibana-plugin-public.itoasts.adddanger.md) +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [addDanger](./kibana-plugin-public.toastsapi.adddanger.md) -## IToasts.addDanger() method +## ToastsApi.addDanger() method Adds a new toast pre-configured with the danger color and alert icon. diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.adderror.md b/docs/development/core/public/kibana-plugin-public.toastsapi.adderror.md similarity index 77% rename from docs/development/core/public/kibana-plugin-public.itoasts.adderror.md rename to docs/development/core/public/kibana-plugin-public.toastsapi.adderror.md index b1c0598f9c38f..c8a48b3fa46c9 100644 --- a/docs/development/core/public/kibana-plugin-public.itoasts.adderror.md +++ b/docs/development/core/public/kibana-plugin-public.toastsapi.adderror.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [addError](./kibana-plugin-public.itoasts.adderror.md) +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [addError](./kibana-plugin-public.toastsapi.adderror.md) -## IToasts.addError() method +## ToastsApi.addError() method Adds a new toast that displays an exception message with a button to open the full stacktrace in a modal. diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.addsuccess.md b/docs/development/core/public/kibana-plugin-public.toastsapi.addsuccess.md similarity index 72% rename from docs/development/core/public/kibana-plugin-public.itoasts.addsuccess.md rename to docs/development/core/public/kibana-plugin-public.toastsapi.addsuccess.md index 9e355c6c5492f..0e01dc1364d07 100644 --- a/docs/development/core/public/kibana-plugin-public.itoasts.addsuccess.md +++ b/docs/development/core/public/kibana-plugin-public.toastsapi.addsuccess.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [addSuccess](./kibana-plugin-public.itoasts.addsuccess.md) +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [addSuccess](./kibana-plugin-public.toastsapi.addsuccess.md) -## IToasts.addSuccess() method +## ToastsApi.addSuccess() method Adds a new toast pre-configured with the success color and check icon. diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.addwarning.md b/docs/development/core/public/kibana-plugin-public.toastsapi.addwarning.md similarity index 72% rename from docs/development/core/public/kibana-plugin-public.itoasts.addwarning.md rename to docs/development/core/public/kibana-plugin-public.toastsapi.addwarning.md index 06efc2c94cf06..0e236f2737b12 100644 --- a/docs/development/core/public/kibana-plugin-public.itoasts.addwarning.md +++ b/docs/development/core/public/kibana-plugin-public.toastsapi.addwarning.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [addWarning](./kibana-plugin-public.itoasts.addwarning.md) +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [addWarning](./kibana-plugin-public.toastsapi.addwarning.md) -## IToasts.addWarning() method +## ToastsApi.addWarning() method Adds a new toast pre-configured with the warning color and help icon. diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.get_.md b/docs/development/core/public/kibana-plugin-public.toastsapi.get_.md similarity index 65% rename from docs/development/core/public/kibana-plugin-public.itoasts.get_.md rename to docs/development/core/public/kibana-plugin-public.toastsapi.get_.md index f5d00f4c10341..ec02654fa3c82 100644 --- a/docs/development/core/public/kibana-plugin-public.itoasts.get_.md +++ b/docs/development/core/public/kibana-plugin-public.toastsapi.get_.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [get$](./kibana-plugin-public.itoasts.get_.md) +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [get$](./kibana-plugin-public.toastsapi.get_.md) -## IToasts.get$() method +## ToastsApi.get$() method Current array of toast messages to show to user. diff --git a/docs/development/core/public/kibana-plugin-public.toastsapi.md b/docs/development/core/public/kibana-plugin-public.toastsapi.md new file mode 100644 index 0000000000000..4a53a59d9b173 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-public.toastsapi.md @@ -0,0 +1,32 @@ + + +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) + +## ToastsApi class + +Methods for adding and removing global toast messages. + +Signature: + +```typescript +export declare class ToastsApi implements IToasts +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(deps)](./kibana-plugin-public.toastsapi._constructor_.md) | | Constructs a new instance of the ToastsApi class | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(toastOrTitle)](./kibana-plugin-public.toastsapi.add.md) | | Adds a new toast to current array of toast. | +| [addDanger(toastOrTitle)](./kibana-plugin-public.toastsapi.adddanger.md) | | Adds a new toast pre-configured with the danger color and alert icon. | +| [addError(error, options)](./kibana-plugin-public.toastsapi.adderror.md) | | Adds a new toast that displays an exception message with a button to open the full stacktrace in a modal. | +| [addSuccess(toastOrTitle)](./kibana-plugin-public.toastsapi.addsuccess.md) | | Adds a new toast pre-configured with the success color and check icon. | +| [addWarning(toastOrTitle)](./kibana-plugin-public.toastsapi.addwarning.md) | | Adds a new toast pre-configured with the warning color and help icon. | +| [get$()](./kibana-plugin-public.toastsapi.get_.md) | | Current array of toast messages to show to user. | +| [remove(toast)](./kibana-plugin-public.toastsapi.remove.md) | | Removes a toast from the current array of toasts if present. | + diff --git a/docs/development/core/public/kibana-plugin-public.itoasts.remove.md b/docs/development/core/public/kibana-plugin-public.toastsapi.remove.md similarity index 57% rename from docs/development/core/public/kibana-plugin-public.itoasts.remove.md rename to docs/development/core/public/kibana-plugin-public.toastsapi.remove.md index cebb38c0fcc6f..5025c83a666c8 100644 --- a/docs/development/core/public/kibana-plugin-public.itoasts.remove.md +++ b/docs/development/core/public/kibana-plugin-public.toastsapi.remove.md @@ -1,22 +1,22 @@ -[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IToasts](./kibana-plugin-public.itoasts.md) > [remove](./kibana-plugin-public.itoasts.remove.md) +[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [ToastsApi](./kibana-plugin-public.toastsapi.md) > [remove](./kibana-plugin-public.toastsapi.remove.md) -## IToasts.remove() method +## ToastsApi.remove() method Removes a toast from the current array of toasts if present. Signature: ```typescript -remove(toasts: Toast): void; +remove(toast: Toast): void; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| toasts | Toast | | +| toast | Toast | a returned by | Returns: diff --git a/docs/development/core/server/kibana-plugin-server.assistanceapiresponse.md b/docs/development/core/server/kibana-plugin-server.assistanceapiresponse.md index 8e8dfb07ca08a..398fe62ce2479 100644 --- a/docs/development/core/server/kibana-plugin-server.assistanceapiresponse.md +++ b/docs/development/core/server/kibana-plugin-server.assistanceapiresponse.md @@ -4,6 +4,7 @@ ## AssistanceAPIResponse interface + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-server.assistantapiclientparams.md b/docs/development/core/server/kibana-plugin-server.assistantapiclientparams.md index eb03b943a30ef..cf7ca56c8a75e 100644 --- a/docs/development/core/server/kibana-plugin-server.assistantapiclientparams.md +++ b/docs/development/core/server/kibana-plugin-server.assistantapiclientparams.md @@ -4,6 +4,7 @@ ## AssistantAPIClientParams interface + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-server.authenticated.md b/docs/development/core/server/kibana-plugin-server.authenticated.md new file mode 100644 index 0000000000000..d955f1f32f1f7 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.authenticated.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [Authenticated](./kibana-plugin-server.authenticated.md) + +## Authenticated interface + + +Signature: + +```typescript +export interface Authenticated extends AuthResultParams +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [type](./kibana-plugin-server.authenticated.type.md) | AuthResultType.authenticated | | + diff --git a/docs/development/core/server/kibana-plugin-server.authenticated.type.md b/docs/development/core/server/kibana-plugin-server.authenticated.type.md new file mode 100644 index 0000000000000..08a73e812d157 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.authenticated.type.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [Authenticated](./kibana-plugin-server.authenticated.md) > [type](./kibana-plugin-server.authenticated.type.md) + +## Authenticated.type property + +Signature: + +```typescript +type: AuthResultType.authenticated; +``` diff --git a/docs/development/core/server/kibana-plugin-server.authenticationhandler.md b/docs/development/core/server/kibana-plugin-server.authenticationhandler.md index 7b845b49eab59..ff60e6e811ed6 100644 --- a/docs/development/core/server/kibana-plugin-server.authenticationhandler.md +++ b/docs/development/core/server/kibana-plugin-server.authenticationhandler.md @@ -9,5 +9,5 @@ See [AuthToolkit](./kibana-plugin-server.authtoolkit.md). Signature: ```typescript -export declare type AuthenticationHandler = (request: KibanaRequest, response: LifecycleResponseFactory, toolkit: AuthToolkit) => AuthResult | KibanaResponse | Promise; +export declare type AuthenticationHandler = (request: KibanaRequest, response: LifecycleResponseFactory, toolkit: AuthToolkit) => AuthResult | IKibanaResponse | Promise; ``` diff --git a/docs/development/core/server/kibana-plugin-server.authresult.md b/docs/development/core/server/kibana-plugin-server.authresult.md new file mode 100644 index 0000000000000..5d1bdbc8e7118 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.authresult.md @@ -0,0 +1,12 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [AuthResult](./kibana-plugin-server.authresult.md) + +## AuthResult type + + +Signature: + +```typescript +export declare type AuthResult = Authenticated; +``` diff --git a/docs/development/core/server/kibana-plugin-server.authresulttype.md b/docs/development/core/server/kibana-plugin-server.authresulttype.md new file mode 100644 index 0000000000000..e8962cb14d198 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.authresulttype.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [AuthResultType](./kibana-plugin-server.authresulttype.md) + +## AuthResultType enum + + +Signature: + +```typescript +export declare enum AuthResultType +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| authenticated | "authenticated" | | + diff --git a/docs/development/core/server/kibana-plugin-server.deprecationapiclientparams.md b/docs/development/core/server/kibana-plugin-server.deprecationapiclientparams.md index 3dfe6b181a3d3..47af79ae464b2 100644 --- a/docs/development/core/server/kibana-plugin-server.deprecationapiclientparams.md +++ b/docs/development/core/server/kibana-plugin-server.deprecationapiclientparams.md @@ -4,6 +4,7 @@ ## DeprecationAPIClientParams interface + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-server.deprecationapiresponse.md b/docs/development/core/server/kibana-plugin-server.deprecationapiresponse.md index 8ebe61f4efaa5..5a2954d10c161 100644 --- a/docs/development/core/server/kibana-plugin-server.deprecationapiresponse.md +++ b/docs/development/core/server/kibana-plugin-server.deprecationapiresponse.md @@ -4,6 +4,7 @@ ## DeprecationAPIResponse interface + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-server.deprecationinfo.md b/docs/development/core/server/kibana-plugin-server.deprecationinfo.md index 21c10bde26378..c27f5d3404c22 100644 --- a/docs/development/core/server/kibana-plugin-server.deprecationinfo.md +++ b/docs/development/core/server/kibana-plugin-server.deprecationinfo.md @@ -4,6 +4,7 @@ ## DeprecationInfo interface + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-server.elasticsearcherror.md b/docs/development/core/server/kibana-plugin-server.elasticsearcherror.md index a1d15704d5e1c..9d9e21c44760c 100644 --- a/docs/development/core/server/kibana-plugin-server.elasticsearcherror.md +++ b/docs/development/core/server/kibana-plugin-server.elasticsearcherror.md @@ -4,6 +4,7 @@ ## ElasticsearchError interface + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.adminclient_.md b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.adminclient_.md index 4c3de56938d2d..b5bfc68d3ca0c 100644 --- a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.adminclient_.md +++ b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.adminclient_.md @@ -4,7 +4,7 @@ ## ElasticsearchServiceSetup.adminClient$ property -Observable of clients for the `admin` cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md) +Observable of clients for the `admin` cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md). ```js diff --git a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.dataclient_.md b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.dataclient_.md index eafc0f3929374..9411f2f6b8694 100644 --- a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.dataclient_.md +++ b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.dataclient_.md @@ -4,7 +4,7 @@ ## ElasticsearchServiceSetup.dataClient$ property -Observable of clients for the `data` cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md) +Observable of clients for the `data` cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md). ```js diff --git a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md index 4690033be6e2d..e3d151cdc0d8b 100644 --- a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md +++ b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md @@ -15,14 +15,14 @@ export interface ElasticsearchServiceSetup | Property | Type | Description | | --- | --- | --- | -| [adminClient$](./kibana-plugin-server.elasticsearchservicesetup.adminclient_.md) | Observable<IClusterClient> | Observable of clients for the admin cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md) +| [adminClient$](./kibana-plugin-server.elasticsearchservicesetup.adminclient_.md) | Observable<IClusterClient> | Observable of clients for the admin cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md). ```js const client = await elasticsearch.adminClient$.pipe(take(1)).toPromise(); ``` | | [createClient](./kibana-plugin-server.elasticsearchservicesetup.createclient.md) | (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => IClusterClient | Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-server.iclusterclient.md). | -| [dataClient$](./kibana-plugin-server.elasticsearchservicesetup.dataclient_.md) | Observable<IClusterClient> | Observable of clients for the data cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md) +| [dataClient$](./kibana-plugin-server.elasticsearchservicesetup.dataclient_.md) | Observable<IClusterClient> | Observable of clients for the data cluster. Observable emits when Elasticsearch config changes on the Kibana server. See [IClusterClient](./kibana-plugin-server.iclusterclient.md). ```js const client = await elasticsearch.dataClient$.pipe(take(1)).toPromise(); diff --git a/docs/development/core/server/kibana-plugin-server.httpservicesetup.createrouter.md b/docs/development/core/server/kibana-plugin-server.httpservicesetup.createrouter.md index 826136853fd6a..6431589c55bd1 100644 --- a/docs/development/core/server/kibana-plugin-server.httpservicesetup.createrouter.md +++ b/docs/development/core/server/kibana-plugin-server.httpservicesetup.createrouter.md @@ -14,7 +14,7 @@ createRouter: () => IRouter; ## Remarks -Each route can have only one handler functions, which is executed when the route is matched. All routes are prefixed with plugin name as a first segment of URL path. See the [IRouter](./kibana-plugin-server.irouter.md) documentation for more information. +Each route can have only one handler function, which is executed when the route is matched. See the [IRouter](./kibana-plugin-server.irouter.md) documentation for more information. ## Example diff --git a/docs/development/core/server/kibana-plugin-server.ikibanaresponse.md b/docs/development/core/server/kibana-plugin-server.ikibanaresponse.md new file mode 100644 index 0000000000000..4971d6eb97a28 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.ikibanaresponse.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [IKibanaResponse](./kibana-plugin-server.ikibanaresponse.md) + +## IKibanaResponse interface + +A response data object, expected to returned as a result of [RequestHandler](./kibana-plugin-server.requesthandler.md) execution + +Signature: + +```typescript +export interface IKibanaResponse +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [options](./kibana-plugin-server.ikibanaresponse.options.md) | HttpResponseOptions | | +| [payload](./kibana-plugin-server.ikibanaresponse.payload.md) | T | | +| [status](./kibana-plugin-server.ikibanaresponse.status.md) | number | | + diff --git a/docs/development/core/server/kibana-plugin-server.ikibanaresponse.options.md b/docs/development/core/server/kibana-plugin-server.ikibanaresponse.options.md new file mode 100644 index 0000000000000..988d873c088fe --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.ikibanaresponse.options.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [IKibanaResponse](./kibana-plugin-server.ikibanaresponse.md) > [options](./kibana-plugin-server.ikibanaresponse.options.md) + +## IKibanaResponse.options property + +Signature: + +```typescript +readonly options: HttpResponseOptions; +``` diff --git a/docs/development/core/server/kibana-plugin-server.ikibanaresponse.payload.md b/docs/development/core/server/kibana-plugin-server.ikibanaresponse.payload.md new file mode 100644 index 0000000000000..f1d10c5d22a42 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.ikibanaresponse.payload.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [IKibanaResponse](./kibana-plugin-server.ikibanaresponse.md) > [payload](./kibana-plugin-server.ikibanaresponse.payload.md) + +## IKibanaResponse.payload property + +Signature: + +```typescript +readonly payload?: T; +``` diff --git a/docs/development/core/server/kibana-plugin-server.ikibanaresponse.status.md b/docs/development/core/server/kibana-plugin-server.ikibanaresponse.status.md new file mode 100644 index 0000000000000..b766ff66c357f --- /dev/null +++ b/docs/development/core/server/kibana-plugin-server.ikibanaresponse.status.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [IKibanaResponse](./kibana-plugin-server.ikibanaresponse.md) > [status](./kibana-plugin-server.ikibanaresponse.status.md) + +## IKibanaResponse.status property + +Signature: + +```typescript +readonly status: number; +``` diff --git a/docs/development/core/server/kibana-plugin-server.indexsettingsdeprecationinfo.md b/docs/development/core/server/kibana-plugin-server.indexsettingsdeprecationinfo.md index 8fd0c6bb9f997..66b15e532e2ad 100644 --- a/docs/development/core/server/kibana-plugin-server.indexsettingsdeprecationinfo.md +++ b/docs/development/core/server/kibana-plugin-server.indexsettingsdeprecationinfo.md @@ -4,6 +4,7 @@ ## IndexSettingsDeprecationInfo interface + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-server.md b/docs/development/core/server/kibana-plugin-server.md index 5e22b7908bddc..bd55924bd45bd 100644 --- a/docs/development/core/server/kibana-plugin-server.md +++ b/docs/development/core/server/kibana-plugin-server.md @@ -27,6 +27,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | Enumeration | Description | | --- | --- | +| [AuthResultType](./kibana-plugin-server.authresulttype.md) | | | [AuthStatus](./kibana-plugin-server.authstatus.md) | Status indicating an outcome of the authentication. | ## Interfaces @@ -36,6 +37,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [APICaller](./kibana-plugin-server.apicaller.md) | | | [AssistanceAPIResponse](./kibana-plugin-server.assistanceapiresponse.md) | | | [AssistantAPIClientParams](./kibana-plugin-server.assistantapiclientparams.md) | | +| [Authenticated](./kibana-plugin-server.authenticated.md) | | | [AuthResultParams](./kibana-plugin-server.authresultparams.md) | Result of an incoming request authentication. | | [AuthToolkit](./kibana-plugin-server.authtoolkit.md) | A tool set defining an outcome of Auth interceptor for incoming request. | | [CallAPIOptions](./kibana-plugin-server.callapioptions.md) | The set of options that defines how API call should be made and result be processed. | @@ -55,6 +57,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to hapi server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. | | [HttpServiceStart](./kibana-plugin-server.httpservicestart.md) | | | [IContextContainer](./kibana-plugin-server.icontextcontainer.md) | An object that handles registration of context providers and configuring handlers with context. | +| [IKibanaResponse](./kibana-plugin-server.ikibanaresponse.md) | A response data object, expected to returned as a result of [RequestHandler](./kibana-plugin-server.requesthandler.md) execution | | [IKibanaSocket](./kibana-plugin-server.ikibanasocket.md) | A tiny abstraction for TCP socket. | | [IndexSettingsDeprecationInfo](./kibana-plugin-server.indexsettingsdeprecationinfo.md) | | | [IRouter](./kibana-plugin-server.irouter.md) | Registers route handlers for specified resource path and method. See [RouteConfig](./kibana-plugin-server.routeconfig.md) and [RequestHandler](./kibana-plugin-server.requesthandler.md) for more information about arguments to route registrations. | @@ -118,6 +121,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | --- | --- | | [AuthenticationHandler](./kibana-plugin-server.authenticationhandler.md) | See [AuthToolkit](./kibana-plugin-server.authtoolkit.md). | | [AuthHeaders](./kibana-plugin-server.authheaders.md) | Auth Headers map | +| [AuthResult](./kibana-plugin-server.authresult.md) | | | [ConfigPath](./kibana-plugin-server.configpath.md) | | | [ElasticsearchClientConfig](./kibana-plugin-server.elasticsearchclientconfig.md) | | | [GetAuthHeaders](./kibana-plugin-server.getauthheaders.md) | Get headers to authenticate a user against Elasticsearch. | diff --git a/docs/development/core/server/kibana-plugin-server.migration_assistance_index_action.md b/docs/development/core/server/kibana-plugin-server.migration_assistance_index_action.md index 4753bd0db71f6..e5ecc6779b282 100644 --- a/docs/development/core/server/kibana-plugin-server.migration_assistance_index_action.md +++ b/docs/development/core/server/kibana-plugin-server.migration_assistance_index_action.md @@ -4,6 +4,7 @@ ## MIGRATION\_ASSISTANCE\_INDEX\_ACTION type + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-server.migration_deprecation_level.md b/docs/development/core/server/kibana-plugin-server.migration_deprecation_level.md index 2751faf6a1cd9..33e02a1b2bce0 100644 --- a/docs/development/core/server/kibana-plugin-server.migration_deprecation_level.md +++ b/docs/development/core/server/kibana-plugin-server.migration_deprecation_level.md @@ -4,6 +4,7 @@ ## MIGRATION\_DEPRECATION\_LEVEL type + Signature: ```typescript diff --git a/docs/development/core/server/kibana-plugin-server.requesthandler.md b/docs/development/core/server/kibana-plugin-server.requesthandler.md index 0b6a127119d8e..035d16c9fca3c 100644 --- a/docs/development/core/server/kibana-plugin-server.requesthandler.md +++ b/docs/development/core/server/kibana-plugin-server.requesthandler.md @@ -9,7 +9,7 @@ A function executed when route path matched requested resource path. Request han Signature: ```typescript -export declare type RequestHandler

= (context: RequestHandlerContext, request: KibanaRequest, TypeOf, TypeOf>, response: KibanaResponseFactory) => KibanaResponse | Promise>; +export declare type RequestHandler

= (context: RequestHandlerContext, request: KibanaRequest, TypeOf, TypeOf>, response: KibanaResponseFactory) => IKibanaResponse | Promise>; ``` ## Example diff --git a/src/core/public/http/types.ts b/src/core/public/http/types.ts index 4aa872ca59fb6..9bc1313fae546 100644 --- a/src/core/public/http/types.ts +++ b/src/core/public/http/types.ts @@ -30,8 +30,8 @@ export interface HttpServiceBase { basePath: IBasePath; /** - * Adds a new {@link HTTPInterceptor} to the global HTTP client. - * @param interceptor a {@link HTTPInterceptor} + * Adds a new {@link HttpInterceptor} to the global HTTP client. + * @param interceptor a {@link HttpInterceptor} * @returns a function for removing the attached interceptor. */ intercept(interceptor: HttpInterceptor): () => void; @@ -71,6 +71,10 @@ export interface HttpServiceBase { getLoadingCount$(): Observable; } +/** + * APIs for manipulating the basePath on URL segments. + * @public + */ export interface IBasePath { /** * Gets the `basePath` string. @@ -112,7 +116,9 @@ export interface HttpHeadersInit { * @public */ export interface HttpRequestInit { - /** {@inheritdoc RequestInit.body} */ + /** + * A BodyInit object or null to set request's body. + */ body?: BodyInit | null; /** diff --git a/src/core/public/index.ts b/src/core/public/index.ts index 381d8e6e1f0b0..5efc94af38246 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -106,6 +106,7 @@ export { HttpResponse, HttpHandler, HttpBody, + IBasePath, IHttpInterceptController, IHttpFetchError, } from './http'; @@ -122,6 +123,8 @@ export { Toast, ToastInput, IToasts, + ToastsApi, + ToastInputFields, ToastsSetup, ToastsStart, ErrorToastOptions, diff --git a/src/core/public/notifications/index.ts b/src/core/public/notifications/index.ts index f67c34709ea52..55b64ac375f08 100644 --- a/src/core/public/notifications/index.ts +++ b/src/core/public/notifications/index.ts @@ -17,7 +17,16 @@ * under the License. */ -export { ErrorToastOptions, Toast, ToastInput, IToasts, ToastsSetup, ToastsStart } from './toasts'; +export { + ErrorToastOptions, + Toast, + ToastInput, + IToasts, + ToastsApi, + ToastInputFields, + ToastsSetup, + ToastsStart, +} from './toasts'; export { NotificationsService, NotificationsSetup, diff --git a/src/core/public/notifications/toasts/index.ts b/src/core/public/notifications/toasts/index.ts index 57901747eca9d..83c2d52f3d77a 100644 --- a/src/core/public/notifications/toasts/index.ts +++ b/src/core/public/notifications/toasts/index.ts @@ -18,5 +18,5 @@ */ export { ToastsService, ToastsSetup, ToastsStart } from './toasts_service'; -export { ErrorToastOptions, ToastsApi, ToastInput, IToasts } from './toasts_api'; +export { ErrorToastOptions, ToastsApi, ToastInput, IToasts, ToastInputFields } from './toasts_api'; export { EuiGlobalToastListToast as Toast } from '@elastic/eui'; diff --git a/src/core/public/notifications/toasts/toasts_api.tsx b/src/core/public/notifications/toasts/toasts_api.tsx index 5cc5b46ab458a..17015faf2c0a3 100644 --- a/src/core/public/notifications/toasts/toasts_api.tsx +++ b/src/core/public/notifications/toasts/toasts_api.tsx @@ -25,11 +25,26 @@ import { ErrorToast } from './error_toast'; import { UiSettingsClientContract } from '../../ui_settings'; import { OverlayStart } from '../../overlays'; -type ToastInputFields = Pick>; +/** + * Allowed fields for {@link ToastInput}. + * + * @remarks + * `id` cannot be specified. + * + * @public + */ +export type ToastInputFields = Pick>; -/** @public */ +/** + * Inputs for {@link IToasts} APIs. + * @public + */ export type ToastInput = string | ToastInputFields | Promise; +/** + * Options available for {@link IToast} APIs. + * @public + */ export interface ErrorToastOptions { /** * The title of the toast and the dialog when expanding the message. @@ -54,60 +69,19 @@ const normalizeToast = (toastOrTitle: ToastInput) => { return toastOrTitle; }; -/** @public */ -export interface IToasts { - /** Current array of toast messages to show to user. */ - get$(): Rx.Observable; - - /** - * Adds a new toast to current array of toast. - * - * @param toastOrTitle - a {@link ToastInput} - * @returns a {@link Toast} - */ - add(toastOrTitle: ToastInput): Toast; - - /** - * Removes a toast from the current array of toasts if present. - * @param toast - a {@link Toast} returned by {@link IToast.add} - */ - remove(toasts: Toast): void; - - /** - * Adds a new toast pre-configured with the success color and check icon. - * - * @param toastOrTitle - a {@link ToastInput} - * @returns a {@link Toast} - */ - addSuccess(toastOrTitle: ToastInput): Toast; - - /** - * Adds a new toast pre-configured with the warning color and help icon. - * - * @param toastOrTitle - a {@link ToastInput} - * @returns a {@link Toast} - */ - addWarning(toastOrTitle: ToastInput): Toast; - - /** - * Adds a new toast pre-configured with the danger color and alert icon. - * - * @param toastOrTitle - a {@link ToastInput} - * @returns a {@link Toast} - */ - addDanger(toastOrTitle: ToastInput): Toast; - - /** - * Adds a new toast that displays an exception message with a button to open the full stacktrace in a modal. - * - * @param error - an `Error` instance. - * @param options - {@link ErrorToastOptions} - * @returns a {@link Toast} - */ - addError(error: Error, options: ErrorToastOptions): Toast; -} - -/** @internal */ +/** + * Methods for adding and removing global toast messages. See {@link ToastsApi}. + * @public + */ +export type IToasts = Pick< + ToastsApi, + 'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError' +>; + +/** + * Methods for adding and removing global toast messages. + * @public + */ export class ToastsApi implements IToasts { private toasts$ = new Rx.BehaviorSubject([]); private idCounter = 0; @@ -119,14 +93,22 @@ export class ToastsApi implements IToasts { this.uiSettings = deps.uiSettings; } + /** @internal */ public registerOverlays(overlays: OverlayStart) { this.overlays = overlays; } + /** Current array of toast messages to show to user. */ public get$() { return this.toasts$.asObservable(); } + /** + * Adds a new toast to current array of toast. + * + * @param toastOrTitle - a {@link ToastInput} + * @returns a {@link Toast} + */ public add(toastOrTitle: ToastInput) { const toast: Toast = { id: String(this.idCounter++), @@ -139,6 +121,10 @@ export class ToastsApi implements IToasts { return toast; } + /** + * Removes a toast from the current array of toasts if present. + * @param toast - a {@link Toast} returned by {@link ToastApi.add} + */ public remove(toast: Toast) { const list = this.toasts$.getValue(); const listWithoutToast = list.filter(t => t !== toast); @@ -147,6 +133,12 @@ export class ToastsApi implements IToasts { } } + /** + * Adds a new toast pre-configured with the success color and check icon. + * + * @param toastOrTitle - a {@link ToastInput} + * @returns a {@link Toast} + */ public addSuccess(toastOrTitle: ToastInput) { return this.add({ color: 'success', @@ -155,6 +147,12 @@ export class ToastsApi implements IToasts { }); } + /** + * Adds a new toast pre-configured with the warning color and help icon. + * + * @param toastOrTitle - a {@link ToastInput} + * @returns a {@link Toast} + */ public addWarning(toastOrTitle: ToastInput) { return this.add({ color: 'warning', @@ -164,6 +162,12 @@ export class ToastsApi implements IToasts { }); } + /** + * Adds a new toast pre-configured with the danger color and alert icon. + * + * @param toastOrTitle - a {@link ToastInput} + * @returns a {@link Toast} + */ public addDanger(toastOrTitle: ToastInput) { return this.add({ color: 'danger', @@ -173,6 +177,13 @@ export class ToastsApi implements IToasts { }); } + /** + * Adds a new toast that displays an exception message with a button to open the full stacktrace in a modal. + * + * @param error - an `Error` instance. + * @param options - {@link ErrorToastOptions} + * @returns a {@link Toast} + */ public addError(error: Error, options: ErrorToastOptions) { const message = options.toastMessage || error.message; return this.add({ diff --git a/src/core/public/overlays/overlay_service.ts b/src/core/public/overlays/overlay_service.ts index ca7b1a0d4ef9d..1a72bb5dbe435 100644 --- a/src/core/public/overlays/overlay_service.ts +++ b/src/core/public/overlays/overlay_service.ts @@ -25,6 +25,10 @@ import { I18nStart } from '../i18n'; import { OverlayBannersStart, OverlayBannersService } from './banners'; import { UiSettingsClientContract } from '../ui_settings'; +/** + * Returned by {@link OverlayStart} methods for closing a mounted overlay. + * @public + */ export interface OverlayRef { /** * A Promise that will resolve once this overlay is closed. diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index e765304192018..e710ee2abd67e 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -379,9 +379,9 @@ export interface DocLinksStart { }; } -// Warning: (ae-missing-release-tag) "ErrorToastOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "IToast" // -// @public (undocumented) +// @public export interface ErrorToastOptions { title: string; toastMessage?: string; @@ -465,9 +465,6 @@ export interface HttpInterceptor { // @public export interface HttpRequestInit { - // Warning: (ae-unresolved-inheritdoc-reference) The @inheritDoc reference could not be resolved: The package "kibana" does not have an export "RequestInit" - // - // (undocumented) body?: BodyInit | null; cache?: RequestCache; credentials?: RequestCredentials; @@ -497,15 +494,12 @@ export interface HttpResponse { // @public (undocumented) export interface HttpServiceBase { addLoadingCount(countSource$: Observable): void; - // Warning: (ae-forgotten-export) The symbol "IBasePath" needs to be exported by the entry point index.d.ts basePath: IBasePath; delete: HttpHandler; fetch: HttpHandler; get: HttpHandler; getLoadingCount$(): Observable; head: HttpHandler; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "HTTPInterceptor" - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "HTTPInterceptor" intercept(interceptor: HttpInterceptor): () => void; options: HttpHandler; patch: HttpHandler; @@ -529,6 +523,13 @@ export interface I18nStart { }) => JSX.Element; } +// @public +export interface IBasePath { + get: () => string; + prepend: (url: string) => string; + remove: (url: string) => string; +} + // @public export interface IContextContainer> { createHandler(pluginOpaqueId: PluginOpaqueId, handler: THandler): (...rest: HandlerParameters) => ShallowPromise>; @@ -554,23 +555,8 @@ export interface IHttpInterceptController { halted: boolean; } -// @public (undocumented) -export interface IToasts { - // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported - add(toastOrTitle: ToastInput): Toast; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported - addDanger(toastOrTitle: ToastInput): Toast; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported - addError(error: Error, options: ErrorToastOptions): Toast; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported - addSuccess(toastOrTitle: ToastInput): Toast; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported - addWarning(toastOrTitle: ToastInput): Toast; - get$(): Rx.Observable; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "IToast" - remove(toasts: Toast): void; -} +// @public +export type IToasts = Pick; // @public @deprecated export interface LegacyCoreSetup extends CoreSetup { @@ -635,9 +621,7 @@ export interface OverlayBannersStart { // @public export type OverlayBannerUnmount = () => void; -// Warning: (ae-missing-release-tag) "OverlayRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public export interface OverlayRef { close(): Promise; onClose: Promise; @@ -866,11 +850,35 @@ export class SimpleSavedObject { export { Toast } -// Warning: (ae-forgotten-export) The symbol "ToastInputFields" needs to be exported by the entry point index.d.ts -// -// @public (undocumented) +// @public export type ToastInput = string | ToastInputFields | Promise; +// @public +export type ToastInputFields = Pick>; + +// @public +export class ToastsApi implements IToasts { + constructor(deps: { + uiSettings: UiSettingsClientContract; + }); + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + add(toastOrTitle: ToastInput): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + addDanger(toastOrTitle: ToastInput): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + addError(error: Error, options: ErrorToastOptions): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + addSuccess(toastOrTitle: ToastInput): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + addWarning(toastOrTitle: ToastInput): Toast; + get$(): Rx.Observable; + // @internal (undocumented) + registerOverlays(overlays: OverlayStart): void; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported + // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "ToastApi" + remove(toast: Toast): void; + } + // @public (undocumented) export type ToastsSetup = IToasts; diff --git a/src/core/server/elasticsearch/api_types.ts b/src/core/server/elasticsearch/api_types.ts index 02834739942b5..8444f97b0c7f0 100644 --- a/src/core/server/elasticsearch/api_types.ts +++ b/src/core/server/elasticsearch/api_types.ts @@ -317,14 +317,18 @@ export interface APICaller { /* eslint-enable */ } +/** @public */ export interface AssistantAPIClientParams extends GenericParams { path: '/_migration/assistance'; method: 'GET'; } +/** @public */ export type MIGRATION_ASSISTANCE_INDEX_ACTION = 'upgrade' | 'reindex'; +/** @public */ export type MIGRATION_DEPRECATION_LEVEL = 'none' | 'info' | 'warning' | 'critical'; +/** @public */ export interface AssistanceAPIResponse { indices: { [indexName: string]: { @@ -333,11 +337,13 @@ export interface AssistanceAPIResponse { }; } +/** @public */ export interface DeprecationAPIClientParams extends GenericParams { path: '/_migration/deprecations'; method: 'GET'; } +/** @public */ export interface DeprecationInfo { level: MIGRATION_DEPRECATION_LEVEL; message: string; @@ -345,10 +351,12 @@ export interface DeprecationInfo { details?: string; } +/** @public */ export interface IndexSettingsDeprecationInfo { [indexName: string]: DeprecationInfo[]; } +/** @public */ export interface DeprecationAPIResponse { cluster_settings: DeprecationInfo[]; ml_settings: DeprecationInfo[]; diff --git a/src/core/server/elasticsearch/errors.ts b/src/core/server/elasticsearch/errors.ts index 0db6841e2e1f6..6852b8632ebf1 100644 --- a/src/core/server/elasticsearch/errors.ts +++ b/src/core/server/elasticsearch/errors.ts @@ -26,6 +26,7 @@ enum ErrorCode { NOT_AUTHORIZED = 'Elasticsearch/notAuthorized', } +/** @public */ export interface ElasticsearchError extends Boom { [code]?: string; } diff --git a/src/core/server/elasticsearch/types.ts b/src/core/server/elasticsearch/types.ts index 234d7e13e3ac4..505b57c7c9e8e 100644 --- a/src/core/server/elasticsearch/types.ts +++ b/src/core/server/elasticsearch/types.ts @@ -35,7 +35,7 @@ export interface ElasticsearchServiceSetup { * We fill all the missing properties in the `clientConfig` using the default * Elasticsearch config so that we don't depend on default values set and * controlled by underlying Elasticsearch JS client. - * We don't run validation against passed config expect it to be valid. + * We don't run validation against the passed config and expect it to be valid. * * @example * ```js @@ -50,7 +50,7 @@ export interface ElasticsearchServiceSetup { /** * Observable of clients for the `admin` cluster. Observable emits when Elasticsearch config changes on the Kibana - * server. See {@link IClusterClient} + * server. See {@link IClusterClient}. * * @exmaple * ```js @@ -61,7 +61,7 @@ export interface ElasticsearchServiceSetup { /** * Observable of clients for the `data` cluster. Observable emits when Elasticsearch config changes on the Kibana - * server. See {@link IClusterClient} + * server. See {@link IClusterClient}. * * @exmaple * ```js diff --git a/src/core/server/http/index.ts b/src/core/server/http/index.ts index 20cfe8a27843a..ff1ff3acfae3d 100644 --- a/src/core/server/http/index.ts +++ b/src/core/server/http/index.ts @@ -30,6 +30,7 @@ export { ErrorHttpResponseOptions, KibanaRequest, KibanaRequestRoute, + IKibanaResponse, KnownHeaders, LegacyRequest, LifecycleResponseFactory, @@ -52,6 +53,9 @@ export { AuthHeaders, AuthResultParams, AuthToolkit, + AuthResult, + Authenticated, + AuthResultType, } from './lifecycle/auth'; export { OnPostAuthHandler, OnPostAuthToolkit } from './lifecycle/on_post_auth'; export { SessionStorageFactory, SessionStorage } from './session_storage'; diff --git a/src/core/server/http/lifecycle/auth.ts b/src/core/server/http/lifecycle/auth.ts index 72acbff8cfb38..036ab0211c2ff 100644 --- a/src/core/server/http/lifecycle/auth.ts +++ b/src/core/server/http/lifecycle/auth.ts @@ -21,32 +21,36 @@ import { Logger } from '../../logging'; import { HapiResponseAdapter, KibanaRequest, - KibanaResponse, + IKibanaResponse, lifecycleResponseFactory, LifecycleResponseFactory, + isKibanaResponse, } from '../router'; -enum ResultType { +/** @public */ +export enum AuthResultType { authenticated = 'authenticated', } -interface Authenticated extends AuthResultParams { - type: ResultType.authenticated; +/** @public */ +export interface Authenticated extends AuthResultParams { + type: AuthResultType.authenticated; } -type AuthResult = Authenticated; +/** @public */ +export type AuthResult = Authenticated; const authResult = { authenticated(data: Partial = {}): AuthResult { return { - type: ResultType.authenticated, + type: AuthResultType.authenticated, state: data.state, requestHeaders: data.requestHeaders, responseHeaders: data.responseHeaders, }; }, isAuthenticated(result: AuthResult): result is Authenticated { - return result && result.type === ResultType.authenticated; + return result && result.type === AuthResultType.authenticated; }, }; @@ -99,7 +103,7 @@ export type AuthenticationHandler = ( request: KibanaRequest, response: LifecycleResponseFactory, toolkit: AuthToolkit -) => AuthResult | KibanaResponse | Promise; +) => AuthResult | IKibanaResponse | Promise; /** @public */ export function adoptToHapiAuthFormat( @@ -118,7 +122,7 @@ export function adoptToHapiAuthFormat( lifecycleResponseFactory, toolkit ); - if (result instanceof KibanaResponse) { + if (isKibanaResponse(result)) { return hapiResponseAdapter.handle(result); } if (authResult.isAuthenticated(result)) { diff --git a/src/core/server/http/router/index.ts b/src/core/server/http/router/index.ts index d7393a1b98546..56ed9ca11edc1 100644 --- a/src/core/server/http/router/index.ts +++ b/src/core/server/http/router/index.ts @@ -37,10 +37,12 @@ export { ResponseError, ResponseErrorAttributes, KibanaResponse, + IKibanaResponse, kibanaResponseFactory, KibanaResponseFactory, lifecycleResponseFactory, LifecycleResponseFactory, + isKibanaResponse, } from './response'; export { IKibanaSocket } from './socket'; diff --git a/src/core/server/http/router/response.ts b/src/core/server/http/router/response.ts index 874b494a1676c..f1ee44726ebef 100644 --- a/src/core/server/http/router/response.ts +++ b/src/core/server/http/router/response.ts @@ -36,11 +36,26 @@ export type ResponseError = attributes?: ResponseErrorAttributes; }; +/** + * A response data object, expected to returned as a result of {@link RequestHandler} execution + * @public + */ +export interface IKibanaResponse { + readonly status: number; + readonly payload?: T; + readonly options: HttpResponseOptions; +} + +export function isKibanaResponse(response: Record): response is IKibanaResponse { + return typeof response.status === 'number' && typeof response.options === 'object'; +} + /** * A response data object, expected to returned as a result of {@link RequestHandler} execution * @internal */ -export class KibanaResponse { +export class KibanaResponse + implements IKibanaResponse { constructor( readonly status: number, readonly payload?: T, diff --git a/src/core/server/http/router/router.ts b/src/core/server/http/router/router.ts index b2eef1305ed4a..e4f328c51a008 100644 --- a/src/core/server/http/router/router.ts +++ b/src/core/server/http/router/router.ts @@ -23,7 +23,7 @@ import Boom from 'boom'; import { Logger } from '../../logging'; import { KibanaRequest } from './request'; -import { KibanaResponse, KibanaResponseFactory, kibanaResponseFactory } from './response'; +import { KibanaResponseFactory, kibanaResponseFactory, IKibanaResponse } from './response'; import { RouteConfig, RouteConfigOptions, RouteMethod, RouteSchemas } from './route'; import { HapiResponseAdapter } from './response_adapter'; import { RequestHandlerContext } from '../../../server'; @@ -264,4 +264,4 @@ export type RequestHandler

, TypeOf, TypeOf>, response: KibanaResponseFactory -) => KibanaResponse | Promise>; +) => IKibanaResponse | Promise>; diff --git a/src/core/server/http/types.ts b/src/core/server/http/types.ts index 65c564e3c25fc..d75028ca12d66 100644 --- a/src/core/server/http/types.ts +++ b/src/core/server/http/types.ts @@ -178,8 +178,7 @@ export interface HttpServiceSetup { * Provides ability to declare a handler function for a particular path and HTTP request method. * * @remarks - * Each route can have only one handler functions, which is executed when the route is matched. - * All routes are prefixed with plugin name as a first segment of URL path. + * Each route can have only one handler function, which is executed when the route is matched. * See the {@link IRouter} documentation for more information. * * @example diff --git a/src/core/server/index.ts b/src/core/server/index.ts index 82e95ff559e40..369accad43ffc 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -79,6 +79,9 @@ export { AuthResultParams, AuthStatus, AuthToolkit, + AuthResult, + AuthResultType, + Authenticated, BasePath, IBasePath, CustomHttpResponseOptions, @@ -93,6 +96,7 @@ export { IsAuthenticated, KibanaRequest, KibanaRequestRoute, + IKibanaResponse, LifecycleResponseFactory, KnownHeaders, LegacyRequest, diff --git a/src/core/server/saved_objects/service/saved_objects_client.ts b/src/core/server/saved_objects/service/saved_objects_client.ts index 6e23f81aa3df9..634f5ba007397 100644 --- a/src/core/server/saved_objects/service/saved_objects_client.ts +++ b/src/core/server/saved_objects/service/saved_objects_client.ts @@ -28,8 +28,6 @@ import { } from '../types'; import { SavedObjectsErrorHelpers } from './lib/errors'; -type Omit = Pick>; - /** * * @public diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index e3fdef708f03a..24d555d758cb3 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -388,8 +388,6 @@ export interface APICaller { (endpoint: string, clientParams?: Record, options?: CallAPIOptions): Promise; } -// Warning: (ae-missing-release-tag) "AssistanceAPIResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface AssistanceAPIResponse { // (undocumented) @@ -400,8 +398,6 @@ export interface AssistanceAPIResponse { }; } -// Warning: (ae-missing-release-tag) "AssistantAPIClientParams" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface AssistantAPIClientParams extends GenericParams { // (undocumented) @@ -410,15 +406,21 @@ export interface AssistantAPIClientParams extends GenericParams { path: '/_migration/assistance'; } -// Warning: (ae-forgotten-export) The symbol "AuthResult" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "KibanaResponse" needs to be exported by the entry point index.d.ts -// +// @public (undocumented) +export interface Authenticated extends AuthResultParams { + // (undocumented) + type: AuthResultType.authenticated; +} + // @public -export type AuthenticationHandler = (request: KibanaRequest, response: LifecycleResponseFactory, toolkit: AuthToolkit) => AuthResult | KibanaResponse | Promise; +export type AuthenticationHandler = (request: KibanaRequest, response: LifecycleResponseFactory, toolkit: AuthToolkit) => AuthResult | IKibanaResponse | Promise; // @public export type AuthHeaders = Record; +// @public (undocumented) +export type AuthResult = Authenticated; + // @public export interface AuthResultParams { requestHeaders?: AuthHeaders; @@ -426,6 +428,12 @@ export interface AuthResultParams { state?: Record; } +// @public (undocumented) +export enum AuthResultType { + // (undocumented) + authenticated = "authenticated" +} + // @public export enum AuthStatus { authenticated = "authenticated", @@ -518,8 +526,6 @@ export interface CustomHttpResponseOptions; }; -// Warning: (ae-missing-release-tag) "ElasticsearchError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface ElasticsearchError extends Boom { // (undocumented) @@ -674,6 +674,16 @@ export interface IContextContainer> { // @public export type IContextProvider, TContextName extends keyof HandlerContextType> = (context: Partial>, ...rest: HandlerParameters) => Promise[TContextName]> | HandlerContextType[TContextName]; +// @public +export interface IKibanaResponse { + // (undocumented) + readonly options: HttpResponseOptions; + // (undocumented) + readonly payload?: T; + // (undocumented) + readonly status: number; +} + // @public export interface IKibanaSocket { readonly authorizationError?: Error; @@ -685,8 +695,6 @@ export interface IKibanaSocket { getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate | null; } -// Warning: (ae-missing-release-tag) "IndexSettingsDeprecationInfo" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface IndexSettingsDeprecationInfo { // (undocumented) @@ -895,13 +903,9 @@ export interface LogRecord { timestamp: Date; } -// Warning: (ae-missing-release-tag) "MIGRATION_ASSISTANCE_INDEX_ACTION" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type MIGRATION_ASSISTANCE_INDEX_ACTION = 'upgrade' | 'reindex'; -// Warning: (ae-missing-release-tag) "MIGRATION_DEPRECATION_LEVEL" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type MIGRATION_DEPRECATION_LEVEL = 'none' | 'info' | 'warning' | 'critical'; @@ -1006,7 +1010,7 @@ export type RedirectResponseOptions = HttpResponseOptions & { }; // @public -export type RequestHandler

= (context: RequestHandlerContext, request: KibanaRequest, TypeOf, TypeOf>, response: KibanaResponseFactory) => KibanaResponse | Promise>; +export type RequestHandler

= (context: RequestHandlerContext, request: KibanaRequest, TypeOf, TypeOf>, response: KibanaResponseFactory) => IKibanaResponse | Promise>; // @public export interface RequestHandlerContext { @@ -1480,8 +1484,6 @@ export interface SavedObjectsUpdateOptions extends SavedObjectsBaseOptions { version?: string; } -// Warning: (ae-forgotten-export) The symbol "Omit" needs to be exported by the entry point index.d.ts -// // @public (undocumented) export interface SavedObjectsUpdateResponse extends Omit, 'attributes' | 'references'> { // (undocumented) @@ -1521,6 +1523,7 @@ export interface SessionStorageFactory { // Warnings were encountered during analysis: // +// src/core/server/http/router/response.ts:316:3 - (ae-forgotten-export) The symbol "KibanaResponse" needs to be exported by the entry point index.d.ts // src/core/server/plugins/plugins_service.ts:39:5 - (ae-forgotten-export) The symbol "DiscoveredPluginInternal" needs to be exported by the entry point index.d.ts // src/core/server/plugins/types.ts:162:10 - (ae-forgotten-export) The symbol "EnvironmentMode" needs to be exported by the entry point index.d.ts From 981432fd5f76d36186fb34865443fa12a25e1e0c Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Tue, 8 Oct 2019 12:03:13 -0500 Subject: [PATCH 3/5] Update context examples --- .../core/public/kibana-plugin-public.contextsetup.md | 11 +++++------ .../core/server/kibana-plugin-server.contextsetup.md | 11 +++++------ src/core/public/context/context_service.ts | 11 +++++------ src/core/server/context/context_service.ts | 11 +++++------ 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/docs/development/core/public/kibana-plugin-public.contextsetup.md b/docs/development/core/public/kibana-plugin-public.contextsetup.md index d9c158fcaae05..2b67c7cdaf0e1 100644 --- a/docs/development/core/public/kibana-plugin-public.contextsetup.md +++ b/docs/development/core/public/kibana-plugin-public.contextsetup.md @@ -91,18 +91,17 @@ export interface VizRenderContext { } export type VizRenderer = (context: VizRenderContext, domElement: HTMLElement) => () => void; +// When a renderer is bound via `contextContainer.createHandler` this is the type that will be returned. +type BoundVizRenderer = (domElement: HTMLElement) => () => void; class VizRenderingPlugin { - private readonly vizRenderers = new Map () => void)>(); + private readonly contextContainer?: IContextContainer; + private readonly vizRenderers = new Map(); constructor(private readonly initContext: PluginInitializerContext) {} setup(core) { - this.contextContainer = core.context.createContextContainer< - VizRenderContext, - ReturnType, - [HTMLElement] - >(); + this.contextContainer = core.context.createContextContainer(); return { registerContext: this.contextContainer.registerContext, diff --git a/docs/development/core/server/kibana-plugin-server.contextsetup.md b/docs/development/core/server/kibana-plugin-server.contextsetup.md index 0b4f5aa5d403b..67504faf0534a 100644 --- a/docs/development/core/server/kibana-plugin-server.contextsetup.md +++ b/docs/development/core/server/kibana-plugin-server.contextsetup.md @@ -91,18 +91,17 @@ export interface VizRenderContext { } export type VizRenderer = (context: VizRenderContext, domElement: HTMLElement) => () => void; +// When a renderer is bound via `contextContainer.createHandler` this is the type that will be returned. +type BoundVizRenderer = (domElement: HTMLElement) => () => void; class VizRenderingPlugin { - private readonly vizRenderers = new Map () => void)>(); + private readonly contextContainer?: IContextContainer; + private readonly vizRenderers = new Map(); constructor(private readonly initContext: PluginInitializerContext) {} setup(core) { - this.contextContainer = core.context.createContextContainer< - VizRenderContext, - ReturnType, - [HTMLElement] - >(); + this.contextContainer = core.context.createContextContainer(); return { registerContext: this.contextContainer.registerContext, diff --git a/src/core/public/context/context_service.ts b/src/core/public/context/context_service.ts index dadc509c97821..e39292f87d7b9 100644 --- a/src/core/public/context/context_service.ts +++ b/src/core/public/context/context_service.ts @@ -53,18 +53,17 @@ export class ContextService { * } * * export type VizRenderer = (context: VizRenderContext, domElement: HTMLElement) => () => void; + * // When a renderer is bound via `contextContainer.createHandler` this is the type that will be returned. + * type BoundVizRenderer = (domElement: HTMLElement) => () => void; * * class VizRenderingPlugin { - * private readonly vizRenderers = new Map () => void)>(); + * private readonly contextContainer?: IContextContainer; + * private readonly vizRenderers = new Map(); * * constructor(private readonly initContext: PluginInitializerContext) {} * * setup(core) { - * this.contextContainer = core.context.createContextContainer< - * VizRenderContext, - * ReturnType, - * [HTMLElement] - * >(); + * this.contextContainer = core.context.createContextContainer(); * * return { * registerContext: this.contextContainer.registerContext, diff --git a/src/core/server/context/context_service.ts b/src/core/server/context/context_service.ts index 1c5bd41a01f0f..1625fc9ad75ed 100644 --- a/src/core/server/context/context_service.ts +++ b/src/core/server/context/context_service.ts @@ -54,18 +54,17 @@ export class ContextService { * } * * export type VizRenderer = (context: VizRenderContext, domElement: HTMLElement) => () => void; + * // When a renderer is bound via `contextContainer.createHandler` this is the type that will be returned. + * type BoundVizRenderer = (domElement: HTMLElement) => () => void; * * class VizRenderingPlugin { - * private readonly vizRenderers = new Map () => void)>(); + * private readonly contextContainer?: IContextContainer; + * private readonly vizRenderers = new Map(); * * constructor(private readonly initContext: PluginInitializerContext) {} * * setup(core) { - * this.contextContainer = core.context.createContextContainer< - * VizRenderContext, - * ReturnType, - * [HTMLElement] - * >(); + * this.contextContainer = core.context.createContextContainer(); * * return { * registerContext: this.contextContainer.registerContext, From 206456a2d0a2687d7c29ce4a8faf3cc7cead8a2c Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Mon, 14 Oct 2019 15:11:01 -0500 Subject: [PATCH 4/5] Fix IToasts link --- .../core/public/kibana-plugin-public.errortoastoptions.md | 2 +- docs/development/core/public/kibana-plugin-public.md | 2 +- src/core/public/notifications/toasts/toasts_api.tsx | 2 +- src/core/public/public.api.md | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/development/core/public/kibana-plugin-public.errortoastoptions.md b/docs/development/core/public/kibana-plugin-public.errortoastoptions.md index 30fc044ff93e6..1755e6cbde919 100644 --- a/docs/development/core/public/kibana-plugin-public.errortoastoptions.md +++ b/docs/development/core/public/kibana-plugin-public.errortoastoptions.md @@ -4,7 +4,7 @@ ## ErrorToastOptions interface -Options available for APIs. +Options available for [IToasts](./kibana-plugin-public.itoasts.md) APIs. Signature: diff --git a/docs/development/core/public/kibana-plugin-public.md b/docs/development/core/public/kibana-plugin-public.md index 4df9a10a3e65c..a7a495fb23240 100644 --- a/docs/development/core/public/kibana-plugin-public.md +++ b/docs/development/core/public/kibana-plugin-public.md @@ -44,7 +44,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [CoreSetup](./kibana-plugin-public.coresetup.md) | Core services exposed to the Plugin setup lifecycle | | [CoreStart](./kibana-plugin-public.corestart.md) | Core services exposed to the Plugin start lifecycle | | [DocLinksStart](./kibana-plugin-public.doclinksstart.md) | | -| [ErrorToastOptions](./kibana-plugin-public.errortoastoptions.md) | Options available for APIs. | +| [ErrorToastOptions](./kibana-plugin-public.errortoastoptions.md) | Options available for [IToasts](./kibana-plugin-public.itoasts.md) APIs. | | [FatalErrorInfo](./kibana-plugin-public.fatalerrorinfo.md) | Represents the message and stack of a fatal Error | | [FatalErrorsSetup](./kibana-plugin-public.fatalerrorssetup.md) | FatalErrors stop the Kibana Public Core and displays a fatal error screen with details about the Kibana build and the error. | | [HttpErrorRequest](./kibana-plugin-public.httperrorrequest.md) | | diff --git a/src/core/public/notifications/toasts/toasts_api.tsx b/src/core/public/notifications/toasts/toasts_api.tsx index 17015faf2c0a3..d803f75d6eb0a 100644 --- a/src/core/public/notifications/toasts/toasts_api.tsx +++ b/src/core/public/notifications/toasts/toasts_api.tsx @@ -42,7 +42,7 @@ export type ToastInputFields = Pick>; export type ToastInput = string | ToastInputFields | Promise; /** - * Options available for {@link IToast} APIs. + * Options available for {@link IToasts} APIs. * @public */ export interface ErrorToastOptions { diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index e710ee2abd67e..52a4f94945e19 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -379,8 +379,6 @@ export interface DocLinksStart { }; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "IToast" -// // @public export interface ErrorToastOptions { title: string; From fcbc658746a7091abf453cfbd43cc908f0525c46 Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Mon, 14 Oct 2019 16:35:44 -0500 Subject: [PATCH 5/5] nits --- src/core/public/notifications/toasts/toasts_api.tsx | 2 +- src/core/public/notifications/toasts/toasts_service.mock.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/public/notifications/toasts/toasts_api.tsx b/src/core/public/notifications/toasts/toasts_api.tsx index d803f75d6eb0a..24514cb11548b 100644 --- a/src/core/public/notifications/toasts/toasts_api.tsx +++ b/src/core/public/notifications/toasts/toasts_api.tsx @@ -98,7 +98,7 @@ export class ToastsApi implements IToasts { this.overlays = overlays; } - /** Current array of toast messages to show to user. */ + /** Observable of the toast messages to show to the user. */ public get$() { return this.toasts$.asObservable(); } diff --git a/src/core/public/notifications/toasts/toasts_service.mock.ts b/src/core/public/notifications/toasts/toasts_service.mock.ts index 37c4ae99c2bb1..f44bd3253048d 100644 --- a/src/core/public/notifications/toasts/toasts_service.mock.ts +++ b/src/core/public/notifications/toasts/toasts_service.mock.ts @@ -18,10 +18,10 @@ */ import { Observable } from 'rxjs'; -import { ToastsSetup } from './toasts_service'; +import { IToasts } from './toasts_api'; const createToastsApiMock = () => { - const api: jest.Mocked = { + const api: jest.Mocked = { get$: jest.fn(() => new Observable()), add: jest.fn(), remove: jest.fn(),