Skip to content

[Controls as Code] Use discriminated union#259670

Merged
Heenawter merged 32 commits into
elastic:mainfrom
Heenawter:controls-discriminated-union_2026-03-25
Apr 7, 2026
Merged

[Controls as Code] Use discriminated union#259670
Heenawter merged 32 commits into
elastic:mainfrom
Heenawter:controls-discriminated-union_2026-03-25

Conversation

@Heenawter
Copy link
Copy Markdown
Contributor

@Heenawter Heenawter commented Mar 25, 2026

Closes #259864

Summary

This PR makes two changes to control schemas.

  1. Rather than having pinned panels be oneOf an array of control schemas, it instead uses a discriminated union based on the type of the control.

  2. There are two types of ES|QL controls - static value and query - which are distinguished via the control_type attribute. Previously, both available_options (for static value controls) and esql_query (for query controls) were optional parts of the schema - however, to make the schemas clearer, I made them both required but as a discriminated union based on control_type.

    In other words, a STATIC_VALUES control requires available_options but will throw if esql_query is included and, conversely, a VALUES_FROM_QUERY control requires an esql_query but will throw if available_options is included.

Checklist

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

@Heenawter Heenawter self-assigned this Mar 25, 2026
@Heenawter Heenawter added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// loe:small Small Level of Effort release_note:skip Skip the PR/issue when compiling release notes impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. backport:skip This PR does not require backporting Project:Dashboards API labels Mar 25, 2026
@Heenawter Heenawter requested review from a team as code owners April 1, 2026 21:17
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@Heenawter Heenawter added impact:critical This issue should be addressed immediately due to a critical level of impact on the product. and removed impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. labels Apr 1, 2026

export const getOptionsListControlFactory = (): EmbeddableFactory<
OptionsListControlState,
OptionsListDSLControlState,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbondyra Can you explain why you changed this to the generic type in #260082?

Copy link
Copy Markdown
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-only review, Data Discovery changes LGTM 👍

@nreese nreese self-requested a review April 3, 2026 14:12
Copy link
Copy Markdown
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kibana-presentation changes LGTM
code review only

Comment thread src/platform/packages/shared/controls/controls-schemas/src/types.ts Outdated
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Apr 3, 2026

💔 Build Failed

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
controls 428 427 -1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
controls 525.5KB 524.8KB -726.0B
esql 819.8KB 819.9KB +84.0B
total -642.0B

History

cc @Heenawter

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #81 / Entity Analytics - Risk Score Maintainer @ess @serverless @serverlessQA Risk Score Maintainer Entity Calculation with test log data @skipInServerless with asset criticality modifiers calculates risk scores with criticality modifiers

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
controls 428 427 -1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/esql-types 129 135 +6

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
controls 525.5KB 524.8KB -726.0B
esql 819.8KB 819.9KB +84.0B
total -642.0B
Unknown metric groups

API count

id before after diff
@kbn/esql-types 143 149 +6

History

cc @Heenawter

@Heenawter Heenawter merged commit 2e70b88 into elastic:main Apr 7, 2026
16 checks passed
@Heenawter Heenawter deleted the controls-discriminated-union_2026-03-25 branch April 7, 2026 18:04
nickpeihl added a commit that referenced this pull request Apr 8, 2026
…cal Preview (#256302)

Fixes #256073

## Summary

Introduces the Dashboard API endpoints as Technical Preview

Dashboard API documentation will be published as OpenAPI specifications
and available in the [Kibana API
Documentation](https://www.elastic.co/docs/api/doc/kibana/). Dashboard
API create/update endpoints are initially limited to a select few types
including Lens, markdown, synthetics, and SLO panels. Support for
additional panel types will be available in future updates.

## OAS documentation
To build documentation bundle for public route
* Add `server.oas.enabled: true` to `config/kibana.dev.yml`
* Run `node scripts/capture_oas_snapshot --include-path /api/dashboards
--no-serverless --update`

### Blocked by

- [x] #259670
- [x] #259461
- [x] #260040
- [x] #261186
- [x] #260945

---------

Co-authored-by: Nathan Reese <reese.nathan@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Nick Partridge <nicholas.partridge@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting impact:critical This issue should be addressed immediately due to a critical level of impact on the product. loe:small Small Level of Effort Project:Dashboards API release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Controls as Code] Use discriminated union for type and ES|QL controls

6 participants