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

feat: user id map in MigrationExchangeResponse as map #1821

Merged
merged 1 commit into from
Jun 17, 2024
Merged

feat: user id map in MigrationExchangeResponse as map #1821

merged 1 commit into from
Jun 17, 2024

Conversation

davidlj95
Copy link
Contributor

Summary

Fixes #1584

In slackapi/java-slack-sdk#1325 , JSON samples were updated so that quicktype properly infers user_id_map property type of MigrationExchangeResponse as a type.

Here the type is updated after running the response types generation script

Note that I manually discarded many changes after type generation: fields were added, new responses, ... In order to keep it in scope. Also some changes were related to code formatting and couldn't find the formatter tool & config used for the project if any.

Requirements (place an x in each [ ])

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.76%. Comparing base (893b836) to head (2882b0a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1821   +/-   ##
=======================================
  Coverage   81.76%   81.76%           
=======================================
  Files          35       35           
  Lines        7742     7742           
  Branches      316      316           
=======================================
  Hits         6330     6330           
  Misses       1400     1400           
  Partials       12       12           
Flag Coverage Δ
cli-hooks 95.07% <ø> (ø)
cli-test 53.80% <ø> (ø)
oauth 76.51% <ø> (ø)
socket-mode 59.41% <ø> (ø)
web-api 96.53% <ø> (ø)
webhook 95.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

warning?: string;
};

export interface UseridMap {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

⚠️ BREAKING CHANGE

If anyone was using that interface. Though given it was not very useful and cast was needed anyway, removing usage would be enough to fix it.

Copy link
Contributor

Choose a reason for hiding this comment

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

How exactly is this a breaking change? Because the values within user_id_map were typed to any before, and now would be a string?

Copy link
Member

Choose a reason for hiding this comment

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

I don’t consider this a breaking change. The auto-generated types here have been changed based on quicktype outputs over time. We've been trying to maintain backward compatibility as much as possible, but when an existing type is incomplete and/or invalid, changes like this can happen.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. Perhaps in the future, if we start paying closer attention to the response types, and start augmenting them with manual types, we could employ a more stringent backwards compatibility policy for the response types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's technically a breaking change regarding to type definitions as:

  1. Interface UseridMap is exported. It's also included in published dist/ files. So it's part of public API surface
  2. Interface UseridMap gets removed. Which is a breaking change in case someone was importing it & using it.
  3. Type definition is narrower. Before it was very open (any non null type). Now it's an indexed type which is a stricter type. So it's also non backwards compatible.

But given the type needed a cast anyways and cast was needed it's probably not enough for a new major version bump due to this kind of small breaking change. And more if auto-generated types are following a good-enough approach.

I'm happy with whatever you decide, reasons sound fair enough to me :)

@filmaj
Copy link
Contributor

filmaj commented Jun 17, 2024

Note that I manually discarded many changes after type generation

That is a problem, as when we go to generate the responses the next time, we will lose these changes, right?

We have been discussing internally with @seratch about possibly combining the response type generation together with manual curation / integration with manually-crafted types in order to improve the experience (probably best shown off in @seratch's personal Slack client project's type generation here: for certain responses containing Block Kit elements, the generated types "link" up the correct, manually-curated Block types to the responses).

If anything, I would like for us to use a similar approach to solve this issue: let the quicktype-based automation do its things to automatically generate baseline, but sub-optimal, types, and augment them with targeted, manually-written types in (at least at the beginning) a few specific areas that provide the best developer experience value. Something like this example I put together in a TypeScript Playground.

What do y'all think?

@seratch
Copy link
Member

seratch commented Jun 17, 2024

Specifically talking about this PR (rather than general discussion about the future), if @davidlj95 just didn't include other unrelated changes, that's fine. When we run the generator script, other changes won't conflict with this PR. I understand @davidlj95 might hesitate to include other changes.

If @davidlj95 made some manual changes to the generated outputs, those changes will be overwritten when any of us executes the script next time (as @filmaj mentioned).

Either way, the generator script should generate code in an idempotent manner (as long as the JSON source files remain the same). Therefore, I'd suggest either:

  1. Including other changes in this PR
  2. @filmaj running the generator script on behalf of @davidlj95

As for the option 2, I can run the generator tomorrow too (if others don't have time in North American timezone today).

@filmaj
Copy link
Contributor

filmaj commented Jun 17, 2024

I regenerated the latest response types in the branch migration-exchange-as-map-regenerated, which branched off of this PR. It didn't seem to modify the response payload 🤔 so maybe the file as-is here was not manually tweaked / it is fine?

@davidlj95
Copy link
Contributor Author

Specifically talking about this PR (rather than general discussion about the future), if @davidlj95 just didn't include other unrelated changes, that's fine. When we run the generator script, other changes won't conflict with this PR. I understand @davidlj95 might hesitate to include other changes.

hehe yup, don't want so much responsibility over me 😛

If @davidlj95 made some manual changes to the generated outputs, those changes will be overwritten when any of us executes the script next time (as @filmaj mentioned).

I didn't! I just discarded changes out of scope. But the change in this PR has been autogenerated by current script as @filmaj found out below (sorry was out for a bit and didn't get in time!)

Either way, the generator script should generate code in an idempotent manner (as long as the JSON source files remain the same). Therefore, I'd suggest either:

  1. Including other changes in this PR
  2. @filmaj running the generator script on behalf of @davidlj95

As for the option 2, I can run the generator tomorrow too (if others don't have time in North American timezone today).

I'd lean into option 2, we can close this if you want :) Just wanted to close the issue but there's no rush so happy for the issue to be fixed in next type update run

Thanks folks :)

Copy link
Contributor

@filmaj filmaj left a comment

Choose a reason for hiding this comment

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

Thanks for confirming you didn't make any manual changes to the changed file in this PR! That tells me the generation script output for MigrationExchangeResponse.ts is correct and idempotent, so I will merge this PR.

Thanks you for the contribution! 🙇

@filmaj filmaj added this to the [email protected] milestone Jun 17, 2024
@filmaj filmaj merged commit 20f026b into slackapi:main Jun 17, 2024
21 checks passed
@davidlj95 davidlj95 deleted the migration-exchange-as-map branch June 17, 2024 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type generation creates UseridMap as an interface when it is a Map/Record/object
3 participants