Skip to content

Commit

Permalink
chore: remove unused types and constructors, use consistent naming (#…
Browse files Browse the repository at this point in the history
…4603)

* chore: remove unused types and properties

* fix: set path of S3Item in download file

* chore: use consistent naming when resolving path

* chore: update path resolution in tests

* fix: update where leading `/` is added for getUrl
  • Loading branch information
Jordan-Nelson authored Mar 27, 2024
1 parent 4f65c69 commit f284d55
Show file tree
Hide file tree
Showing 34 changed files with 55 additions and 454 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ abstract class StorageOperation<Request, Result> {
required this.result,
}) : operationId = uuid();

// TODO(Jordan-Nelson): determine if this should be private.
@internal
final Request request;
final String operationId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@ class StorageDownloadDataOptions extends StorageOperationOptions
AWSDebuggable {
/// {@macro amplify_core.storage.download_data_options}
const StorageDownloadDataOptions({
super.accessLevel,
this.pluginOptions,
});

/// {@macro amplify_core.storage.download_data_plugin_options}
final StorageDownloadDataPluginOptions? pluginOptions;

@override
List<Object?> get props => [accessLevel, pluginOptions];
List<Object?> get props => [pluginOptions];

@override
String get runtimeTypeName => 'StorageDownloadDataOptions';

@override
Map<String, Object?> toJson() => {
'accessLevel': accessLevel?.name,
'pluginOptions': pluginOptions?.toJson(),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@ class StorageGetPropertiesOptions extends StorageOperationOptions
AWSDebuggable {
/// {@macro amplify_core.storage.get_properties_options}
const StorageGetPropertiesOptions({
super.accessLevel,
this.pluginOptions,
});

/// {@macro amplify_core.storage.download_get_properties_plugin_options}
final StorageGetPropertiesPluginOptions? pluginOptions;

@override
List<Object?> get props => [accessLevel, pluginOptions];
List<Object?> get props => [pluginOptions];

@override
String get runtimeTypeName => 'StorageGetPropertiesOptions';

@override
Map<String, Object?> toJson() => {
'accessLevel': accessLevel?.name,
'pluginOptions': pluginOptions?.toJson(),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class StorageGetPropertiesRequest {
this.options,
});

// Path of the object to get properties of.
final StoragePath path;

/// Configurable options of the [StorageGetPropertiesRequest].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ class StorageGetUrlOptions extends StorageOperationOptions
final StorageGetUrlPluginOptions? pluginOptions;

@override
List<Object?> get props => [accessLevel, pluginOptions];
List<Object?> get props => [pluginOptions];

@override
String get runtimeTypeName => 'StorageGetUrlOptions';

@override
Map<String, Object?> toJson() => {
'accessLevel': accessLevel?.name,
'pluginOptions': pluginOptions?.toJson(),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import 'package:amplify_core/amplify_core.dart';
class StorageGetUrlRequest {
/// {@macro amplify_core.storage.get_url_request}
const StorageGetUrlRequest({
this.path,
required this.path,
this.options,
});

final StoragePath? path;
// Path of the object to get the URL of.
final StoragePath path;

/// Configurable options of the [StorageGetUrlRequest].
final StorageGetUrlOptions? options;
Expand Down
18 changes: 0 additions & 18 deletions packages/amplify_core/lib/src/types/storage/move_operation.dart

This file was deleted.

42 changes: 0 additions & 42 deletions packages/amplify_core/lib/src/types/storage/move_options.dart

This file was deleted.

25 changes: 0 additions & 25 deletions packages/amplify_core/lib/src/types/storage/move_request.dart

This file was deleted.

17 changes: 0 additions & 17 deletions packages/amplify_core/lib/src/types/storage/move_result.dart

This file was deleted.

16 changes: 0 additions & 16 deletions packages/amplify_core/lib/src/types/storage/storage_item.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import 'package:amplify_core/src/types/storage/access_level.dart';

/// {@template amplify_core.storage.storage_item}
/// Presents a storage object.
/// {@endtemplate}
Expand All @@ -26,17 +24,3 @@ class StorageItem {
final String? eTag;
final Map<String, String> metadata;
}

/// {@template amplify_core.storage.storage_item_access_level}
/// Presents a storage object with its access level information.
/// {@endtemplate}
class StorageItemWithAccessLevel<Item extends StorageItem> {
/// {@macro amplify_core.storage.storage_item_access_level}
const StorageItemWithAccessLevel({
required this.storageItem,
required this.accessLevel,
});

final Item storageItem;
final StorageAccessLevel accessLevel;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export 'list_operation.dart';
export 'list_options.dart';
export 'list_request.dart';
export 'list_result.dart';
export 'move_operation.dart';
export 'move_options.dart';
export 'move_request.dart';
export 'move_result.dart';
export 'remove_many_operation.dart';
export 'remove_many_options.dart';
export 'remove_many_request.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import 'package:amplify_core/amplify_core.dart';
class StorageUploadDataRequest {
/// {@macro amplify_core.storage.upload_data_request}
const StorageUploadDataRequest({
required this.path,
required this.data,
this.options,
});

/// Path to upload the data to.
final StoragePath path;

/// The data payload to upload.
final StorageDataPayload data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import 'package:amplify_core/amplify_core.dart';
class StorageUploadFileRequest {
/// {@macro amplify_core.storage.upload_file_request}
const StorageUploadFileRequest({
required this.path,
required this.localFile,
this.options,
});

/// Path to upload the file to.
final StoragePath path;

/// The local file to upload.
final AWSFile localFile;

Expand Down
14 changes: 2 additions & 12 deletions packages/storage/amplify_storage_s3_dart/example/bin/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,10 @@ Future<void> listOperation() async {

Future<void> getPropertiesOperation() async {
final key = prompt('Enter the object to get properties for: ');
final accessLevel = promptStorageAccessLevel(
'Choose the storage access level associated with the object: ',
);

final s3Plugin = Amplify.Storage.getPlugin(AmplifyStorageS3Dart.pluginKey);
final getPropertiesOperation = s3Plugin.getProperties(
path: StoragePath.fromString(key),
options: StorageGetPropertiesOptions(
accessLevel: accessLevel,
),
);
final result = await getPropertiesOperation.result;

Expand Down Expand Up @@ -201,16 +195,12 @@ Future<void> getUrlOperation() async {

Future<void> downloadDataOperation() async {
final key = prompt('Enter the key of the object to download: ');
final accessLevel = promptStorageAccessLevel(
'Choose the storage access level associated with the object: ',
);

final s3Plugin = Amplify.Storage.getPlugin(AmplifyStorageS3Dart.pluginKey);
final downloadDataOperation = s3Plugin.downloadData(
path: StoragePath.fromString(key),
options: StorageDownloadDataOptions(
accessLevel: accessLevel,
pluginOptions: const S3DownloadDataPluginOptions(
options: const StorageDownloadDataOptions(
pluginOptions: S3DownloadDataPluginOptions(
getProperties: true,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ class AmplifyStorageS3Dart extends StoragePluginInterface
);

final s3Options = StorageGetPropertiesOptions(
accessLevel: options?.accessLevel,
pluginOptions: s3PluginOptions,
);

Expand Down Expand Up @@ -311,6 +310,7 @@ class AmplifyStorageS3Dart extends StoragePluginInterface

return S3UploadDataOperation(
request: StorageUploadDataRequest(
path: path,
data: data,
options: options,
),
Expand Down Expand Up @@ -347,6 +347,7 @@ class AmplifyStorageS3Dart extends StoragePluginInterface

return S3UploadFileOperation(
request: StorageUploadFileRequest(
path: path,
localFile: localFile,
options: options,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ class S3DownloadDataOptions extends StorageDownloadDataOptions {
'use StorageDownloadDataOptions(pluginOptions:S3DownloadDataPluginOptions(...)) instead.',
)
const S3DownloadDataOptions({
StorageAccessLevel accessLevel = StorageAccessLevel.guest,
bool getProperties = false,
S3DataBytesRange? bytesRange,
bool useAccelerateEndpoint = false,
}) : this._(
accessLevel: accessLevel,
bytesRange: bytesRange,
getProperties: getProperties,
useAccelerateEndpoint: useAccelerateEndpoint,
Expand All @@ -30,7 +28,6 @@ class S3DownloadDataOptions extends StorageDownloadDataOptions {
'use StorageDownloadDataOptions(pluginOptions:S3DownloadDataPluginOptions(...)) instead.',
)
const S3DownloadDataOptions._({
super.accessLevel = StorageAccessLevel.guest,
this.getProperties = false,
this.bytesRange,
this.useAccelerateEndpoint = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,10 @@ class S3GetPropertiesOptions extends StorageGetPropertiesOptions {
@Deprecated(
'use StorageGetPropertiesOptions(pluginOptions: S3GetPropertiesPluginOptions(...)) instead.',
)
const S3GetPropertiesOptions({
StorageAccessLevel accessLevel = StorageAccessLevel.guest,
}) : this._(
accessLevel: accessLevel,
);
const S3GetPropertiesOptions() : this._();

@Deprecated(
'use StorageGetPropertiesOptions(pluginOptions: S3GetPropertiesPluginOptions(...)) instead.',
)
const S3GetPropertiesOptions._({
super.accessLevel = StorageAccessLevel.guest,
this.targetIdentityId,
});

/// {@macro storage.amplify_storage_s3.get_properties_options}
///
/// Use this when calling `getProperties` on an object that belongs to other
/// user (identified by [targetIdentityId]) rather than the currently signed
/// user.
@Deprecated(
'use StorageGetPropertiesOptions(pluginOptions: S3GetPropertiesPluginOptions.forIdentity(...)) instead.',
)
const S3GetPropertiesOptions.forIdentity(
String targetIdentityId,
) : this._(
accessLevel: StorageAccessLevel.protected,
targetIdentityId: targetIdentityId,
);

/// The identity ID of another user who uploaded the object.
///
/// This can be set by using [S3GetPropertiesOptions.forIdentity].
final String? targetIdentityId;
const S3GetPropertiesOptions._();
}
Loading

0 comments on commit f284d55

Please sign in to comment.