From c624023fc1788548de75e916879a6742c312bc52 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Dec 2024 01:06:53 +1300 Subject: [PATCH] Add new push message parameters --- README.md | 4 +-- Sources/Appwrite/Client.swift | 16 ++++----- Sources/Appwrite/Services/Account.swift | 26 +++++++------- Sources/Appwrite/Services/Locale.swift | 2 +- Sources/Appwrite/Services/Messaging.swift | 34 ++++++++++++++----- Sources/Appwrite/Services/Storage.swift | 2 +- Sources/Appwrite/Services/Teams.swift | 6 ++-- Sources/Appwrite/Services/Users.swift | 22 ++++++------ .../AppwriteEnums/AuthenticationFactor.swift | 7 ++-- Sources/AppwriteEnums/AuthenticatorType.swift | 7 ++-- Sources/AppwriteEnums/Browser.swift | 7 ++-- Sources/AppwriteEnums/Compression.swift | 7 ++-- Sources/AppwriteEnums/CreditCard.swift | 7 ++-- Sources/AppwriteEnums/ExecutionMethod.swift | 7 ++-- Sources/AppwriteEnums/Flag.swift | 7 ++-- Sources/AppwriteEnums/ImageFormat.swift | 8 ++--- Sources/AppwriteEnums/ImageGravity.swift | 7 ++-- Sources/AppwriteEnums/IndexType.swift | 7 ++-- Sources/AppwriteEnums/MessagePriority.swift | 10 ++++++ .../AppwriteEnums/MessagingProviderType.swift | 7 ++-- Sources/AppwriteEnums/Name.swift | 7 ++-- Sources/AppwriteEnums/OAuthProvider.swift | 7 ++-- Sources/AppwriteEnums/PasswordHash.swift | 7 ++-- Sources/AppwriteEnums/RelationMutate.swift | 7 ++-- Sources/AppwriteEnums/RelationshipType.swift | 7 ++-- Sources/AppwriteEnums/Runtime.swift | 22 +++++++++--- Sources/AppwriteEnums/SmtpEncryption.swift | 7 ++-- Sources/AppwriteModels/AttributeBoolean.swift | 14 ++++++++ .../AppwriteModels/AttributeDatetime.swift | 14 ++++++++ Sources/AppwriteModels/AttributeEmail.swift | 14 ++++++++ Sources/AppwriteModels/AttributeEnum.swift | 20 +++++++++-- Sources/AppwriteModels/AttributeFloat.swift | 14 ++++++++ Sources/AppwriteModels/AttributeInteger.swift | 14 ++++++++ Sources/AppwriteModels/AttributeIp.swift | 14 ++++++++ .../AttributeRelationship.swift | 14 ++++++++ Sources/AppwriteModels/AttributeString.swift | 14 ++++++++ Sources/AppwriteModels/AttributeUrl.swift | 14 ++++++++ Sources/AppwriteModels/Bucket.swift | 12 +++---- Sources/AppwriteModels/Collection.swift | 6 ++-- Sources/AppwriteModels/Document.swift | 6 ++-- Sources/AppwriteModels/Execution.swift | 6 ++-- Sources/AppwriteModels/File.swift | 6 ++-- Sources/AppwriteModels/Function.swift | 20 +++++------ Sources/AppwriteModels/Index.swift | 28 +++++++++++---- Sources/AppwriteModels/Membership.swift | 12 +++---- Sources/AppwriteModels/Message.swift | 24 ++++++------- Sources/AppwriteModels/MfaRecoveryCodes.swift | 6 ++-- Sources/AppwriteModels/Runtime.swift | 6 ++-- Sources/AppwriteModels/Session.swift | 6 ++-- Sources/AppwriteModels/Target.swift | 13 +++++-- Sources/AppwriteModels/Topic.swift | 6 ++-- Sources/AppwriteModels/User.swift | 6 ++-- .../databases/update-string-attribute.md | 2 +- docs/examples/messaging/create-push.md | 12 ++++--- docs/examples/messaging/update-push.md | 6 +++- 55 files changed, 393 insertions(+), 200 deletions(-) create mode 100644 Sources/AppwriteEnums/MessagePriority.swift diff --git a/README.md b/README.md index 426c314..c670df4 100644 --- a/README.md +++ b/README.md @@ -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.6.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.1-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) @@ -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: "6.1.0"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "6.2.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 4d6ae63..ecd48cd 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -21,7 +21,7 @@ open class Client { "x-sdk-name": "Swift", "x-sdk-platform": "server", "x-sdk-language": "swift", - "x-sdk-version": "6.1.0", + "x-sdk-version": "6.2.0", "x-appwrite-response-format": "1.6.0" ] @@ -530,23 +530,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).. AppwriteModels.Message { let apiPath: String = "/messaging/messages/push" @@ -243,7 +249,10 @@ open class Messaging: Service { "tag": tag, "badge": badge, "draft": draft, - "scheduledAt": scheduledAt + "scheduledAt": scheduledAt, + "contentAvailable": contentAvailable, + "critical": critical, + "priority": priority ] let apiHeaders: [String: String] = [ @@ -285,6 +294,9 @@ open class Messaging: Service { /// @param Int badge /// @param Bool draft /// @param String scheduledAt + /// @param Bool contentAvailable + /// @param Bool critical + /// @param AppwriteEnums.MessagePriority priority /// @throws Exception /// @return array /// @@ -304,7 +316,10 @@ open class Messaging: Service { tag: String? = nil, badge: Int? = nil, draft: Bool? = nil, - scheduledAt: String? = nil + scheduledAt: String? = nil, + contentAvailable: Bool? = nil, + critical: Bool? = nil, + priority: AppwriteEnums.MessagePriority? = nil ) async throws -> AppwriteModels.Message { let apiPath: String = "/messaging/messages/push/{messageId}" .replacingOccurrences(of: "{messageId}", with: messageId) @@ -324,7 +339,10 @@ open class Messaging: Service { "tag": tag, "badge": badge, "draft": draft, - "scheduledAt": scheduledAt + "scheduledAt": scheduledAt, + "contentAvailable": contentAvailable, + "critical": critical, + "priority": priority ] let apiHeaders: [String: String] = [ diff --git a/Sources/Appwrite/Services/Storage.swift b/Sources/Appwrite/Services/Storage.swift index 28f602a..c3454aa 100644 --- a/Sources/Appwrite/Services/Storage.swift +++ b/Sources/Appwrite/Services/Storage.swift @@ -426,7 +426,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/Appwrite/Services/Users.swift b/Sources/Appwrite/Services/Users.swift index 62d2fc6..f9e7361 100644 --- a/Sources/Appwrite/Services/Users.swift +++ b/Sources/Appwrite/Services/Users.swift @@ -305,7 +305,7 @@ open class Users: Service { } /// - /// List Identities + /// List identities /// /// Get identities for all users. /// @@ -1208,7 +1208,7 @@ open class Users: Service { } /// - /// Delete Authenticator + /// Delete authenticator /// /// Delete an authenticator app. /// @@ -1246,7 +1246,7 @@ open class Users: Service { } /// - /// Delete Authenticator + /// Delete authenticator /// /// Delete an authenticator app. /// @@ -1267,7 +1267,7 @@ open class Users: Service { } /// - /// List Factors + /// List factors /// /// List the factors available on the account to be used as a MFA challange. /// @@ -1301,7 +1301,7 @@ open class Users: Service { } /// - /// Get MFA Recovery Codes + /// Get MFA recovery codes /// /// Get recovery codes that can be used as backup for MFA flow by User ID. /// Before getting codes, they must be generated using @@ -1338,7 +1338,7 @@ open class Users: Service { } /// - /// Regenerate MFA Recovery Codes + /// Regenerate MFA recovery codes /// /// Regenerate recovery codes that can be used as backup for MFA flow by User /// ID. Before regenerating codes, they must be first generated using @@ -1375,7 +1375,7 @@ open class Users: Service { } /// - /// Create MFA Recovery Codes + /// Create MFA recovery codes /// /// Generate recovery codes used as backup for MFA flow for User ID. Recovery /// codes can be used as a MFA verification type in @@ -1903,7 +1903,7 @@ open class Users: Service { } /// - /// List User Targets + /// List user targets /// /// List the messaging targets that are associated with a user. /// @@ -1941,7 +1941,7 @@ open class Users: Service { } /// - /// Create User Target + /// Create user target /// /// Create a messaging target. /// @@ -1991,7 +1991,7 @@ open class Users: Service { } /// - /// Get User Target + /// Get user target /// /// Get a user's push notification target by ID. /// @@ -2028,7 +2028,7 @@ open class Users: Service { } /// - /// Update User target + /// Update user target /// /// Update a messaging target. /// 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/Compression.swift b/Sources/AppwriteEnums/Compression.swift index a9256c5..054e1ad 100644 --- a/Sources/AppwriteEnums/Compression.swift +++ b/Sources/AppwriteEnums/Compression.swift @@ -1,12 +1,11 @@ import Foundation -public enum Compression: String, Codable { +public enum Compression: String, CustomStringConvertible { case `none` = "none" case gzip = "gzip" case zstd = "zstd" - 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/IndexType.swift b/Sources/AppwriteEnums/IndexType.swift index a6ff794..9687f08 100644 --- a/Sources/AppwriteEnums/IndexType.swift +++ b/Sources/AppwriteEnums/IndexType.swift @@ -1,12 +1,11 @@ import Foundation -public enum IndexType: String, Codable { +public enum IndexType: String, CustomStringConvertible { case key = "key" case fulltext = "fulltext" case unique = "unique" - 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/MessagePriority.swift b/Sources/AppwriteEnums/MessagePriority.swift new file mode 100644 index 0000000..59ad9c6 --- /dev/null +++ b/Sources/AppwriteEnums/MessagePriority.swift @@ -0,0 +1,10 @@ +import Foundation + +public enum MessagePriority: String, CustomStringConvertible { + case normal = "normal" + case high = "high" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/MessagingProviderType.swift b/Sources/AppwriteEnums/MessagingProviderType.swift index e6c8332..6ea6f37 100644 --- a/Sources/AppwriteEnums/MessagingProviderType.swift +++ b/Sources/AppwriteEnums/MessagingProviderType.swift @@ -1,12 +1,11 @@ import Foundation -public enum MessagingProviderType: String, Codable { +public enum MessagingProviderType: String, CustomStringConvertible { case email = "email" case sms = "sms" case push = "push" - 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/Name.swift b/Sources/AppwriteEnums/Name.swift index f792c31..3db0d91 100644 --- a/Sources/AppwriteEnums/Name.swift +++ b/Sources/AppwriteEnums/Name.swift @@ -1,6 +1,6 @@ import Foundation -public enum Name: String, Codable { +public enum Name: String, CustomStringConvertible { case v1Database = "v1-database" case v1Deletes = "v1-deletes" case v1Audits = "v1-audits" @@ -14,8 +14,7 @@ public enum Name: String, Codable { case v1Messaging = "v1-messaging" case v1Migrations = "v1-migrations" - 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/AppwriteEnums/PasswordHash.swift b/Sources/AppwriteEnums/PasswordHash.swift index 5b6845f..078ad8a 100644 --- a/Sources/AppwriteEnums/PasswordHash.swift +++ b/Sources/AppwriteEnums/PasswordHash.swift @@ -1,6 +1,6 @@ import Foundation -public enum PasswordHash: String, Codable { +public enum PasswordHash: String, CustomStringConvertible { case sha1 = "sha1" case sha224 = "sha224" case sha256 = "sha256" @@ -13,8 +13,7 @@ public enum PasswordHash: String, Codable { case sha3384 = "sha3-384" case sha3512 = "sha3-512" - 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/RelationMutate.swift b/Sources/AppwriteEnums/RelationMutate.swift index 174e3bf..86ec10f 100644 --- a/Sources/AppwriteEnums/RelationMutate.swift +++ b/Sources/AppwriteEnums/RelationMutate.swift @@ -1,12 +1,11 @@ import Foundation -public enum RelationMutate: String, Codable { +public enum RelationMutate: String, CustomStringConvertible { case cascade = "cascade" case restrict = "restrict" case setNull = "setNull" - 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/RelationshipType.swift b/Sources/AppwriteEnums/RelationshipType.swift index 5c5efbe..a02c161 100644 --- a/Sources/AppwriteEnums/RelationshipType.swift +++ b/Sources/AppwriteEnums/RelationshipType.swift @@ -1,13 +1,12 @@ import Foundation -public enum RelationshipType: String, Codable { +public enum RelationshipType: String, CustomStringConvertible { case oneToOne = "oneToOne" case manyToOne = "manyToOne" case manyToMany = "manyToMany" case oneToMany = "oneToMany" - 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/Runtime.swift b/Sources/AppwriteEnums/Runtime.swift index 12abf93..6fbf901 100644 --- a/Sources/AppwriteEnums/Runtime.swift +++ b/Sources/AppwriteEnums/Runtime.swift @@ -1,12 +1,13 @@ import Foundation -public enum Runtime: String, Codable { +public enum Runtime: String, CustomStringConvertible { case node145 = "node-14.5" case node160 = "node-16.0" case node180 = "node-18.0" case node190 = "node-19.0" case node200 = "node-20.0" case node210 = "node-21.0" + case node22 = "node-22" case php80 = "php-8.0" case php81 = "php-8.1" case php82 = "php-8.2" @@ -21,7 +22,12 @@ public enum Runtime: String, Codable { case python311 = "python-3.11" case python312 = "python-3.12" case pythonMl311 = "python-ml-3.11" + case deno121 = "deno-1.21" + case deno124 = "deno-1.24" + case deno135 = "deno-1.35" case deno140 = "deno-1.40" + case deno146 = "deno-1.46" + case deno20 = "deno-2.0" case dart215 = "dart-2.15" case dart216 = "dart-2.16" case dart217 = "dart-2.17" @@ -29,27 +35,33 @@ public enum Runtime: String, Codable { case dart30 = "dart-3.0" case dart31 = "dart-3.1" case dart33 = "dart-3.3" - case dotnet31 = "dotnet-3.1" + case dart35 = "dart-3.5" case dotnet60 = "dotnet-6.0" case dotnet70 = "dotnet-7.0" + case dotnet80 = "dotnet-8.0" case java80 = "java-8.0" case java110 = "java-11.0" case java170 = "java-17.0" case java180 = "java-18.0" case java210 = "java-21.0" + case java22 = "java-22" case swift55 = "swift-5.5" case swift58 = "swift-5.8" case swift59 = "swift-5.9" + case swift510 = "swift-5.10" case kotlin16 = "kotlin-1.6" case kotlin18 = "kotlin-1.8" case kotlin19 = "kotlin-1.9" + case kotlin20 = "kotlin-2.0" case cpp17 = "cpp-17" case cpp20 = "cpp-20" case bun10 = "bun-1.0" + case bun11 = "bun-1.1" case go123 = "go-1.23" + case static1 = "static-1" + case flutter324 = "flutter-3.24" - 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/SmtpEncryption.swift b/Sources/AppwriteEnums/SmtpEncryption.swift index 6c23257..d3f8e92 100644 --- a/Sources/AppwriteEnums/SmtpEncryption.swift +++ b/Sources/AppwriteEnums/SmtpEncryption.swift @@ -1,12 +1,11 @@ import Foundation -public enum SmtpEncryption: String, Codable { +public enum SmtpEncryption: String, CustomStringConvertible { case `none` = "none" case ssl = "ssl" case tls = "tls" - 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/AttributeBoolean.swift b/Sources/AppwriteModels/AttributeBoolean.swift index 11bb89c..f8373c4 100644 --- a/Sources/AppwriteModels/AttributeBoolean.swift +++ b/Sources/AppwriteModels/AttributeBoolean.swift @@ -22,6 +22,12 @@ public class AttributeBoolean { /// Is attribute an array? public let array: Bool? + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + /// Default value for attribute when not provided. Cannot be set when attribute is required. public let `default`: Bool? @@ -33,6 +39,8 @@ public class AttributeBoolean { error: String, `required`: Bool, array: Bool?, + createdAt: String, + updatedAt: String, `default`: Bool? ) { self.key = key @@ -41,6 +49,8 @@ public class AttributeBoolean { self.error = error self.`required` = `required` self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt self.`default` = `default` } @@ -52,6 +62,8 @@ public class AttributeBoolean { "error": error as Any, "`required`": `required` as Any, "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, "`default`": `default` as Any ] } @@ -64,6 +76,8 @@ public class AttributeBoolean { error: map["error"] as! String, `required`: map["required"] as! Bool, array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, `default`: map["default"] as? Bool ) } diff --git a/Sources/AppwriteModels/AttributeDatetime.swift b/Sources/AppwriteModels/AttributeDatetime.swift index 24beb48..260e978 100644 --- a/Sources/AppwriteModels/AttributeDatetime.swift +++ b/Sources/AppwriteModels/AttributeDatetime.swift @@ -22,6 +22,12 @@ public class AttributeDatetime { /// Is attribute an array? public let array: Bool? + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + /// ISO 8601 format. public let format: String @@ -36,6 +42,8 @@ public class AttributeDatetime { error: String, `required`: Bool, array: Bool?, + createdAt: String, + updatedAt: String, format: String, `default`: String? ) { @@ -45,6 +53,8 @@ public class AttributeDatetime { self.error = error self.`required` = `required` self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt self.format = format self.`default` = `default` } @@ -57,6 +67,8 @@ public class AttributeDatetime { "error": error as Any, "`required`": `required` as Any, "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, "format": format as Any, "`default`": `default` as Any ] @@ -70,6 +82,8 @@ public class AttributeDatetime { error: map["error"] as! String, `required`: map["required"] as! Bool, array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, format: map["format"] as! String, `default`: map["default"] as? String ) diff --git a/Sources/AppwriteModels/AttributeEmail.swift b/Sources/AppwriteModels/AttributeEmail.swift index f6a7098..9223060 100644 --- a/Sources/AppwriteModels/AttributeEmail.swift +++ b/Sources/AppwriteModels/AttributeEmail.swift @@ -22,6 +22,12 @@ public class AttributeEmail { /// Is attribute an array? public let array: Bool? + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + /// String format. public let format: String @@ -36,6 +42,8 @@ public class AttributeEmail { error: String, `required`: Bool, array: Bool?, + createdAt: String, + updatedAt: String, format: String, `default`: String? ) { @@ -45,6 +53,8 @@ public class AttributeEmail { self.error = error self.`required` = `required` self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt self.format = format self.`default` = `default` } @@ -57,6 +67,8 @@ public class AttributeEmail { "error": error as Any, "`required`": `required` as Any, "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, "format": format as Any, "`default`": `default` as Any ] @@ -70,6 +82,8 @@ public class AttributeEmail { error: map["error"] as! String, `required`: map["required"] as! Bool, array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, format: map["format"] as! String, `default`: map["default"] as? String ) diff --git a/Sources/AppwriteModels/AttributeEnum.swift b/Sources/AppwriteModels/AttributeEnum.swift index 003f961..8694823 100644 --- a/Sources/AppwriteModels/AttributeEnum.swift +++ b/Sources/AppwriteModels/AttributeEnum.swift @@ -22,8 +22,14 @@ public class AttributeEnum { /// Is attribute an array? public let array: Bool? + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + /// Array of elements in enumerated type. - public let elements: [Any] + public let elements: [String] /// String format. public let format: String @@ -39,7 +45,9 @@ public class AttributeEnum { error: String, `required`: Bool, array: Bool?, - elements: [Any], + createdAt: String, + updatedAt: String, + elements: [String], format: String, `default`: String? ) { @@ -49,6 +57,8 @@ public class AttributeEnum { self.error = error self.`required` = `required` self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt self.elements = elements self.format = format self.`default` = `default` @@ -62,6 +72,8 @@ public class AttributeEnum { "error": error as Any, "`required`": `required` as Any, "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, "elements": elements as Any, "format": format as Any, "`default`": `default` as Any @@ -76,7 +88,9 @@ public class AttributeEnum { error: map["error"] as! String, `required`: map["required"] as! Bool, array: map["array"] as? Bool, - elements: map["elements"] as! [Any], + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + elements: map["elements"] as! [String], format: map["format"] as! String, `default`: map["default"] as? String ) diff --git a/Sources/AppwriteModels/AttributeFloat.swift b/Sources/AppwriteModels/AttributeFloat.swift index 27869a1..72d2353 100644 --- a/Sources/AppwriteModels/AttributeFloat.swift +++ b/Sources/AppwriteModels/AttributeFloat.swift @@ -22,6 +22,12 @@ public class AttributeFloat { /// Is attribute an array? public let array: Bool? + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + /// Minimum value to enforce for new documents. public let min: Double? @@ -39,6 +45,8 @@ public class AttributeFloat { error: String, `required`: Bool, array: Bool?, + createdAt: String, + updatedAt: String, min: Double?, max: Double?, `default`: Double? @@ -49,6 +57,8 @@ public class AttributeFloat { self.error = error self.`required` = `required` self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt self.min = min self.max = max self.`default` = `default` @@ -62,6 +72,8 @@ public class AttributeFloat { "error": error as Any, "`required`": `required` as Any, "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, "min": min as Any, "max": max as Any, "`default`": `default` as Any @@ -76,6 +88,8 @@ public class AttributeFloat { error: map["error"] as! String, `required`: map["required"] as! Bool, array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, min: map["min"] as? Double, max: map["max"] as? Double, `default`: map["default"] as? Double diff --git a/Sources/AppwriteModels/AttributeInteger.swift b/Sources/AppwriteModels/AttributeInteger.swift index bf85a88..eaca8ac 100644 --- a/Sources/AppwriteModels/AttributeInteger.swift +++ b/Sources/AppwriteModels/AttributeInteger.swift @@ -22,6 +22,12 @@ public class AttributeInteger { /// Is attribute an array? public let array: Bool? + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + /// Minimum value to enforce for new documents. public let min: Int? @@ -39,6 +45,8 @@ public class AttributeInteger { error: String, `required`: Bool, array: Bool?, + createdAt: String, + updatedAt: String, min: Int?, max: Int?, `default`: Int? @@ -49,6 +57,8 @@ public class AttributeInteger { self.error = error self.`required` = `required` self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt self.min = min self.max = max self.`default` = `default` @@ -62,6 +72,8 @@ public class AttributeInteger { "error": error as Any, "`required`": `required` as Any, "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, "min": min as Any, "max": max as Any, "`default`": `default` as Any @@ -76,6 +88,8 @@ public class AttributeInteger { error: map["error"] as! String, `required`: map["required"] as! Bool, array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, min: map["min"] as? Int, max: map["max"] as? Int, `default`: map["default"] as? Int diff --git a/Sources/AppwriteModels/AttributeIp.swift b/Sources/AppwriteModels/AttributeIp.swift index 5bce92e..39bd657 100644 --- a/Sources/AppwriteModels/AttributeIp.swift +++ b/Sources/AppwriteModels/AttributeIp.swift @@ -22,6 +22,12 @@ public class AttributeIp { /// Is attribute an array? public let array: Bool? + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + /// String format. public let format: String @@ -36,6 +42,8 @@ public class AttributeIp { error: String, `required`: Bool, array: Bool?, + createdAt: String, + updatedAt: String, format: String, `default`: String? ) { @@ -45,6 +53,8 @@ public class AttributeIp { self.error = error self.`required` = `required` self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt self.format = format self.`default` = `default` } @@ -57,6 +67,8 @@ public class AttributeIp { "error": error as Any, "`required`": `required` as Any, "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, "format": format as Any, "`default`": `default` as Any ] @@ -70,6 +82,8 @@ public class AttributeIp { error: map["error"] as! String, `required`: map["required"] as! Bool, array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, format: map["format"] as! String, `default`: map["default"] as? String ) diff --git a/Sources/AppwriteModels/AttributeRelationship.swift b/Sources/AppwriteModels/AttributeRelationship.swift index b1246a7..8d8c8d0 100644 --- a/Sources/AppwriteModels/AttributeRelationship.swift +++ b/Sources/AppwriteModels/AttributeRelationship.swift @@ -22,6 +22,12 @@ public class AttributeRelationship { /// Is attribute an array? public let array: Bool? + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + /// The ID of the related collection. public let relatedCollection: String @@ -48,6 +54,8 @@ public class AttributeRelationship { error: String, `required`: Bool, array: Bool?, + createdAt: String, + updatedAt: String, relatedCollection: String, relationType: String, twoWay: Bool, @@ -61,6 +69,8 @@ public class AttributeRelationship { self.error = error self.`required` = `required` self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt self.relatedCollection = relatedCollection self.relationType = relationType self.twoWay = twoWay @@ -77,6 +87,8 @@ public class AttributeRelationship { "error": error as Any, "`required`": `required` as Any, "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, "relatedCollection": relatedCollection as Any, "relationType": relationType as Any, "twoWay": twoWay as Any, @@ -94,6 +106,8 @@ public class AttributeRelationship { error: map["error"] as! String, `required`: map["required"] as! Bool, array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, relatedCollection: map["relatedCollection"] as! String, relationType: map["relationType"] as! String, twoWay: map["twoWay"] as! Bool, diff --git a/Sources/AppwriteModels/AttributeString.swift b/Sources/AppwriteModels/AttributeString.swift index c6b0f6e..d609b0a 100644 --- a/Sources/AppwriteModels/AttributeString.swift +++ b/Sources/AppwriteModels/AttributeString.swift @@ -22,6 +22,12 @@ public class AttributeString { /// Is attribute an array? public let array: Bool? + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + /// Attribute size. public let size: Int @@ -36,6 +42,8 @@ public class AttributeString { error: String, `required`: Bool, array: Bool?, + createdAt: String, + updatedAt: String, size: Int, `default`: String? ) { @@ -45,6 +53,8 @@ public class AttributeString { self.error = error self.`required` = `required` self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt self.size = size self.`default` = `default` } @@ -57,6 +67,8 @@ public class AttributeString { "error": error as Any, "`required`": `required` as Any, "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, "size": size as Any, "`default`": `default` as Any ] @@ -70,6 +82,8 @@ public class AttributeString { error: map["error"] as! String, `required`: map["required"] as! Bool, array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, size: map["size"] as! Int, `default`: map["default"] as? String ) diff --git a/Sources/AppwriteModels/AttributeUrl.swift b/Sources/AppwriteModels/AttributeUrl.swift index 0853bd6..952d990 100644 --- a/Sources/AppwriteModels/AttributeUrl.swift +++ b/Sources/AppwriteModels/AttributeUrl.swift @@ -22,6 +22,12 @@ public class AttributeUrl { /// Is attribute an array? public let array: Bool? + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + /// String format. public let format: String @@ -36,6 +42,8 @@ public class AttributeUrl { error: String, `required`: Bool, array: Bool?, + createdAt: String, + updatedAt: String, format: String, `default`: String? ) { @@ -45,6 +53,8 @@ public class AttributeUrl { self.error = error self.`required` = `required` self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt self.format = format self.`default` = `default` } @@ -57,6 +67,8 @@ public class AttributeUrl { "error": error as Any, "`required`": `required` as Any, "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, "format": format as Any, "`default`": `default` as Any ] @@ -70,6 +82,8 @@ public class AttributeUrl { error: map["error"] as! String, `required`: map["required"] as! Bool, array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, format: map["format"] as! String, `default`: map["default"] as? String ) diff --git a/Sources/AppwriteModels/Bucket.swift b/Sources/AppwriteModels/Bucket.swift index 9986ae6..d10f6a8 100644 --- a/Sources/AppwriteModels/Bucket.swift +++ b/Sources/AppwriteModels/Bucket.swift @@ -14,7 +14,7 @@ public class Bucket { public let updatedAt: String /// Bucket permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - public let permissions: [Any] + public let permissions: [String] /// Whether file-level security is enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). public let fileSecurity: Bool @@ -29,7 +29,7 @@ public class Bucket { public let maximumFileSize: Int /// Allowed file extensions. - public let allowedFileExtensions: [Any] + public let allowedFileExtensions: [String] /// Compression algorithm choosen for compression. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). public let compression: String @@ -45,12 +45,12 @@ public class Bucket { id: String, createdAt: String, updatedAt: String, - permissions: [Any], + permissions: [String], fileSecurity: Bool, name: String, enabled: Bool, maximumFileSize: Int, - allowedFileExtensions: [Any], + allowedFileExtensions: [String], compression: String, encryption: Bool, antivirus: Bool @@ -91,12 +91,12 @@ public class Bucket { 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], fileSecurity: map["fileSecurity"] as! Bool, name: map["name"] as! String, enabled: map["enabled"] as! Bool, maximumFileSize: map["maximumFileSize"] as! Int, - allowedFileExtensions: map["allowedFileExtensions"] as! [Any], + allowedFileExtensions: map["allowedFileExtensions"] as! [String], compression: map["compression"] as! String, encryption: map["encryption"] as! Bool, antivirus: map["antivirus"] as! Bool diff --git a/Sources/AppwriteModels/Collection.swift b/Sources/AppwriteModels/Collection.swift index 7ff6243..7b609ad 100644 --- a/Sources/AppwriteModels/Collection.swift +++ b/Sources/AppwriteModels/Collection.swift @@ -14,7 +14,7 @@ public class Collection { public let updatedAt: String /// Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - public let permissions: [Any] + public let permissions: [String] /// Database ID. public let databaseId: String @@ -39,7 +39,7 @@ public class Collection { id: String, createdAt: String, updatedAt: String, - permissions: [Any], + permissions: [String], databaseId: String, name: String, enabled: Bool, @@ -79,7 +79,7 @@ public class Collection { 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], databaseId: map["databaseId"] as! String, name: map["name"] as! String, enabled: map["enabled"] as! Bool, diff --git a/Sources/AppwriteModels/Document.swift b/Sources/AppwriteModels/Document.swift index 94069f9..c0c49c6 100644 --- a/Sources/AppwriteModels/Document.swift +++ b/Sources/AppwriteModels/Document.swift @@ -20,7 +20,7 @@ public class Document { 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 @@ -31,7 +31,7 @@ public class Document { databaseId: String, createdAt: String, updatedAt: String, - permissions: [Any], + permissions: [String], data: T ) { self.id = id @@ -62,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/Execution.swift b/Sources/AppwriteModels/Execution.swift index 0f04430..d589342 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -14,7 +14,7 @@ public class Execution { public let updatedAt: String /// Execution roles. - public let permissions: [Any] + public let permissions: [String] /// Function ID. public let functionId: String @@ -60,7 +60,7 @@ public class Execution { id: String, createdAt: String, updatedAt: String, - permissions: [Any], + permissions: [String], functionId: String, trigger: String, status: String, @@ -121,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, diff --git a/Sources/AppwriteModels/File.swift b/Sources/AppwriteModels/File.swift index 04a5b89..db896ab 100644 --- a/Sources/AppwriteModels/File.swift +++ b/Sources/AppwriteModels/File.swift @@ -17,7 +17,7 @@ public class File { 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 @@ -43,7 +43,7 @@ public class File { bucketId: String, createdAt: String, updatedAt: String, - permissions: [Any], + permissions: [String], name: String, signature: String, mimeType: String, @@ -86,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/Function.swift b/Sources/AppwriteModels/Function.swift index 2eb3f97..c91ce93 100644 --- a/Sources/AppwriteModels/Function.swift +++ b/Sources/AppwriteModels/Function.swift @@ -14,7 +14,7 @@ public class Function { public let updatedAt: String /// Execution permissions. - public let execute: [Any] + public let execute: [String] /// Function name. public let name: String @@ -35,15 +35,15 @@ public class Function { public let deployment: String /// Allowed permission scopes. - public let scopes: [Any] + public let scopes: [String] /// Function variables. public let vars: [Variable] /// Function trigger events. - public let events: [Any] + public let events: [String] - /// Function execution schedult in CRON format. + /// Function execution schedule in CRON format. public let schedule: String /// Function execution timeout in seconds. @@ -81,16 +81,16 @@ public class Function { id: String, createdAt: String, updatedAt: String, - execute: [Any], + execute: [String], name: String, enabled: Bool, live: Bool, logging: Bool, runtime: String, deployment: String, - scopes: [Any], + scopes: [String], vars: [Variable], - events: [Any], + events: [String], schedule: String, timeout: Int, entrypoint: String, @@ -163,16 +163,16 @@ public class Function { id: map["$id"] as! String, createdAt: map["$createdAt"] as! String, updatedAt: map["$updatedAt"] as! String, - execute: map["execute"] as! [Any], + execute: map["execute"] as! [String], name: map["name"] as! String, enabled: map["enabled"] as! Bool, live: map["live"] as! Bool, logging: map["logging"] as! Bool, runtime: map["runtime"] as! String, deployment: map["deployment"] as! String, - scopes: map["scopes"] as! [Any], + scopes: map["scopes"] as! [String], vars: (map["vars"] as! [[String: Any]]).map { Variable.from(map: $0) }, - events: map["events"] as! [Any], + events: map["events"] as! [String], schedule: map["schedule"] as! String, timeout: map["timeout"] as! Int, entrypoint: map["entrypoint"] as! String, diff --git a/Sources/AppwriteModels/Index.swift b/Sources/AppwriteModels/Index.swift index c878e39..019ec28 100644 --- a/Sources/AppwriteModels/Index.swift +++ b/Sources/AppwriteModels/Index.swift @@ -17,10 +17,16 @@ public class Index { public let error: String /// Index attributes. - public let attributes: [Any] + public let attributes: [String] /// Index orders. - public let orders: [Any]? + public let orders: [String]? + + /// Index creation date in ISO 8601 format. + public let createdAt: String + + /// Index update date in ISO 8601 format. + public let updatedAt: String init( @@ -28,8 +34,10 @@ public class Index { type: String, status: String, error: String, - attributes: [Any], - orders: [Any]? + attributes: [String], + orders: [String]?, + createdAt: String, + updatedAt: String ) { self.key = key self.type = type @@ -37,6 +45,8 @@ public class Index { self.error = error self.attributes = attributes self.orders = orders + self.createdAt = createdAt + self.updatedAt = updatedAt } public func toMap() -> [String: Any] { @@ -46,7 +56,9 @@ public class Index { "status": status as Any, "error": error as Any, "attributes": attributes as Any, - "orders": orders as Any + "orders": orders as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any ] } @@ -56,8 +68,10 @@ public class Index { type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, - attributes: map["attributes"] as! [Any], - orders: map["orders"] as? [Any] + attributes: map["attributes"] as! [String], + orders: map["orders"] as? [String], + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String ) } } diff --git a/Sources/AppwriteModels/Membership.swift b/Sources/AppwriteModels/Membership.swift index 55fb199..805cb47 100644 --- a/Sources/AppwriteModels/Membership.swift +++ b/Sources/AppwriteModels/Membership.swift @@ -16,10 +16,10 @@ public class Membership { /// 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. @@ -37,11 +37,11 @@ public class Membership { /// 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( @@ -57,7 +57,7 @@ public class Membership { joined: String, confirm: Bool, mfa: Bool, - roles: [Any] + roles: [String] ) { self.id = id self.createdAt = createdAt @@ -106,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/Message.swift b/Sources/AppwriteModels/Message.swift index 32e8897..1bbe9f9 100644 --- a/Sources/AppwriteModels/Message.swift +++ b/Sources/AppwriteModels/Message.swift @@ -17,13 +17,13 @@ public class Message { public let providerType: String /// Topic IDs set as recipients. - public let topics: [Any] + public let topics: [String] /// User IDs set as recipients. - public let users: [Any] + public let users: [String] /// Target IDs set as recipients. - public let targets: [Any] + public let targets: [String] /// The scheduled time for message. public let scheduledAt: String? @@ -32,7 +32,7 @@ public class Message { public let deliveredAt: String? /// Delivery errors if any. - public let deliveryErrors: [Any]? + public let deliveryErrors: [String]? /// Number of recipients the message was delivered to. public let deliveredTotal: Int @@ -49,12 +49,12 @@ public class Message { createdAt: String, updatedAt: String, providerType: String, - topics: [Any], - users: [Any], - targets: [Any], + topics: [String], + users: [String], + targets: [String], scheduledAt: String?, deliveredAt: String?, - deliveryErrors: [Any]?, + deliveryErrors: [String]?, deliveredTotal: Int, data: Any, status: String @@ -98,12 +98,12 @@ public class Message { createdAt: map["$createdAt"] as! String, updatedAt: map["$updatedAt"] as! String, providerType: map["providerType"] as! String, - topics: map["topics"] as! [Any], - users: map["users"] as! [Any], - targets: map["targets"] as! [Any], + topics: map["topics"] as! [String], + users: map["users"] as! [String], + targets: map["targets"] as! [String], scheduledAt: map["scheduledAt"] as? String, deliveredAt: map["deliveredAt"] as? String, - deliveryErrors: map["deliveryErrors"] as? [Any], + deliveryErrors: map["deliveryErrors"] as? [String], deliveredTotal: map["deliveredTotal"] as! Int, data: map["data"] as! Any, status: map["status"] as! String diff --git a/Sources/AppwriteModels/MfaRecoveryCodes.swift b/Sources/AppwriteModels/MfaRecoveryCodes.swift index 8dd063b..314e11c 100644 --- a/Sources/AppwriteModels/MfaRecoveryCodes.swift +++ b/Sources/AppwriteModels/MfaRecoveryCodes.swift @@ -5,11 +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 } @@ -22,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/Runtime.swift b/Sources/AppwriteModels/Runtime.swift index 66906e1..01ea4c4 100644 --- a/Sources/AppwriteModels/Runtime.swift +++ b/Sources/AppwriteModels/Runtime.swift @@ -26,7 +26,7 @@ public class Runtime { public let logo: String /// List of supported architectures. - public let supports: [Any] + public let supports: [String] init( @@ -37,7 +37,7 @@ public class Runtime { base: String, image: String, logo: String, - supports: [Any] + supports: [String] ) { self.id = id self.key = key @@ -71,7 +71,7 @@ public class Runtime { base: map["base"] as! String, image: map["image"] as! String, logo: map["logo"] as! String, - supports: map["supports"] as! [Any] + supports: map["supports"] as! [String] ) } } diff --git a/Sources/AppwriteModels/Session.swift b/Sources/AppwriteModels/Session.swift index 7214468..86f4a7c 100644 --- a/Sources/AppwriteModels/Session.swift +++ b/Sources/AppwriteModels/Session.swift @@ -83,7 +83,7 @@ public class 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 @@ -119,7 +119,7 @@ public class Session { countryCode: String, countryName: String, current: Bool, - factors: [Any], + factors: [String], secret: String, mfaUpdatedAt: String ) { @@ -216,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/Target.swift b/Sources/AppwriteModels/Target.swift index 087eca6..2e81790 100644 --- a/Sources/AppwriteModels/Target.swift +++ b/Sources/AppwriteModels/Target.swift @@ -28,6 +28,9 @@ public class Target { /// The target identifier. public let identifier: String + /// Is the target expired. + public let expired: Bool + init( id: String, @@ -37,7 +40,8 @@ public class Target { userId: String, providerId: String?, providerType: String, - identifier: String + identifier: String, + expired: Bool ) { self.id = id self.createdAt = createdAt @@ -47,6 +51,7 @@ public class Target { self.providerId = providerId self.providerType = providerType self.identifier = identifier + self.expired = expired } public func toMap() -> [String: Any] { @@ -58,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 ] } @@ -71,7 +77,8 @@ public class Target { userId: map["userId"] 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/Topic.swift b/Sources/AppwriteModels/Topic.swift index c8398e6..bc89a07 100644 --- a/Sources/AppwriteModels/Topic.swift +++ b/Sources/AppwriteModels/Topic.swift @@ -26,7 +26,7 @@ public class Topic { public let pushTotal: Int /// Subscribe permissions. - public let subscribe: [Any] + public let subscribe: [String] init( @@ -37,7 +37,7 @@ public class Topic { emailTotal: Int, smsTotal: Int, pushTotal: Int, - subscribe: [Any] + subscribe: [String] ) { self.id = id self.createdAt = createdAt @@ -71,7 +71,7 @@ public class Topic { emailTotal: map["emailTotal"] as! Int, smsTotal: map["smsTotal"] as! Int, pushTotal: map["pushTotal"] as! Int, - subscribe: map["subscribe"] as! [Any] + subscribe: map["subscribe"] as! [String] ) } } diff --git a/Sources/AppwriteModels/User.swift b/Sources/AppwriteModels/User.swift index d12c343..0229dc5 100644 --- a/Sources/AppwriteModels/User.swift +++ b/Sources/AppwriteModels/User.swift @@ -32,7 +32,7 @@ public class User { 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 @@ -72,7 +72,7 @@ public class User { hashOptions: Any?, registration: String, status: Bool, - labels: [Any], + labels: [String], passwordUpdate: String, email: String, phone: String, @@ -139,7 +139,7 @@ public class User { 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/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index 5fafd5e..d3129dc 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -13,7 +13,7 @@ let attributeString = try await databases.updateStringAttribute( key: "", required: false, default: "", - size: 0, // optional + size: 1, // optional newKey: "" // optional ) diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index dbc7bf0..42f48dd 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -1,4 +1,5 @@ import Appwrite +import AppwriteEnums let client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,8 +10,8 @@ let messaging = Messaging(client) let message = try await messaging.createPush( messageId: "", - title: "", - body: "<BODY>", + title: "<TITLE>", // optional + body: "<BODY>", // optional topics: [], // optional users: [], // optional targets: [], // optional @@ -21,8 +22,11 @@ let message = try await messaging.createPush( sound: "<SOUND>", // optional color: "<COLOR>", // optional tag: "<TAG>", // optional - badge: "<BADGE>", // optional + badge: 0, // optional draft: false, // optional - scheduledAt: "" // optional + scheduledAt: "", // optional + contentAvailable: false, // optional + critical: false, // optional + priority: .normal // optional ) diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index 40ce34b..02893a1 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -1,4 +1,5 @@ import Appwrite +import AppwriteEnums let client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -23,6 +24,9 @@ let message = try await messaging.updatePush( tag: "<TAG>", // optional badge: 0, // optional draft: false, // optional - scheduledAt: "" // optional + scheduledAt: "", // optional + contentAvailable: false, // optional + critical: false, // optional + priority: .normal // optional )