Commit graph

57 commits

Author SHA1 Message Date
Corey Robertson
a1aa908ae9
[CANVAS] Relax workpad schema to allow existing templates to work (#54019) (#54643)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-01-13 16:58:01 -05:00
Catherine Liu
41120ae84a
[7.x] Migrates ES Fields Route to NP (#54398) (#54609)
* Migrated es fields route to NP and added tests

* Removed extraneous import

* Removed check for index query

* Fixed broken test
2020-01-13 12:11:37 -07:00
Poff Poffenberger
efdfe9b493
[Canvas] Migrate usage collector to NP plugin (#53303) (#53842)
* Move canvas usage collector to NP plugin

* Removing old usage collector fom legacy Canvas plugin

* Adding types placeholder

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2019-12-30 10:49:02 -06:00
Alejandro Fernández Haro
f3f1bd2ec6
[NP] Allow custom validations in HTTP Routes apart from @kbn/config-schema (#51919) (#53714)
* [NP] Allow custom validations in HTTP Routes apart from @kbn/config-schema

* API docs

* Allow validate function in the route handler (run-code validation)

* Prefix RouteXXX + Params and Body Validation Aliases

* Fix test broken by lodash

* Update API docs

* Add default types for simpler manual declaration

* Add run-time validation of the RouteValidateSpec

* Expose RouteValidationError instead of SchemaTypeError

* RouteValidator as a class to match config-schema interface

* Test for not-inline handler (need to check IRouter for #47047)

* Add preValidation of the input for a safer custom validation

* Better types for RouteHandlers

* [NP] Move route validation to RouteValidator wrapper

* Use the class only internally but maintain the same API

* Fix types

* Ensure RouteValidator instance in KibanaRequest.from

* Fix validator.tests (Buffer.from instead of new Buffer)

* Default precheck should allow null values

* Also allow undefined in preChecks

* MR feedback fixes

* Provide RouteValidationResolver to the validation function

* Add functional tests

* Fix new functional tests

* Fix validator additional test

* Fix test with new resolver

* Remove unused import

* Rename ValidationResolver to ValidationResultFactory and change the interface to look more like the KibanaResponseFactory

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2019-12-21 00:02:35 +00:00
Corey Robertson
851196a951
Adds maxBytes and accepts options for workpad api routes that need it (#52189) (#53194) 2019-12-17 09:17:09 -05:00
Poff Poffenberger
80e5f77170
[Canvas] Add NP routing for custom elements (#52561) (#52790)
* [Canvas] Add NP routing for custom elements

* Remove unused type

* Cleanup

* Adding await to delete

* Cleanup
2019-12-11 13:23:51 -06:00
Corey Robertson
246ce1e262
[Canvas] Move workpad api routes to New Platform (#51116) (#52347)
* Move workpad api routes to New Platform

* Cleanup

* Clean up/Pr Feedback

* Adding missing dependency to tests

* Fix typecheck

* Loosen workpad schema restrictions
2019-12-06 14:24:55 -05:00
Court Ewing
dbb0534c21 Move x-pack plugins/server/common to x-pack/legacy 2019-06-20 13:35:00 -04:00
Corey Robertson
5d441123e4
Reapply custom element telemetry (#37113) (#39070)
* Revert "Revert "[Canvas] Adds telemetry info for custom elements (#36177)" (#37100)"

This reverts commit 3f4c2c89ec.

* Cast fromExpression unknown type

* PR Feedback
2019-06-17 09:32:21 -04:00
Catherine Liu
c62613a839
[Canvas] Fixes broken elements in web logs sample data workpad (#37931) (#38034)
* Fixed broken elements in logs sample workpad. Cleaned up expression formatting in each element

* Removed return characters at the beginning of expressions
2019-06-04 15:07:28 -07:00
Robert Monfera
40cf0978ba
[Canvas] Don't render error triangle on group created by cloning a page (#37497) (#37566)
* Dispatch on node id convention as we don't carry around the node type information

* place groups previously misplaced into its proper array

* don't render (always invisible) groups, which are free of own contents
2019-05-31 00:10:38 +02:00
Chris Roberson
2ac88caf21
[Monitoring/Telemetry] Force collectors to indicate when they are ready (#36153) (#36706)
* Initial code to force collectors to indicate when they are ready

* Add and fix tests

* Remove debug

* Add ready check in api call

* Fix prettier complaints

* Return 503 if not all collectors are ready

* PR feedback

* Add retry logic for  usage collection in the reporting tests

* Fix incorrect boomify usage

* Fix more issues with the tests

* Just add debug I guess

* More debug

* Try and handle this exception

* Try and make the tests more defensive and remove console logs

* Retry logic here too

* Debug for the reporting tests failure

* I don't like this, but lets see if it works

* Move the retry logic into the collector set directly

* Add support for this new collector

* Localize this

* This shouldn't be static on the class, but rather static for the entire runtime
2019-05-20 16:39:46 -04:00
Catherine Liu
4446984009
[Canvas]Feat: Custom Elements (#34140) (#35988) 2019-05-02 18:46:19 -05:00
Catherine Liu
4907541c3b
[Canvas] Fixes esdocs fields (#34894) (#35008)
* Fixed api route for esFields

* Changes canvas api route back to /api/canvas
2019-04-12 13:28:16 -05:00
Peter
53cc4fff6e
Exclude assets from canvas usage query - fixes #34513 2019-04-04 13:12:47 -04:00
Spencer
883ea31bd2
[@kbn/expect] "fork" expect.js into repo (#33761) (#33794)
* [@kbn/expect] "fork" expect.js into repo

* [eslint] autofix references to expect.js

* [tslint] autofix all expect.js imports

* now that expect.js is in strict mode, avoid reassigning fn.length
2019-03-25 13:13:21 -07:00
Catherine Liu
aa23acbaa9
Updates ecommerce sample data workpad (#33442) (#33447) 2019-03-18 15:55:18 -07:00
Nathan Reese
da81772bb8
Sample data - allow plugins to register additional view data links (#33052) (#33198)
* Sample data - allow plugins to register additional view data links

* remove comment

* remove unused function

* review feedback
2019-03-13 18:22:24 -06:00
Mikhail Shustov
c2c8f9d878
Update jest to v24 (#31825) (#32193)
* udpate jest, jest-cli, @types/jest to v24

* fix type error in kibana-i18n package

* return serivce explicitly to fix typings

* add explicit never

* suppress typings errors

* update jest versions in x-pack

* make tests in x-pack more robust and fix incompatibility

* suppress CallCluster mock typings

Mock interface doesn't match CallCluster. Requires
additional work

* x-pack. resolve other typing conflicts

* remove unused types/jest

* fix snapshots

* restore mocks after jest.spyOn

* remove outdated definitions for jest

* cleanup x-pack package.json and update @types/jest

* fix tests merged from master

* updated yarn.lock and log errors for scripts/type_check

* This commit fixes error in TS, which failed on parsing the file.

* suppress type errors from master

* jest-cli is devDep

Removes sinon from saved objects unit tests. (#32045) (#32151)

* Removes sinon from saved objects unit tests.

* Uses mockResolvedValue for return values as promises.

temp
2019-02-28 15:57:48 +01:00
Joe Fleming
d3491fad76
chore: unify the workpad update handler (#31218) (#31817)
* test: assets and structures routes

* chore: unify the workpad update handler

the 3 functions were pretty much the same already
2019-02-27 10:23:00 -07:00
Joe Fleming
57afd665c1
fix: hours label container size (#31838) (#31862) 2019-02-25 09:49:15 -07:00
Joe Fleming
16106d8954
Feat: Add support for time_zone in essql (#31291) (#31545)
As noted in [the SQL docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-rest.html), you can pass in a `time_zone` property to control what timezone is used for date operations. This adds a new arg, `timezone` (`tz` for short) to the `essql` function so that users can control what timezone is used.

Below, I have a query that groups results by the hour of the day. You can see the values change when I shift the timezone 12 hours (from `UTC` to `UTC-12`).

![feb-15-2019 10-38-49](https://user-images.githubusercontent.com/404731/52874173-0b46c000-310e-11e9-84b7-9074dfd09b59.gif)
2019-02-20 10:00:22 -07:00
Mike Côté
5b40f3a102
Remove id attribute from canvas attributes (#30736) (#31138)
* Remove id attribute from canvas attributes

* Fix create and update API

* Add migration tests

* Use constants

* Add API tests

* Cleanup tests

* Apply PR feedback
2019-02-14 12:00:18 -05:00
Joe Fleming
1c948594f8 fix: switch fonts to 48px (#30747)
they still look good and fit in their containers better
2019-02-12 15:08:06 -07:00
Chris Davies
e0eee4422b
Remove custom WebPack bundles from Canvas (#30123) (#30521)
This removes the custom build process for Canvas plugins. Canvas plugins are now regular
Kibana plugins. They can register server-side functions like so:

```js
server.plugins.interpreter.register({
  serverFunctions: [yourFunctionsHere],
});
```

And client-side functions need to be included in `uiExports.canvas`, then they need to
register themselves like so:

```js
// kbnInterpreter is a global, sadly, but it makes registration simple
kbnInterpreter.register({
  elements: [yourElementsHere],
  browserFunctions: [yourFnsHere],
});
```
2019-02-08 14:03:11 -05:00
Robert Monfera
d91809d7de
[Canvas] Perf: save workbook assets separately from lighter weight structures (#29594)
* Perf: save workbook assets separately from lighter weight structures

* Chore: simplification
2019-02-01 19:18:10 +01:00
Joe Fleming
006cd31007 fix: add datetime as a date identifier (#29537) 2019-02-01 15:22:23 +01:00
Jonathan Budzenski
e9f0006890
Remove es _xpack endpoint usage (#29465)
* _xpack/rollup -> _rollup

* _xpack/sql -> _sql

* _xpack/license -> _license

* _xpack/migration -> _migration

* _xpack/watcher -> _watcher

* _xpack/monitoring -> _monitoring

* _xpack/security -> _security

* [console_extensions] regenerate

* [console_extensions] update ml overrides

* [console_extensions] update security overrides

* [console_extensions] update rollup overrides

* Revert "[console_extensions] update rollup overrides"

This reverts commit bb3742570d.

* Revert "[console_extensions] update security overrides"

This reverts commit 5c0263b35e.

* Revert "[console_extensions] update ml overrides"

This reverts commit e8254d5671.

* Revert "[console_extensions] regenerate"

This reverts commit 91b754e956.
2019-01-29 13:28:32 -06:00
Robert Monfera
5a95d2e000
Feat: identify Canvas for metrics collection (#29078) 2019-01-24 15:02:09 +01:00
Spencer
9bdee51c1b
[home/sampleData] add empty migrationVersion to auto-migration objects (#29226)
The sample data does not currently specify a migration version, which means we have manually update the data sets when updating the saved objects API. This just sets the migration version for all the saved objects to `{}`, which signals to the saved objects API that the object has not been migrated and should have all migrations applied.
2019-01-23 16:20:19 -08:00
Joe Fleming
9b0a093448 fix: reject instead of resolving (#28129) 2019-01-09 17:07:06 -07:00
Joe Fleming
dcc01f77df
fix: trick build into including dependencies (#27858)
import server and common functions so the build correctly includes their
dependencies
2019-01-03 10:22:56 -07:00
Clint Andrew Hall
626ba78b5f
[Canvas] Fix SQL issues in sample data (#27161)
Fixing sample data.
2018-12-18 15:19:47 -06:00
Spencer
ccfa8a3530
[canvas] remove unnecessary eslint style overrides, use curlys (#27176)
* [canvas] remove styling rules that are handled by prettier, always use curlys in if

* [eslint] autofix missing curly brackets

* [eslint/canvas] remove redundant prettier plugin config

* autofix lint errors in canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.js
2018-12-17 17:32:06 -08:00
Catherine Liu
abeafa1ae1
Consistent error messages between esdocs and essql (#26399)
* Added catch promise to esdocs

* Extracted query to elasticsearch into a lib function
2018-12-03 16:29:22 -07:00
Spencer
54f1a739cd
[@kbn/interpreter] improve build/packaging (#26096)
Summary of changes:

 - move all build artifacts under `target` directory
 - run babel and webpack in parallel
 - support optional watch and sourcemaps in build
 - expose /common /public /plugin /server sub-exports as index.js
 - avoid importing deeply from `@kbn/interpreter`
 - move a couple missed dependencies from x-pack to kibana
 - remove custom babel-register implementation
2018-11-23 14:16:38 -07:00
Peter Pisljar
f82d73285a
Ref/canvas interpreter2 oss take5 (#26068) 2018-11-23 06:37:25 +01:00
Joe Fleming
4f1ca7e07f
Fix: revert and enable canvas tests (#26054)
## Summary

CI was broken when enabling functional smoke tests via #25262. The problem is that the Kibana build is broken in master...

I think #25711 broke it, which was merged in between #25262 passing and it being merged (and then CI breaking). So this PR reverts that PR and enabled canvas smoke tests again to see if CI will pass.

- Revert #25711
- Revert 7ae0d28d87
2018-11-21 16:25:12 -07:00
Peter Pisljar
43b1d00128
move canvas interpreter to OSS (#25711) 2018-11-20 09:56:50 +01:00
Nathan Reese
30ebf9c2dc
use savedObjectsClient to get index-patterns (#25630) 2018-11-15 16:02:57 -07:00
Spencer
59eff29786
[canvas] Improve plugin pre-build (#25267)
Fixes https://github.com/elastic/kibana/issues/23552

Extends the webpack config used to pre-build `x-pack/plugins/canvas/canvas_plugins_src` so that it does a couple things:
 - use the "browser" and "main" fields when defined by packages, this allows the already transpiled output of packages like `@elastic/eui` to be used rather than rebuilding from source
 - use the `@kbn/babel-preset/webpack_preset` for babel-loader
 - include all errors in the log output when an error occurs
2018-11-12 16:04:36 -08:00
Joe Fleming
830c195b0d
fix: get correct plugins path (#25448)
we can't check the name of the outer path because it can change, instead, just make sure there's a plugins path there
2018-11-08 17:37:17 -07:00
Joe Fleming
ac625701f2
Fix: Canvas babel build (#25184)
Closes https://github.com/elastic/kibana/issues/25154

Canvas' threading code uses babel-register for the runtime, much like Kibana does, so we can execute code that uses newer syntax (mostly es modules at this point...). The default configuration of babel-register ignores `node_modules`, and since x-pack is built into `node_modules`, this worked fine in dev mode and not at all in the build.

There was also an issue where Kibana's build step removes all bablerc files, which meant Canvas' threaded runtime also wasn't getting any of the settings.

This PR pulls in the configuration from Kibana, which has an exception for transpiling x-pack code, and allows the runtime to operate correctly in the build.

Huge thanks to @jbudz for helping me sort out the issue!

@spalger ~~know more about babel than I do, if we can just use `@kbn/babel-preset/node_preset` directly instead, that seems less likely to break going forward. I meant to try it but ran out of time yesterday to make another build.~~ Works! PR updated.
2018-11-07 09:56:30 -07:00
Joe Fleming
1cb1c25d41
Fix: socket setup (#24550)
PR fixes issues with the socket connection.

- handle socket failures 
  - previously would either leave Canvas in an infinite loading state, or load the app even when it wouldn't function
- upgrade socket.io
- add headers to socket connection and modify auth connection
2018-11-02 10:26:52 -07:00
Catherine Liu
ffe24a8318
Fixes font picker when using custom fonts (#24937)
* Adds custom font as option in font picker

* Adjusted font sizes in ecommerce sample worpad

* Adjusted font sizes in sample flight workpad

* Adjusted font sizes in smaple web logs workpad
2018-11-01 14:16:26 -07:00
Catherine Liu
0c0444cd6e
Fixes unauthorized error in es datasources (#24624)
* Fixes check for security plugin

* Cleaned up security check logic. Fixed tests for create_handlers. Added TODOs

* Updated comment

* Added tests

* Updated variable names
2018-10-29 20:21:55 -07:00
Joe Fleming
b8b0229fd6
Feat/expression threading (#24598)
Replaces https://github.com/elastic/kibana/pull/23301
Closes https://github.com/elastic/kibana/issues/23080

---

This is a minimal threading implementation for Canvas. There's still a lot to be done to make this concept great, but this is a start. 

What it does:
- Creates a server side abstraction on top of the interpreter
- Determines where to send the expression by checking the first function to be run
- Loads common functions in a separate worker thread on the server. 
- Routes to a single forked worker (thread), the main thread (server), or the browser (browser), in that order
- Defers back to the router when a function isn't found. Fails if the function isn't found in any of the above 3 environments
- Times out the worker if it takes too long, and respawns it as needed.
- Simplifies the error dialog to remove the stack. 

What is does not.:
- Round robin a pool of workers
- Queue. If one expression in the threaded env fails then anything sent to it in the meantime will fail. The upstream environment handles managing timeouts. I think this would only make sense todo with a pool.
- Client side. This doesn't implement web workers, but we could use roughly the same architecture. 
- Implement a specific, pluggable `worker` environment on the server. Right now it's just common functions, so plugin authors will always end up in a thread if they put their function in the common directory.

What I don't like:
- The socketProvider code. This was reused across the server & browser, but now that it's only used in the browser there's no good reason for the abstraction
- The serialize/deserialize stuff feels messy. Do we really need serialization?
2018-10-26 09:49:46 -07:00
Josh Dover
27e5406d7a
Upgrade Hapi in legacy platform to v17 (#21707)
* Disable even-better monitoring

* Upgrade to Hapi v15

* Upgrade to Hapi v16

* Handle optional req params correctly

* Update http and kbnServer

* Get mocha tests passing

* Convert `reply` usages [wip]

* Fix Joi and Plugin incompatibilities

* Get server up and running

* Get basic logging working

* Fix optimizer

* Fix recent route handlers

* Various fixes

* Fix recent routes

* Upgrade wreck for async/await

* Fix mocha tests

* Fix joi issues

* Fix xpack jest tests

* Fix recent routes

* Fix tests

* Fix index setup

* Decouple monitoring stats collection from good plugin

* Update reload logging test to work

* Reimplement logging with updated good plugin

* Fix unit tests

* Fix getConnections back

* Make LegacyLoggingServer compatible with Hapi v17

* Update joi types

* Fix x-pack unit tests

* Remove stray debugger

* Remove hapi-compat

* Fix API integrations

* Upgrade boom

* Fix security plugin

* Misc fixes

* bump

* Fix licensePreRoutingFactory

* Fix failing integration tests

* Remove unnecessary test change

* Remove hapi-latest package

* fx

* Various cleanup

* Fix race condition in oppsy events

* Use elastic/good fork

* Fix boom.wrap and hapi-latest changes

* Simplify LegacyLoggingServer updates

* package.json cleanup + test fix

* yarn.lock cleanup

* Change good tag

* Fixes

* Change return err -> throw err in routes

* Fix await returns

* Fix new load_data test

* Make cookie security flags consistent

* tmp doc

* Fix types

* Fix tests

* Upgrade canvas plugin

* Move good package to published @elastic/good one

* Fix SO test

* Fix logging reloading

* Update APM apis

* Fix error logging

* Fix logging test

* Convert spaces plugin

* Add validation error shim

* Remove 7.0 release notes

* Await renderApp

* Fix ccr routes

* Prevent header popovers from scrolling with page content (#23850)

* Fix spaces test

* new yarn.lock-s

* Fix spaces tests

* Remove h2o2-latest

* Fix @types/hapi

* Upgrade InfraOps plugin

* Fix package.json

* Add back isSameSite: false

* Upgrade beats_management plugin

* Update snapshot

* Fix InfraOps

* Upgrade kql_telemetry

* Merge upstream/master

* Upgrade apm and ml

* Put snapshot test back

* Fx beats

* Upgrade rollups

* Update boom usages in new plugins
2018-10-25 16:01:12 -05:00
Joe Fleming
7d96e671c1
Fix: Plugin loading in the build (#24426)
* fix: correctly wait on server plugins

* fix: correctly resolve canvas plugins in build
2018-10-23 17:25:33 -07:00
Joe Fleming
5009efde13
Fix: Canvas socket auth (#24094)
## Summary

Closes https://github.com/elastic/kibana/issues/23303 ~(@cqliu1 can you confirm this too?)~ confirmed

Fixes the way we capture the request info when configuring the socket and providing it to plugins via `callWithRequest`. Instead of exposing a route that returns the info, simply use the request object that comes back from `server.inject`.

Also adds a check in the `elasticsearchClient` handler exposed to plugins to ensure the session is still valid because using `callWithRequest`.

![screenshot 2018-10-16 10 37 56](https://user-images.githubusercontent.com/404731/47036828-32768c00-d132-11e8-81a0-122b5e83c7ef.png)
*Note:* the actual error message is a bit different, but this is how the failure is exposed to the user
2018-10-23 17:19:32 -07:00