Skip to content

Commit 6bf07cf

Browse files
committed
fix: Updating init parameters to some StorageBucket for autocompletion (#3833)
1 parent d1cdacd commit 6bf07cf

8 files changed

+99
-40
lines changed

Amplify/Categories/Storage/Operation/Request/StorageDownloadDataRequest.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,30 @@ public extension StorageDownloadDataRequest {
9595

9696
///
9797
/// - Tag: StorageDownloadDataRequestOptions.init
98-
@available(*, deprecated, message: "Use init(bucket:pluginOptions)")
98+
@available(*, deprecated, message: "Use init(pluginOptions)")
9999
public init(
100100
accessLevel: StorageAccessLevel = .guest,
101101
targetIdentityId: String? = nil,
102-
bucket: (any StorageBucket)? = nil,
103102
pluginOptions: Any? = nil
104103
) {
105104
self.accessLevel = accessLevel
106105
self.targetIdentityId = targetIdentityId
107-
self.bucket = bucket
106+
self.bucket = nil
108107
self.pluginOptions = pluginOptions
109108
}
110109

111110
///
111+
/// - Tag: StorageDownloadDataRequestOptions.init
112+
public init(pluginOptions: Any? = nil) {
113+
self.accessLevel = .guest
114+
self.targetIdentityId = nil
115+
self.bucket = nil
116+
self.pluginOptions = pluginOptions
117+
}
118+
112119
/// - Tag: StorageDownloadDataRequestOptions.init
113120
public init(
114-
bucket: (any StorageBucket)? = nil,
121+
bucket: some StorageBucket,
115122
pluginOptions: Any? = nil
116123
) {
117124
self.accessLevel = .guest

Amplify/Categories/Storage/Operation/Request/StorageDownloadFileRequest.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,29 @@ public extension StorageDownloadFileRequest {
8484
public let pluginOptions: Any?
8585

8686
/// - Tag: StorageDownloadFileRequestOptions.init
87-
@available(*, deprecated, message: "Use init(bucket:pluginOptions)")
87+
@available(*, deprecated, message: "Use init(pluginOptions)")
8888
public init(
8989
accessLevel: StorageAccessLevel = .guest,
9090
targetIdentityId: String? = nil,
91-
bucket: (any StorageBucket)? = nil,
9291
pluginOptions: Any? = nil
9392
) {
9493
self.accessLevel = accessLevel
9594
self.targetIdentityId = targetIdentityId
96-
self.bucket = bucket
95+
self.bucket = nil
96+
self.pluginOptions = pluginOptions
97+
}
98+
99+
/// - Tag: StorageDownloadFileRequestOptions.init
100+
public init(pluginOptions: Any? = nil) {
101+
self.accessLevel = .guest
102+
self.targetIdentityId = nil
103+
self.bucket = nil
97104
self.pluginOptions = pluginOptions
98105
}
99106

100107
/// - Tag: StorageDownloadFileRequestOptions.init
101108
public init(
102-
bucket: (any StorageBucket)? = nil,
109+
bucket: some StorageBucket,
103110
pluginOptions: Any? = nil
104111
) {
105112
self.accessLevel = .guest

Amplify/Categories/Storage/Operation/Request/StorageGetURLRequest.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,36 @@ public extension StorageGetURLRequest {
8888
public let pluginOptions: Any?
8989

9090
/// - Tag: StorageGetURLRequest.Options.init
91-
@available(*, deprecated, message: "Use init(expires:bucket:pluginOptions)")
91+
@available(*, deprecated, message: "Use init(expires:pluginOptions)")
9292
public init(
9393
accessLevel: StorageAccessLevel = .guest,
9494
targetIdentityId: String? = nil,
9595
expires: Int = Options.defaultExpireInSeconds,
96-
bucket: (any StorageBucket)? = nil,
9796
pluginOptions: Any? = nil
9897
) {
9998
self.accessLevel = accessLevel
10099
self.targetIdentityId = targetIdentityId
101100
self.expires = expires
102-
self.bucket = bucket
101+
self.bucket = nil
102+
self.pluginOptions = pluginOptions
103+
}
104+
105+
/// - Tag: StorageGetURLRequest.Options.init
106+
public init(
107+
expires: Int = Options.defaultExpireInSeconds,
108+
pluginOptions: Any? = nil
109+
) {
110+
self.expires = expires
111+
self.bucket = nil
103112
self.pluginOptions = pluginOptions
113+
self.accessLevel = .guest
114+
self.targetIdentityId = nil
104115
}
105116

106117
/// - Tag: StorageGetURLRequest.Options.init
107118
public init(
108119
expires: Int = Options.defaultExpireInSeconds,
109-
bucket: (any StorageBucket)? = nil,
120+
bucket: some StorageBucket,
110121
pluginOptions: Any? = nil
111122
) {
112123
self.expires = expires

Amplify/Categories/Storage/Operation/Request/StorageListRequest.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ public extension StorageListRequest {
107107
path: String? = nil,
108108
subpathStrategy: SubpathStrategy = .include,
109109
pageSize: UInt = 1000,
110-
bucket: (any StorageBucket)? = nil,
111110
nextToken: String? = nil,
112111
pluginOptions: Any? = nil
113112
) {
@@ -116,6 +115,24 @@ public extension StorageListRequest {
116115
self.path = path
117116
self.subpathStrategy = subpathStrategy
118117
self.pageSize = pageSize
118+
self.bucket = nil
119+
self.nextToken = nextToken
120+
self.pluginOptions = pluginOptions
121+
}
122+
123+
/// - Tag: StorageListRequestOptions.init
124+
public init(
125+
subpathStrategy: SubpathStrategy = .include,
126+
pageSize: UInt = 1000,
127+
bucket: some StorageBucket,
128+
nextToken: String? = nil,
129+
pluginOptions: Any? = nil
130+
) {
131+
self.accessLevel = .guest
132+
self.targetIdentityId = nil
133+
self.path = nil
134+
self.subpathStrategy = subpathStrategy
135+
self.pageSize = pageSize
119136
self.bucket = bucket
120137
self.nextToken = nextToken
121138
self.pluginOptions = pluginOptions

Amplify/Categories/Storage/Operation/Request/StorageRemoveRequest.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,19 @@ public extension StorageRemoveRequest {
7171
/// - Tag: StorageRemoveRequestOptions.init
7272
public init(
7373
accessLevel: StorageAccessLevel = .guest,
74-
bucket: (any StorageBucket)? = nil,
7574
pluginOptions: Any? = nil
7675
) {
7776
self.accessLevel = accessLevel
77+
self.bucket = nil
78+
self.pluginOptions = pluginOptions
79+
}
80+
81+
/// - Tag: StorageRemoveRequestOptions.init
82+
public init(
83+
bucket: some StorageBucket,
84+
pluginOptions: Any? = nil
85+
) {
86+
self.accessLevel = .guest
7887
self.bucket = bucket
7988
self.pluginOptions = pluginOptions
8089
}

Amplify/Categories/Storage/Operation/Request/StorageUploadDataRequest.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,40 @@ public extension StorageUploadDataRequest {
9393
public let pluginOptions: Any?
9494

9595
/// - Tag: StorageUploadDataRequestOptions.init
96-
@available(*, deprecated, message: "Use init(metadata:bucket:contentType:options)")
96+
@available(*, deprecated, message: "Use init(metadata:contentType:options)")
9797
public init(
9898
accessLevel: StorageAccessLevel = .guest,
9999
targetIdentityId: String? = nil,
100100
metadata: [String: String]? = nil,
101-
bucket: (any StorageBucket)? = nil,
102101
contentType: String? = nil,
103102
pluginOptions: Any? = nil
104103
) {
105104
self.accessLevel = accessLevel
106105
self.targetIdentityId = targetIdentityId
107106
self.metadata = metadata
108-
self.bucket = bucket
107+
self.bucket = nil
108+
self.contentType = contentType
109+
self.pluginOptions = pluginOptions
110+
}
111+
112+
/// - Tag: StorageUploadDataRequestOptions.init
113+
public init(
114+
metadata: [String: String]? = nil,
115+
contentType: String? = nil,
116+
pluginOptions: Any? = nil
117+
) {
118+
self.accessLevel = .guest
119+
self.targetIdentityId = nil
120+
self.metadata = metadata
121+
self.bucket = nil
109122
self.contentType = contentType
110123
self.pluginOptions = pluginOptions
111124
}
112125

113126
/// - Tag: StorageUploadDataRequestOptions.init
114127
public init(
115128
metadata: [String: String]? = nil,
116-
bucket: (any StorageBucket)? = nil,
129+
bucket: some StorageBucket,
117130
contentType: String? = nil,
118131
pluginOptions: Any? = nil
119132
) {

Amplify/Categories/Storage/Operation/Request/StorageUploadFileRequest.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,40 @@ public extension StorageUploadFileRequest {
9090
public let pluginOptions: Any?
9191

9292
/// - Tag: StorageUploadFileRequestOptions.init
93-
@available(*, deprecated, message: "Use init(metadata:bucket:contentType:pluginOptions)")
93+
@available(*, deprecated, message: "Use init(metadata:contentType:pluginOptions)")
9494
public init(
9595
accessLevel: StorageAccessLevel = .guest,
9696
targetIdentityId: String? = nil,
9797
metadata: [String: String]? = nil,
98-
bucket: (any StorageBucket)? = nil,
9998
contentType: String? = nil,
10099
pluginOptions: Any? = nil
101100
) {
102101
self.accessLevel = accessLevel
103102
self.targetIdentityId = targetIdentityId
104103
self.metadata = metadata
105-
self.bucket = bucket
104+
self.bucket = nil
105+
self.contentType = contentType
106+
self.pluginOptions = pluginOptions
107+
}
108+
109+
/// - Tag: StorageUploadFileRequestOptions.init
110+
public init(
111+
metadata: [String: String]? = nil,
112+
contentType: String? = nil,
113+
pluginOptions: Any? = nil
114+
) {
115+
self.accessLevel = .guest
116+
self.targetIdentityId = nil
117+
self.metadata = metadata
118+
self.bucket = nil
106119
self.contentType = contentType
107120
self.pluginOptions = pluginOptions
108121
}
109122

110123
/// - Tag: StorageUploadFileRequestOptions.init
111124
public init(
112125
metadata: [String: String]? = nil,
113-
bucket: (any StorageBucket)? = nil,
126+
bucket: some StorageBucket,
114127
contentType: String? = nil,
115128
pluginOptions: Any? = nil
116129
) {

Amplify/Categories/Storage/StorageBucket.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public protocol StorageBucket { }
1616
///
1717
/// - Tag: BucketInfo
1818
public struct BucketInfo: Hashable {
19-
2019
/// The name of the bucket
2120
/// - Tag: BucketInfo.bucketName
2221
public let bucketName: String
@@ -32,7 +31,6 @@ public struct BucketInfo: Hashable {
3231
}
3332

3433
public extension StorageBucket where Self == OutputsStorageBucket {
35-
3634
/// References a `StorageBucket` in the AmplifyOutputs file using the given name.
3735
///
3836
/// - Parameter name: The name of the bucket
@@ -63,19 +61,3 @@ public struct OutputsStorageBucket: StorageBucket {
6361
public struct ResolvedStorageBucket: StorageBucket {
6462
public let bucketInfo: BucketInfo
6563
}
66-
67-
public extension Optional where Wrapped == any StorageBucket {
68-
/// References a `StorageBucket` in the AmplifyOutputs file using the given name.
69-
///
70-
/// - Parameter name: The name of the bucket
71-
static func fromOutputs(name: String) -> (any StorageBucket)? {
72-
return OutputsStorageBucket.fromOutputs(name: name)
73-
}
74-
75-
/// References a `StorageBucket` using the data from the given `BucketInfo`.
76-
///
77-
/// - Parameter bucketInfo: A `BucketInfo` instance
78-
static func fromBucketInfo(_ bucketInfo: BucketInfo) -> (any StorageBucket)? {
79-
return ResolvedStorageBucket.fromBucketInfo(bucketInfo)
80-
}
81-
}

0 commit comments

Comments
 (0)