[Infra] Replace infra aggregation runtime types with the types in estypes#192059
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
e529ea7 to
7b7fd57
Compare
estypes
jennypavlova
left a comment
There was a problem hiding this comment.
I know it's still a draft, I am just adding some questions.
db8c5da to
7b7fd57
Compare
|
Hey @crespocarlos I see you had some good comments in similar PR #190495 therefore could you please take a look at this one? Questions:
|
crespocarlos
left a comment
There was a problem hiding this comment.
Nice one! Left a few comments.
There was a problem hiding this comment.
Tip
Maybe this can be simplified?
| if (agg && typeof agg === 'object' && Object.keys(agg).length !== 0) { | |
| for (const key in agg) { | |
| if (Object.hasOwn(agg, key)) { | |
| return !!( | |
| agg[key as keyof typeof agg] === undefined || | |
| (agg[key as keyof typeof agg] as estypes.AggregationsMetricAggregationBase).field | |
| ); | |
| } | |
| } | |
| } | |
| if (typeof agg !== 'object' || agg === null) { | |
| return false; | |
| } | |
| return Object.values(agg).some( | |
| value => value === undefined || 'field' in (value as estypes.AggregationsMetricAggregationBase) | |
| ); |
There was a problem hiding this comment.
Should we add tests for the functions here?
There was a problem hiding this comment.
Should these be in the types file? I wonder if it would be better if we created a utils file or something like that. wdyt?
There was a problem hiding this comment.
I forgot this one. Let's try to replace this too.
There was a problem hiding this comment.
I had a chat with Jenny earlier today, and we weren't sure about replacing ESTermsWithAggregationRT. I'll do it then. Thanks
|
Hey! I had reviewed it before reading this:
I agree with moving the type guards to another file, I've even left a comment about it already :).
From what I've seen, there is only |
There was a problem hiding this comment.
nit to avoid repetition
| return !!( | |
| (agg as estypes.AggregationsAggregationContainer).aggregations && | |
| (agg as estypes.AggregationsAggregationContainer).terms | |
| ); | |
| const container = agg as estypes.AggregationsAggregationContainer; | |
| return !!(container?.terms && container?.aggregations); |
|
Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services) |
crespocarlos
left a comment
There was a problem hiding this comment.
LGTM! Thanks for this PR. Left just one nit.
There was a problem hiding this comment.
it's fine to leave these mocks on this file. do we still need this todo?
There was a problem hiding this comment.
Ops. I committed it unintentionally. It was a reminder for me to clarify it with you guys. Updated, thanks!
There was a problem hiding this comment.
Thanks for add the test.
jennypavlova
left a comment
There was a problem hiding this comment.
LGTM 💯 Thank you for changing those types, it looks better and we don't need to maintain those types anymore!
20bb82a to
7aa5f38
Compare
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Public APIs missing comments
Page load bundle
History
To update your PR or re-run it, just comment with: |
Closes #190497
Summary
This PR replaces infra aggregation types with types provided by the Elasticsearch client.
Testing
Alerting tested manually.
Checklist
Delete any items that are not applicable to this PR.