-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(storage): internal GetProperties API #13869
feat(storage): internal GetProperties API #13869
Conversation
…Is and add it to separate internal API; Internal getProperties implementation
packages/storage/src/providers/s3/apis/internal/getProperties.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Jim Blanchard <[email protected]>
3239e6b
to
0c367c0
Compare
5814597
to
7860519
Compare
packages/storage/__tests__/internals/apis/getProperties.test.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Jim Blanchard <[email protected]>
path: InputType['path']; | ||
options?: PublicInputOptionsType & ExtendedOptionsType; | ||
} | ||
: InputType extends StorageCopyInputWithPath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It always falls back to check this Copy Input type StorageCopyInputWithPath
? Isn't this type ExtendInputWithAdvancedOptions
a generic one used for multiple APIs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah copy API signature is different any other Storage APIs. That's why I check the copy input interface explicitly. Here copy is the only API that does not extend from StorageOperationInputWithPath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we split the copy logic out and explicitly define it when it comes to copy? Will make the whole thing read much simpler IMO
jest.mock('../../../src/providers/s3/apis/internal/getProperties'); | ||
const mockedGetPropertiesInternal = jest.mocked(getPropertiesInternal); | ||
|
||
describe('getProperties (internal)', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is getting confusing 😅
@@ -44,7 +58,7 @@ const storageBucketAssertion = ( | |||
|
|||
export const copy = async ( | |||
amplify: AmplifyClassV6, | |||
input: CopyInput | CopyWithPathInput, | |||
input: CopyInput | InputWithPathAndAdvancedOptions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not CopyWithPathInputAndAdvancedOptions
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for other places as well.
/** | ||
* @internal | ||
*/ | ||
export type GetPropertiesInput = ExtendInputWithAdvancedOptions< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im confused here. Why are we creating this and not using this type? but rather have a duplicate again here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, we should keep types as simple as we can, and avoid type programming as much as we can 😅 when we deprecating the key
use cases, it should just simple splitting and deleting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashika112 I think I was debating all the different conventions, GetPropertiesInput
name cannot be referred as-is in the other places. I can change to use this definition everywhere.
path: InputType['path']; | ||
options?: PublicInputOptionsType & ExtendedOptionsType; | ||
} | ||
: InputType extends StorageCopyInputWithPath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we split the copy logic out and explicitly define it when it comes to copy? Will make the whole thing read much simpler IMO
InputType extends StorageOperationInputWithPath & | ||
StorageOperationOptionsInput<infer PublicInputOptionsType> | ||
? { | ||
path: InputType['path']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about key? Not supporting it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we only support Gen2 signature with extended option.
packages/storage/__tests__/internals/apis/getProperties.test.ts
Outdated
Show resolved
Hide resolved
packages/storage/__tests__/internals/apis/getProperties.test.ts
Outdated
Show resolved
Hide resolved
/** | ||
* @internal | ||
*/ | ||
export type GetPropertiesInput = ExtendInputWithAdvancedOptions< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, we should keep types as simple as we can, and avoid type programming as much as we can 😅 when we deprecating the key
use cases, it should just simple splitting and deleting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -21,6 +25,16 @@ import { assertValidationError } from '../../../../errors/utils/assertValidation | |||
import { copyObject } from '../../utils/client/s3data'; | |||
import { getStorageUserAgentValue } from '../../utils/userAgent'; | |||
import { logger } from '../../../../utils'; | |||
// TODO: Remove this interface when we move to public advanced APIs. | |||
import { ExtendInputWithAdvancedOptions } from '../../../../internals/types/inputs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx love these TODO items
export function getProperties( | ||
input: GetPropertiesInput, | ||
): Promise<GetPropertiesOutput> { | ||
return getPropertiesInternal(Amplify, { | ||
path: input.path, | ||
options: { | ||
useAccelerateEndpoint: input?.options?.useAccelerateEndpoint, | ||
bucket: input?.options?.bucket, | ||
locationCredentialsProvider: input?.options?.locationCredentialsProvider, | ||
}, | ||
// Type casting is necessary because `getPropertiesInternal` supports both Gen1 and Gen2 signatures, but here | ||
// given in input can only be Gen2 signature, the return can only ben Gen2 signature. | ||
}) as Promise<GetPropertiesOutput>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit,
export function getProperties( | |
input: GetPropertiesInput, | |
): Promise<GetPropertiesOutput> { | |
return getPropertiesInternal(Amplify, { | |
path: input.path, | |
options: { | |
useAccelerateEndpoint: input?.options?.useAccelerateEndpoint, | |
bucket: input?.options?.bucket, | |
locationCredentialsProvider: input?.options?.locationCredentialsProvider, | |
}, | |
// Type casting is necessary because `getPropertiesInternal` supports both Gen1 and Gen2 signatures, but here | |
// given in input can only be Gen2 signature, the return can only ben Gen2 signature. | |
}) as Promise<GetPropertiesOutput>; | |
} | |
export const getProperties = ( | |
input: GetPropertiesInput | |
): Promise<GetPropertiesOutput> => | |
getPropertiesInternal(Amplify, { | |
path: input.path, | |
options: { | |
useAccelerateEndpoint: input?.options?.useAccelerateEndpoint, | |
bucket: input?.options?.bucket, | |
locationCredentialsProvider: input?.options?.locationCredentialsProvider, | |
}, | |
// Type casting is necessary because `getPropertiesInternal` supports both Gen1 and Gen2 signatures, but here | |
// given in input can only be Gen2 signature, the return can only ben Gen2 signature. | |
}) as Promise<GetPropertiesOutput>; |
287d0e5
into
aws-amplify:storage-browser/integrity
Description of changes
Following changes are made as part of this PR:
locationCredentialsProvider
option from the public API input options' common interface:getProperties
API exported from@aws-amplify/storage/internals
path that containslocationCredentialsProvider
option. The resolving logic is unchanged.Issue #, if available
Description of how you validated changes
Checklist
yarn test
passesChecklist for repo maintainers
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.