kibana/x-pack/plugins/watcher
Mikhail Shustov d920682e4e
Update @elastic/elasticsearch to 8.0.0-canary13 (#98266)
* bump @elastic/elasticsearch to canary.7

* address errors in core

* address errors in data plugin

* address errors in Alerting team plugins

* remove outdated messages in Lens

* remove unnecessary comments in ML

* address errors in Observability plugin

* address errors in reporting plugin

* address errors in Rule registry plugin

* fix errors in Security plugins

* fix errors in ES-UI plugin

* remove unnecessary union.

* update core tests

* fix kbn-es-archiver

* update to canary 8

* bump to v9

* use new typings

* fix new errors in core

* fix errors in core typeings

* fix type errors in data plugin

* fix type errors in telemetray plugin

* fix data plugin tests

* fix search examples type error

* fix errors in discover plugin

* fix errors in index_pattern_management

* fix type errors in vis_type_*

* fix errors in typings/elasticsearch

* fix type errors in actions plugin

* fix type errors in alerting and apm plugins

* fix type errors in canvas and cases

* fix errors in event_log

* fix type errors in ILM and ingest_pipelines

* fix errors in lens plugin

* fix errors in lists plugin

* fix errors in logstash

* fix errors in metrics_entities

* fix errors in o11y

* fix errors in watcher

* fix errors in uptime

* fix errors in upgrade_assistant

* fix errors in task_manager

* fix errors in stack_alerts

* fix errors in security_solution

* fix errors in rule_registry

* fix errors in snapshot_restore

* fix remaining errors

* fix search intergration tests

* adjust assetion

* bump version to canary.10

* adapt code to new naming schema

* use mapping types provided by the client library

* Revert "adjust assetion"

This reverts commit 19b8fe0464.

* fix so intergration tests

* fix http integration tests

* bump version to canary 11

* fix login test

* fix http integration test

* fix apm test

* update docs

* fixing some ml types

* fix new errors in data plugin

* fix new errors in alerting plugin

* fix new errors in lists plugin

* fix new errors in reporting

* fix or mute errors in rule_registry plugin

* more ML type fixes

* bump to canary 12

* fix errors after merge conflict

* additional ML fixes

* bump to canary 13

* fix errors in apm plugin

* fix errors in fleet plugin

* fix errors in infra plugin

* fix errors in monitoring plugin

* fix errors in osquery plugin

* fix errors in security solution plugins

* fix errors in transform plugin

* Update type imports for ES

* fix errors in x-pack plugins

* fix errors in tests

* update docs

* fix errors in x-pack/test

* update error description

* fix errors after master merge

* update comment in infra plugin

* fix new errors on xpack tests/

Co-authored-by: James Gowdy <jgowdy@elastic.co>
Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
2021-06-08 15:06:06 +02:00
..
__fixtures__
__jest__/client_integration Rename client integration test folders (#100119) 2021-05-20 08:54:47 -04:00
common
public Update dependency @elastic/charts to v28 (master) (#96163) 2021-04-06 14:17:50 -05:00
server Update @elastic/elasticsearch to 8.0.0-canary13 (#98266) 2021-06-08 15:06:06 +02:00
jest.config.js
kibana.json Extract License service from CCR and Watcher into license_api_guard plugin in x-pack (#95973) 2021-04-15 14:54:49 -07:00
README.md
tsconfig.json Rename client integration test folders (#100119) 2021-05-20 08:54:47 -04:00

Watcher

This plugins adopts some conventions in addition to or in place of conventions in Kibana (at the time of the plugin's creation):

Folder structure

common/
  constants/ // constants used across client and server
  lib/ // helpers used across client and server
  types/ // TS definitions
public/
  components/ // common React components
  constants/ // constants used on the client
  lib/ // helpers used on the client
  models/ // client models
  sections/ // Sections of the app with corresponding React components
    watch_edit
    watch_list
    watch_status
server/
  lib/
    screenshots/
      screenshots.js
      index.js // ONLY exposes screenshots service
      screenshot.js // helper service, not exposed in index.js
      __tests__/
        screenshots.js
        screenshot.js
    say_hello/
      index.js
      say_hello.js

Data Flow

We have a layered architecture in the Watcher UI codebase, with each layer performing a specific function to the data as it flows through it.

Elasticsearch APIs <---> Kibana server models <---> Kibana APIs <---> Kibana client services <---> Kibana client models <---> Kibana client code

Each of these layers is described below.

Elasticsearch APIs

This the ultimate source or destination of any persisted data: watches, watch history, etc.

Kibana server models

These set of classes translate data coming from Elasticsearch into a shape required by the Watcher UI codebase. Conversely, they translate data generated by the Watcher UI into a shape required by Elasticsearch APIs.

Kibana APIs

This layer is responsible for transporting data between the Kibana server and Kibana client (browser).

Kibana client services

This layer is responsible for calling Kibana APIs, using client models to parse responses from APIs or create requests for APIs.

Service methods should consume models as arguments and return models as much as possible. The exception to this might be services that perform an initial load of a piece of data from the API; in this case the service method may consume a scalar ID as it argument.

Kibana client models

Much like their server counterparts, these set of classes translate data coming from the Kibana APIs into in-memory representations for use in the Kibana client-side code or vice-versa. Unlike their server counterparts they typically don't change the shape of the data (as that is typically done by the server models already).

They do, however, serve as a consistent place in the data path for translating wire representations of certain types of data into more suitable in-memory representations, for example: converting an ISO8601-formatted timestamp into a moment instance.

They are also the right place for establishing relationships between models — for example, a watch contains many actions — and for encapsulating operations around such relationships — for example, updating the status of a watch's action.

Kibana client code

This layer deals almost exclusively with data in the form of client models. The one exception to this rule is when the client code needs to bootstrap a model instance from a bare JS object — for example, creating a new Watch model from the contents of the Add/Edit Watch Form.