Skip to content

Commit

Permalink
fix: Updating init parameters to some StorageBucket for autocompletion (
Browse files Browse the repository at this point in the history
  • Loading branch information
ruisebas committed Sep 17, 2024
1 parent d1cdacd commit 6bf07cf
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,30 @@ public extension StorageDownloadDataRequest {

///
/// - Tag: StorageDownloadDataRequestOptions.init
@available(*, deprecated, message: "Use init(bucket:pluginOptions)")
@available(*, deprecated, message: "Use init(pluginOptions)")
public init(
accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
bucket: (any StorageBucket)? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.targetIdentityId = targetIdentityId
self.bucket = bucket
self.bucket = nil
self.pluginOptions = pluginOptions
}

///
/// - Tag: StorageDownloadDataRequestOptions.init
public init(pluginOptions: Any? = nil) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.bucket = nil
self.pluginOptions = pluginOptions
}

/// - Tag: StorageDownloadDataRequestOptions.init
public init(
bucket: (any StorageBucket)? = nil,
bucket: some StorageBucket,
pluginOptions: Any? = nil
) {
self.accessLevel = .guest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,29 @@ public extension StorageDownloadFileRequest {
public let pluginOptions: Any?

/// - Tag: StorageDownloadFileRequestOptions.init
@available(*, deprecated, message: "Use init(bucket:pluginOptions)")
@available(*, deprecated, message: "Use init(pluginOptions)")
public init(
accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
bucket: (any StorageBucket)? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.targetIdentityId = targetIdentityId
self.bucket = bucket
self.bucket = nil
self.pluginOptions = pluginOptions
}

/// - Tag: StorageDownloadFileRequestOptions.init
public init(pluginOptions: Any? = nil) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.bucket = nil
self.pluginOptions = pluginOptions
}

/// - Tag: StorageDownloadFileRequestOptions.init
public init(
bucket: (any StorageBucket)? = nil,
bucket: some StorageBucket,
pluginOptions: Any? = nil
) {
self.accessLevel = .guest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,36 @@ public extension StorageGetURLRequest {
public let pluginOptions: Any?

/// - Tag: StorageGetURLRequest.Options.init
@available(*, deprecated, message: "Use init(expires:bucket:pluginOptions)")
@available(*, deprecated, message: "Use init(expires:pluginOptions)")
public init(
accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
expires: Int = Options.defaultExpireInSeconds,
bucket: (any StorageBucket)? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.targetIdentityId = targetIdentityId
self.expires = expires
self.bucket = bucket
self.bucket = nil
self.pluginOptions = pluginOptions
}

/// - Tag: StorageGetURLRequest.Options.init
public init(
expires: Int = Options.defaultExpireInSeconds,
pluginOptions: Any? = nil
) {
self.expires = expires
self.bucket = nil
self.pluginOptions = pluginOptions
self.accessLevel = .guest
self.targetIdentityId = nil
}

/// - Tag: StorageGetURLRequest.Options.init
public init(
expires: Int = Options.defaultExpireInSeconds,
bucket: (any StorageBucket)? = nil,
bucket: some StorageBucket,
pluginOptions: Any? = nil
) {
self.expires = expires
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public extension StorageListRequest {
path: String? = nil,
subpathStrategy: SubpathStrategy = .include,
pageSize: UInt = 1000,
bucket: (any StorageBucket)? = nil,
nextToken: String? = nil,
pluginOptions: Any? = nil
) {
Expand All @@ -116,6 +115,24 @@ public extension StorageListRequest {
self.path = path
self.subpathStrategy = subpathStrategy
self.pageSize = pageSize
self.bucket = nil
self.nextToken = nextToken
self.pluginOptions = pluginOptions
}

/// - Tag: StorageListRequestOptions.init
public init(
subpathStrategy: SubpathStrategy = .include,
pageSize: UInt = 1000,
bucket: some StorageBucket,
nextToken: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.path = nil
self.subpathStrategy = subpathStrategy
self.pageSize = pageSize
self.bucket = bucket
self.nextToken = nextToken
self.pluginOptions = pluginOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,19 @@ public extension StorageRemoveRequest {
/// - Tag: StorageRemoveRequestOptions.init
public init(
accessLevel: StorageAccessLevel = .guest,
bucket: (any StorageBucket)? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.bucket = nil
self.pluginOptions = pluginOptions
}

/// - Tag: StorageRemoveRequestOptions.init
public init(
bucket: some StorageBucket,
pluginOptions: Any? = nil
) {
self.accessLevel = .guest
self.bucket = bucket
self.pluginOptions = pluginOptions
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,40 @@ public extension StorageUploadDataRequest {
public let pluginOptions: Any?

/// - Tag: StorageUploadDataRequestOptions.init
@available(*, deprecated, message: "Use init(metadata:bucket:contentType:options)")
@available(*, deprecated, message: "Use init(metadata:contentType:options)")
public init(
accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
metadata: [String: String]? = nil,
bucket: (any StorageBucket)? = nil,
contentType: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.targetIdentityId = targetIdentityId
self.metadata = metadata
self.bucket = bucket
self.bucket = nil
self.contentType = contentType
self.pluginOptions = pluginOptions
}

/// - Tag: StorageUploadDataRequestOptions.init
public init(
metadata: [String: String]? = nil,
contentType: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.metadata = metadata
self.bucket = nil
self.contentType = contentType
self.pluginOptions = pluginOptions
}

/// - Tag: StorageUploadDataRequestOptions.init
public init(
metadata: [String: String]? = nil,
bucket: (any StorageBucket)? = nil,
bucket: some StorageBucket,
contentType: String? = nil,
pluginOptions: Any? = nil
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,40 @@ public extension StorageUploadFileRequest {
public let pluginOptions: Any?

/// - Tag: StorageUploadFileRequestOptions.init
@available(*, deprecated, message: "Use init(metadata:bucket:contentType:pluginOptions)")
@available(*, deprecated, message: "Use init(metadata:contentType:pluginOptions)")
public init(
accessLevel: StorageAccessLevel = .guest,
targetIdentityId: String? = nil,
metadata: [String: String]? = nil,
bucket: (any StorageBucket)? = nil,
contentType: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = accessLevel
self.targetIdentityId = targetIdentityId
self.metadata = metadata
self.bucket = bucket
self.bucket = nil
self.contentType = contentType
self.pluginOptions = pluginOptions
}

/// - Tag: StorageUploadFileRequestOptions.init
public init(
metadata: [String: String]? = nil,
contentType: String? = nil,
pluginOptions: Any? = nil
) {
self.accessLevel = .guest
self.targetIdentityId = nil
self.metadata = metadata
self.bucket = nil
self.contentType = contentType
self.pluginOptions = pluginOptions
}

/// - Tag: StorageUploadFileRequestOptions.init
public init(
metadata: [String: String]? = nil,
bucket: (any StorageBucket)? = nil,
bucket: some StorageBucket,
contentType: String? = nil,
pluginOptions: Any? = nil
) {
Expand Down
18 changes: 0 additions & 18 deletions Amplify/Categories/Storage/StorageBucket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public protocol StorageBucket { }
///
/// - Tag: BucketInfo
public struct BucketInfo: Hashable {

/// The name of the bucket
/// - Tag: BucketInfo.bucketName
public let bucketName: String
Expand All @@ -32,7 +31,6 @@ public struct BucketInfo: Hashable {
}

public extension StorageBucket where Self == OutputsStorageBucket {

/// References a `StorageBucket` in the AmplifyOutputs file using the given name.
///
/// - Parameter name: The name of the bucket
Expand Down Expand Up @@ -63,19 +61,3 @@ public struct OutputsStorageBucket: StorageBucket {
public struct ResolvedStorageBucket: StorageBucket {
public let bucketInfo: BucketInfo
}

public extension Optional where Wrapped == any StorageBucket {
/// References a `StorageBucket` in the AmplifyOutputs file using the given name.
///
/// - Parameter name: The name of the bucket
static func fromOutputs(name: String) -> (any StorageBucket)? {
return OutputsStorageBucket.fromOutputs(name: name)
}

/// References a `StorageBucket` using the data from the given `BucketInfo`.
///
/// - Parameter bucketInfo: A `BucketInfo` instance
static func fromBucketInfo(_ bucketInfo: BucketInfo) -> (any StorageBucket)? {
return ResolvedStorageBucket.fromBucketInfo(bucketInfo)
}
}

0 comments on commit 6bf07cf

Please sign in to comment.