diff --git a/.github/workflows/autoclose.yml b/.github/workflows/autoclose.yml new file mode 100644 index 0000000..3e2b3cb --- /dev/null +++ b/.github/workflows/autoclose.yml @@ -0,0 +1,11 @@ +name: Auto-close External Pull Requests + +on: + pull_request_target: + types: [opened, reopened] + +jobs: + auto_close: + uses: appwrite/.github/.github/workflows/autoclose.yml@main + secrets: + GH_AUTO_CLOSE_PR_TOKEN: ${{ secrets.GH_AUTO_CLOSE_PR_TOKEN }} diff --git a/README.md b/README.md index b0310bc..a76390e 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: "7.0.0"), + .package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "7.1.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 13754d1..c2d0fd0 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": "7.0.0", + "x-sdk-version": "7.1.0", "x-appwrite-response-format": "1.6.0" ] @@ -464,23 +464,23 @@ open class Client { if param is String || param is Int || param is Float + || param is Double || param is Bool || param is [String] || param is [Int] || param is [Float] + || param is [Double] || param is [Bool] || param is [String: Any] || param is [Int: Any] || param is [Float: Any] + || param is [Double: Any] || param is [Bool: Any] { encodedParams[key] = param - } else { - let value = try! (param as! Encodable).toJson() - - let range = value.index(value.startIndex, offsetBy: 1)..) -> Void]() + #if canImport(AuthenticationServices) + private static var currentAuthSession: ASWebAuthenticationSession? + #endif /// /// Authenticate Session with OAuth2 @@ -41,9 +39,29 @@ public class WebAuthComponent { ) { callbacks[callbackScheme] = onComplete - #if canImport(SwiftUI) - openURL(url) - #endif + #if canImport(AuthenticationServices) + currentAuthSession = ASWebAuthenticationSession( + url: url, + callbackURLScheme: callbackScheme + ) { callbackURL, error in + if let error = error { + cleanUp() + } else if let callbackURL = callbackURL { + // handle cookies here itself! + WebAuthComponent.handleIncomingCookie(from: callbackURL) + cleanUp() + } + } + + if let session = currentAuthSession { + /// Indicates that the session should be a private session. + session.prefersEphemeralWebBrowserSession = true + session.presentationContextProvider = PresentationContextProvider.shared + session.start() + } else { + print("Failed to create ASWebAuthenticationSession") + } + #endif } /// @@ -130,5 +148,24 @@ public class WebAuthComponent { callbacks.forEach { (_, callback) in callback(.failure(AppwriteError(message: "User cancelled login."))) } + + #if canImport(AuthenticationServices) + currentAuthSession = nil + #endif + } +} + +#if canImport(AuthenticationServices) +/// Presentation context for the ASWebAuthenticationSession. +class PresentationContextProvider: NSObject, ASWebAuthenticationPresentationContextProviding { + static let shared = PresentationContextProvider() + + func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor { + if let mainWindow = OSApplication.shared.windows.first { $0.isKeyWindow } { + return mainWindow + } + + return ASPresentationAnchor() } } +#endif \ No newline at end of file diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 87e1b98..f3e6d28 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -214,7 +214,7 @@ open class Account: Service { } /// - /// List Identities + /// List identities /// /// Get the list of identities for the currently logged in user. /// @@ -402,7 +402,7 @@ open class Account: Service { } /// - /// Create Authenticator + /// Create authenticator /// /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify @@ -439,7 +439,7 @@ open class Account: Service { } /// - /// Verify Authenticator + /// Verify authenticator /// /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) @@ -480,7 +480,7 @@ open class Account: Service { } /// - /// Verify Authenticator + /// Verify authenticator /// /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) @@ -503,7 +503,7 @@ open class Account: Service { } /// - /// Delete Authenticator + /// Delete authenticator /// /// Delete an authenticator for a user by ID. /// @@ -531,7 +531,7 @@ open class Account: Service { } /// - /// Create MFA 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) @@ -568,7 +568,7 @@ open class Account: Service { } /// - /// Create MFA Challenge (confirmation) + /// Create MFA challenge (confirmation) /// /// Complete the MFA challenge by providing the one-time password. Finish the /// process of MFA verification by providing the one-time password. To begin @@ -604,7 +604,7 @@ open class Account: Service { } /// - /// List Factors + /// List factors /// /// List the factors available on the account to be used as a MFA challange. /// @@ -635,7 +635,7 @@ open class Account: Service { } /// - /// Get MFA Recovery Codes + /// Get MFA recovery codes /// /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using @@ -669,7 +669,7 @@ open class Account: Service { } /// - /// Create MFA Recovery Codes + /// Create MFA recovery codes /// /// Generate recovery codes as backup for MFA flow. It's recommended to /// generate and show then immediately after user successfully adds their @@ -704,7 +704,7 @@ open class Account: Service { } /// - /// Regenerate MFA Recovery Codes + /// Regenerate MFA recovery codes /// /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using @@ -1350,12 +1350,16 @@ open class Account: Service { let callbackScheme = "appwrite-callback-\(client.config["project"] ?? "")" _ = try await withCheckedThrowingContinuation { continuation in - WebAuthComponent.authenticate(url: url, callbackScheme: callbackScheme) { result in - continuation.resume(with: result) + /// main thread for PresentationContextProvider + DispatchQueue.main.async { + WebAuthComponent.authenticate(url: url, callbackScheme: callbackScheme) { result in + continuation.resume(with: result) + } } } - + return true + } /// @@ -1849,12 +1853,16 @@ open class Account: Service { let callbackScheme = "appwrite-callback-\(client.config["project"] ?? "")" _ = try await withCheckedThrowingContinuation { continuation in - WebAuthComponent.authenticate(url: url, callbackScheme: callbackScheme) { result in - continuation.resume(with: result) + /// main thread for PresentationContextProvider + DispatchQueue.main.async { + WebAuthComponent.authenticate(url: url, callbackScheme: callbackScheme) { result in + continuation.resume(with: result) + } } } - + return true + } /// diff --git a/Sources/Appwrite/Services/Locale.swift b/Sources/Appwrite/Services/Locale.swift index 3ad37de..170e11a 100644 --- a/Sources/Appwrite/Services/Locale.swift +++ b/Sources/Appwrite/Services/Locale.swift @@ -45,7 +45,7 @@ open class Locale: Service { } /// - /// List Locale Codes + /// List locale codes /// /// List of all locale codes in [ISO /// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). diff --git a/Sources/Appwrite/Services/Realtime.swift b/Sources/Appwrite/Services/Realtime.swift index 3bc2e9e..ecc4a05 100644 --- a/Sources/Appwrite/Services/Realtime.swift +++ b/Sources/Appwrite/Services/Realtime.swift @@ -7,11 +7,14 @@ open class Realtime : Service { private let TYPE_ERROR = "error" private let TYPE_EVENT = "event" + private let TYPE_PONG = "pong" private let DEBOUNCE_NANOS = 1_000_000 + private let HEARTBEAT_INTERVAL: UInt64 = 20_000_000_000 // 20 seconds in nanoseconds private var socketClient: WebSocketClient? = nil private var activeChannels = Set() private var activeSubscriptions = [Int: RealtimeCallback]() + private var heartbeatTask: Task? = nil let connectSync = DispatchQueue(label: "ConnectSync") @@ -20,6 +23,29 @@ open class Realtime : Service { private var subscriptionsCounter = 0 private var reconnect = true + private func startHeartbeat() { + stopHeartbeat() + heartbeatTask = Task { + do { + while !Task.isCancelled { + if let client = socketClient, client.isConnected { + client.send(text: #"{"type": "ping"}"#) + } + try await Task.sleep(nanoseconds: HEARTBEAT_INTERVAL) + } + } catch { + if !Task.isCancelled { + print("Heartbeat task failed: \(error.localizedDescription)") + } + } + } + } + + private func stopHeartbeat() { + heartbeatTask?.cancel() + heartbeatTask = nil + } + private func createSocket() async throws { guard activeChannels.count > 0 else { reconnect = false @@ -50,6 +76,8 @@ open class Realtime : Service { } private func closeSocket() async throws { + stopHeartbeat() + guard let client = socketClient, let group = client.threadGroup else { return @@ -163,6 +191,7 @@ extension Realtime: WebSocketClientDelegate { public func onOpen(channel: Channel) { self.reconnectAttempts = 0 + startHeartbeat() } public func onMessage(text: String) { @@ -172,6 +201,7 @@ extension Realtime: WebSocketClientDelegate { switch type { case TYPE_ERROR: try! handleResponseError(from: json) case TYPE_EVENT: handleResponseEvent(from: json) + case TYPE_PONG: break // Handle pong response if needed default: break } } @@ -179,6 +209,8 @@ extension Realtime: WebSocketClientDelegate { } public func onClose(channel: Channel, data: Data) async throws { + stopHeartbeat() + if (!reconnect) { reconnect = true return @@ -196,6 +228,7 @@ extension Realtime: WebSocketClientDelegate { } public func onError(error: Swift.Error?, status: HTTPResponseStatus?) { + stopHeartbeat() print(error?.localizedDescription ?? "Unknown error") } diff --git a/Sources/Appwrite/Services/Storage.swift b/Sources/Appwrite/Services/Storage.swift index 9823478..382ab83 100644 --- a/Sources/Appwrite/Services/Storage.swift +++ b/Sources/Appwrite/Services/Storage.swift @@ -200,7 +200,7 @@ open class Storage: Service { } /// - /// Delete File + /// Delete file /// /// Delete a file by its unique ID. Only users with write permissions have /// access to delete this resource. diff --git a/Sources/Appwrite/Services/Teams.swift b/Sources/Appwrite/Services/Teams.swift index b926efd..a4d3123 100644 --- a/Sources/Appwrite/Services/Teams.swift +++ b/Sources/Appwrite/Services/Teams.swift @@ -286,7 +286,8 @@ open class Teams: Service { /// List team memberships /// /// Use this endpoint to list a team's members using the team's ID. All team - /// members have read access to this endpoint. + /// members have read access to this endpoint. Hide sensitive attributes from + /// the response by toggling membership privacy in the Console. /// /// @param String teamId /// @param [String] queries @@ -401,7 +402,8 @@ open class Teams: Service { /// Get team membership /// /// Get a team member by the membership unique id. All team members have read - /// access for this resource. + /// access for this resource. Hide sensitive attributes from the response by + /// toggling membership privacy in the Console. /// /// @param String teamId /// @param String membershipId diff --git a/Sources/AppwriteEnums/AuthenticationFactor.swift b/Sources/AppwriteEnums/AuthenticationFactor.swift index c8f0559..1768544 100644 --- a/Sources/AppwriteEnums/AuthenticationFactor.swift +++ b/Sources/AppwriteEnums/AuthenticationFactor.swift @@ -1,13 +1,12 @@ import Foundation -public enum AuthenticationFactor: String, Codable { +public enum AuthenticationFactor: String, CustomStringConvertible { case email = "email" case phone = "phone" case totp = "totp" case recoverycode = "recoverycode" - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(rawValue) + public var description: String { + return rawValue } } diff --git a/Sources/AppwriteEnums/AuthenticatorType.swift b/Sources/AppwriteEnums/AuthenticatorType.swift index fd516fd..066e377 100644 --- a/Sources/AppwriteEnums/AuthenticatorType.swift +++ b/Sources/AppwriteEnums/AuthenticatorType.swift @@ -1,10 +1,9 @@ import Foundation -public enum AuthenticatorType: String, Codable { +public enum AuthenticatorType: String, CustomStringConvertible { case totp = "totp" - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(rawValue) + public var description: String { + return rawValue } } diff --git a/Sources/AppwriteEnums/Browser.swift b/Sources/AppwriteEnums/Browser.swift index dbc88fc..f1fd1d2 100644 --- a/Sources/AppwriteEnums/Browser.swift +++ b/Sources/AppwriteEnums/Browser.swift @@ -1,6 +1,6 @@ import Foundation -public enum Browser: String, Codable { +public enum Browser: String, CustomStringConvertible { case avantBrowser = "aa" case androidWebViewBeta = "an" case googleChrome = "ch" @@ -16,8 +16,7 @@ public enum Browser: String, Codable { case opera = "op" case operaNext = "on" - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(rawValue) + public var description: String { + return rawValue } } diff --git a/Sources/AppwriteEnums/CreditCard.swift b/Sources/AppwriteEnums/CreditCard.swift index 3720b54..0922fbc 100644 --- a/Sources/AppwriteEnums/CreditCard.swift +++ b/Sources/AppwriteEnums/CreditCard.swift @@ -1,6 +1,6 @@ import Foundation -public enum CreditCard: String, Codable { +public enum CreditCard: String, CustomStringConvertible { case americanExpress = "amex" case argencard = "argencard" case cabal = "cabal" @@ -18,8 +18,7 @@ public enum CreditCard: String, Codable { case mIR = "mir" case maestro = "maestro" - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(rawValue) + public var description: String { + return rawValue } } diff --git a/Sources/AppwriteEnums/ExecutionMethod.swift b/Sources/AppwriteEnums/ExecutionMethod.swift index b03f856..85111a6 100644 --- a/Sources/AppwriteEnums/ExecutionMethod.swift +++ b/Sources/AppwriteEnums/ExecutionMethod.swift @@ -1,6 +1,6 @@ import Foundation -public enum ExecutionMethod: String, Codable { +public enum ExecutionMethod: String, CustomStringConvertible { case gET = "GET" case pOST = "POST" case pUT = "PUT" @@ -8,8 +8,7 @@ public enum ExecutionMethod: String, Codable { case dELETE = "DELETE" case oPTIONS = "OPTIONS" - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(rawValue) + public var description: String { + return rawValue } } diff --git a/Sources/AppwriteEnums/Flag.swift b/Sources/AppwriteEnums/Flag.swift index c577fcf..53ebf33 100644 --- a/Sources/AppwriteEnums/Flag.swift +++ b/Sources/AppwriteEnums/Flag.swift @@ -1,6 +1,6 @@ import Foundation -public enum Flag: String, Codable { +public enum Flag: String, CustomStringConvertible { case afghanistan = "af" case angola = "ao" case albania = "al" @@ -197,8 +197,7 @@ public enum Flag: String, Codable { case zambia = "zm" case zimbabwe = "zw" - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(rawValue) + public var description: String { + return rawValue } } diff --git a/Sources/AppwriteEnums/ImageFormat.swift b/Sources/AppwriteEnums/ImageFormat.swift index f4f49ee..2081ed0 100644 --- a/Sources/AppwriteEnums/ImageFormat.swift +++ b/Sources/AppwriteEnums/ImageFormat.swift @@ -1,14 +1,14 @@ import Foundation -public enum ImageFormat: String, Codable { +public enum ImageFormat: String, CustomStringConvertible { case jpg = "jpg" case jpeg = "jpeg" case gif = "gif" case png = "png" case webp = "webp" + case avif = "avif" - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(rawValue) + public var description: String { + return rawValue } } diff --git a/Sources/AppwriteEnums/ImageGravity.swift b/Sources/AppwriteEnums/ImageGravity.swift index 1997ace..386f93d 100644 --- a/Sources/AppwriteEnums/ImageGravity.swift +++ b/Sources/AppwriteEnums/ImageGravity.swift @@ -1,6 +1,6 @@ import Foundation -public enum ImageGravity: String, Codable { +public enum ImageGravity: String, CustomStringConvertible { case center = "center" case topLeft = "top-left" case top = "top" @@ -11,8 +11,7 @@ public enum ImageGravity: String, Codable { case bottom = "bottom" case bottomRight = "bottom-right" - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(rawValue) + public var description: String { + return rawValue } } diff --git a/Sources/AppwriteEnums/OAuthProvider.swift b/Sources/AppwriteEnums/OAuthProvider.swift index 3414684..e00ba46 100644 --- a/Sources/AppwriteEnums/OAuthProvider.swift +++ b/Sources/AppwriteEnums/OAuthProvider.swift @@ -1,6 +1,6 @@ import Foundation -public enum OAuthProvider: String, Codable { +public enum OAuthProvider: String, CustomStringConvertible { case amazon = "amazon" case apple = "apple" case auth0 = "auth0" @@ -41,8 +41,7 @@ public enum OAuthProvider: String, Codable { case zoom = "zoom" case mock = "mock" - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(rawValue) + public var description: String { + return rawValue } } diff --git a/Sources/AppwriteModels/AlgoArgon2.swift b/Sources/AppwriteModels/AlgoArgon2.swift index b473771..c93c034 100644 --- a/Sources/AppwriteModels/AlgoArgon2.swift +++ b/Sources/AppwriteModels/AlgoArgon2.swift @@ -7,20 +7,16 @@ public class AlgoArgon2 { /// Algo type. public let type: String - /// Memory used to compute hash. public let memoryCost: Int - /// Amount of time consumed to compute hash public let timeCost: Int - /// Number of threads used to compute hash. public let threads: Int - init( type: String, memoryCost: Int, diff --git a/Sources/AppwriteModels/AlgoBcrypt.swift b/Sources/AppwriteModels/AlgoBcrypt.swift index 3635cec..8d59f2d 100644 --- a/Sources/AppwriteModels/AlgoBcrypt.swift +++ b/Sources/AppwriteModels/AlgoBcrypt.swift @@ -8,7 +8,6 @@ public class AlgoBcrypt { public let type: String - init( type: String ) { diff --git a/Sources/AppwriteModels/AlgoMd5.swift b/Sources/AppwriteModels/AlgoMd5.swift index db970a6..050fe5c 100644 --- a/Sources/AppwriteModels/AlgoMd5.swift +++ b/Sources/AppwriteModels/AlgoMd5.swift @@ -8,7 +8,6 @@ public class AlgoMd5 { public let type: String - init( type: String ) { diff --git a/Sources/AppwriteModels/AlgoPhpass.swift b/Sources/AppwriteModels/AlgoPhpass.swift index fe960fb..493463d 100644 --- a/Sources/AppwriteModels/AlgoPhpass.swift +++ b/Sources/AppwriteModels/AlgoPhpass.swift @@ -8,7 +8,6 @@ public class AlgoPhpass { public let type: String - init( type: String ) { diff --git a/Sources/AppwriteModels/AlgoScrypt.swift b/Sources/AppwriteModels/AlgoScrypt.swift index 8821bfb..73254f2 100644 --- a/Sources/AppwriteModels/AlgoScrypt.swift +++ b/Sources/AppwriteModels/AlgoScrypt.swift @@ -7,24 +7,19 @@ public class AlgoScrypt { /// Algo type. public let type: String - /// CPU complexity of computed hash. public let costCpu: Int - /// Memory complexity of computed hash. public let costMemory: Int - /// Parallelization of computed hash. public let costParallel: Int - /// Length used to compute hash. public let length: Int - init( type: String, costCpu: Int, diff --git a/Sources/AppwriteModels/AlgoScryptModified.swift b/Sources/AppwriteModels/AlgoScryptModified.swift index 0adf147..bc1fde5 100644 --- a/Sources/AppwriteModels/AlgoScryptModified.swift +++ b/Sources/AppwriteModels/AlgoScryptModified.swift @@ -7,20 +7,16 @@ public class AlgoScryptModified { /// Algo type. public let type: String - /// Salt used to compute hash. public let salt: String - /// Separator used to compute hash. public let saltSeparator: String - /// Key used to compute hash. public let signerKey: String - init( type: String, salt: String, diff --git a/Sources/AppwriteModels/AlgoSha.swift b/Sources/AppwriteModels/AlgoSha.swift index 88d6bfc..c0a0532 100644 --- a/Sources/AppwriteModels/AlgoSha.swift +++ b/Sources/AppwriteModels/AlgoSha.swift @@ -8,7 +8,6 @@ public class AlgoSha { public let type: String - init( type: String ) { diff --git a/Sources/AppwriteModels/Continent.swift b/Sources/AppwriteModels/Continent.swift index 7eb40b9..f181353 100644 --- a/Sources/AppwriteModels/Continent.swift +++ b/Sources/AppwriteModels/Continent.swift @@ -7,12 +7,10 @@ public class Continent { /// Continent name. public let name: String - /// Continent two letter code. public let code: String - init( name: String, code: String diff --git a/Sources/AppwriteModels/ContinentList.swift b/Sources/AppwriteModels/ContinentList.swift index 0b60954..3cd7620 100644 --- a/Sources/AppwriteModels/ContinentList.swift +++ b/Sources/AppwriteModels/ContinentList.swift @@ -7,12 +7,10 @@ public class ContinentList { /// Total number of continents documents that matched your query. public let total: Int - /// List of continents. public let continents: [Continent] - init( total: Int, continents: [Continent] diff --git a/Sources/AppwriteModels/Country.swift b/Sources/AppwriteModels/Country.swift index 5a79308..3ce533b 100644 --- a/Sources/AppwriteModels/Country.swift +++ b/Sources/AppwriteModels/Country.swift @@ -7,12 +7,10 @@ public class Country { /// Country name. public let name: String - /// Country two-character ISO 3166-1 alpha code. public let code: String - init( name: String, code: String diff --git a/Sources/AppwriteModels/CountryList.swift b/Sources/AppwriteModels/CountryList.swift index 622ebf0..8d120bd 100644 --- a/Sources/AppwriteModels/CountryList.swift +++ b/Sources/AppwriteModels/CountryList.swift @@ -7,12 +7,10 @@ public class CountryList { /// Total number of countries documents that matched your query. public let total: Int - /// List of countries. public let countries: [Country] - init( total: Int, countries: [Country] diff --git a/Sources/AppwriteModels/Currency.swift b/Sources/AppwriteModels/Currency.swift index 7ec64d2..d93ce0c 100644 --- a/Sources/AppwriteModels/Currency.swift +++ b/Sources/AppwriteModels/Currency.swift @@ -7,32 +7,25 @@ public class Currency { /// Currency symbol. public let symbol: String - /// Currency name. public let name: String - /// Currency native symbol. public let symbolNative: String - /// Number of decimal digits. public let decimalDigits: Int - /// Currency digit rounding. public let rounding: Double - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. public let code: String - /// Currency plural name public let namePlural: String - init( symbol: String, name: String, diff --git a/Sources/AppwriteModels/CurrencyList.swift b/Sources/AppwriteModels/CurrencyList.swift index e42d9ad..a2e9f00 100644 --- a/Sources/AppwriteModels/CurrencyList.swift +++ b/Sources/AppwriteModels/CurrencyList.swift @@ -7,12 +7,10 @@ public class CurrencyList { /// Total number of currencies documents that matched your query. public let total: Int - /// List of currencies. public let currencies: [Currency] - init( total: Int, currencies: [Currency] diff --git a/Sources/AppwriteModels/Document.swift b/Sources/AppwriteModels/Document.swift index 20a4f86..c0c49c6 100644 --- a/Sources/AppwriteModels/Document.swift +++ b/Sources/AppwriteModels/Document.swift @@ -7,26 +7,20 @@ public class Document { /// Document ID. public let id: String - /// Collection ID. public let collectionId: String - /// Database ID. public let databaseId: String - /// Document creation date in ISO 8601 format. public let createdAt: String - /// Document update date in ISO 8601 format. public let updatedAt: String - /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - public let permissions: [Any] - + public let permissions: [String] /// Additional properties public let data: T @@ -37,7 +31,7 @@ public class Document { databaseId: String, createdAt: String, updatedAt: String, - permissions: [Any], + permissions: [String], data: T ) { self.id = id @@ -68,7 +62,7 @@ public class Document { databaseId: map["$databaseId"] as! String, createdAt: map["$createdAt"] as! String, updatedAt: map["$updatedAt"] as! String, - permissions: map["$permissions"] as! [Any], + permissions: map["$permissions"] as! [String], data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) ) } diff --git a/Sources/AppwriteModels/DocumentList.swift b/Sources/AppwriteModels/DocumentList.swift index e71c5ad..4a573fe 100644 --- a/Sources/AppwriteModels/DocumentList.swift +++ b/Sources/AppwriteModels/DocumentList.swift @@ -7,12 +7,10 @@ public class DocumentList { /// Total number of documents documents that matched your query. public let total: Int - /// List of documents. public let documents: [Document] - init( total: Int, documents: [Document] diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index 9301a8b..d589342 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -7,77 +7,60 @@ public class Execution { /// Execution ID. public let id: String - /// Execution creation date in ISO 8601 format. public let createdAt: String - /// Execution upate date in ISO 8601 format. public let updatedAt: String - /// Execution roles. - public let permissions: [Any] - + public let permissions: [String] /// Function ID. public let functionId: String - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. public let trigger: String - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. public let status: String - /// HTTP request method type. public let requestMethod: String - /// HTTP request path and query. public let requestPath: String - /// HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. public let requestHeaders: [Headers] - /// HTTP response status code. public let responseStatusCode: Int - /// HTTP response body. This will return empty unless execution is created as synchronous. public let responseBody: String - /// HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. public let responseHeaders: [Headers] - /// Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. public let logs: String - /// Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. public let errors: String - /// 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, createdAt: String, updatedAt: String, - permissions: [Any], + permissions: [String], functionId: String, trigger: String, status: String, @@ -138,7 +121,7 @@ public class Execution { id: map["$id"] as! String, createdAt: map["$createdAt"] as! String, updatedAt: map["$updatedAt"] as! String, - permissions: map["$permissions"] as! [Any], + permissions: map["$permissions"] as! [String], functionId: map["functionId"] as! String, trigger: map["trigger"] as! String, status: map["status"] as! String, @@ -151,7 +134,7 @@ public class Execution { logs: map["logs"] as! String, errors: map["errors"] as! String, duration: map["duration"] as! Double, - scheduledAt: map["scheduledAt"] as? String? + scheduledAt: map["scheduledAt"] as? String ) } } diff --git a/Sources/AppwriteModels/ExecutionList.swift b/Sources/AppwriteModels/ExecutionList.swift index ae92f73..8a502d9 100644 --- a/Sources/AppwriteModels/ExecutionList.swift +++ b/Sources/AppwriteModels/ExecutionList.swift @@ -7,12 +7,10 @@ public class ExecutionList { /// Total number of executions documents that matched your query. public let total: Int - /// List of executions. public let executions: [Execution] - init( total: Int, executions: [Execution] diff --git a/Sources/AppwriteModels/File.swift b/Sources/AppwriteModels/File.swift index e1669ec..db896ab 100644 --- a/Sources/AppwriteModels/File.swift +++ b/Sources/AppwriteModels/File.swift @@ -7,54 +7,43 @@ public class File { /// File ID. public let id: String - /// Bucket ID. public let bucketId: String - /// File creation date in ISO 8601 format. public let createdAt: String - /// File update date in ISO 8601 format. public let updatedAt: String - /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - public let permissions: [Any] - + public let permissions: [String] /// File name. public let name: String - /// File MD5 signature. public let signature: String - /// File mime type. public let mimeType: String - /// File original size in bytes. public let sizeOriginal: Int - /// Total number of chunks available public let chunksTotal: Int - /// Total number of chunks uploaded public let chunksUploaded: Int - init( id: String, bucketId: String, createdAt: String, updatedAt: String, - permissions: [Any], + permissions: [String], name: String, signature: String, mimeType: String, @@ -97,7 +86,7 @@ public class File { bucketId: map["bucketId"] as! String, createdAt: map["$createdAt"] as! String, updatedAt: map["$updatedAt"] as! String, - permissions: map["$permissions"] as! [Any], + permissions: map["$permissions"] as! [String], name: map["name"] as! String, signature: map["signature"] as! String, mimeType: map["mimeType"] as! String, diff --git a/Sources/AppwriteModels/FileList.swift b/Sources/AppwriteModels/FileList.swift index 51dbd44..0d6ad88 100644 --- a/Sources/AppwriteModels/FileList.swift +++ b/Sources/AppwriteModels/FileList.swift @@ -7,12 +7,10 @@ public class FileList { /// Total number of files documents that matched your query. public let total: Int - /// List of files. public let files: [File] - init( total: Int, files: [File] diff --git a/Sources/AppwriteModels/Headers.swift b/Sources/AppwriteModels/Headers.swift index aa1a95f..6f554ac 100644 --- a/Sources/AppwriteModels/Headers.swift +++ b/Sources/AppwriteModels/Headers.swift @@ -7,12 +7,10 @@ public class Headers { /// Header name. public let name: String - /// Header value. public let value: String - init( name: String, value: String diff --git a/Sources/AppwriteModels/Identity.swift b/Sources/AppwriteModels/Identity.swift index 0c7d09e..fb54237 100644 --- a/Sources/AppwriteModels/Identity.swift +++ b/Sources/AppwriteModels/Identity.swift @@ -7,44 +7,34 @@ public class Identity { /// Identity ID. public let id: String - /// Identity creation date in ISO 8601 format. public let createdAt: String - /// Identity update date in ISO 8601 format. public let updatedAt: String - /// User ID. public let userId: String - /// Identity Provider. public let provider: String - /// ID of the User in the Identity Provider. public let providerUid: String - /// Email of the User in the Identity Provider. public let providerEmail: String - /// Identity Provider Access Token. public let providerAccessToken: String - /// The date of when the access token expires in ISO 8601 format. public let providerAccessTokenExpiry: String - /// Identity Provider Refresh Token. public let providerRefreshToken: String - init( id: String, createdAt: String, diff --git a/Sources/AppwriteModels/IdentityList.swift b/Sources/AppwriteModels/IdentityList.swift index a6c3477..b068f4c 100644 --- a/Sources/AppwriteModels/IdentityList.swift +++ b/Sources/AppwriteModels/IdentityList.swift @@ -7,12 +7,10 @@ public class IdentityList { /// Total number of identities documents that matched your query. public let total: Int - /// List of identities. public let identities: [Identity] - init( total: Int, identities: [Identity] diff --git a/Sources/AppwriteModels/Jwt.swift b/Sources/AppwriteModels/Jwt.swift index 902f5b2..5778435 100644 --- a/Sources/AppwriteModels/Jwt.swift +++ b/Sources/AppwriteModels/Jwt.swift @@ -8,7 +8,6 @@ public class Jwt { public let jwt: String - init( jwt: String ) { diff --git a/Sources/AppwriteModels/Language.swift b/Sources/AppwriteModels/Language.swift index 3111149..f385d5a 100644 --- a/Sources/AppwriteModels/Language.swift +++ b/Sources/AppwriteModels/Language.swift @@ -7,16 +7,13 @@ public class Language { /// Language name. public let name: String - /// Language two-character ISO 639-1 codes. public let code: String - /// Language native name. public let nativeName: String - init( name: String, code: String, diff --git a/Sources/AppwriteModels/LanguageList.swift b/Sources/AppwriteModels/LanguageList.swift index acba750..b4515e3 100644 --- a/Sources/AppwriteModels/LanguageList.swift +++ b/Sources/AppwriteModels/LanguageList.swift @@ -7,12 +7,10 @@ public class LanguageList { /// Total number of languages documents that matched your query. public let total: Int - /// List of languages. public let languages: [Language] - init( total: Int, languages: [Language] diff --git a/Sources/AppwriteModels/Locale.swift b/Sources/AppwriteModels/Locale.swift index 2f4d046..7445776 100644 --- a/Sources/AppwriteModels/Locale.swift +++ b/Sources/AppwriteModels/Locale.swift @@ -7,32 +7,25 @@ public class Locale { /// User IP address. public let ip: String - /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format public let countryCode: String - /// Country name. This field support localization. public let country: String - /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. public let continentCode: String - /// Continent name. This field support localization. public let continent: String - /// True if country is part of the European Union. public let eu: Bool - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format public let currency: String - init( ip: String, countryCode: String, diff --git a/Sources/AppwriteModels/LocaleCode.swift b/Sources/AppwriteModels/LocaleCode.swift index 2d6185e..8e561c7 100644 --- a/Sources/AppwriteModels/LocaleCode.swift +++ b/Sources/AppwriteModels/LocaleCode.swift @@ -7,12 +7,10 @@ public class LocaleCode { /// Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) public let code: String - /// Locale name public let name: String - init( code: String, name: String diff --git a/Sources/AppwriteModels/LocaleCodeList.swift b/Sources/AppwriteModels/LocaleCodeList.swift index dca47d8..895ef7d 100644 --- a/Sources/AppwriteModels/LocaleCodeList.swift +++ b/Sources/AppwriteModels/LocaleCodeList.swift @@ -7,12 +7,10 @@ public class LocaleCodeList { /// Total number of localeCodes documents that matched your query. public let total: Int - /// List of localeCodes. public let localeCodes: [LocaleCode] - init( total: Int, localeCodes: [LocaleCode] diff --git a/Sources/AppwriteModels/Log.swift b/Sources/AppwriteModels/Log.swift index bf0135e..df5464d 100644 --- a/Sources/AppwriteModels/Log.swift +++ b/Sources/AppwriteModels/Log.swift @@ -7,88 +7,67 @@ public class Log { /// Event name. public let event: String - /// User ID. public let userId: String - /// User Email. public let userEmail: String - /// User Name. public let userName: String - /// API mode when event triggered. public let mode: String - /// IP session in use when the session was created. public let ip: String - /// Log creation date in ISO 8601 format. public let time: String - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). public let osCode: String - /// Operating system name. public let osName: String - /// Operating system version. public let osVersion: String - /// Client type. public let clientType: String - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). public let clientCode: String - /// Client name. public let clientName: String - /// Client version. public let clientVersion: String - /// Client engine name. public let clientEngine: String - /// Client engine name. public let clientEngineVersion: String - /// Device name. public let deviceName: String - /// Device brand name. public let deviceBrand: String - /// Device model name. public let deviceModel: String - /// Country two-character ISO 3166-1 alpha code. public let countryCode: String - /// Country name. public let countryName: String - init( event: String, userId: String, diff --git a/Sources/AppwriteModels/LogList.swift b/Sources/AppwriteModels/LogList.swift index 241f775..2f99674 100644 --- a/Sources/AppwriteModels/LogList.swift +++ b/Sources/AppwriteModels/LogList.swift @@ -7,12 +7,10 @@ public class LogList { /// Total number of logs documents that matched your query. public let total: Int - /// List of logs. public let logs: [Log] - init( total: Int, logs: [Log] diff --git a/Sources/AppwriteModels/Membership.swift b/Sources/AppwriteModels/Membership.swift index 176b746..805cb47 100644 --- a/Sources/AppwriteModels/Membership.swift +++ b/Sources/AppwriteModels/Membership.swift @@ -7,54 +7,41 @@ public class Membership { /// Membership ID. public let id: String - /// Membership creation date in ISO 8601 format. public let createdAt: String - /// Membership update date in ISO 8601 format. public let updatedAt: String - /// User ID. public let userId: String - - /// User name. + /// User name. Hide this attribute by toggling membership privacy in the Console. public let userName: String - - /// User email address. + /// User email address. Hide this attribute by toggling membership privacy in the Console. public let userEmail: String - /// Team ID. public let teamId: String - /// Team name. public let teamName: String - /// Date, the user has been invited to join the team in ISO 8601 format. public let invited: String - /// Date, the user has accepted the invitation to join the team in ISO 8601 format. public let joined: String - /// User confirmation status, true if the user has joined the team or false otherwise. public let confirm: Bool - - /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. public let mfa: Bool - /// User list of roles - public let roles: [Any] - + public let roles: [String] init( @@ -70,7 +57,7 @@ public class Membership { joined: String, confirm: Bool, mfa: Bool, - roles: [Any] + roles: [String] ) { self.id = id self.createdAt = createdAt @@ -119,7 +106,7 @@ public class Membership { joined: map["joined"] as! String, confirm: map["confirm"] as! Bool, mfa: map["mfa"] as! Bool, - roles: map["roles"] as! [Any] + roles: map["roles"] as! [String] ) } } diff --git a/Sources/AppwriteModels/MembershipList.swift b/Sources/AppwriteModels/MembershipList.swift index 5218b20..f27cc99 100644 --- a/Sources/AppwriteModels/MembershipList.swift +++ b/Sources/AppwriteModels/MembershipList.swift @@ -7,12 +7,10 @@ public class MembershipList { /// Total number of memberships documents that matched your query. public let total: Int - /// List of memberships. public let memberships: [Membership] - init( total: Int, memberships: [Membership] diff --git a/Sources/AppwriteModels/MfaChallenge.swift b/Sources/AppwriteModels/MfaChallenge.swift index 6d7481b..5a1e874 100644 --- a/Sources/AppwriteModels/MfaChallenge.swift +++ b/Sources/AppwriteModels/MfaChallenge.swift @@ -7,20 +7,16 @@ public class MfaChallenge { /// Token ID. public let id: String - /// Token creation date in ISO 8601 format. public let createdAt: String - /// User ID. public let userId: String - /// Token expiration date in ISO 8601 format. public let expire: String - init( id: String, createdAt: String, diff --git a/Sources/AppwriteModels/MfaFactors.swift b/Sources/AppwriteModels/MfaFactors.swift index 88adf5e..716c055 100644 --- a/Sources/AppwriteModels/MfaFactors.swift +++ b/Sources/AppwriteModels/MfaFactors.swift @@ -7,20 +7,16 @@ public class MfaFactors { /// Can TOTP be used for MFA challenge for this account. public let totp: Bool - /// Can phone (SMS) be used for MFA challenge for this account. public let phone: Bool - /// Can email be used for MFA challenge for this account. public let email: Bool - /// Can recovery code be used for MFA challenge for this account. public let recoveryCode: Bool - init( totp: Bool, phone: Bool, diff --git a/Sources/AppwriteModels/MfaRecoveryCodes.swift b/Sources/AppwriteModels/MfaRecoveryCodes.swift index 8b57721..314e11c 100644 --- a/Sources/AppwriteModels/MfaRecoveryCodes.swift +++ b/Sources/AppwriteModels/MfaRecoveryCodes.swift @@ -5,12 +5,11 @@ import JSONCodable public class MfaRecoveryCodes { /// Recovery codes. - public let recoveryCodes: [Any] - + public let recoveryCodes: [String] init( - recoveryCodes: [Any] + recoveryCodes: [String] ) { self.recoveryCodes = recoveryCodes } @@ -23,7 +22,7 @@ public class MfaRecoveryCodes { public static func from(map: [String: Any] ) -> MfaRecoveryCodes { return MfaRecoveryCodes( - recoveryCodes: map["recoveryCodes"] as! [Any] + recoveryCodes: map["recoveryCodes"] as! [String] ) } } diff --git a/Sources/AppwriteModels/MfaType.swift b/Sources/AppwriteModels/MfaType.swift index 80c3526..503134f 100644 --- a/Sources/AppwriteModels/MfaType.swift +++ b/Sources/AppwriteModels/MfaType.swift @@ -7,12 +7,10 @@ public class MfaType { /// Secret token used for TOTP factor. public let secret: String - /// URI for authenticator apps. public let uri: String - init( secret: String, uri: String diff --git a/Sources/AppwriteModels/Phone.swift b/Sources/AppwriteModels/Phone.swift index a1bb096..2e113b4 100644 --- a/Sources/AppwriteModels/Phone.swift +++ b/Sources/AppwriteModels/Phone.swift @@ -7,16 +7,13 @@ public class Phone { /// Phone code. public let code: String - /// Country two-character ISO 3166-1 alpha code. public let countryCode: String - /// Country name. public let countryName: String - init( code: String, countryCode: String, diff --git a/Sources/AppwriteModels/PhoneList.swift b/Sources/AppwriteModels/PhoneList.swift index 6918afa..38a5a6f 100644 --- a/Sources/AppwriteModels/PhoneList.swift +++ b/Sources/AppwriteModels/PhoneList.swift @@ -7,12 +7,10 @@ public class PhoneList { /// Total number of phones documents that matched your query. public let total: Int - /// List of phones. public let phones: [Phone] - init( total: Int, phones: [Phone] diff --git a/Sources/AppwriteModels/Session.swift b/Sources/AppwriteModels/Session.swift index c6aca5b..86f4a7c 100644 --- a/Sources/AppwriteModels/Session.swift +++ b/Sources/AppwriteModels/Session.swift @@ -7,120 +7,91 @@ public class Session { /// Session ID. public let id: String - /// Session creation date in ISO 8601 format. public let createdAt: String - /// Session update date in ISO 8601 format. public let updatedAt: String - /// User ID. public let userId: String - /// Session expiration date in ISO 8601 format. public let expire: String - /// Session Provider. public let provider: String - /// Session Provider User ID. public let providerUid: String - /// Session Provider Access Token. public let providerAccessToken: String - /// The date of when the access token expires in ISO 8601 format. public let providerAccessTokenExpiry: String - /// Session Provider Refresh Token. public let providerRefreshToken: String - /// IP in use when the session was created. public let ip: String - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). public let osCode: String - /// Operating system name. public let osName: String - /// Operating system version. public let osVersion: String - /// Client type. public let clientType: String - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). public let clientCode: String - /// Client name. public let clientName: String - /// Client version. public let clientVersion: String - /// Client engine name. public let clientEngine: String - /// Client engine name. public let clientEngineVersion: String - /// Device name. public let deviceName: String - /// Device brand name. public let deviceBrand: String - /// Device model name. public let deviceModel: String - /// Country two-character ISO 3166-1 alpha code. public let countryCode: String - /// Country name. public let countryName: String - /// Returns true if this the current user session. public let current: Bool - /// Returns a list of active session factors. - public let factors: [Any] - + public let factors: [String] /// Secret used to authenticate the user. Only included if the request was made with an API key public let secret: String - /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. public let mfaUpdatedAt: String - init( id: String, createdAt: String, @@ -148,7 +119,7 @@ public class Session { countryCode: String, countryName: String, current: Bool, - factors: [Any], + factors: [String], secret: String, mfaUpdatedAt: String ) { @@ -245,7 +216,7 @@ public class Session { countryCode: map["countryCode"] as! String, countryName: map["countryName"] as! String, current: map["current"] as! Bool, - factors: map["factors"] as! [Any], + factors: map["factors"] as! [String], secret: map["secret"] as! String, mfaUpdatedAt: map["mfaUpdatedAt"] as! String ) diff --git a/Sources/AppwriteModels/SessionList.swift b/Sources/AppwriteModels/SessionList.swift index c526af9..409f72a 100644 --- a/Sources/AppwriteModels/SessionList.swift +++ b/Sources/AppwriteModels/SessionList.swift @@ -7,12 +7,10 @@ public class SessionList { /// Total number of sessions documents that matched your query. public let total: Int - /// List of sessions. public let sessions: [Session] - init( total: Int, sessions: [Session] diff --git a/Sources/AppwriteModels/Subscriber.swift b/Sources/AppwriteModels/Subscriber.swift index f990bb4..5ab202d 100644 --- a/Sources/AppwriteModels/Subscriber.swift +++ b/Sources/AppwriteModels/Subscriber.swift @@ -7,40 +7,31 @@ public class Subscriber { /// Subscriber ID. public let id: String - /// Subscriber creation time in ISO 8601 format. public let createdAt: String - /// Subscriber update date in ISO 8601 format. public let updatedAt: String - /// Target ID. public let targetId: String - /// Target. public let target: Target - /// Topic ID. public let userId: String - /// User Name. public let userName: String - /// Topic ID. public let topicId: String - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. public let providerType: String - init( id: String, createdAt: String, diff --git a/Sources/AppwriteModels/Target.swift b/Sources/AppwriteModels/Target.swift index eaaf267..2e81790 100644 --- a/Sources/AppwriteModels/Target.swift +++ b/Sources/AppwriteModels/Target.swift @@ -7,34 +7,29 @@ public class Target { /// Target ID. public let id: String - /// Target creation time in ISO 8601 format. public let createdAt: String - /// Target update date in ISO 8601 format. public let updatedAt: String - /// Target Name. public let name: String - /// User ID. public let userId: String - /// Provider ID. public let providerId: String? - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. public let providerType: String - /// The target identifier. public let identifier: String + /// Is the target expired. + public let expired: Bool init( @@ -45,7 +40,8 @@ public class Target { userId: String, providerId: String?, providerType: String, - identifier: String + identifier: String, + expired: Bool ) { self.id = id self.createdAt = createdAt @@ -55,6 +51,7 @@ public class Target { self.providerId = providerId self.providerType = providerType self.identifier = identifier + self.expired = expired } public func toMap() -> [String: Any] { @@ -66,7 +63,8 @@ public class Target { "userId": userId as Any, "providerId": providerId as Any, "providerType": providerType as Any, - "identifier": identifier as Any + "identifier": identifier as Any, + "expired": expired as Any ] } @@ -77,9 +75,10 @@ public class Target { updatedAt: map["$updatedAt"] as! String, name: map["name"] as! String, userId: map["userId"] as! String, - providerId: map["providerId"] as? String?, + providerId: map["providerId"] as? String, providerType: map["providerType"] as! String, - identifier: map["identifier"] as! String + identifier: map["identifier"] as! String, + expired: map["expired"] as! Bool ) } } diff --git a/Sources/AppwriteModels/Team.swift b/Sources/AppwriteModels/Team.swift index 9830c39..a44c305 100644 --- a/Sources/AppwriteModels/Team.swift +++ b/Sources/AppwriteModels/Team.swift @@ -7,28 +7,22 @@ public class Team { /// Team ID. public let id: String - /// Team creation date in ISO 8601 format. public let createdAt: String - /// Team update date in ISO 8601 format. public let updatedAt: String - /// Team name. public let name: String - /// Total number of team members. public let total: Int - /// Team preferences as a key-value object public let prefs: Preferences - init( id: String, createdAt: String, diff --git a/Sources/AppwriteModels/TeamList.swift b/Sources/AppwriteModels/TeamList.swift index 2934a13..ec7e0bd 100644 --- a/Sources/AppwriteModels/TeamList.swift +++ b/Sources/AppwriteModels/TeamList.swift @@ -7,12 +7,10 @@ public class TeamList { /// Total number of teams documents that matched your query. public let total: Int - /// List of teams. public let teams: [Team] - init( total: Int, teams: [Team] diff --git a/Sources/AppwriteModels/Token.swift b/Sources/AppwriteModels/Token.swift index 5facdef..31d4b4a 100644 --- a/Sources/AppwriteModels/Token.swift +++ b/Sources/AppwriteModels/Token.swift @@ -7,28 +7,22 @@ public class Token { /// Token ID. public let id: String - /// Token creation date in ISO 8601 format. public let createdAt: String - /// User ID. public let userId: String - /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. public let secret: String - /// Token expiration date in ISO 8601 format. public let expire: String - /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. public let phrase: String - init( id: String, createdAt: String, diff --git a/Sources/AppwriteModels/User.swift b/Sources/AppwriteModels/User.swift index a087357..0229dc5 100644 --- a/Sources/AppwriteModels/User.swift +++ b/Sources/AppwriteModels/User.swift @@ -7,80 +7,61 @@ public class User { /// User ID. public let id: String - /// User creation date in ISO 8601 format. public let createdAt: String - /// User update date in ISO 8601 format. public let updatedAt: String - /// User name. public let name: String - /// Hashed user password. public let password: String? - /// Password hashing algorithm. public let hash: String? - /// Password hashing algorithm configuration. public let hashOptions: Any? - /// User registration date in ISO 8601 format. public let registration: String - /// User status. Pass `true` for enabled and `false` for disabled. public let status: Bool - /// Labels for the user. - public let labels: [Any] - + public let labels: [String] /// Password update time in ISO 8601 format. public let passwordUpdate: String - /// User email address. public let email: String - /// User phone number in E.164 format. public let phone: String - /// Email verification status. public let emailVerification: Bool - /// Phone verification status. public let phoneVerification: Bool - /// Multi factor authentication status. public let mfa: Bool - /// User preferences as a key-value object public let prefs: Preferences - /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. public let targets: [Target] - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. public let accessedAt: String - init( id: String, createdAt: String, @@ -91,7 +72,7 @@ public class User { hashOptions: Any?, registration: String, status: Bool, - labels: [Any], + labels: [String], passwordUpdate: String, email: String, phone: String, @@ -153,12 +134,12 @@ public class User { createdAt: map["$createdAt"] as! String, updatedAt: map["$updatedAt"] as! String, name: map["name"] as! String, - password: map["password"] as? String?, - hash: map["hash"] as? String?, - hashOptions: map["hashOptions"] as? Any?, + password: map["password"] as? String, + hash: map["hash"] as? String, + hashOptions: map["hashOptions"] as? Any, registration: map["registration"] as! String, status: map["status"] as! Bool, - labels: map["labels"] as! [Any], + labels: map["labels"] as! [String], passwordUpdate: map["passwordUpdate"] as! String, email: map["email"] as! String, phone: map["phone"] as! String, diff --git a/example-uikit/UIKitExample/ViewController.swift b/example-uikit/UIKitExample/ViewController.swift index b1d2f14..656825f 100644 --- a/example-uikit/UIKitExample/ViewController.swift +++ b/example-uikit/UIKitExample/ViewController.swift @@ -2,7 +2,7 @@ import UIKit import NIO import Appwrite -let host = "https://demo.appwrite.io/v1" +let host = "https://cloud.appwrite.io/v1" class ViewController: UIViewController { @@ -72,8 +72,8 @@ class ViewController: UIViewController { do { let response = try await account.createOAuth2Session( provider: "facebook", - success: "https://demo.appwrite.io/auth/oauth2/success", - failure: "https://demo.appwrite.io/auth/oauth2/failure" + success: "https://cloud.appwrite.io/auth/oauth2/success", + failure: "https://cloud.appwrite.io/auth/oauth2/failure" ) self.response = String(describing: response) } catch {