[Lens] Update Lens CM and APIs#229534
Conversation
- make accessible from /common - fix reference.name schema misalignment - add `createdBy` and `updatedBy` to the SO schema - use generics on common schema functions to pass type correctly - add schema for search result
- The `getContentClientFactory` required request but never uses it. - Add `request` to `StorageContext` to pass to CM storage handlers
- This never checked if `mSearch` was available when creating the ctx. - Check for `mSearch` before adding to ctx, log server warning if missing - Add `logger` to `mSearch` factory
- We should allow transforms to run on unversioned items - These version are not targets, they are only pulled up to the first version. - allow using `kbn/object-versioning` in common.
- Vis type alias client only needs basic methods (i.e. `get` and `update`). - Create a slim `BasicVisualizationClient` - The basic client can use `cm` or `http`.
- isolates the Lens SO to CM
- update constants and use route schema - update handling of API formats in and out of CM client
- This add CM transforms to convert existing lens items to v1 - Adds version number to lens SO attributes. - Duplicates and tweaks runtime migrations for legend and color mappings.
- Refactor lens client to use new CRUD api instead of CM - Create basic lens client using CM to use new API types - Convert lens type alias client to use new basic client - Update calls to lens client dependency to `http` - Update lens doc service to use new lens client - Update lens attribute service to use updated doc service
…ns-transforms-phase-1
markov00
left a comment
There was a problem hiding this comment.
As previously discussed, you need to remove the isNewApiFormat before saving the config into the SO. Currently this is not done and that property is currently going to be stored into the SO.
## Summary Changes to the `down` method type from elastic#153304, missed passing the generic input type. Also fixes types on schema utility functions from `@kbn/content-management-utils`. I created elastic#231191 and a child issues for CO teams to track and fix. _Pulling this out of a larger PR, elastic#229534, to ease CO review._ ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
markov00
left a comment
There was a problem hiding this comment.
Changes looks good to me, addressed all my concerns
AlexGPlay
left a comment
There was a problem hiding this comment.
data discovery changes lgtm
- change version index to false - set dynamic to explicit default of strict
…ns-transforms-phase-1
There was a problem hiding this comment.
Pull Request Overview
This PR implements Phase 1 of the Lens by-ref transforms foundation, introducing a comprehensive overhaul of the Lens Content Management system to use schema-driven types and establishing a new API structure aligned with the dashboard API.
Key changes include:
- Complete restructuring of Lens Content Management to use strict schema-driven types with runtime migrations from v0 to v1
- Introduction of new Lens CRUD API with data/meta structure format replacing direct CM client usage
- Implementation of Config Builder stubs for API format transformations
- Addition of comprehensive schema definitions and versioning system
Reviewed Changes
Copilot reviewed 141 out of 141 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
x-pack/platform/plugins/shared/lens/server/ |
Complete overhaul of server-side CM with new v1 schemas, transforms, and API routes |
x-pack/platform/plugins/shared/lens/public/persistence/ |
Refactored client-side persistence layer with new LensClient and attribute service |
x-pack/platform/test/api_integration/apis/lens/ |
Updated API integration tests to use new endpoint paths and response formats |
x-pack/solutions/security/plugins/security_solution/public/ |
Removed deprecated type, updated_at, and version properties from Lens attributes |
x-pack/platform/plugins/shared/lens/common/ |
Added new transform system, constants, and content management schemas |
x-pack/platform/plugins/shared/lens/public/visualizations/xy/persistence.ts
Show resolved
Hide resolved
x-pack/platform/plugins/shared/lens/public/visualizations/xy/persistence.ts
Show resolved
Hide resolved
x-pack/platform/plugins/shared/lens/server/content_management/v1/schema/common.ts
Show resolved
Hide resolved
x-pack/platform/plugins/shared/lens/server/api/routes/visualizations/create.ts
Show resolved
Hide resolved
x-pack/platform/plugins/shared/lens/server/content_management/v1/schema/common.ts
Show resolved
Hide resolved
TinaHeiligers
left a comment
There was a problem hiding this comment.
Saved objects changes LGTM.
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
|
## Summary **Lens transforms Phase 1** - Foundation for Lens by-ref transforms. Major Changes: - Overhauls the Lens Content Management to use schema-driven types - Defines rigid schema and types to be used inside CM. - Implement a working item transform based on the lens item version. - Applied runtime migrations (`v0` to `v1`) on all necessary CRUD operations. - Attempts to isolate lens SO types to CM. - All Lens /public CRUD operations pass through API, no more CM public client. One exception is the `mSearch` used from visualizations plugin. - Refactors Lens API - Allow new API structure (i.e. `data` & `meta`) as to align with the dashboard API (see elastic#196609). - Stub out usage of different formats between API request/response types and the Lens CM Item. - Stubs out the Config Builder flow to convert the new API format to Lens item, and vise versa. - Use CM schemas to build out Lens route request and response schema - Refactor lens /public client to use new CRUD API - Need to patch a basic lens client for visualizations plugin to use for updating basic attributes. - Refactor lens client to new client consuming the Lens API instead of CM client. - Patch Lens item to conform to the `LensDocument`, the new client still expect the old `LensDocument` but converts the API format to pass to/from the server. The client does all the conversions. - Updates all usages of lens client to new client. - Rely on shared/common schema definitions whenever possible. - Change the visualize library client to use a basic client with only `get` and `update` methods. Closes elastic#225367 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [x] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
## Summary **Lens transforms Phase 1** - Foundation for Lens by-ref transforms. Major Changes: - Overhauls the Lens Content Management to use schema-driven types - Defines rigid schema and types to be used inside CM. - Implement a working item transform based on the lens item version. - Applied runtime migrations (`v0` to `v1`) on all necessary CRUD operations. - Attempts to isolate lens SO types to CM. - All Lens /public CRUD operations pass through API, no more CM public client. One exception is the `mSearch` used from visualizations plugin. - Refactors Lens API - Allow new API structure (i.e. `data` & `meta`) as to align with the dashboard API (see elastic#196609). - Stub out usage of different formats between API request/response types and the Lens CM Item. - Stubs out the Config Builder flow to convert the new API format to Lens item, and vise versa. - Use CM schemas to build out Lens route request and response schema - Refactor lens /public client to use new CRUD API - Need to patch a basic lens client for visualizations plugin to use for updating basic attributes. - Refactor lens client to new client consuming the Lens API instead of CM client. - Patch Lens item to conform to the `LensDocument`, the new client still expect the old `LensDocument` but converts the API format to pass to/from the server. The client does all the conversions. - Updates all usages of lens client to new client. - Rely on shared/common schema definitions whenever possible. - Change the visualize library client to use a basic client with only `get` and `update` methods. Closes elastic#225367 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [x] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
## Summary **Lens transforms Phase 1** - Foundation for Lens by-ref transforms. Major Changes: - Overhauls the Lens Content Management to use schema-driven types - Defines rigid schema and types to be used inside CM. - Implement a working item transform based on the lens item version. - Applied runtime migrations (`v0` to `v1`) on all necessary CRUD operations. - Attempts to isolate lens SO types to CM. - All Lens /public CRUD operations pass through API, no more CM public client. One exception is the `mSearch` used from visualizations plugin. - Refactors Lens API - Allow new API structure (i.e. `data` & `meta`) as to align with the dashboard API (see elastic#196609). - Stub out usage of different formats between API request/response types and the Lens CM Item. - Stubs out the Config Builder flow to convert the new API format to Lens item, and vise versa. - Use CM schemas to build out Lens route request and response schema - Refactor lens /public client to use new CRUD API - Need to patch a basic lens client for visualizations plugin to use for updating basic attributes. - Refactor lens client to new client consuming the Lens API instead of CM client. - Patch Lens item to conform to the `LensDocument`, the new client still expect the old `LensDocument` but converts the API format to pass to/from the server. The client does all the conversions. - Updates all usages of lens client to new client. - Rely on shared/common schema definitions whenever possible. - Change the visualize library client to use a basic client with only `get` and `update` methods. Closes elastic#225367 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [x] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
## Summary **Lens transforms Phase 1** - Foundation for Lens by-ref transforms. Major Changes: - Overhauls the Lens Content Management to use schema-driven types - Defines rigid schema and types to be used inside CM. - Implement a working item transform based on the lens item version. - Applied runtime migrations (`v0` to `v1`) on all necessary CRUD operations. - Attempts to isolate lens SO types to CM. - All Lens /public CRUD operations pass through API, no more CM public client. One exception is the `mSearch` used from visualizations plugin. - Refactors Lens API - Allow new API structure (i.e. `data` & `meta`) as to align with the dashboard API (see #196609). - Stub out usage of different formats between API request/response types and the Lens CM Item. - Stubs out the Config Builder flow to convert the new API format to Lens item, and vise versa. - Use CM schemas to build out Lens route request and response schema - Refactor lens /public client to use new CRUD API - Need to patch a basic lens client for visualizations plugin to use for updating basic attributes. - Refactor lens client to new client consuming the Lens API instead of CM client. - Patch Lens item to conform to the `LensDocument`, the new client still expect the old `LensDocument` but converts the API format to pass to/from the server. The client does all the conversions. - Updates all usages of lens client to new client. - Rely on shared/common schema definitions whenever possible. - Change the visualize library client to use a basic client with only `get` and `update` methods. Closes #225367 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [x] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
## Summary Lens transforms Phase 2 ### Changes #### Integrate the Config Builder This integrates the `LensConfigBuilder` into the full end-to-end flow of all aspects of Lens including: - Lens APIs (transforms config to pass over the wire, convert to SO for saving) - Lens public client (transform api format to old Lens state) - Lens transforms (transforms Lens by-value panels for dashboards) #### Update Lens CM and API schema The schemas following changes from #229534, did not match the integration perfectly and stubbed out a few things. So there was some cleanup needed to these schema to make them clearer and easier to understand. These also needed to be changed to integrate the new `lensApiStateSchema` that will include all New API Formats. #### Registers Lens embeddable transforms Transforms: - `dashboard/server` - Used to transform by-ref Lens dashboard panels. - `dashboard/public` - Used to transform panels from url state. - `lens/public` - Used to transform standalone Lens embeddables (see example [here](https://github.com/elastic/kibana/blob/ed9f709ef56b182116ebcd788245fdecfdacfd8b/x-pack/platform/plugins/shared/cases/public/components/visualizations/lens_renderer.tsx#L40)). These transforms are meant to transform both: - **Item transforms** - Current `v0` Lens state/attributes with old configurations to the latest state/attributes. Applying all existing runtime migrations and pins version to latest Lens item `v1`. - Only for `lens/public` transforms, we are not saving standalone Lens embeddable state in new API format. - **API Format transforms** - Transforms the current `v1` Lens state to the new API format and vis-versa. - Needed to save Lens as `v1` as SO but pass the New API Format over the wire. - Needed to save Lens state in dashboard by-value panels in the New API Format. Transforms are behind a features flag, when enabled it will transform only supported chart types for all lens visualizations including by-ref and by-value. When disabled (default) it will pass around the only Lens SO state as it does today. ```yml # kibana.dev.yml feature_flags.overrides: lens.apiFormat: true ``` ### Issues Closes #229543 Closes #229546 Closed #237192 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) --------- Co-authored-by: Peter Pisljar <peter.pisljar@elastic.co> Co-authored-by: dej611 <dej611@gmail.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Marco Liberati <dej611@users.noreply.github.com> Co-authored-by: Marco Vettorello <marco.vettorello@elastic.co>
) ## Summary Lens transforms Phase 2 ### Changes #### Integrate the Config Builder This integrates the `LensConfigBuilder` into the full end-to-end flow of all aspects of Lens including: - Lens APIs (transforms config to pass over the wire, convert to SO for saving) - Lens public client (transform api format to old Lens state) - Lens transforms (transforms Lens by-value panels for dashboards) #### Update Lens CM and API schema The schemas following changes from elastic#229534, did not match the integration perfectly and stubbed out a few things. So there was some cleanup needed to these schema to make them clearer and easier to understand. These also needed to be changed to integrate the new `lensApiStateSchema` that will include all New API Formats. #### Registers Lens embeddable transforms Transforms: - `dashboard/server` - Used to transform by-ref Lens dashboard panels. - `dashboard/public` - Used to transform panels from url state. - `lens/public` - Used to transform standalone Lens embeddables (see example [here](https://github.com/elastic/kibana/blob/ed9f709ef56b182116ebcd788245fdecfdacfd8b/x-pack/platform/plugins/shared/cases/public/components/visualizations/lens_renderer.tsx#L40)). These transforms are meant to transform both: - **Item transforms** - Current `v0` Lens state/attributes with old configurations to the latest state/attributes. Applying all existing runtime migrations and pins version to latest Lens item `v1`. - Only for `lens/public` transforms, we are not saving standalone Lens embeddable state in new API format. - **API Format transforms** - Transforms the current `v1` Lens state to the new API format and vis-versa. - Needed to save Lens as `v1` as SO but pass the New API Format over the wire. - Needed to save Lens state in dashboard by-value panels in the New API Format. Transforms are behind a features flag, when enabled it will transform only supported chart types for all lens visualizations including by-ref and by-value. When disabled (default) it will pass around the only Lens SO state as it does today. ```yml # kibana.dev.yml feature_flags.overrides: lens.apiFormat: true ``` ### Issues Closes elastic#229543 Closes elastic#229546 Closed elastic#237192 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) --------- Co-authored-by: Peter Pisljar <peter.pisljar@elastic.co> Co-authored-by: dej611 <dej611@gmail.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Marco Liberati <dej611@users.noreply.github.com> Co-authored-by: Marco Vettorello <marco.vettorello@elastic.co>
Summary
Lens transforms Phase 1 - Foundation for Lens by-ref transforms.
Major Changes:
v0tov1) on all necessary CRUD operations.mSearchused from visualizations plugin.data&meta) as to align with the dashboard API (see [Dashboards as code] Return meta information in API response #196609).LensDocument, the new client still expect the oldLensDocumentbut converts the API format to pass to/from the server. The client does all the conversions.getandupdatemethods.Closes #225367
Checklist
release_note:breakinglabel should be applied in these situations.