[data.fieldFormats] Remove aggs format decorator from fieldFormats.deserialize()
#71967
Labels
Feature:FieldFormatters
impact:medium
Addressing this issue will have a medium level of impact on the quality/strength of our product.
loe:medium
Medium Level of Effort
technical debt
Improvement of the software architecture and operational architecture
As part of the preparation for making aggs available on the server, we extracted the aggs-specific logic from fieldFormats.deserialize and consolidated all of it into a single utility which decorates
getFieldFormat
with some special agg-specific formatter types:kibana/src/plugins/data/public/field_formats/utils/deserialize.ts
Lines 55 to 56 in 16eaf82
While this created a clearer separation of concerns, it still feels wrong to have field formats depending on aggs in this way.
So why can't aggs just be added to the registry like other formatters? This would be ideal as they wouldn't need special treatment by the field formats service. Currently there are two reasons we can't do this:
field
param with some additional functionality.After some discussion with @stacey-gammon around whether the enhancements pattern could solve this problem, we agreed it is probably overkill for this particular scenario.
With that in mind, I'd propose taking the following steps to resolve this:
FieldFormat
that allows you to specify a format ashidden
. The idea is that formats withhidden: true
would not be surfaced in the UI. This could be achieved a number of ways, but perhaps the most simple way is to make it so that these formats are only available in the registry if you get them by ID (e.g.getType('some_hidden_format')
), but they would not be available when you are getting collections of formats (e.g.getFieldByType('number')
).getType
to every registeredFieldFormat
. This way any formatter in the registry could look up other formatters by ID at runtime, which opens up the possibility of new formatters enhancing/decorating existing ones. This could probably be provided via thefieldFormatMetaParamsDecorator
.hidden: true
and use the injectedgetType
to access other formats at runtime.FieldFormat.from()
method. This is only used internally & by the aggs formatters. If the agg formatters exist in the registry, there is no longer a need for this method to be exposed publicly.fieldFormats.deserialize
dependency on aggs.The text was updated successfully, but these errors were encountered: