Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Fix: improve GetFilesResponse interface#2466

Merged
ddelgrosso1 merged 5 commits into
googleapis:mainfrom
olishevskii:dev
May 14, 2024
Merged

Fix: improve GetFilesResponse interface#2466
ddelgrosso1 merged 5 commits into
googleapis:mainfrom
olishevskii:dev

Conversation

@olishevskii

@olishevskii olishevskii commented May 12, 2024

Copy link
Copy Markdown
Contributor

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 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
Copy Markdown
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

olishevskii commented May 13, 2024

Copy link
Copy Markdown
Contributor Author

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 : {};

Comment thread src/bucket.ts Outdated
}

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

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.

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

@olishevskii olishevskii May 14, 2024

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 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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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