-
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
refactor(storage): add foundation deleteObject client #13795
refactor(storage): add foundation deleteObject client #13795
Conversation
f60b1fb
to
328f0b2
Compare
packages/storage/src/foundation/factories/serviceClients/s3/data/createDeleteObjectClient.ts
Outdated
Show resolved
Hide resolved
packages/storage/src/foundation/factories/serviceClients/s3/data/types/Sdk.ts
Outdated
Show resolved
Hide resolved
packages/storage/src/foundation/factories/serviceClients/s3/data/base.ts
Outdated
Show resolved
Hide resolved
packages/storage/src/foundation/factories/serviceClients/s3/data/createDeleteObjectClient.ts
Outdated
Show resolved
Hide resolved
packages/storage/src/foundation/factories/serviceClients/s3/data/base.ts
Outdated
Show resolved
Hide resolved
packages/storage/src/foundation/factories/serviceClients/s3/utils/index.ts
Outdated
Show resolved
Hide resolved
packages/storage/src/foundation/factories/serviceClients/s3/utils/parsePayload.ts
Outdated
Show resolved
Hide resolved
.../storage/src/foundation/factories/serviceClients/s3/utils/runtime/s3TransferHandler/fetch.ts
Outdated
Show resolved
Hide resolved
packages/storage/src/foundation/factories/serviceClients/s3/utils/runtime/xmlParser/dom.ts
Outdated
Show resolved
Hide resolved
edddbba
to
024857b
Compare
packages/storage/src/foundation/factories/serviceClients/s3/serializeHelpers.ts
Outdated
Show resolved
Hide resolved
packages/storage/src/foundation/factories/serviceClients/s3/deserializeHelpers.ts
Outdated
Show resolved
Hide resolved
High level looks good to me. |
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.
The folder structure under factories/serviceClient
should better be this IMO:
factories/serviceClient
|_shared
|_deserialization
|_serialization
|_parsePayload.ts // this can be moved into deserialization as well
|_retryDecider.ts
|_index.ts
|_s3data
|_constants.ts
|_createDeleteObjectClient.ts
|_index.ts
|_validators
|_isDnsCompatibleBucketName.ts
Let me what you think! @ashwinkumar6 @cshfang @HuiSF
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.
|_deserialization
|_serialization
We are using serde
else where :D
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.
Updated to
foundation
├── constants.ts
└── factories
└── serviceClients
├── index.ts
├── s3data
│ ├── constants.ts
│ ├── createDeleteObjectClient.ts
│ ├── endpointResolver.ts
│ ├── index.ts
│ ├── shared
│ │ └── serde
│ │ ├── CreateDeleteObjectDeserializer.ts
│ │ ├── CreateDeleteObjectSerializer.ts
│ │ └── index.ts
│ ├── types
│ │ ├── index.ts
│ │ ├── sdk.ts
│ │ └── serviceClient.ts
│ └── validators
│ └── isDnsCompatibleBucketName.ts
└── shared
├── retryDecider.ts
└── serde
├── deserializeBoolean.ts
├── deserializeMetadata.ts
├── serializeObjectConfigsToHeaders.ts
├── serializePathnameObjectKey.ts......
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 are the things inside s3data/shared shared between? From the way it looks right now, the two functions don't look share-able?
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.
Tied to keep it similar to auth so it's easy to find clients/serde
across packages.
But i see your point we can always add shared/serde
if needed in future. updated
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.
After further discussion, every client has it's own specific serializer deserializer so we can create a folder for each client in this manner
s3data/deleteObject
|--createClient.ts
|--createDeserializer.ts
|--createSerializer.ts
dir structure
foundation
└── factories
└── serviceClients
├── index.ts
├── s3data
│ ├── constants.ts
│ ├── deleteObject
│ │ ├── createClient.ts
│ │ ├── createDeserializer.ts
│ │ └── createSerializer.ts
│ ├── endpointResolver.ts
│ ├── index.ts
│ ├── types
│ │ ├── index.ts
│ │ ├── sdk.ts
│ │ └── serviceClient.ts
│ └── validators
│ └── isDnsCompatibleBucketName.ts
└── shared
├── retryDecider.ts
└── serde
├── deserializeMetadata.ts
├── deserializeNumber.ts
├── serializeObjectConfigsToHeaders.ts
├── serializePathnameObjectKey.ts
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.
Questions for me here:
- having
shared/serde
makes it read like its all serializer or deserializer. Rather since these are utils for serde should we put it asshared/utils/serde
orshared/serdeUtils
?
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.
Updated to foundation/factories/serviceClients/shared/serde
-> foundation/factories/serviceClients/shared/serdeUtils
latest dir structure cc @ashika112 @cshfang @HuiSF @AllanZhengYP
foundation
├── constants.ts
└── factories
└── serviceClients
├── index.ts
├── s3data
│ ├── constants.ts
│ ├── deleteObject
│ │ ├── createDeleteObjectClient.ts
│ │ ├── createDeleteObjectDeserializer.ts
│ │ └── createDeleteObjectSerializer.ts
│ ├── endpointResolver.ts
│ ├── index.ts
│ ├── types
│ │ ├── index.ts
│ │ ├── sdk.ts
│ │ └── serviceClient.ts
│ └── validators
│ └── isDnsCompatibleBucketName.ts
└── shared
├── retryDecider.ts
└── serdeUtils
├── deserializeBoolean.ts
├── deserializeMetadata.ts
├── serializeObjectConfigsToHeaders.ts
├── serializePathnameObjectKey.ts
packages/storage/src/foundation/factories/serviceClients/s3/s3data/types/index.ts
Outdated
Show resolved
Hide resolved
...rc/foundation/factories/serviceClients/s3data/shared/serde/CreateDeleteObjectDeserializer.ts
Outdated
Show resolved
Hide resolved
packages/storage/src/foundation/factories/serviceClients/shared/serde/deserializeBoolean.ts
Outdated
Show resolved
Hide resolved
packages/storage/src/foundation/factories/serviceClients/shared/serde/deserializeTimestamp.ts
Outdated
Show resolved
Hide resolved
deserializer: (value: any[]) => T, | ||
): T => { | ||
if (value === '') { | ||
return [] as any as T; |
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.
return [] as any as T; | |
return [] as unknown as T; |
Is this double casting really needed? as []
should conform to any[]
?
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.
Updated to return [] as unknown as T;
Looks like double casting is needed [] as T
gives error:
'never[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'any[]'
|
||
import { StorageError } from '../../../../../errors/StorageError'; | ||
|
||
export function validateS3RequiredParameter( |
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.
Does this belong in serde
?
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.
Proposal comment to rename serde
to serdeUtils
since technically all of these are just utils/helpers not serde in itself.
With that in mind validateS3RequiredParameter is used by createDeleteObjectSerializer
packages/storage/src/foundation/factories/serviceClients/shared/serde/index.ts
Outdated
Show resolved
Hide resolved
packages/storage/src/foundation/dI/runtime/base64/index.native.ts
Outdated
Show resolved
Hide resolved
30e5484
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 should me moved to the validators/
folder
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.
Sounds good, will address this on the next PR
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.
Looks good to me. I only had 1 non-blocking comment. feel free address it in follow PRs?
4e164ab
into
aws-amplify:storage-browser/foundation
Description of changes
Testing
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.