Skip to content

Commit 1672cb0

Browse files
committed
chore: release rc
1 parent 0ad70d0 commit 1672cb0

17 files changed

+449
-38
lines changed

Package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ let package = Package(
2222
),
2323
],
2424
dependencies: [
25-
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.9.0"),
26-
.package(url: "https://github.com/apple/swift-nio.git", from: "2.32.0"),
25+
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.19.0"),
26+
.package(url: "https://github.com/apple/swift-nio.git", from: "2.58.0"),
2727
],
2828
targets: [
2929
.target(

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-1.5.7-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.6.0-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
@@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:
3333

3434
```swift
3535
dependencies: [
36-
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "5.0.2"),
36+
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "6.0.0-rc.1"),
3737
],
3838
```
3939

Sources/Appwrite/Client.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ open class Client {
2121
"x-sdk-name": "Swift",
2222
"x-sdk-platform": "server",
2323
"x-sdk-language": "swift",
24-
"x-sdk-version": "5.0.2",
25-
"x-appwrite-response-format": "1.5.0"
24+
"x-sdk-version": "6.0.0-rc.1",
25+
"x-appwrite-response-format": "1.6.0"
2626
]
2727

2828
internal var config: [String: String] = [:]

Sources/Appwrite/Services/Account.swift

+5-9
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ open class Account: Service {
402402
}
403403

404404
///
405-
/// Add Authenticator
405+
/// Create Authenticator
406406
///
407407
/// Add an authenticator app to be used as an MFA factor. Verify the
408408
/// authenticator using the [verify
@@ -508,20 +508,16 @@ open class Account: Service {
508508
/// Delete an authenticator for a user by ID.
509509
///
510510
/// @param AppwriteEnums.AuthenticatorType type
511-
/// @param String otp
512511
/// @throws Exception
513512
/// @return array
514513
///
515514
open func deleteMfaAuthenticator(
516-
type: AppwriteEnums.AuthenticatorType,
517-
otp: String
515+
type: AppwriteEnums.AuthenticatorType
518516
) async throws -> Any {
519517
let apiPath: String = "/account/mfa/authenticators/{type}"
520518
.replacingOccurrences(of: "{type}", with: type.rawValue)
521519

522-
let apiParams: [String: Any?] = [
523-
"otp": otp
524-
]
520+
let apiParams: [String: Any] = [:]
525521

526522
let apiHeaders: [String: String] = [
527523
"content-type": "application/json"
@@ -535,7 +531,7 @@ open class Account: Service {
535531
}
536532

537533
///
538-
/// Create 2FA Challenge
534+
/// Create MFA Challenge
539535
///
540536
/// Begin the process of MFA verification after sign-in. Finish the flow with
541537
/// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
@@ -1877,7 +1873,7 @@ open class Account: Service {
18771873
}
18781874

18791875
///
1880-
/// Create phone verification (confirmation)
1876+
/// Update phone verification (confirmation)
18811877
///
18821878
/// Use this endpoint to complete the user phone verification process. Use the
18831879
/// **userId** and **secret** that were sent to your user's phone number to

Sources/Appwrite/Services/Avatars.swift

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ open class Avatars: Service {
111111
/// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
112112
/// website URL.
113113
///
114+
/// This endpoint does not follow HTTP redirects.
114115
///
115116
/// @param String url
116117
/// @throws Exception
@@ -200,6 +201,7 @@ open class Avatars: Service {
200201
/// image at source quality. If dimensions are not specified, the default size
201202
/// of image returned is 400x400px.
202203
///
204+
/// This endpoint does not follow HTTP redirects.
203205
///
204206
/// @param String url
205207
/// @param Int width

Sources/Appwrite/Services/Functions.swift

+101-15
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ open class Functions: Service {
7575
/// @param String templateRepository
7676
/// @param String templateOwner
7777
/// @param String templateRootDirectory
78-
/// @param String templateBranch
78+
/// @param String templateVersion
7979
/// @throws Exception
8080
/// @return array
8181
///
@@ -100,7 +100,7 @@ open class Functions: Service {
100100
templateRepository: String? = nil,
101101
templateOwner: String? = nil,
102102
templateRootDirectory: String? = nil,
103-
templateBranch: String? = nil
103+
templateVersion: String? = nil
104104
) async throws -> AppwriteModels.Function {
105105
let apiPath: String = "/functions"
106106

@@ -125,7 +125,7 @@ open class Functions: Service {
125125
"templateRepository": templateRepository,
126126
"templateOwner": templateOwner,
127127
"templateRootDirectory": templateRootDirectory,
128-
"templateBranch": templateBranch
128+
"templateVersion": templateVersion
129129
]
130130

131131
let apiHeaders: [String: String] = [
@@ -176,6 +176,88 @@ open class Functions: Service {
176176
)
177177
}
178178

179+
///
180+
/// List function templates
181+
///
182+
/// List available function templates. You can use template details in
183+
/// [createFunction](/docs/references/cloud/server-nodejs/functions#create)
184+
/// method.
185+
///
186+
/// @param [String] runtimes
187+
/// @param [String] useCases
188+
/// @param Int limit
189+
/// @param Int offset
190+
/// @throws Exception
191+
/// @return array
192+
///
193+
open func listTemplates(
194+
runtimes: [String]? = nil,
195+
useCases: [String]? = nil,
196+
limit: Int? = nil,
197+
offset: Int? = nil
198+
) async throws -> AppwriteModels.TemplateFunctionList {
199+
let apiPath: String = "/functions/templates"
200+
201+
let apiParams: [String: Any?] = [
202+
"runtimes": runtimes,
203+
"useCases": useCases,
204+
"limit": limit,
205+
"offset": offset
206+
]
207+
208+
let apiHeaders: [String: String] = [
209+
"content-type": "application/json"
210+
]
211+
212+
let converter: (Any) -> AppwriteModels.TemplateFunctionList = { response in
213+
return AppwriteModels.TemplateFunctionList.from(map: response as! [String: Any])
214+
}
215+
216+
return try await client.call(
217+
method: "GET",
218+
path: apiPath,
219+
headers: apiHeaders,
220+
params: apiParams,
221+
converter: converter
222+
)
223+
}
224+
225+
///
226+
/// Get function template
227+
///
228+
/// Get a function template using ID. You can use template details in
229+
/// [createFunction](/docs/references/cloud/server-nodejs/functions#create)
230+
/// method.
231+
///
232+
/// @param String templateId
233+
/// @throws Exception
234+
/// @return array
235+
///
236+
open func getTemplate(
237+
templateId: String
238+
) async throws -> AppwriteModels.TemplateFunction {
239+
let apiPath: String = "/functions/templates/{templateId}"
240+
.replacingOccurrences(of: "{templateId}", with: templateId)
241+
242+
let apiParams: [String: Any] = [:]
243+
244+
let apiHeaders: [String: String] = [
245+
"content-type": "application/json"
246+
]
247+
248+
let converter: (Any) -> AppwriteModels.TemplateFunction = { response in
249+
return AppwriteModels.TemplateFunction.from(map: response as! [String: Any])
250+
}
251+
252+
return try await client.call(
253+
method: "GET",
254+
path: apiPath,
255+
headers: apiHeaders,
256+
params: apiParams,
257+
converter: converter
258+
)
259+
}
260+
179261
///
180262
/// Get function
181263
///
@@ -462,7 +544,7 @@ open class Functions: Service {
462544
}
463545

464546
///
465-
/// Update function deployment
547+
/// Update deployment
466548
///
467549
/// Update the function code deployment ID using the unique function ID. Use
468550
/// this endpoint to switch the code deployment that should be executed by the
@@ -600,7 +682,7 @@ open class Functions: Service {
600682
}
601683

602684
///
603-
/// Download Deployment
685+
/// Download deployment
604686
///
605687
/// Get a Deployment's contents by its unique ID. This endpoint supports range
606688
/// requests for partial or streaming file download.
@@ -610,7 +692,7 @@ open class Functions: Service {
610692
/// @throws Exception
611693
/// @return array
612694
///
613-
open func downloadDeployment(
695+
open func getDeploymentDownload(
614696
functionId: String,
615697
deploymentId: String
616698
) async throws -> ByteBuffer {
@@ -698,12 +780,13 @@ open class Functions: Service {
698780
path: String? = nil,
699781
method: AppwriteEnums.ExecutionMethod? = nil,
700782
headers: Any? = nil,
701-
scheduledAt: String? = nil
783+
scheduledAt: String? = nil,
784+
onProgress: ((UploadProgress) -> Void)? = nil
702785
) async throws -> AppwriteModels.Execution {
703786
let apiPath: String = "/functions/{functionId}/executions"
704787
.replacingOccurrences(of: "{functionId}", with: functionId)
705788

706-
let apiParams: [String: Any?] = [
789+
var apiParams: [String: Any?] = [
707790
"body": body,
708791
"async": async,
709792
"path": path,
@@ -712,20 +795,23 @@ open class Functions: Service {
712795
"scheduledAt": scheduledAt
713796
]
714797

715-
let apiHeaders: [String: String] = [
716-
"content-type": "application/json"
798+
var apiHeaders: [String: String] = [
799+
"content-type": "multipart/form-data"
717800
]
718801

719802
let converter: (Any) -> AppwriteModels.Execution = { response in
720803
return AppwriteModels.Execution.from(map: response as! [String: Any])
721804
}
722805

723-
return try await client.call(
724-
method: "POST",
806+
let idParamName: String? = nil
807+
return try await client.chunkedUpload(
725808
path: apiPath,
726-
headers: apiHeaders,
727-
params: apiParams,
728-
converter: converter
809+
headers: &apiHeaders,
810+
params: &apiParams,
811+
paramName: paramName,
812+
idParamName: idParamName,
813+
converter: converter,
814+
onProgress: onProgress
729815
)
730816
}
731817

Sources/AppwriteModels/Execution.swift

+10-3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class Execution {
5252
/// Function execution duration in seconds.
5353
public let duration: Double
5454

55+
/// The scheduled time for execution. If left empty, execution will be queued immediately.
56+
public let scheduledAt: String??
57+
5558

5659
init(
5760
id: String,
@@ -69,7 +72,8 @@ public class Execution {
6972
responseHeaders: [Headers],
7073
logs: String,
7174
errors: String,
72-
duration: Double
75+
duration: Double,
76+
scheduledAt: String??
7377
) {
7478
self.id = id
7579
self.createdAt = createdAt
@@ -87,6 +91,7 @@ public class Execution {
8791
self.logs = logs
8892
self.errors = errors
8993
self.duration = duration
94+
self.scheduledAt = scheduledAt
9095
}
9196

9297
public func toMap() -> [String: Any] {
@@ -106,7 +111,8 @@ public class Execution {
106111
"responseHeaders": responseHeaders.map { $0.toMap() } as Any,
107112
"logs": logs as Any,
108113
"errors": errors as Any,
109-
"duration": duration as Any
114+
"duration": duration as Any,
115+
"scheduledAt": scheduledAt as Any
110116
]
111117
}
112118

@@ -127,7 +133,8 @@ public class Execution {
127133
responseHeaders: (map["responseHeaders"] as! [[String: Any]]).map { Headers.from(map: $0) },
128134
logs: map["logs"] as! String,
129135
errors: map["errors"] as! String,
130-
duration: map["duration"] as! Double
136+
duration: map["duration"] as! Double,
137+
scheduledAt: map["scheduledAt"] as? String?
131138
)
132139
}
133140
}

Sources/AppwriteModels/Runtime.swift

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ public class Runtime {
77
/// Runtime ID.
88
public let id: String
99

10+
/// Parent runtime key.
11+
public let key: String
12+
1013
/// Runtime Name.
1114
public let name: String
1215

@@ -28,6 +31,7 @@ public class Runtime {
2831

2932
init(
3033
id: String,
34+
key: String,
3135
name: String,
3236
version: String,
3337
base: String,
@@ -36,6 +40,7 @@ public class Runtime {
3640
supports: [Any]
3741
) {
3842
self.id = id
43+
self.key = key
3944
self.name = name
4045
self.version = version
4146
self.base = base
@@ -47,6 +52,7 @@ public class Runtime {
4752
public func toMap() -> [String: Any] {
4853
return [
4954
"$id": id as Any,
55+
"key": key as Any,
5056
"name": name as Any,
5157
"version": version as Any,
5258
"base": base as Any,
@@ -59,6 +65,7 @@ public class Runtime {
5965
public static func from(map: [String: Any] ) -> Runtime {
6066
return Runtime(
6167
id: map["$id"] as! String,
68+
key: map["key"] as! String,
6269
name: map["name"] as! String,
6370
version: map["version"] as! String,
6471
base: map["base"] as! String,

0 commit comments

Comments
 (0)