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(core): update storage outputs class for multi-bucket support #5476

Open
wants to merge 10 commits into
base: multi-bucket
Choose a base branch
from

Conversation

ekjotmultani
Copy link

added the list names buckets in storage_outputs.dart, built the new generator file for it, and updated the test to match the expected json output as described in the api review doc

@ekjotmultani ekjotmultani requested a review from a team as a code owner September 17, 2024 17:41
@@ -23,6 +23,9 @@ class StorageOutputs
/// The Amazon S3 bucket name.
final String bucketName;

/// The list of buckets if there are multiple buckets for the project
final List<Map<String,String>>? buckets;
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to define a class Bucket and use it instead of Map.

/// {@template amplify_core.amplify_outputs.amazon_pinpoint_channel}
/// Supported channels for Amazon Pinpoint.
/// {@endtemplate}
class StorageOutputBucket {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class StorageOutputBucket {
class BucketOutputs {

Comment on lines 11 to 16
factory StorageOutputBucket.fromJson(Map<String, dynamic> json) => StorageOutputBucket(json['name'].toString(), json['bucket_name'].toString(), json['aws_region'].toString());
String name;
String bucketName;
String awsRegion;
Map<String, dynamic> toJson() => <String, dynamic>{'name':name, 'bucket_name':bucketName, 'aws_region':awsRegion};
}
Copy link
Member

Choose a reason for hiding this comment

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

instead of wrting the fromJson and toJson use generated code similar to other Amplify Outputs types.

Copy link
Author

Choose a reason for hiding this comment

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

if these functions are not written into the class no code gets generated and an error is thrown because the generator does not know how to serialize and deserialize this object

/// Supported channels for Amazon Pinpoint.
/// {@endtemplate}
class StorageOutputBucket {
StorageOutputBucket(this.name, this.bucketName, this.awsRegion);
Copy link
Member

Choose a reason for hiding this comment

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

the ctor can be const. I would suggest to use named parameter similat to other Amplify Outputs type

Copy link
Author

Choose a reason for hiding this comment

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

I dont know how this got changed, I think I clicked a vscode 'optimization' by mistake, I will change this back right now

part 'bucket_output.g.dart';

@zAmplifyOutputsSerializable
class BucketOutput
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class BucketOutput
class BucketOutputs

Copy link
Member

Choose a reason for hiding this comment

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

@NikaHsn NikaHsn changed the title updating storage_outputs class for multi-bucket support feat(core): update storage outputs class for multi-bucket support Sep 18, 2024
Copy link
Member

Choose a reason for hiding this comment

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

Question: I see the test data has been updated, but are the tests written in a way that validate the new functionality too? Do they need to be updated?

Copy link
Author

@ekjotmultani ekjotmultani Sep 19, 2024

Choose a reason for hiding this comment

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

This is a good question, since multiple buckets are optional, I think we should validate that it works when only one bucket is supplied too. I'll check this out

Copy link
Author

Choose a reason for hiding this comment

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

I've verified that the test does work properly when only a single bucket is supplied and that the test itself actually validates the new function for multi-bucket support

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.

3 participants