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: add gen2 path parameter to getProperties and getUrl #13144

Merged

Conversation

erinleigh90
Copy link
Contributor

@erinleigh90 erinleigh90 commented Mar 18, 2024

Description of changes

Adds support for gen2 path to getUrl and getProperties API's.

Issue #, if available

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@erinleigh90 erinleigh90 changed the title Gen2 get url get properties feat: add gen2 path parameter to getProperties and getUrl Mar 19, 2024
@erinleigh90 erinleigh90 changed the base branch from main to gen2-storage March 19, 2024 16:41
@erinleigh90 erinleigh90 marked this pull request as ready for review March 19, 2024 23:03
@erinleigh90 erinleigh90 requested review from a team as code owners March 19, 2024 23:03
ashika112
ashika112 previously approved these changes Mar 22, 2024
@ashika112
Copy link
Member

Amazing work 🎉

Co-authored-by: ashika112 <155593080+ashika112@users.noreply.github.com>
packages/storage/src/providers/s3/apis/getProperties.ts Outdated Show resolved Hide resolved
options,
);
if (getUrlOptions?.validateObjectExistence) {
await getProperties(
Copy link
Member

Choose a reason for hiding this comment

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

I know this is existing code, but is the idea here that this will throw if there is no such object? Like why call it and not use it's response?

Copy link
Contributor Author

@erinleigh90 erinleigh90 Mar 25, 2024

Choose a reason for hiding this comment

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

Yes, that is the idea. Validated that it is working as expected, throwing an error if there is no such object

/**
* Output type for S3 getProperties API.
*/
export type GetPropertiesOutput = ItemKey;
export type GetPropertiesOutput =
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a StrictUnion here?

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm. StrictUnion on output types may not needed. Strict union is need mostly for DX validation. Output will have that through Overload that should be enough.

Copy link
Member

Choose a reason for hiding this comment

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

nit question, Is this scenario possible
I think without StrictUnion, sometimes properties of key could be allowed in path. In case the internal getProperties API using this GetPropertiesOutput type by mistakes appends a keyProperty to both key and path would this be able to catch it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should be returning what we need for each scenario. Can validate in a unit test that we are not returning both in any scenario, but I don't see how the key could simply slip through in an if/else scenario.

packages/storage/src/providers/s3/apis/getUrl.ts Outdated Show resolved Hide resolved
packages/storage/src/providers/s3/apis/getProperties.ts Outdated Show resolved Hide resolved
packages/storage/src/providers/s3/apis/getProperties.ts Outdated Show resolved Hide resolved
packages/storage/src/providers/s3/types/inputs.ts Outdated Show resolved Hide resolved
packages/storage/src/providers/s3/types/options.ts Outdated Show resolved Hide resolved
/**
* Output type for S3 getProperties API.
*/
export type GetPropertiesOutput = ItemKey;
export type GetPropertiesOutput =
Copy link
Member

Choose a reason for hiding this comment

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

nit question, Is this scenario possible
I think without StrictUnion, sometimes properties of key could be allowed in path. In case the internal getProperties API using this GetPropertiesOutput type by mistakes appends a keyProperty to both key and path would this be able to catch it

Copy link
Contributor

@jimblanc jimblanc left a comment

Choose a reason for hiding this comment

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

Looking good! Few questions & nits

@erinleigh90 erinleigh90 merged commit 6456588 into aws-amplify:gen2-storage Mar 25, 2024
28 checks passed
@erinleigh90 erinleigh90 deleted the gen2-getUrl-getProperties branch March 25, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants