From 12009e68740d483f9d7f0e1b5449b062fc061b7b Mon Sep 17 00:00:00 2001 From: root Date: Fri, 26 Sep 2025 09:05:37 +0000 Subject: [PATCH 1/3] chore: regenerate sdks --- README.md | 2 +- Sources/Appwrite/Client.swift | 2 +- Sources/Appwrite/Query.swift | 6 --- Sources/Appwrite/Services/Account.swift | 48 ++++++++++---------- Sources/Appwrite/Services/Avatars.swift | 12 ++--- Sources/Appwrite/Services/Functions.swift | 4 +- Sources/Appwrite/Services/Storage.swift | 8 ++-- Sources/AppwriteEnums/ExecutionStatus.swift | 12 +++++ Sources/AppwriteEnums/ExecutionTrigger.swift | 11 +++++ Sources/AppwriteModels/Execution.swift | 25 +++++----- 10 files changed, 74 insertions(+), 56 deletions(-) create mode 100644 Sources/AppwriteEnums/ExecutionStatus.swift create mode 100644 Sources/AppwriteEnums/ExecutionTrigger.swift diff --git a/README.md b/README.md index 4f0ed84..17239a0 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies: ```swift dependencies: [ - .package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "12.1.0"), + .package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "12.2.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index cc5e009..6af2bd0 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -23,7 +23,7 @@ open class Client { "x-sdk-name": "Apple", "x-sdk-platform": "client", "x-sdk-language": "apple", - "x-sdk-version": "12.1.0", + "x-sdk-version": "12.2.0", "x-appwrite-response-format": "1.8.0" ] diff --git a/Sources/Appwrite/Query.swift b/Sources/Appwrite/Query.swift index e4f06b5..5af7f4a 100644 --- a/Sources/Appwrite/Query.swift +++ b/Sources/Appwrite/Query.swift @@ -280,12 +280,6 @@ public struct Query : Codable, CustomStringConvertible { ).description } - public static func orderRandom() -> String { - return Query( - method: "orderRandom" - ).description - } - public static func cursorBefore(_ id: String) -> String { return Query( method: "cursorBefore", diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 9457229..ad2efba 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -387,13 +387,13 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AppwriteEnums.AuthenticatorType + /// - type: AuthenticatorType /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaType /// @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.") open func createMfaAuthenticator( - type: AppwriteEnums.AuthenticatorType + type: AuthenticatorType ) async throws -> AppwriteModels.MfaType { let apiPath: String = "/account/mfa/authenticators/{type}" .replacingOccurrences(of: "{type}", with: type.rawValue) @@ -424,12 +424,12 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AppwriteEnums.AuthenticatorType + /// - type: AuthenticatorType /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaType /// open func createMFAAuthenticator( - type: AppwriteEnums.AuthenticatorType + type: AuthenticatorType ) async throws -> AppwriteModels.MfaType { let apiPath: String = "/account/mfa/authenticators/{type}" .replacingOccurrences(of: "{type}", with: type.rawValue) @@ -459,14 +459,14 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AppwriteEnums.AuthenticatorType + /// - type: AuthenticatorType /// - otp: String /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.") open func updateMfaAuthenticator( - type: AppwriteEnums.AuthenticatorType, + type: AuthenticatorType, otp: String, nestedType: T.Type ) async throws -> AppwriteModels.User { @@ -500,14 +500,14 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AppwriteEnums.AuthenticatorType + /// - type: AuthenticatorType /// - otp: String /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.") open func updateMfaAuthenticator( - type: AppwriteEnums.AuthenticatorType, + type: AuthenticatorType, otp: String ) async throws -> AppwriteModels.User<[String: AnyCodable]> { return try await updateMfaAuthenticator( @@ -523,13 +523,13 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AppwriteEnums.AuthenticatorType + /// - type: AuthenticatorType /// - otp: String /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// open func updateMFAAuthenticator( - type: AppwriteEnums.AuthenticatorType, + type: AuthenticatorType, otp: String, nestedType: T.Type ) async throws -> AppwriteModels.User { @@ -563,13 +563,13 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AppwriteEnums.AuthenticatorType + /// - type: AuthenticatorType /// - otp: String /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// open func updateMFAAuthenticator( - type: AppwriteEnums.AuthenticatorType, + type: AuthenticatorType, otp: String ) async throws -> AppwriteModels.User<[String: AnyCodable]> { return try await updateMFAAuthenticator( @@ -583,13 +583,13 @@ open class Account: Service { /// Delete an authenticator for a user by ID. /// /// - Parameters: - /// - type: AppwriteEnums.AuthenticatorType + /// - type: AuthenticatorType /// - Throws: Exception if the request fails /// - Returns: Any /// @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.") open func deleteMfaAuthenticator( - type: AppwriteEnums.AuthenticatorType + type: AuthenticatorType ) async throws -> Any { let apiPath: String = "/account/mfa/authenticators/{type}" .replacingOccurrences(of: "{type}", with: type.rawValue) @@ -611,12 +611,12 @@ open class Account: Service { /// Delete an authenticator for a user by ID. /// /// - Parameters: - /// - type: AppwriteEnums.AuthenticatorType + /// - type: AuthenticatorType /// - Throws: Exception if the request fails /// - Returns: Any /// open func deleteMFAAuthenticator( - type: AppwriteEnums.AuthenticatorType + type: AuthenticatorType ) async throws -> Any { let apiPath: String = "/account/mfa/authenticators/{type}" .replacingOccurrences(of: "{type}", with: type.rawValue) @@ -640,13 +640,13 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - factor: AppwriteEnums.AuthenticationFactor + /// - factor: AuthenticationFactor /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaChallenge /// @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.") open func createMfaChallenge( - factor: AppwriteEnums.AuthenticationFactor + factor: AuthenticationFactor ) async throws -> AppwriteModels.MfaChallenge { let apiPath: String = "/account/mfa/challenge" @@ -677,12 +677,12 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - factor: AppwriteEnums.AuthenticationFactor + /// - factor: AuthenticationFactor /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaChallenge /// open func createMFAChallenge( - factor: AppwriteEnums.AuthenticationFactor + factor: AuthenticationFactor ) async throws -> AppwriteModels.MfaChallenge { let apiPath: String = "/account/mfa/challenge" @@ -1596,7 +1596,7 @@ open class Account: Service { /// /// /// - Parameters: - /// - provider: AppwriteEnums.OAuthProvider + /// - provider: OAuthProvider /// - success: String (optional) /// - failure: String (optional) /// - scopes: [String] (optional) @@ -1605,7 +1605,7 @@ open class Account: Service { /// @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) open func createOAuth2Session( - provider: AppwriteEnums.OAuthProvider, + provider: OAuthProvider, success: String? = nil, failure: String? = nil, scopes: [String]? = nil @@ -2101,7 +2101,7 @@ open class Account: Service { /// limits](https://appwrite.io/docs/authentication-security#limits). /// /// - Parameters: - /// - provider: AppwriteEnums.OAuthProvider + /// - provider: OAuthProvider /// - success: String (optional) /// - failure: String (optional) /// - scopes: [String] (optional) @@ -2110,7 +2110,7 @@ open class Account: Service { /// @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) open func createOAuth2Token( - provider: AppwriteEnums.OAuthProvider, + provider: OAuthProvider, success: String? = nil, failure: String? = nil, scopes: [String]? = nil diff --git a/Sources/Appwrite/Services/Avatars.swift b/Sources/Appwrite/Services/Avatars.swift index 9acfaf2..8eb2434 100644 --- a/Sources/Appwrite/Services/Avatars.swift +++ b/Sources/Appwrite/Services/Avatars.swift @@ -21,7 +21,7 @@ open class Avatars: Service { /// of image returned is 100x100px. /// /// - Parameters: - /// - code: AppwriteEnums.Browser + /// - code: Browser /// - width: Int (optional) /// - height: Int (optional) /// - quality: Int (optional) @@ -29,7 +29,7 @@ open class Avatars: Service { /// - Returns: ByteBuffer /// open func getBrowser( - code: AppwriteEnums.Browser, + code: Browser, width: Int? = nil, height: Int? = nil, quality: Int? = nil @@ -63,7 +63,7 @@ open class Avatars: Service { /// /// /// - Parameters: - /// - code: AppwriteEnums.CreditCard + /// - code: CreditCard /// - width: Int (optional) /// - height: Int (optional) /// - quality: Int (optional) @@ -71,7 +71,7 @@ open class Avatars: Service { /// - Returns: ByteBuffer /// open func getCreditCard( - code: AppwriteEnums.CreditCard, + code: CreditCard, width: Int? = nil, height: Int? = nil, quality: Int? = nil @@ -134,7 +134,7 @@ open class Avatars: Service { /// /// /// - Parameters: - /// - code: AppwriteEnums.Flag + /// - code: Flag /// - width: Int (optional) /// - height: Int (optional) /// - quality: Int (optional) @@ -142,7 +142,7 @@ open class Avatars: Service { /// - Returns: ByteBuffer /// open func getFlag( - code: AppwriteEnums.Flag, + code: Flag, width: Int? = nil, height: Int? = nil, quality: Int? = nil diff --git a/Sources/Appwrite/Services/Functions.swift b/Sources/Appwrite/Services/Functions.swift index 21dea14..c29f737 100644 --- a/Sources/Appwrite/Services/Functions.swift +++ b/Sources/Appwrite/Services/Functions.swift @@ -55,7 +55,7 @@ open class Functions: Service { /// - body: String (optional) /// - async: Bool (optional) /// - path: String (optional) - /// - method: AppwriteEnums.ExecutionMethod (optional) + /// - method: ExecutionMethod (optional) /// - headers: Any (optional) /// - scheduledAt: String (optional) /// - Throws: Exception if the request fails @@ -66,7 +66,7 @@ open class Functions: Service { body: String? = nil, async: Bool? = nil, path: String? = nil, - method: AppwriteEnums.ExecutionMethod? = nil, + method: ExecutionMethod? = nil, headers: Any? = nil, scheduledAt: String? = nil ) async throws -> AppwriteModels.Execution { diff --git a/Sources/Appwrite/Services/Storage.swift b/Sources/Appwrite/Services/Storage.swift index 1dd7621..e6e46d1 100644 --- a/Sources/Appwrite/Services/Storage.swift +++ b/Sources/Appwrite/Services/Storage.swift @@ -267,7 +267,7 @@ open class Storage: Service { /// - fileId: String /// - width: Int (optional) /// - height: Int (optional) - /// - gravity: AppwriteEnums.ImageGravity (optional) + /// - gravity: ImageGravity (optional) /// - quality: Int (optional) /// - borderWidth: Int (optional) /// - borderColor: String (optional) @@ -275,7 +275,7 @@ open class Storage: Service { /// - opacity: Double (optional) /// - rotation: Int (optional) /// - background: String (optional) - /// - output: AppwriteEnums.ImageFormat (optional) + /// - output: ImageFormat (optional) /// - token: String (optional) /// - Throws: Exception if the request fails /// - Returns: ByteBuffer @@ -285,7 +285,7 @@ open class Storage: Service { fileId: String, width: Int? = nil, height: Int? = nil, - gravity: AppwriteEnums.ImageGravity? = nil, + gravity: ImageGravity? = nil, quality: Int? = nil, borderWidth: Int? = nil, borderColor: String? = nil, @@ -293,7 +293,7 @@ open class Storage: Service { opacity: Double? = nil, rotation: Int? = nil, background: String? = nil, - output: AppwriteEnums.ImageFormat? = nil, + output: ImageFormat? = nil, token: String? = nil ) async throws -> ByteBuffer { let apiPath: String = "/storage/buckets/{bucketId}/files/{fileId}/preview" diff --git a/Sources/AppwriteEnums/ExecutionStatus.swift b/Sources/AppwriteEnums/ExecutionStatus.swift new file mode 100644 index 0000000..2f167a9 --- /dev/null +++ b/Sources/AppwriteEnums/ExecutionStatus.swift @@ -0,0 +1,12 @@ +import Foundation + +public enum ExecutionStatus: String, CustomStringConvertible { + case waiting = "waiting" + case processing = "processing" + case completed = "completed" + case failed = "failed" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/ExecutionTrigger.swift b/Sources/AppwriteEnums/ExecutionTrigger.swift new file mode 100644 index 0000000..8aecde3 --- /dev/null +++ b/Sources/AppwriteEnums/ExecutionTrigger.swift @@ -0,0 +1,11 @@ +import Foundation + +public enum ExecutionTrigger: String, CustomStringConvertible { + case http = "http" + case schedule = "schedule" + case event = "event" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index 069264b..7972e32 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// Execution open class Execution: Codable { @@ -44,10 +45,10 @@ open class Execution: Codable { public let deploymentId: String /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - public let trigger: String + public let trigger: ExecutionTrigger /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - public let status: String + public let status: ExecutionStatus /// HTTP request method type. public let requestMethod: String @@ -87,8 +88,8 @@ open class Execution: Codable { permissions: [String], functionId: String, deploymentId: String, - trigger: String, - status: String, + trigger: ExecutionTrigger, + status: ExecutionStatus, requestMethod: String, requestPath: String, requestHeaders: [Headers], @@ -129,8 +130,8 @@ open class Execution: Codable { self.permissions = try container.decode([String].self, forKey: .permissions) self.functionId = try container.decode(String.self, forKey: .functionId) self.deploymentId = try container.decode(String.self, forKey: .deploymentId) - self.trigger = try container.decode(String.self, forKey: .trigger) - self.status = try container.decode(String.self, forKey: .status) + self.trigger = ExecutionTrigger(rawValue: try container.decode(String.self, forKey: .trigger))! + self.status = ExecutionStatus(rawValue: try container.decode(String.self, forKey: .status))! self.requestMethod = try container.decode(String.self, forKey: .requestMethod) self.requestPath = try container.decode(String.self, forKey: .requestPath) self.requestHeaders = try container.decode([Headers].self, forKey: .requestHeaders) @@ -152,8 +153,8 @@ open class Execution: Codable { try container.encode(permissions, forKey: .permissions) try container.encode(functionId, forKey: .functionId) try container.encode(deploymentId, forKey: .deploymentId) - try container.encode(trigger, forKey: .trigger) - try container.encode(status, forKey: .status) + try container.encode(trigger.rawValue, forKey: .trigger) + try container.encode(status.rawValue, forKey: .status) try container.encode(requestMethod, forKey: .requestMethod) try container.encode(requestPath, forKey: .requestPath) try container.encode(requestHeaders, forKey: .requestHeaders) @@ -174,8 +175,8 @@ open class Execution: Codable { "$permissions": permissions as Any, "functionId": functionId as Any, "deploymentId": deploymentId as Any, - "trigger": trigger as Any, - "status": status as Any, + "trigger": trigger.rawValue as Any, + "status": status.rawValue as Any, "requestMethod": requestMethod as Any, "requestPath": requestPath as Any, "requestHeaders": requestHeaders.map { $0.toMap() } as Any, @@ -197,8 +198,8 @@ open class Execution: Codable { permissions: map["$permissions"] as! [String], functionId: map["functionId"] as! String, deploymentId: map["deploymentId"] as! String, - trigger: map["trigger"] as! String, - status: map["status"] as! String, + trigger: ExecutionTrigger(rawValue: map["trigger"] as! String)!, + status: ExecutionStatus(rawValue: map["status"] as! String)!, requestMethod: map["requestMethod"] as! String, requestPath: map["requestPath"] as! String, requestHeaders: (map["requestHeaders"] as! [[String: Any]]).map { Headers.from(map: $0) }, From 966fb3385ac22573b80a508df5b9eb3130b6f995 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 1 Oct 2025 04:34:29 +0000 Subject: [PATCH 2/3] regen --- Sources/Appwrite/Client.swift | 2 +- Sources/Appwrite/Query.swift | 6 +++ Sources/Appwrite/Services/Account.swift | 48 +++++++++++------------ Sources/Appwrite/Services/Avatars.swift | 12 +++--- Sources/Appwrite/Services/Functions.swift | 4 +- Sources/Appwrite/Services/Storage.swift | 8 ++-- Sources/AppwriteModels/Document.swift | 2 +- Sources/AppwriteModels/Execution.swift | 12 +++--- Sources/AppwriteModels/Preferences.swift | 2 +- Sources/AppwriteModels/Row.swift | 2 +- 10 files changed, 52 insertions(+), 46 deletions(-) diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 6af2bd0..3179fd6 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -354,7 +354,7 @@ open class Client { if let warning = response.headers["x-appwrite-warning"].first { warning.split(separator: ";").forEach { warning in - print("Warning: \(warning)") + fputs("Warning: \(warning)\n", stderr) } } diff --git a/Sources/Appwrite/Query.swift b/Sources/Appwrite/Query.swift index 5af7f4a..e4f06b5 100644 --- a/Sources/Appwrite/Query.swift +++ b/Sources/Appwrite/Query.swift @@ -280,6 +280,12 @@ public struct Query : Codable, CustomStringConvertible { ).description } + public static func orderRandom() -> String { + return Query( + method: "orderRandom" + ).description + } + public static func cursorBefore(_ id: String) -> String { return Query( method: "cursorBefore", diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index ad2efba..9457229 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -387,13 +387,13 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AuthenticatorType + /// - type: AppwriteEnums.AuthenticatorType /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaType /// @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.") open func createMfaAuthenticator( - type: AuthenticatorType + type: AppwriteEnums.AuthenticatorType ) async throws -> AppwriteModels.MfaType { let apiPath: String = "/account/mfa/authenticators/{type}" .replacingOccurrences(of: "{type}", with: type.rawValue) @@ -424,12 +424,12 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AuthenticatorType + /// - type: AppwriteEnums.AuthenticatorType /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaType /// open func createMFAAuthenticator( - type: AuthenticatorType + type: AppwriteEnums.AuthenticatorType ) async throws -> AppwriteModels.MfaType { let apiPath: String = "/account/mfa/authenticators/{type}" .replacingOccurrences(of: "{type}", with: type.rawValue) @@ -459,14 +459,14 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AuthenticatorType + /// - type: AppwriteEnums.AuthenticatorType /// - otp: String /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.") open func updateMfaAuthenticator( - type: AuthenticatorType, + type: AppwriteEnums.AuthenticatorType, otp: String, nestedType: T.Type ) async throws -> AppwriteModels.User { @@ -500,14 +500,14 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AuthenticatorType + /// - type: AppwriteEnums.AuthenticatorType /// - otp: String /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.") open func updateMfaAuthenticator( - type: AuthenticatorType, + type: AppwriteEnums.AuthenticatorType, otp: String ) async throws -> AppwriteModels.User<[String: AnyCodable]> { return try await updateMfaAuthenticator( @@ -523,13 +523,13 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AuthenticatorType + /// - type: AppwriteEnums.AuthenticatorType /// - otp: String /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// open func updateMFAAuthenticator( - type: AuthenticatorType, + type: AppwriteEnums.AuthenticatorType, otp: String, nestedType: T.Type ) async throws -> AppwriteModels.User { @@ -563,13 +563,13 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - type: AuthenticatorType + /// - type: AppwriteEnums.AuthenticatorType /// - otp: String /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// open func updateMFAAuthenticator( - type: AuthenticatorType, + type: AppwriteEnums.AuthenticatorType, otp: String ) async throws -> AppwriteModels.User<[String: AnyCodable]> { return try await updateMFAAuthenticator( @@ -583,13 +583,13 @@ open class Account: Service { /// Delete an authenticator for a user by ID. /// /// - Parameters: - /// - type: AuthenticatorType + /// - type: AppwriteEnums.AuthenticatorType /// - Throws: Exception if the request fails /// - Returns: Any /// @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.") open func deleteMfaAuthenticator( - type: AuthenticatorType + type: AppwriteEnums.AuthenticatorType ) async throws -> Any { let apiPath: String = "/account/mfa/authenticators/{type}" .replacingOccurrences(of: "{type}", with: type.rawValue) @@ -611,12 +611,12 @@ open class Account: Service { /// Delete an authenticator for a user by ID. /// /// - Parameters: - /// - type: AuthenticatorType + /// - type: AppwriteEnums.AuthenticatorType /// - Throws: Exception if the request fails /// - Returns: Any /// open func deleteMFAAuthenticator( - type: AuthenticatorType + type: AppwriteEnums.AuthenticatorType ) async throws -> Any { let apiPath: String = "/account/mfa/authenticators/{type}" .replacingOccurrences(of: "{type}", with: type.rawValue) @@ -640,13 +640,13 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - factor: AuthenticationFactor + /// - factor: AppwriteEnums.AuthenticationFactor /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaChallenge /// @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.") open func createMfaChallenge( - factor: AuthenticationFactor + factor: AppwriteEnums.AuthenticationFactor ) async throws -> AppwriteModels.MfaChallenge { let apiPath: String = "/account/mfa/challenge" @@ -677,12 +677,12 @@ open class Account: Service { /// method. /// /// - Parameters: - /// - factor: AuthenticationFactor + /// - factor: AppwriteEnums.AuthenticationFactor /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaChallenge /// open func createMFAChallenge( - factor: AuthenticationFactor + factor: AppwriteEnums.AuthenticationFactor ) async throws -> AppwriteModels.MfaChallenge { let apiPath: String = "/account/mfa/challenge" @@ -1596,7 +1596,7 @@ open class Account: Service { /// /// /// - Parameters: - /// - provider: OAuthProvider + /// - provider: AppwriteEnums.OAuthProvider /// - success: String (optional) /// - failure: String (optional) /// - scopes: [String] (optional) @@ -1605,7 +1605,7 @@ open class Account: Service { /// @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) open func createOAuth2Session( - provider: OAuthProvider, + provider: AppwriteEnums.OAuthProvider, success: String? = nil, failure: String? = nil, scopes: [String]? = nil @@ -2101,7 +2101,7 @@ open class Account: Service { /// limits](https://appwrite.io/docs/authentication-security#limits). /// /// - Parameters: - /// - provider: OAuthProvider + /// - provider: AppwriteEnums.OAuthProvider /// - success: String (optional) /// - failure: String (optional) /// - scopes: [String] (optional) @@ -2110,7 +2110,7 @@ open class Account: Service { /// @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) open func createOAuth2Token( - provider: OAuthProvider, + provider: AppwriteEnums.OAuthProvider, success: String? = nil, failure: String? = nil, scopes: [String]? = nil diff --git a/Sources/Appwrite/Services/Avatars.swift b/Sources/Appwrite/Services/Avatars.swift index 8eb2434..9acfaf2 100644 --- a/Sources/Appwrite/Services/Avatars.swift +++ b/Sources/Appwrite/Services/Avatars.swift @@ -21,7 +21,7 @@ open class Avatars: Service { /// of image returned is 100x100px. /// /// - Parameters: - /// - code: Browser + /// - code: AppwriteEnums.Browser /// - width: Int (optional) /// - height: Int (optional) /// - quality: Int (optional) @@ -29,7 +29,7 @@ open class Avatars: Service { /// - Returns: ByteBuffer /// open func getBrowser( - code: Browser, + code: AppwriteEnums.Browser, width: Int? = nil, height: Int? = nil, quality: Int? = nil @@ -63,7 +63,7 @@ open class Avatars: Service { /// /// /// - Parameters: - /// - code: CreditCard + /// - code: AppwriteEnums.CreditCard /// - width: Int (optional) /// - height: Int (optional) /// - quality: Int (optional) @@ -71,7 +71,7 @@ open class Avatars: Service { /// - Returns: ByteBuffer /// open func getCreditCard( - code: CreditCard, + code: AppwriteEnums.CreditCard, width: Int? = nil, height: Int? = nil, quality: Int? = nil @@ -134,7 +134,7 @@ open class Avatars: Service { /// /// /// - Parameters: - /// - code: Flag + /// - code: AppwriteEnums.Flag /// - width: Int (optional) /// - height: Int (optional) /// - quality: Int (optional) @@ -142,7 +142,7 @@ open class Avatars: Service { /// - Returns: ByteBuffer /// open func getFlag( - code: Flag, + code: AppwriteEnums.Flag, width: Int? = nil, height: Int? = nil, quality: Int? = nil diff --git a/Sources/Appwrite/Services/Functions.swift b/Sources/Appwrite/Services/Functions.swift index c29f737..21dea14 100644 --- a/Sources/Appwrite/Services/Functions.swift +++ b/Sources/Appwrite/Services/Functions.swift @@ -55,7 +55,7 @@ open class Functions: Service { /// - body: String (optional) /// - async: Bool (optional) /// - path: String (optional) - /// - method: ExecutionMethod (optional) + /// - method: AppwriteEnums.ExecutionMethod (optional) /// - headers: Any (optional) /// - scheduledAt: String (optional) /// - Throws: Exception if the request fails @@ -66,7 +66,7 @@ open class Functions: Service { body: String? = nil, async: Bool? = nil, path: String? = nil, - method: ExecutionMethod? = nil, + method: AppwriteEnums.ExecutionMethod? = nil, headers: Any? = nil, scheduledAt: String? = nil ) async throws -> AppwriteModels.Execution { diff --git a/Sources/Appwrite/Services/Storage.swift b/Sources/Appwrite/Services/Storage.swift index e6e46d1..1dd7621 100644 --- a/Sources/Appwrite/Services/Storage.swift +++ b/Sources/Appwrite/Services/Storage.swift @@ -267,7 +267,7 @@ open class Storage: Service { /// - fileId: String /// - width: Int (optional) /// - height: Int (optional) - /// - gravity: ImageGravity (optional) + /// - gravity: AppwriteEnums.ImageGravity (optional) /// - quality: Int (optional) /// - borderWidth: Int (optional) /// - borderColor: String (optional) @@ -275,7 +275,7 @@ open class Storage: Service { /// - opacity: Double (optional) /// - rotation: Int (optional) /// - background: String (optional) - /// - output: ImageFormat (optional) + /// - output: AppwriteEnums.ImageFormat (optional) /// - token: String (optional) /// - Throws: Exception if the request fails /// - Returns: ByteBuffer @@ -285,7 +285,7 @@ open class Storage: Service { fileId: String, width: Int? = nil, height: Int? = nil, - gravity: ImageGravity? = nil, + gravity: AppwriteEnums.ImageGravity? = nil, quality: Int? = nil, borderWidth: Int? = nil, borderColor: String? = nil, @@ -293,7 +293,7 @@ open class Storage: Service { opacity: Double? = nil, rotation: Int? = nil, background: String? = nil, - output: ImageFormat? = nil, + output: AppwriteEnums.ImageFormat? = nil, token: String? = nil ) async throws -> ByteBuffer { let apiPath: String = "/storage/buckets/{bucketId}/files/{fileId}/preview" diff --git a/Sources/AppwriteModels/Document.swift b/Sources/AppwriteModels/Document.swift index f076cc5..763db10 100644 --- a/Sources/AppwriteModels/Document.swift +++ b/Sources/AppwriteModels/Document.swift @@ -107,7 +107,7 @@ open class Document: Codable { createdAt: map["$createdAt"] as? String ?? "", updatedAt: map["$updatedAt"] as? String ?? "", permissions: map["$permissions"] as? [String] ?? [], - data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) + data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map["data"] as? [String: Any] ?? map, options: [])) ) } } diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index 7972e32..47d7734 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -45,10 +45,10 @@ open class Execution: Codable { public let deploymentId: String /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - public let trigger: ExecutionTrigger + public let trigger: AppwriteEnums.ExecutionTrigger /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - public let status: ExecutionStatus + public let status: AppwriteEnums.ExecutionStatus /// HTTP request method type. public let requestMethod: String @@ -88,8 +88,8 @@ open class Execution: Codable { permissions: [String], functionId: String, deploymentId: String, - trigger: ExecutionTrigger, - status: ExecutionStatus, + trigger: AppwriteEnums.ExecutionTrigger, + status: AppwriteEnums.ExecutionStatus, requestMethod: String, requestPath: String, requestHeaders: [Headers], @@ -130,8 +130,8 @@ open class Execution: Codable { self.permissions = try container.decode([String].self, forKey: .permissions) self.functionId = try container.decode(String.self, forKey: .functionId) self.deploymentId = try container.decode(String.self, forKey: .deploymentId) - self.trigger = ExecutionTrigger(rawValue: try container.decode(String.self, forKey: .trigger))! - self.status = ExecutionStatus(rawValue: try container.decode(String.self, forKey: .status))! + self.trigger = AppwriteEnums.ExecutionTrigger(rawValue: try container.decode(String.self, forKey: .trigger))! + self.status = AppwriteEnums.ExecutionStatus(rawValue: try container.decode(String.self, forKey: .status))! self.requestMethod = try container.decode(String.self, forKey: .requestMethod) self.requestPath = try container.decode(String.self, forKey: .requestPath) self.requestHeaders = try container.decode([Headers].self, forKey: .requestHeaders) diff --git a/Sources/AppwriteModels/Preferences.swift b/Sources/AppwriteModels/Preferences.swift index 41f94e6..aff6dfe 100644 --- a/Sources/AppwriteModels/Preferences.swift +++ b/Sources/AppwriteModels/Preferences.swift @@ -37,7 +37,7 @@ open class Preferences: Codable { public static func from(map: [String: Any] ) -> Preferences { return Preferences( - data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) + data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map["data"] as? [String: Any] ?? map, options: [])) ) } } diff --git a/Sources/AppwriteModels/Row.swift b/Sources/AppwriteModels/Row.swift index 6e94a9e..5c6a215 100644 --- a/Sources/AppwriteModels/Row.swift +++ b/Sources/AppwriteModels/Row.swift @@ -107,7 +107,7 @@ open class Row: Codable { createdAt: map["$createdAt"] as! String, updatedAt: map["$updatedAt"] as! String, permissions: map["$permissions"] as! [String], - data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) + data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map["data"] as? [String: Any] ?? map, options: [])) ) } } From a32b4e50a7927037e78e7e88694888d05cf050cc Mon Sep 17 00:00:00 2001 From: root Date: Fri, 3 Oct 2025 03:06:23 +0000 Subject: [PATCH 3/3] chore: update title and desc --- README.md | 2 +- Sources/Appwrite/Client.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 17239a0..d3844d8 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies: ```swift dependencies: [ - .package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "12.2.0"), + .package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "13.0.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 3179fd6..3459d57 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -23,7 +23,7 @@ open class Client { "x-sdk-name": "Apple", "x-sdk-platform": "client", "x-sdk-language": "apple", - "x-sdk-version": "12.2.0", + "x-sdk-version": "13.0.0", "x-appwrite-response-format": "1.8.0" ]