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

Fix: improve GetFilesResponse interface #2466

Merged
merged 5 commits into from
May 14, 2024
Merged

Conversation

olishevskii
Copy link
Contributor

@olishevskii olishevskii commented May 12, 2024

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #2464 🦕

@olishevskii olishevskii requested review from a team as code owners May 12, 2024 20:04
@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. api: storage Issues related to the googleapis/nodejs-storage API. labels May 12, 2024
@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label May 13, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 13, 2024
@ddelgrosso1 ddelgrosso1 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 13, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 13, 2024
@ddelgrosso1
Copy link
Contributor

Hi @olishevskii thank you for opening a PR and trying to clean this up.

If you take a look at

nextQuery = Object.assign({}, query, {
you will see that what is actually being returned is a cross between GetFilesOptions & {pageToken?: string}. This PR omits the GetFilesOptions portion.

I'm also not sure we want to define a new interface that will need to be exported just to hold the page token portion.

@olishevskii
Copy link
Contributor Author

olishevskii commented May 13, 2024

Hi @ddelgrosso1.

I see your point of view regarding defining a new interface NextPageFilesOptions. I've rewritten my solution using TypeScript utilities. Additionally, I noticed that a query can be not only like GetFilesOptions but also like GetFilesCallback.

nodejs-storage/src/bucket.ts

Lines 2798 to 2802 in b4dbd73

getFiles(
queryOrCallback?: GetFilesOptions | GetFilesCallback,
callback?: GetFilesCallback
): void | Promise<GetFilesResponse> {
let query = typeof queryOrCallback === 'object' ? queryOrCallback : {};

src/bucket.ts Outdated
@@ -87,7 +87,7 @@ interface MetadataOptions {
ifMetagenerationNotMatch?: number | string;
}

export type GetFilesResponse = [File[], {}, unknown];
export type GetFilesResponse = [File[], (GetFilesOptions | GetFilesCallback) & Partial<Pick<GetFilesOptions, 'pageToken'>>, unknown];
Copy link
Contributor

Choose a reason for hiding this comment

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

You can omit GetFilesCallback, query can only be GetFilesOptions or an empty object. It will never get assigned the callback.

Copy link
Contributor Author

@olishevskii olishevskii May 14, 2024

Choose a reason for hiding this comment

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

I have fixed it.

@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label May 14, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 14, 2024
@ddelgrosso1 ddelgrosso1 added kokoro:force-run Add this label to force Kokoro to re-run the tests. labels May 14, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing interface's property
3 participants