Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Extract server type utils to package #96349

Merged
merged 13 commits into from
Apr 8, 2021

Conversation

dgieselaar
Copy link
Member

Extracts the tooling we use to create fully typed server routes to a separate package for use in the Observability plugin (and possibly others).

For examples, see https://github.com/dgieselaar/kibana/blob/17a48e34970387689a7d6e618dd54f7e77564e91/packages/kbn-server-route-repository/src/test_types.ts

@dgieselaar dgieselaar requested review from a team as code owners April 6, 2021 19:23
@botelastic botelastic bot added Team:APM All issues that need APM UI Team support Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability labels Apr 6, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime (Team:uptime)

@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@dgieselaar dgieselaar added release_note:skip Skip the PR/issue when compiling release notes v7.13.0 labels Apr 6, 2021
Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

Only skimmed this but overall looks great.
Big 👍 to extracting this and making it available to other teams

// It does not allow params for routes without a params codec
client({
endpoint: 'endpoint_without_params',
// @ts-expect-error Object literal may only specify known properties, and 'params' does not exist in type
Copy link
Member

Choose a reason for hiding this comment

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

Good use of @ts-expect-error 👍

Comment on lines 195 to 198
// @ts-expect-error Property 'noParamsForMe' is missing in type
const invalidType: {
noParamsForMe: boolean;
} = res;
Copy link
Member

@sorenlouv sorenlouv Apr 7, 2021

Choose a reason for hiding this comment

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

If you have access to expect you can double this as both a runtime and compile assertion. And I find the intention a little more clear this way

Suggested change
// @ts-expect-error Property 'noParamsForMe' is missing in type
const invalidType: {
noParamsForMe: boolean;
} = res;
// @ts-expect-error Property 'noParamsForMe' is missing in return type
expect(res.noParamsForMe).toBe(undefined)

Copy link
Member Author

Choose a reason for hiding this comment

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

expect might not be the appropriate tool, but let me see if I can write some other utility function

Copy link
Member Author

Choose a reason for hiding this comment

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

what about something like
image

Copy link
Member

Choose a reason for hiding this comment

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

An assert generic is pretty cool 👍

Copy link
Contributor

@shahzad31 shahzad31 left a comment

Choose a reason for hiding this comment

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

Changes LGTM !!

Can we please add a simple readme file with few examples?
I am very much interested in using these in uptime app.
But i am having hard time understanding it from examples that what advantages it would provide.

@dgieselaar
Copy link
Member Author

@shahzad31 I've added a placeholder - I'd like to work with you on integrating it in Uptime and writing the readme together based on that experience. Please ping me next week or after if you have some time for that!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1570 1571 +1

Async chunks

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

id before after diff
apm 4.2MB 4.2MB +815.0B

History

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

@dgieselaar dgieselaar merged commit bfc940c into elastic:master Apr 8, 2021
@dgieselaar dgieselaar deleted the extract-typed-server-repository branch April 8, 2021 11:26
dgieselaar added a commit to dgieselaar/kibana that referenced this pull request Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants