Commit graph

84 commits

Author SHA1 Message Date
Mikhail Shustov
68bcd43f90
Add pre-response http interceptor (#52366) (#52404)
* add onPreResponse interceptor

* expose registerPreResponse to plugins

* address comments

* regen docs
2019-12-07 08:28:13 +01:00
Alejandro Fernández Haro
ea3af98e65
[7.x] [NP] Expose global config to the plugins (#51478) (#52263)
* [NP] Expose global config to the plugins (#51478)

* [NP] Expose global config to the plugins

* globalConfig in Plugin context: expose read-only methods only

* SharedGlobalConfig rework + Moving pkg, fromRoot & path utils from legacy to NP

* Updated API docs

* Fix test references to the moved utils

* Replace zip with combineLatest

* Change tests to describe/it + remove "(deprecated)" from the test description

* Moving path files to a folder + exposing the config path in the contract

* deepFreeze the globalConfig in the pluginContext

* Fix types in tests with new path.config

* Move fromRoot and package_json utils to core/server/utils

* Rename globalConfig to legacy.globalConfig$

* path.config renamed to path.configDir (not renaming path.data because it might be a breaking change)

* Change configDir in mocker as well

* Fix test after config renamed to configDir

* Fix API docs conflicts

* Rename the path properties when exposing them

* path.configDir removed from the path config-schema

* Remove path.configDir. It is already in env.configs

* Add Migration documentation and examples

* Fix 'kibana/server' imports in the MIGRATION docs

* Disable eslint complain for the legacy config/schema.js import
2019-12-05 14:04:47 +00:00
Rudolf Meijering
e06dcd5720
static createRepository factory function (#52056) (#52187)
* static createRepository factory function

* Fix API docs after master merge
2019-12-05 10:37:15 +01:00
Pierre Gayvallet
bc6189d364
Migrate Capabilities to new platform (#51438) (#52051)
* create service skeleton

* move registerCapabilitiesModifier to capabilities service and rename to registerCapabilitiesSwitcher

* starts to move capabilities logic to CapabilitiesService

* move capabilities route to service

* add initial integration test for capabilities route

* capabilitiesMixin now delegates to capability service

* use server-side Capabilities import in server code

* update generated doc

* remove capabilities from injectedMetadatas

* use applications sent from client instead of server-registered navLinks

* disable authRequired for capabilities route

* (temp) exposes two endpoints for capabilities

* Add fetch-mock on capabilities call for karma tests

* adapt xpack Capabilities test - first attempt

* adapt x-pack ui_capabilities test

* add '/status' to the list of anonymous pages

* Add documentation on Capabilities APIs

* move Capabilities to core/types

* update generated docs

* add service tests

* protecting resolveCapabilities against added/removed capabilities

* update generated docs

* adapt mocks due to rebase

* add forgotten exports

* improve capabilities routes registering

* name capabilities registering methods

* resolve conflicts due to merge

* address review issues

* add comment about reason for exposing two routes

* extract createHttpServer test helper

* fix merge conflicts

* improve documentation

* remove `/status` anon registration as now done in NP status plugin

* fix merge conflicts
2019-12-03 11:08:28 +01:00
Rudolf Meijering
5a13a20076
Split legacy plugin discovery, expose SavedObjects scopedClient, wrappers, repository (#48882) (#51978)
* Split legacy plugin discovery, expose internal SavedObjectsClient

* Expose internal SavedObjectsClient to plugins

* Add more documentation

* Expose client wrappers, repository, scoped client from SavedObjects

* Remove unused onBeforeWrite

* Refactor Service / Repository for testability

* Bind exposed clientProvider methods

* Fix eArchiver's KibanaMigrator

* Cleanup

* Use APICaller type

* Expose SavedObjectsServiceStart to plugins

* API documentation

* Rename API methods to be verbs
2019-12-02 18:45:07 +01:00
Mikhail Shustov
51947b006a
Unify uiSettingsClient contracts (#51167) (#51894)
* introduce IUiSettingsClient on the client

* switch uiSettings service to  IUiSettingsClient

* update uiSettings service tests

* all plugins should use IUiSettingsClient

* stop is not public methods anymore

* remove savedobject attribute type references

* regen docs

* remove all references to UiSettingsClient class

* regen docs

* add migration example for uiSettings

* update consumer types and tests

* address comments
2019-11-29 07:42:15 +01:00
Alejandro Fernández Haro
fe7a08c3e2
Allow routes to define some payload config values (#50783) (#51864)
* Allow routes to define some payload config values

* Documentation typo

* Move hapi `payload` config under `body` + additional validations

* Update API docs

* Amend explanation in API docs

* Add stream and buffer types to @kbn/config-schema

* Fixes based on PR feedback:
- Add 'patch' and 'options' to valid RouteMethod
- Add tests for all the new flags
- Allow `stream` and `buffer` schema in the body validations (findings from tests)

* API documentation update

* Fix type definitions

* Fix the NITs in the PR comments + better typing inheritance

* API docs update

* Fix APM-legacy wrapper's types

* Fix KibanaRequest.from type exposure of hapi in API docs

* Move RouterRoute interface back to private + Expose some public docs

* Update @kbn/config-schema docs
2019-11-28 10:44:15 +00:00
Joe Portner
108d9732f0
Fix infinite redirect loop when multiple cookies are sent (#50452) (#51821)
Cookies are now checked for attributes that match the current
Kibana configuration. Invalid cookies are cleared more reliably.
2019-11-27 16:50:08 -05:00
Pierre Gayvallet
7b6349af2c
Add compatibility wrapper for Boom errors thrown from route handler (#51157) (#51695)
* add wrapErrors method to router

* add RouteRegistrar type

* update generated doc

* add migration example

* rename wrapErrors to handleLegacyErrors
2019-11-26 11:43:23 +01:00
Josh Dover
2508337a22
[7.x] Build bundles for all new platform plugins (#51525) (#51664) 2019-11-25 18:14:56 -06:00
Pierre Gayvallet
f0257a8de3
Expose whitelisted config values to client-side plugin (#50641) (#51272)
* introduce PluginConfigDescriptor type

* inject client plugin configs in injectedMetadata

* expose client config in PluginInitializerContext

* add example implementation in testbed

* update generated doc

* only generates ui config entry for plugins exposing properties to client

* separate plugin configs from plugins

* restructure plugin services tests

* fix test/mocks due to plugin configs api changes

* add unit tests

* update migration guide

* update tsdoc

* fix typecheck

* use sync getter for config on client side instead of observable

* change type of exposeToBrowser prop

* updates generated doc

* fix doc and address nits
2019-11-21 14:40:51 +01:00
Mikhail Shustov
bf75969ab0
remove outdated comment (#50895) (#50913) 2019-11-18 17:17:48 +01:00
Pierre Gayvallet
45533f3809
Remove internal platform types exports (#50427) (#50459)
* remove exports of internal core types

* updates documentation

* rename internal types file
2019-11-13 13:23:52 +01:00
Mikhail Shustov
c3f6af3ae3
Provide uiSettings service in NP (#48413) (#49531)
* provide ui settins client via context

* update mocks

* update types and expose setDefaults to plugins

* move ui settings routes to NP

* add typings fro test kbn server

* move integration test & improve typings

* hide client private methods, update tests

* add unit tests for get_upgradable_config

* inline writeErrors into createOrUpgradeConfig to simplify testing

* regen docs

* add functional tests for ui_settings service

* unify test suites

* add types for sipertest in core_plugin tests

* tsify core_plugins tests

* add test for empty saved config

* update renovate

* rename get/setDefaults to reguster

* regen docs

* regen docs

* Update src/core/MIGRATION.md

Co-Authored-By: Josh Dover <me@joshdover.com>
2019-10-28 20:32:51 -04:00
Gidi Meir Morris
f3570747e2
[Saved Objects] Adds support for custom Refresh settings on mutating operations (#48932) (#49290)
Adds the ability to override the Refresh setting of mutating operations (Update, Delete, Bulk, Index) of Saved Objects.
2019-10-25 13:53:01 +01:00
Gidi Meir Morris
f5eec37026
[Saved Objects] Add support for bulkUpdate to SavedObjectsClient (#47540) (#48502)
This PR adds support for `bulkUpdate` to the Saved Objects API and exposes it on all Saved Objects clients (base client, encrypted, spaces etc.).
2019-10-17 14:29:41 +01:00
Mikhail Shustov
f6c03aeb6a
UI settings move to NP (#47590) (#48395)
* add tests for logWithMetadata in LP

* allow passing metadata to log in NP & LP

* move ui_settings_client to NP

* add ui_settings config

* add ui_settings_service

* switch to NP logging

* export types

* bootstrap uiSettings service in NP

* pass NP uiSettings to LP

* move ui_settings mock to NP

* add  test for mixin and switch to NP logger

* make UiSettingsClient.getDefaults sync as it is

* ui_settings_client uses private fields

* ui_settings_client uses private methods

* keep uiSettings config validation in NP only

* update mocks

* core context should know it is mocked

* add tests for ui_settings_service

* remove unused code from ui_settings_mixin test

* improve types in ui_settings_mixin test

* gen docs

* test moved to NP

* set pkg version in tests explicitly

* update mocks in tests

* UiSettingsServiceSetup --> InternalUiSettingsServiceSetup

* add links to types

* address eli comment

* regen docs

* remove unused types
2019-10-16 15:48:34 +02:00
Rudolf Meijering
05c76f293c
Ignore missing references on saved object exports (#47685) (#48388)
* add saved object export details in ndjson response

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* update core doc

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* exclude export details for space copy

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* fixing tests

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* display warning instead of success if export contains missing refs

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* nits/typo

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* properly updates api integration tests

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* fix typings

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* add test on objects_table component

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* remove added translations from jp/cn bundles

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* restoring line feeds

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* improve doc and user alert message

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* restoring line feeds on server.api.md

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* warning test label

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
2019-10-16 15:39:17 +02:00
Rudolf Meijering
83bf4ef0ce
Server saved objects client through request context (#44143) (#48378)
* Expose Saved Objects client in request context

* API Integration test for savedobjects in req context

* SavedObjectsClient docs

* SavedObjectsClient#find remove dependency on indexPatterns

And use the saved objects mappings instead

* Review comments

* Review comments, fixes and tests

* Use correct type for KQL syntax check
2019-10-16 12:08:32 +02:00
Josh Dover
82fc2608aa
[7.x] Make generated type docs more explorable (#47069) (#48252) 2019-10-15 17:05:59 -05:00
Mikhail Shustov
1a3c2e3ba2
Expose package info to NP plugins (#48101) (#48215)
* provide packageInfo to server plugins

* provide env to kbn server

* provide env to client plugins

* update server mocks and tests

* update client mocks and tests

* add integration test

* regen docs

* remove weird file

* export types for the client from special folder

* env should not affect test ourcome
2019-10-15 15:42:22 +02:00
Mikhail Shustov
53aab78577
Document custom validation for http request (#47699) (#48203)
* document custom validation for http request

* generate docs
2019-10-15 12:19:55 +02:00
Rudolf Meijering
da61b42a0a
SavedObjectAttribute allow array of primitives (#47317) (#47591) 2019-10-08 20:53:48 +02:00
Court Ewing
3f56b9b265
[core] Do not overwrite saved object references if not specified (#47248) (#47519)
* saved objects: allow partial update without references

For normal attributes, the update API for saved objects supports partial
updates, where it will only attempt to change those attributes you
specify. References should behave the same way otherwise they will be
replaced entirely if you call update without specifying the original
references.
2019-10-08 10:36:54 -04:00
Josh Dover
8e8a6ef754
[7.x] Add types to Elasticsearch API calls (#46668) (#47496) 2019-10-07 15:55:06 -05:00
Larry Gregory
9bf7fb128c
[7.x] Honor current search criteria when exporting saved objec… (#47466)
* honor current search criteria when exporting saved objects

* adding core docs
2019-10-07 12:30:36 -04:00
Josh Dover
003c3b855e
[7.x] Simplify generics for IContextContainer (#46538) (#47266) 2019-10-03 16:53:30 -05:00
Xavier Mouligneau
aa36b9e994
Add KQL functionality in the find function of the saved objects (#41136) (#47182)
* Add KQL functionality in the find function of the saved objects

wip

rename variable from KQL to filter, fix unit test + add new ones

miss security pluggins

review I

fix api changes

refactor after reviewing with Rudolf

fix type

review III

review IV

for security put back allowed logic back to return empty results

remove StaticIndexPattern

review V

fix core_api_changes

fix type

* validate filter to match requirement type.attributes.key or type.savedObjectKey

* Fix types

* fix a bug + add more api integration test

* fix types in test until we create package @kbn/types

* fix type issue

* fix api integration test

* export nodeTypes from packages @kbn/es-query instead of the function buildNodeKuery

* throw 400- bad request when validation error in find

* fix type issue

* accept api change

* renove _ to represent private

* fix unit test + add doc

* add comment to explain why we removed the private
2019-10-03 08:42:35 -04:00
Rudolf Meijering
a6ea76b209
Move KibanaMigrator into Server SavedObjectsService (#43433) (#47011)
* Rename SavedObjectsService -> SavedObjectsLegacyService

* Expose legacy pluginSpecs from Core LegacyService

* Expose legacy uiExports from Core LegacyService

* Move kibana config to NP

* Expose pluginExtendedConfig from LegacyService

* Make KibanaMigrator NP compatible

* KibanaMigrator -> NP SavedObjectsService

* SavedObjectsService never stop retrying ES connection error

* Move waiting for migrations to complete till after legacy service start

* Fix ESArchiver's KibanaMigrator

* Fix reload logging config tests

* Run migrations on savedobjects start

* Fix env tests

* Fix and make legacy tests more robust/isolated

* Cleanup code

* Fix invalid config test

* Fix SavedObject Migrations logging test

* SavedObjectsService tests

* Lifecycle logging and improve getting kibanaConfig instance

* Fix awaitMigration bug and test

* Fix typing error

* Review comments

* Remove unecessary KibanaConfig class

* Move legacy plugin config extension, specs, uiExports entirely into Core

uiExports, specs, disabledSpecs, config now get injected into KbnServer

* Fix config deprecation test

* Use existing logger mock

* Create SavedObjectsConfig for migration config

* Define KibanaMigratorContract type

* KibanaMigratorContract -> IKibanaMigrator + docs improvements

* Fix esArchiver's KibanaMigrator

* Fix plugin generator integration test

* ConfigServiceContract -> IConfigService

* Address review comments

* Review nits

* Document migrations.skip config

* Review comments continued...

* awaitMigrations -> runMigrations

* Type improvements
2019-10-01 11:09:17 +02:00
Rudolf Meijering
1e2f6d8b1f
Expose serverBasePath fixes #45991 (#45995) (#46966)
* Expose serverBasePath fixes #45991

* Review comments

* Fix basepath mock types

* AppBasePathContract -> IBasePath

* Match basepath test description with assertion

* Fix eslint errors
2019-10-01 09:11:51 +02:00
Josh Dover
721802d456
[7.x] Update @microsoft/api-extractor + @microsoft/api-documen… (#46343) 2019-09-24 17:32:05 -05:00
Rudolf Meijering
1d7c0d4cad Response factory parameters as named arguments (#43248) (#43883) 2019-08-23 14:49:36 -05:00
Josh Dover
8af89eddb6
Extend request handler with request scoped core capabilities (#43103) (#43541) 2019-08-19 15:17:37 -05:00
Aleh Zasypkin
d106a4b3a9
[7.x] Add TLS client authentication support. (#43317) 2019-08-15 08:48:04 +02:00
Josh Dover
8a244223ca
[7.x] Export missing Context types (#43051) (#43143) 2019-08-13 10:06:34 -05:00
Rudolf Meijering
46abb3a1db
[Core] Make type option required for SavedObjects.find (#42236) (#43112)
* Make type option required for SavedObjects.find

* getSortedObjectsForExport test for type or objects
2019-08-12 19:55:14 +02:00
Mikhail Shustov
679de5dca7
Expose createRouter from HttpService, prepare handlers for context introduction (#42686) (#43072)
* expose createRouter, prepare route handler for context introduction.

* fix tests

* update examples in docs

* update tests

* re-genereated docs

* remove registerRouter from http service contract

createRouter registers a router under the hood. that reduces API surface
for consumers

* address comments

* update docs
2019-08-10 11:25:28 +02:00
Mikhail Shustov
ec1093820b
add socket.getPeerCertificate to KibanaRequest (#42929) (#43010)
* add socket.getPeerCertificate to KibanaRequest

* update request mocks

* update docs
2019-08-09 11:47:50 +02:00
Mikhail Shustov
26bd65014b
Unify response interface in handler and request interceptors (#42442) (#42918)
* add response factory to the interceptors

* adopt x-pack code to the changes

* Add a separate response factory for lifecycles.

Only route handler can respond with 2xx response.
Interceptors may redirect or reject an incoming request.

* re-generate docs

* response.internal --> response.internalError

* use internalError for exceptions in authenticator

* before Security plugin proxied ES error status code. now sets explicitly.

* provide error via message field of error response for BWC

* update docs

* add customError response

* restore integration test and update unit tests

* update docs

* support Hapi error format for BWC

* add a couple of tests
2019-08-08 13:51:01 +02:00
Josh Dover
ead46453f1
[7.x] Add PluginManfiest to generated docs (#42795) (#42861) 2019-08-07 16:37:17 -05:00
Rudolf Meijering
1995eafdb0
[Core] Public saved objects client (#39891) (#42760)
* Move SavedObjectClient files to core/public

* Initial SavedObjectsService in public Core

* Public SavedObjectsClient tests

* Import SimpleSavedObject from src/core/public

* Use types from source files for kibana.d.ts

* Add html raw loader to x-pack/jest

* Cleanup

* Drop case utilities and improve test coverage

* Update types and documentation

* Fix build breaking when importing directly from /server in /public

* Ensure that all option paramaters are picked and renamed

* Fix option mapping and introduce stronger types

* Eslint: allow imports from src/core/*/types

* Add compatibility layer for kfetch vs http.fetch error responses

* Improve documentation

* Expose SavedObjectsMigrationLogger

* Documentation and type tweaks

* Revert type changes from 73e601f and update api docs

* Refactor request into savedObjectFetch + test

* Make legacy SavedObject compatible with http.fetch exceptions

* Fix types and tests

* simple_saved_object import from src/core/server

* server imports from root instead of server/types

* Make SavedObjectsService a class

* Don't pick unkown keys from server response

* Rename SavedObjectsFindResponse to SavedObjectsFindResponsePublic

* Remove err.response from SavedObjects fetch errors

* Revert "Remove err.response from SavedObjects fetch errors"

This reverts commit 61705ca361.

* Don't introduce err.response until we deprecate err.res
2019-08-07 11:29:30 +02:00
Josh Dover
6e6c01815d Add ContextService to server (#42395) (#42750) 2019-08-06 21:07:52 +02:00
Mike Côté
07ae78f0db
Make task manager index configurable again (#42394) (#42706)
* Initial work

* Fix type check

* Accept core API changes

* Fix broken tests

* Destructure index pattern
2019-08-06 13:01:58 -04:00
Mikhail Shustov
c2aafcff93
Document HTTP service (#42331) (#42558)
* improving naming, add TSDoc

* re-genereate docs

* use response name in migration guide

* Apply suggestions from code review

Co-Authored-By: Josh Dover <me@joshdover.com>

* place docs near the related code

* re-generate docs

* mark code as example to reduce noise in http-service.md
2019-08-04 12:57:34 +02:00
Mikhail Shustov
c90f663309
revert PR 36804 (#42333) (#42443) 2019-08-02 07:56:05 +02:00
Larry Gregory
d107d0845e
[7.x] Expose saved object import/export from core (#42022) (#42458)
* expose saved object import/export from core

* additional tests

* removing unused mock

* updater snapshots

* add objectLimit to saved objects service

* don't export the import/export functionality from core; only types

* documenting exported types

* export missing type
2019-08-01 13:55:26 -04:00
Mikhail Shustov
a3a70979ee
Http server route handler implementation (#41894) (#42326)
* add response error

* add hapi response adapter

* add router handler

* add tests

* add comments, update docs

* update tests

* cleanup tests

* address @joshdover comments

* move tests under integration test cathegory

* update docs

* get rid of KibanResponseError class

* update docs
2019-07-31 11:38:28 +02:00
Mike Côté
44f8c129f7
Task manager enhancements for error handling in alerting and actions (#39829) (#42004)
* Allow mtask definitions to overwrite default setting maxAttemps

* Leverage scheduledAt from task manager

* Treat maxAttempts like attempts and not retries

* Add support for second intervals

* Min 1 attempt

* Reverse relying on scheduledAt

* Add new startedAt attribute in task manager that keeps track when task started running

* Don't extend runAt when claiming a task

* Remove startedAt from state

* Attempt trying to define custom getBackpressureDelay function

* Pass error object to getBackpressureDelay

* Cleanup processResultForRecurringTask code

* Add backpressure to timed out tasks

* Change default timeout backpressure calculation

* getBackpressureDelay to return seconds instead of milliseconds

* Add comment for task store query

* Compress query

* Revert alert / actions specific code

* Add more interval tests

* Fix failing jest tests

* Fix test

* Add more unit tests

* Fix integration tests

* Fix sorting of tasks to process

* WIP

* Always provide error when getBackpressureDelay is called

* Rename getBackpressureDelay to getRetryDelay

* retryAt to be calculated from timeout time by default

* Remove invalid test

* Add unit tests

* Consider timeout before scheduling a retryAt

* Remove backpressure terminology

* Remove support for 0 based intervals and timeouts

* Apply PR feedback

* Fix last place using Math.abs

* Modify migrations to allow running a script when converting an index to an alias

* Convert task manager to use saved objects

* Fix broken test

* Fix broken tests pt1

* Remove index from task manager config schema

* Accept platform changes

* PR feedback

* Apply PR feedback

* Apply PR feedback pt2

* Apply PR feedback pt3

* Apply PR feedback pt4

* Fix feedback pt3

* Rename RawSavedObjectDoc to SavedObjectsRawDoc
2019-07-25 21:35:42 -04:00
Mikhail Shustov
2dcc69c4fe
AuthResultData configures response headers (#41775) (#41948)
* extend AuthResultData with response headers

* add tests

* update docs

* rename headers --> requestHeaders to clarify intention

* update docs

* address comments
2019-07-25 08:50:49 +02:00
Mikhail Shustov
93e4815b61
Narrow type of PluginDeps to an object (#40846) (#41745)
* Narrow type of PluginDeps to an object

* re-generate docs
2019-07-23 12:01:08 +02:00