Skip to content

Commit 260f5a5

Browse files
committed
chore: release rc
1 parent c15ab70 commit 260f5a5

16 files changed

+488
-39
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
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.17.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

Lines changed: 2 additions & 2 deletions
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-apple.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-apple.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)
@@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:
3131

3232
```swift
3333
dependencies: [
34-
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "6.0.0"),
34+
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "7.0.0-rc.1"),
3535
],
3636
```
3737

Sources/Appwrite/Client.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ open class Client {
2323
"x-sdk-name": "Apple",
2424
"x-sdk-platform": "client",
2525
"x-sdk-language": "apple",
26-
"x-sdk-version": "6.0.0",
27-
"x-appwrite-response-format": "1.5.0"
26+
"x-sdk-version": "7.0.0-rc.1",
27+
"x-appwrite-response-format": "1.6.0"
2828
]
2929

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

Sources/Appwrite/OAuth/WebAuthComponent.swift

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,24 @@ public class WebAuthComponent {
5353
/// - url: The URL containing the cookie
5454
///
5555
public static func handleIncomingCookie(from url: URL) {
56-
let components = URLComponents(string: url.absoluteString)!
5756

58-
let cookieParts = [String: String](uniqueKeysWithValues: components.queryItems!.map {
59-
($0.name, $0.value!)
57+
guard let components = URLComponents(string: url.absoluteString),
58+
let queryItems = components.queryItems else {
59+
return
60+
}
61+
62+
let cookieParts = [String: String](uniqueKeysWithValues: queryItems.compactMap { item in
63+
item.value.map { (item.name, $0) }
6064
})
6165

62-
var domain = cookieParts["domain"]!
66+
guard var domain = cookieParts["domain"],
67+
let key = cookieParts["key"],
68+
let secret = cookieParts["secret"] else {
69+
return
70+
}
71+
6372
domain.remove(at: domain.startIndex)
6473

65-
let key: String = cookieParts["key"]!
66-
let secret: String = cookieParts["secret"]!
6774
let path: String? = cookieParts["path"]
6875
let expires: String? = cookieParts["expires"]
6976
let maxAge: String? = cookieParts["maxAge"]
@@ -92,10 +99,7 @@ public class WebAuthComponent {
9299
cookie += "; secure"
93100
}
94101

95-
let existing = UserDefaults.standard.stringArray(forKey: domain)
96-
let new = [cookie]
97-
98-
UserDefaults.standard.set(new, forKey: domain)
102+
UserDefaults.standard.set([cookie], forKey: domain)
99103

100104
WebAuthComponent.onCallback(
101105
scheme: components.scheme!,

Sources/Appwrite/Services/Account.swift

Lines changed: 5 additions & 9 deletions
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)
@@ -2037,7 +2033,7 @@ open class Account: Service {
20372033
}
20382034

20392035
///
2040-
/// Create phone verification (confirmation)
2036+
/// Update phone verification (confirmation)
20412037
///
20422038
/// Use this endpoint to complete the user phone verification process. Use the
20432039
/// **userId** and **secret** that were sent to your user's phone number to

Sources/Appwrite/Services/Avatars.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ open class Avatars: Service {
101101
/// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
102102
/// website URL.
103103
///
104+
/// This endpoint does not follow HTTP redirects.
104105
///
105106
/// @param String url
106107
/// @throws Exception
@@ -180,6 +181,7 @@ open class Avatars: Service {
180181
/// image at source quality. If dimensions are not specified, the default size
181182
/// of image returned is 400x400px.
182183
///
184+
/// This endpoint does not follow HTTP redirects.
183185
///
184186
/// @param String url
185187
/// @param Int width

Sources/Appwrite/Services/Functions.swift

Lines changed: 123 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,116 @@ import AppwriteModels
88
/// The Functions Service allows you view, create and manage your Cloud Functions.
99
open class Functions: Service {
1010

11+
///
12+
/// List function templates
13+
///
14+
/// List available function templates. You can use template details in
15+
/// [createFunction](/docs/references/cloud/server-nodejs/functions#create)
16+
/// method.
17+
///
18+
/// @param [String] runtimes
19+
/// @param [String] useCases
20+
/// @param Int limit
21+
/// @param Int offset
22+
/// @throws Exception
23+
/// @return array
24+
///
25+
open func listTemplates(
26+
runtimes: [String]? = nil,
27+
useCases: [String]? = nil,
28+
limit: Int? = nil,
29+
offset: Int? = nil
30+
) async throws -> AppwriteModels.TemplateFunctionList {
31+
let apiPath: String = "/functions/templates"
32+
33+
let apiParams: [String: Any?] = [
34+
"runtimes": runtimes,
35+
"useCases": useCases,
36+
"limit": limit,
37+
"offset": offset
38+
]
39+
40+
let apiHeaders: [String: String] = [
41+
"content-type": "application/json"
42+
]
43+
44+
let converter: (Any) -> AppwriteModels.TemplateFunctionList = { response in
45+
return AppwriteModels.TemplateFunctionList.from(map: response as! [String: Any])
46+
}
47+
48+
return try await client.call(
49+
method: "GET",
50+
path: apiPath,
51+
headers: apiHeaders,
52+
params: apiParams,
53+
converter: converter
54+
)
55+
}
56+
57+
///
58+
/// Get function template
59+
///
60+
/// Get a function template using ID. You can use template details in
61+
/// [createFunction](/docs/references/cloud/server-nodejs/functions#create)
62+
/// method.
63+
///
64+
/// @param String templateId
65+
/// @throws Exception
66+
/// @return array
67+
///
68+
open func getTemplate(
69+
templateId: String
70+
) async throws -> AppwriteModels.TemplateFunction {
71+
let apiPath: String = "/functions/templates/{templateId}"
72+
.replacingOccurrences(of: "{templateId}", with: templateId)
73+
74+
let apiParams: [String: Any] = [:]
75+
76+
let apiHeaders: [String: String] = [
77+
"content-type": "application/json"
78+
]
79+
80+
let converter: (Any) -> AppwriteModels.TemplateFunction = { response in
81+
return AppwriteModels.TemplateFunction.from(map: response as! [String: Any])
82+
}
83+
84+
return try await client.call(
85+
method: "GET",
86+
path: apiPath,
87+
headers: apiHeaders,
88+
params: apiParams,
89+
converter: converter
90+
)
91+
}
92+
93+
///
94+
/// Download deployment
95+
///
96+
/// Get a Deployment's contents by its unique ID. This endpoint supports range
97+
/// requests for partial or streaming file download.
98+
///
99+
/// @param String functionId
100+
/// @param String deploymentId
101+
/// @throws Exception
102+
/// @return array
103+
///
104+
open func getDeploymentDownload(
105+
functionId: String,
106+
deploymentId: String
107+
) async throws -> ByteBuffer {
108+
let apiPath: String = "/functions/{functionId}/deployments/{deploymentId}/download"
109+
.replacingOccurrences(of: "{functionId}", with: functionId)
110+
.replacingOccurrences(of: "{deploymentId}", with: deploymentId)
111+
112+
let apiParams: [String: Any] = [:]
113+
114+
return try await client.call(
115+
method: "GET",
116+
path: apiPath,
117+
params: apiParams
118+
)
119+
}
120+
11121
///
12122
/// List executions
13123
///
@@ -75,12 +185,13 @@ open class Functions: Service {
75185
path: String? = nil,
76186
method: AppwriteEnums.ExecutionMethod? = nil,
77187
headers: Any? = nil,
78-
scheduledAt: String? = nil
188+
scheduledAt: String? = nil,
189+
onProgress: ((UploadProgress) -> Void)? = nil
79190
) async throws -> AppwriteModels.Execution {
80191
let apiPath: String = "/functions/{functionId}/executions"
81192
.replacingOccurrences(of: "{functionId}", with: functionId)
82193

83-
let apiParams: [String: Any?] = [
194+
var apiParams: [String: Any?] = [
84195
"body": body,
85196
"async": async,
86197
"path": path,
@@ -89,20 +200,23 @@ open class Functions: Service {
89200
"scheduledAt": scheduledAt
90201
]
91202

92-
let apiHeaders: [String: String] = [
93-
"content-type": "application/json"
203+
var apiHeaders: [String: String] = [
204+
"content-type": "multipart/form-data"
94205
]
95206

96207
let converter: (Any) -> AppwriteModels.Execution = { response in
97208
return AppwriteModels.Execution.from(map: response as! [String: Any])
98209
}
99210

100-
return try await client.call(
101-
method: "POST",
211+
let idParamName: String? = nil
212+
return try await client.chunkedUpload(
102213
path: apiPath,
103-
headers: apiHeaders,
104-
params: apiParams,
105-
converter: converter
214+
headers: &apiHeaders,
215+
params: &apiParams,
216+
paramName: paramName,
217+
idParamName: idParamName,
218+
converter: converter,
219+
onProgress: onProgress
106220
)
107221
}
108222

Sources/AppwriteModels/Execution.swift

Lines changed: 10 additions & 3 deletions
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
}

0 commit comments

Comments
 (0)