Skip to content

[TSVB] Remove request facade and type server code#92964

Merged
sulemanof merged 17 commits intoelastic:masterfrom
sulemanof:feat/tsvb_req_facade_removal
Mar 9, 2021
Merged

[TSVB] Remove request facade and type server code#92964
sulemanof merged 17 commits intoelastic:masterfrom
sulemanof:feat/tsvb_req_facade_removal

Conversation

@sulemanof
Copy link
Copy Markdown
Contributor

@sulemanof sulemanof commented Feb 26, 2021

Summary

Part of #57342

This removes ReqFacade type to provide a nicer extension point for search strategies.
Next files were converted to TypeScript to avoid possible errors with request facade removal:

  • annotations/build_request_body.ts
  • annotations/get_request_params.ts
  • vis_data/get_annotations.ts
  • vis_data/get_series_data.ts
  • vis_data/get_table_data.ts
  • helpers/get_es_query_uisettings.ts
  • vis_data/series/get_request_params.ts
  • vis_data/series/handle_response_body.ts

Checklist

Delete any items that are not applicable to this PR.

For maintainers

Daniil Suleiman added 9 commits February 24, 2021 13:09
…ade_removal

# Conflicts:
#	src/plugins/vis_type_timeseries/server/lib/get_fields.ts
#	src/plugins/vis_type_timeseries/server/lib/get_vis_data.ts
#	src/plugins/vis_type_timeseries/server/lib/search_strategies/strategies/abstract_search_strategy.ts
#	src/plugins/vis_type_timeseries/server/lib/vis_data/annotations/get_request_params.js
#	src/plugins/vis_type_timeseries/server/lib/vis_data/series/get_request_params.js
fakeRequest: FakeRequest,
options: GetVisDataOptions
) => ReturnType<GetVisData>;
// ideally this should be VisPayload type, but currently has inconsistencies with x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks like @dziyanadzeraviankina already fixed that issue here #91977

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.

I would not like to make any changes in infra code in this PR, let's ask @dziyanadzeraviankina to remove this any and comment when resolving merge conflicts?


public get searchTimezone() {
return getTimezoneFromRequest(this.request);
return getTimezoneFromRequest(this.request as VisTypeTimeseriesVisDataRequest);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are you sure we need that casting here? in line 24 you already set VisTypeTimeseriesRequest type for request. getTimezoneFromRequest also works with VisTypeTimeseriesVisDataRequest

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.

VisTypeTimeseriesRequest is a union type of VisTypeTimeseriesFieldsRequest | VisTypeTimeseriesVisDataRequest,
but getTimezoneFromRequest expects only VisTypeTimeseriesVisDataRequest.
If you don't like type casting here, I made a type guard in the recent commit (but it looks overloaded IMHO)

@alexwizp alexwizp requested a review from stratoula March 3, 2021 11:27
Copy link
Copy Markdown
Contributor

@alexwizp alexwizp left a comment

Choose a reason for hiding this comment

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

Thank you for that cleanup. No red flags from my side. @stratoula @VladLasitsa please review.

@alexwizp alexwizp requested a review from VladLasitsa March 4, 2021 12:36
@sulemanof sulemanof marked this pull request as ready for review March 4, 2021 13:09
@sulemanof sulemanof requested a review from a team March 4, 2021 13:09
@sulemanof sulemanof added Feature:TSVB TSVB (Time Series Visual Builder) release_note:skip Skip the PR/issue when compiling release notes labels Mar 4, 2021
* @returns {Object} doc - processed body
*/
export async function buildAnnotationRequest(...args) {
export async function buildAnnotationRequest(...args: any[]) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we type it? Or at least replace it with unknown?

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.

updated

Copy link
Copy Markdown
Contributor

@VladLasitsa VladLasitsa left a comment

Choose a reason for hiding this comment

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

LGTM

Daniil Suleiman added 2 commits March 9, 2021 11:48
…ade_removal

# Conflicts:
#	api_docs/core.json
#	api_docs/vis_type_timeseries.json
Copy link
Copy Markdown
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

LGTM, thanx @sulemanof ❤️

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@stratoula
Copy link
Copy Markdown
Contributor

@elasticmachine run elasticsearch-ci/docs

@sulemanof sulemanof merged commit c7fc78e into elastic:master Mar 9, 2021
@sulemanof sulemanof deleted the feat/tsvb_req_facade_removal branch March 9, 2021 13:32
sulemanof pushed a commit to sulemanof/kibana that referenced this pull request Mar 9, 2021
* Remove request facade and update search strategies

* Use typescript

* Type files

* Update structure

* Update tests

* Type annotations

* Fix type for infra

* Enhance types

* Remove generics

* Use constant

* Update docs

* Type capabilities
sulemanof pushed a commit that referenced this pull request Mar 10, 2021
* Remove request facade and update search strategies

* Use typescript

* Type files

* Update structure

* Update tests

* Type annotations

* Fix type for infra

* Enhance types

* Remove generics

* Use constant

* Update docs

* Type capabilities
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:TSVB TSVB (Time Series Visual Builder) release_note:skip Skip the PR/issue when compiling release notes v7.13.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants