* chore(NA): splits types from code on @kbn/i18n (#119256) * chore(NA): auto creation of the package.json for the new types pkg rule * chore(NA): first alpha api extractor working version * chore(NA): support kbn-analytics * chore(NA): correctly read tsconfig files and deps from ts_config rule * chore(NA): layed out pkg_npm_types tree artifact custom rule * chore(NA): missing todos * chore(NA): node modules link mapping * chore(NA): fully working pkg_npm_types rule * chore(NA): fix changes on new packages using elastic datemath pkgs * docs(NA): remove todo * docs(NA): last todo text correction * chore(NA): removed commented lines * fix(NA): include missing package version * chore(NA): include license keys * chore(NA): change mock types package into private * chore(NA): disable validator on ts_project rule * chore(NA): use the wrapper for ts_project * commit using @elastic.co * chore(NA): commit using @elastic.co * chore(NA): split types from code on @kbn/i18n * chore(NA): update yarn.lock file * chore(NA): split @kbn/i18n and @kbn/i18n-react * chore(NA): missing import fix * chore(NA): fix jest project configs * chore(NA): change imports on kbn i18n * chore(NA): change imports on kbn i18n * chore(NA): correct loader imports * chore(NA): missnig i18nLoader export key * chore(NA): fix type exports * chore(NA): export type only * chore(NA): export type only * fix(NA): type exports * chore(NA): missing @Kbn/i18n/react imports * chore(NA): missing skip path for kbn-i18n-react Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> # Conflicts: # package.json # packages/BUILD.bazel # packages/kbn-monaco/BUILD.bazel # src/core/public/core_app/status/components/server_status.tsx # src/core/public/core_app/status/components/status_table.tsx # src/core/public/core_app/status/components/version_header.tsx # src/core/public/core_app/status/status_app.tsx # src/plugins/console/public/application/components/storage_quota_error.tsx # src/plugins/dashboard/public/application/listing/dashboard_listing.tsx # src/plugins/data_view_field_editor/public/components/field_editor/form_fields/script_field.tsx # src/plugins/dev_tools/public/application.tsx # src/plugins/discover/public/application/apps/context/context_app_route.tsx # src/plugins/discover/public/application/apps/doc/single_doc_route.tsx # src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row_details.tsx # src/plugins/discover/public/application/apps/main/components/layout/discover_documents.tsx # src/plugins/discover/public/application/components/table/table_columns.tsx # src/plugins/discover/public/application/components/table/table_row_btn_filter_remove.tsx # src/plugins/discover/public/application/components/table/table_row_btn_toggle_column.tsx # src/plugins/index_pattern_editor/public/open_editor.tsx # src/plugins/interactive_setup/public/plugin.tsx # src/plugins/kibana_overview/public/application.tsx # src/plugins/kibana_react/public/util/to_mount_point.tsx # src/plugins/presentation_util/public/components/field_picker/field_search.tsx # src/plugins/vis_types/timeseries/public/timeseries_vis_renderer.tsx # src/plugins/vis_types/xy/public/vis_renderer.tsx # src/plugins/visualizations/public/wizard/show_new_vis.tsx # x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_create_from_csv/error_display.tsx # x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_create_from_csv/instructions.tsx # x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_create_from_csv/main.tsx # x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_create_from_csv/pipelines_csv_uploader.tsx # x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_create_from_csv/pipelines_preview.tsx # x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx # x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx # x-pack/plugins/lens/public/indexpattern_datasource/utils.tsx # x-pack/plugins/lens/public/metric_visualization/visualization.tsx # x-pack/plugins/lens/public/pie_visualization/render_function.tsx # x-pack/plugins/maps/public/classes/sources/ems_tms_source/update_source_editor.js # x-pack/plugins/maps/public/classes/sources/es_search_source/util/scaling_documenation_popover.tsx # x-pack/plugins/security/public/authentication/access_agreement/access_agreement_page.tsx # x-pack/plugins/security/public/authentication/logged_out/logged_out_page.tsx # x-pack/plugins/security/public/authentication/login/login_page.tsx # x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_page.tsx # x-pack/plugins/security/public/management/users/users_management_app.tsx # x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.tsx # x-pack/plugins/spaces/public/space_selector/space_selector.tsx # yarn.lock * chore(NA): missing @kbn/i18n/react imports |
||
---|---|---|
.. | ||
__fixtures__ | ||
__jest__/client_integration | ||
common | ||
public | ||
server | ||
jest.config.js | ||
kibana.json | ||
README.md | ||
tsconfig.json |
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.