Skip to content

Commit

Permalink
chore: release rc
Browse files Browse the repository at this point in the history
  • Loading branch information
christyjacob4 committed Aug 17, 2024
1 parent 0ad70d0 commit 1672cb0
Show file tree
Hide file tree
Showing 17 changed files with 449 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.9.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.32.0"),
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.19.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.58.0"),
],
targets: [
.target(
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

```swift
dependencies: [
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "5.0.2"),
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "6.0.0-rc.1"),
],
```

Expand Down
4 changes: 2 additions & 2 deletions Sources/Appwrite/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ open class Client {
"x-sdk-name": "Swift",
"x-sdk-platform": "server",
"x-sdk-language": "swift",
"x-sdk-version": "5.0.2",
"x-appwrite-response-format": "1.5.0"
"x-sdk-version": "6.0.0-rc.1",
"x-appwrite-response-format": "1.6.0"
]

internal var config: [String: String] = [:]
Expand Down
14 changes: 5 additions & 9 deletions Sources/Appwrite/Services/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ open class Account: Service {
}

///
/// Add Authenticator
/// Create Authenticator
///
/// Add an authenticator app to be used as an MFA factor. Verify the
/// authenticator using the [verify
Expand Down Expand Up @@ -508,20 +508,16 @@ open class Account: Service {
/// Delete an authenticator for a user by ID.
///
/// @param AppwriteEnums.AuthenticatorType type
/// @param String otp
/// @throws Exception
/// @return array
///
open func deleteMfaAuthenticator(
type: AppwriteEnums.AuthenticatorType,
otp: String
type: AppwriteEnums.AuthenticatorType
) async throws -> Any {
let apiPath: String = "/account/mfa/authenticators/{type}"
.replacingOccurrences(of: "{type}", with: type.rawValue)

let apiParams: [String: Any?] = [
"otp": otp
]
let apiParams: [String: Any] = [:]

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

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

///
/// Create phone verification (confirmation)
/// Update phone verification (confirmation)
///
/// Use this endpoint to complete the user phone verification process. Use the
/// **userId** and **secret** that were sent to your user's phone number to
Expand Down
2 changes: 2 additions & 0 deletions Sources/Appwrite/Services/Avatars.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ open class Avatars: Service {
/// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
/// website URL.
///
/// This endpoint does not follow HTTP redirects.
///
/// @param String url
/// @throws Exception
Expand Down Expand Up @@ -200,6 +201,7 @@ open class Avatars: Service {
/// image at source quality. If dimensions are not specified, the default size
/// of image returned is 400x400px.
///
/// This endpoint does not follow HTTP redirects.
///
/// @param String url
/// @param Int width
Expand Down
116 changes: 101 additions & 15 deletions Sources/Appwrite/Services/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ open class Functions: Service {
/// @param String templateRepository
/// @param String templateOwner
/// @param String templateRootDirectory
/// @param String templateBranch
/// @param String templateVersion
/// @throws Exception
/// @return array
///
Expand All @@ -100,7 +100,7 @@ open class Functions: Service {
templateRepository: String? = nil,
templateOwner: String? = nil,
templateRootDirectory: String? = nil,
templateBranch: String? = nil
templateVersion: String? = nil
) async throws -> AppwriteModels.Function {
let apiPath: String = "/functions"

Expand All @@ -125,7 +125,7 @@ open class Functions: Service {
"templateRepository": templateRepository,
"templateOwner": templateOwner,
"templateRootDirectory": templateRootDirectory,
"templateBranch": templateBranch
"templateVersion": templateVersion
]

let apiHeaders: [String: String] = [
Expand Down Expand Up @@ -176,6 +176,88 @@ open class Functions: Service {
)
}

///
/// List function templates
///
/// List available function templates. You can use template details in
/// [createFunction](/docs/references/cloud/server-nodejs/functions#create)
/// method.
///
/// @param [String] runtimes
/// @param [String] useCases
/// @param Int limit
/// @param Int offset
/// @throws Exception
/// @return array
///
open func listTemplates(
runtimes: [String]? = nil,
useCases: [String]? = nil,
limit: Int? = nil,
offset: Int? = nil
) async throws -> AppwriteModels.TemplateFunctionList {
let apiPath: String = "/functions/templates"

let apiParams: [String: Any?] = [
"runtimes": runtimes,
"useCases": useCases,
"limit": limit,
"offset": offset
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]

let converter: (Any) -> AppwriteModels.TemplateFunctionList = { response in
return AppwriteModels.TemplateFunctionList.from(map: response as! [String: Any])
}

return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}

///
/// Get function template
///
/// Get a function template using ID. You can use template details in
/// [createFunction](/docs/references/cloud/server-nodejs/functions#create)
/// method.
///
/// @param String templateId
/// @throws Exception
/// @return array
///
open func getTemplate(
templateId: String
) async throws -> AppwriteModels.TemplateFunction {
let apiPath: String = "/functions/templates/{templateId}"
.replacingOccurrences(of: "{templateId}", with: templateId)

let apiParams: [String: Any] = [:]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]

let converter: (Any) -> AppwriteModels.TemplateFunction = { response in
return AppwriteModels.TemplateFunction.from(map: response as! [String: Any])
}

return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}

///
/// Get function
///
Expand Down Expand Up @@ -462,7 +544,7 @@ open class Functions: Service {
}

///
/// Update function deployment
/// Update deployment
///
/// Update the function code deployment ID using the unique function ID. Use
/// this endpoint to switch the code deployment that should be executed by the
Expand Down Expand Up @@ -600,7 +682,7 @@ open class Functions: Service {
}

///
/// Download Deployment
/// Download deployment
///
/// Get a Deployment's contents by its unique ID. This endpoint supports range
/// requests for partial or streaming file download.
Expand All @@ -610,7 +692,7 @@ open class Functions: Service {
/// @throws Exception
/// @return array
///
open func downloadDeployment(
open func getDeploymentDownload(
functionId: String,
deploymentId: String
) async throws -> ByteBuffer {
Expand Down Expand Up @@ -698,12 +780,13 @@ open class Functions: Service {
path: String? = nil,
method: AppwriteEnums.ExecutionMethod? = nil,
headers: Any? = nil,
scheduledAt: String? = nil
scheduledAt: String? = nil,
onProgress: ((UploadProgress) -> Void)? = nil
) async throws -> AppwriteModels.Execution {
let apiPath: String = "/functions/{functionId}/executions"
.replacingOccurrences(of: "{functionId}", with: functionId)

let apiParams: [String: Any?] = [
var apiParams: [String: Any?] = [
"body": body,
"async": async,
"path": path,
Expand All @@ -712,20 +795,23 @@ open class Functions: Service {
"scheduledAt": scheduledAt
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
var apiHeaders: [String: String] = [
"content-type": "multipart/form-data"
]

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

return try await client.call(
method: "POST",
let idParamName: String? = nil
return try await client.chunkedUpload(
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
headers: &apiHeaders,
params: &apiParams,
paramName: paramName,
idParamName: idParamName,
converter: converter,
onProgress: onProgress
)
}

Expand Down
13 changes: 10 additions & 3 deletions Sources/AppwriteModels/Execution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class Execution {
/// Function execution duration in seconds.
public let duration: Double

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


init(
id: String,
Expand All @@ -69,7 +72,8 @@ public class Execution {
responseHeaders: [Headers],
logs: String,
errors: String,
duration: Double
duration: Double,
scheduledAt: String??
) {
self.id = id
self.createdAt = createdAt
Expand All @@ -87,6 +91,7 @@ public class Execution {
self.logs = logs
self.errors = errors
self.duration = duration
self.scheduledAt = scheduledAt
}

public func toMap() -> [String: Any] {
Expand All @@ -106,7 +111,8 @@ public class Execution {
"responseHeaders": responseHeaders.map { $0.toMap() } as Any,
"logs": logs as Any,
"errors": errors as Any,
"duration": duration as Any
"duration": duration as Any,
"scheduledAt": scheduledAt as Any
]
}

Expand All @@ -127,7 +133,8 @@ public class Execution {
responseHeaders: (map["responseHeaders"] as! [[String: Any]]).map { Headers.from(map: $0) },
logs: map["logs"] as! String,
errors: map["errors"] as! String,
duration: map["duration"] as! Double
duration: map["duration"] as! Double,
scheduledAt: map["scheduledAt"] as? String?
)
}
}
7 changes: 7 additions & 0 deletions Sources/AppwriteModels/Runtime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class Runtime {
/// Runtime ID.
public let id: String

/// Parent runtime key.
public let key: String

/// Runtime Name.
public let name: String

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

init(
id: String,
key: String,
name: String,
version: String,
base: String,
Expand All @@ -36,6 +40,7 @@ public class Runtime {
supports: [Any]
) {
self.id = id
self.key = key
self.name = name
self.version = version
self.base = base
Expand All @@ -47,6 +52,7 @@ public class Runtime {
public func toMap() -> [String: Any] {
return [
"$id": id as Any,
"key": key as Any,
"name": name as Any,
"version": version as Any,
"base": base as Any,
Expand All @@ -59,6 +65,7 @@ public class Runtime {
public static func from(map: [String: Any] ) -> Runtime {
return Runtime(
id: map["$id"] as! String,
key: map["key"] as! String,
name: map["name"] as! String,
version: map["version"] as! String,
base: map["base"] as! String,
Expand Down
Loading

0 comments on commit 1672cb0

Please sign in to comment.