diff --git a/CHANGELOG.md b/CHANGELOG.md index ed5f82c..33ec214 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 13.3.0 + +* Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance +* Add `Operator` class for atomic modification of rows via update, bulk update, upsert, and bulk upsert operations +* Add `createResendProvider` and `updateResendProvider` methods to `Messaging` service + ## 13.2.2 * Fix issue: Missing AppwriteEnums dependency causing build failure diff --git a/README.md b/README.md index ca65b12..61bbff6 100644 --- a/README.md +++ b/README.md @@ -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: "13.2.2"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "13.3.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index ba690e4..383708d 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": "13.2.2", + "x-sdk-version": "13.3.0", "x-appwrite-response-format": "1.8.0" ] diff --git a/Sources/Appwrite/Operator.swift b/Sources/Appwrite/Operator.swift new file mode 100644 index 0000000..6af290f --- /dev/null +++ b/Sources/Appwrite/Operator.swift @@ -0,0 +1,305 @@ +import Foundation + +public enum Condition: String, Codable { + case equal = "equal" + case notEqual = "notEqual" + case greaterThan = "greaterThan" + case greaterThanEqual = "greaterThanEqual" + case lessThan = "lessThan" + case lessThanEqual = "lessThanEqual" + case contains = "contains" + case isNull = "isNull" + case isNotNull = "isNotNull" +} + +enum OperatorValue: Codable { + case string(String) + case int(Int) + case double(Double) + case bool(Bool) + case array([OperatorValue]) + case null + + init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + if container.decodeNil() { + self = .null + } else if let stringValue = try? container.decode(String.self) { + self = .string(stringValue) + } else if let intValue = try? container.decode(Int.self) { + self = .int(intValue) + } else if let doubleValue = try? container.decode(Double.self) { + self = .double(doubleValue) + } else if let boolValue = try? container.decode(Bool.self) { + self = .bool(boolValue) + } else if let arrayValue = try? container.decode([OperatorValue].self) { + self = .array(arrayValue) + } else { + throw DecodingError.dataCorruptedError( + in: container, + debugDescription: "OperatorValue cannot be decoded" + ) + } + } + + func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + switch self { + case .string(let value): + try container.encode(value) + case .int(let value): + try container.encode(value) + case .double(let value): + try container.encode(value) + case .bool(let value): + try container.encode(value) + case .array(let value): + try container.encode(value) + case .null: + try container.encodeNil() + } + } +} + +public struct Operator : Codable, CustomStringConvertible { + var method: String + var values: [OperatorValue]? + + init(method: String, values: Any? = nil) { + self.method = method + self.values = Operator.convertToOperatorValueArray(values) + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.method = try container.decode(String.self, forKey: .method) + self.values = try container.decodeIfPresent([OperatorValue].self, forKey: .values) + } + + private static func convertToOperatorValueArray(_ values: Any?) -> [OperatorValue]? { + // Handle nil + if values == nil { + return nil + } + + // Handle NSNull as [.null] + if values is NSNull { + return [.null] + } + + switch values { + case let valueArray as [OperatorValue]: + return valueArray + case let stringArray as [String]: + return stringArray.map { .string($0) } + case let intArray as [Int]: + return intArray.map { .int($0) } + case let doubleArray as [Double]: + return doubleArray.map { .double($0) } + case let boolArray as [Bool]: + return boolArray.map { .bool($0) } + case let stringValue as String: + return [.string(stringValue)] + case let intValue as Int: + return [.int(intValue)] + case let doubleValue as Double: + return [.double(doubleValue)] + case let boolValue as Bool: + return [.bool(boolValue)] + case let anyArray as [Any]: + // Preserve empty arrays as empty OperatorValue arrays + if anyArray.isEmpty { + return [] + } + + // Map all items, converting nil/unknown to .null + let nestedValues = anyArray.map { item -> OperatorValue in + if item is NSNull { + return .null + } else if let stringValue = item as? String { + return .string(stringValue) + } else if let intValue = item as? Int { + return .int(intValue) + } else if let doubleValue = item as? Double { + return .double(doubleValue) + } else if let boolValue = item as? Bool { + return .bool(boolValue) + } else if let nestedArray = item as? [Any] { + let converted = convertToOperatorValueArray(nestedArray) ?? [] + return .array(converted) + } else { + // Unknown/unsupported types become .null + return .null + } + } + return nestedValues + default: + // Unknown types become [.null] + return [.null] + } + } + + enum CodingKeys: String, CodingKey { + case method + case values + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(method, forKey: .method) + + if (values != nil) { + try container.encode(values, forKey: .values) + } + } + + public var description: String { + guard let data = try? JSONEncoder().encode(self) else { + return "" + } + + return String(data: data, encoding: .utf8) ?? "" + } + + public static func increment(_ value: Double = 1, max: Double? = nil) -> String { + if value.isNaN || value.isInfinite { + fatalError("Value cannot be NaN or Infinity") + } + if let max = max, max.isNaN || max.isInfinite { + fatalError("Max cannot be NaN or Infinity") + } + var values: [Any] = [value] + if let max = max { + values.append(max) + } + return Operator(method: "increment", values: values).description + } + + public static func decrement(_ value: Double = 1, min: Double? = nil) -> String { + if value.isNaN || value.isInfinite { + fatalError("Value cannot be NaN or Infinity") + } + if let min = min, min.isNaN || min.isInfinite { + fatalError("Min cannot be NaN or Infinity") + } + var values: [Any] = [value] + if let min = min { + values.append(min) + } + return Operator(method: "decrement", values: values).description + } + + public static func multiply(_ factor: Double, max: Double? = nil) -> String { + if factor.isNaN || factor.isInfinite { + fatalError("Factor cannot be NaN or Infinity") + } + if let max = max, max.isNaN || max.isInfinite { + fatalError("Max cannot be NaN or Infinity") + } + var values: [Any] = [factor] + if let max = max { + values.append(max) + } + return Operator(method: "multiply", values: values).description + } + + public static func divide(_ divisor: Double, min: Double? = nil) -> String { + if divisor.isNaN || divisor.isInfinite { + fatalError("Divisor cannot be NaN or Infinity") + } + if let min = min, min.isNaN || min.isInfinite { + fatalError("Min cannot be NaN or Infinity") + } + if divisor == 0 { + fatalError("Divisor cannot be zero") + } + var values: [Any] = [divisor] + if let min = min { + values.append(min) + } + return Operator(method: "divide", values: values).description + } + + public static func modulo(_ divisor: Double) -> String { + if divisor.isNaN || divisor.isInfinite { + fatalError("Divisor cannot be NaN or Infinity") + } + if divisor == 0 { + fatalError("Divisor cannot be zero") + } + return Operator(method: "modulo", values: [divisor]).description + } + + public static func power(_ exponent: Double, max: Double? = nil) -> String { + if exponent.isNaN || exponent.isInfinite { + fatalError("Exponent cannot be NaN or Infinity") + } + if let max = max, max.isNaN || max.isInfinite { + fatalError("Max cannot be NaN or Infinity") + } + var values: [Any] = [exponent] + if let max = max { + values.append(max) + } + return Operator(method: "power", values: values).description + } + + public static func arrayAppend(_ values: [Any]) -> String { + return Operator(method: "arrayAppend", values: values).description + } + + public static func arrayPrepend(_ values: [Any]) -> String { + return Operator(method: "arrayPrepend", values: values).description + } + + public static func arrayInsert(_ index: Int, value: Any) -> String { + return Operator(method: "arrayInsert", values: [index, value]).description + } + + public static func arrayRemove(_ value: Any) -> String { + return Operator(method: "arrayRemove", values: [value]).description + } + + public static func arrayUnique() -> String { + return Operator(method: "arrayUnique", values: []).description + } + + public static func arrayIntersect(_ values: [Any]) -> String { + return Operator(method: "arrayIntersect", values: values).description + } + + public static func arrayDiff(_ values: [Any]) -> String { + return Operator(method: "arrayDiff", values: values).description + } + + public static func arrayFilter(_ condition: Condition, value: Any? = nil) -> String { + let values: [Any] = [condition.rawValue, value ?? NSNull()] + return Operator(method: "arrayFilter", values: values).description + } + + public static func stringConcat(_ value: Any) -> String { + return Operator(method: "stringConcat", values: [value]).description + } + + public static func stringReplace(_ search: String, _ replace: String) -> String { + return Operator(method: "stringReplace", values: [search, replace]).description + } + + public static func toggle() -> String { + return Operator(method: "toggle", values: []).description + } + + public static func dateAddDays(_ days: Int) -> String { + return Operator(method: "dateAddDays", values: [days]).description + } + + public static func dateSubDays(_ days: Int) -> String { + return Operator(method: "dateSubDays", values: [days]).description + } + + public static func dateSetNow() -> String { + return Operator(method: "dateSetNow", values: []).description + } +} diff --git a/Sources/Appwrite/Query.swift b/Sources/Appwrite/Query.swift index e4f06b5..7610dc3 100644 --- a/Sources/Appwrite/Query.swift +++ b/Sources/Appwrite/Query.swift @@ -379,45 +379,27 @@ public struct Query : Codable, CustomStringConvertible { } public static func createdBefore(_ value: String) -> String { - return Query( - method: "createdBefore", - values: [value] - ).description + return lessThan("$createdAt", value: value) } public static func createdAfter(_ value: String) -> String { - return Query( - method: "createdAfter", - values: [value] - ).description + return greaterThan("$createdAt", value: value) } public static func createdBetween(_ start: String, _ end: String) -> String { - return Query( - method: "createdBetween", - values: [start, end] - ).description + return between("$createdAt", start: start, end: end) } public static func updatedBefore(_ value: String) -> String { - return Query( - method: "updatedBefore", - values: [value] - ).description + return lessThan("$updatedAt", value: value) } public static func updatedAfter(_ value: String) -> String { - return Query( - method: "updatedAfter", - values: [value] - ).description + return greaterThan("$updatedAt", value: value) } public static func updatedBetween(_ start: String, _ end: String) -> String { - return Query( - method: "updatedBetween", - values: [start, end] - ).description + return between("$updatedAt", start: start, end: end) } public static func or(_ queries: [String]) -> String { diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index e9a9d4d..8a46e2d 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -208,16 +208,19 @@ open class Account: Service { /// /// - Parameters: /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.IdentityList /// open func listIdentities( - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.IdentityList { let apiPath: String = "/account/identities" let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] @@ -301,16 +304,19 @@ open class Account: Service { /// /// - Parameters: /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.LogList /// open func listLogs( - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.LogList { let apiPath: String = "/account/logs" let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index 4a450f8..4381d13 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -15,19 +15,22 @@ open class Databases: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DatabaseList /// @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.list` instead.") open func list( queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.DatabaseList { let apiPath: String = "/databases" let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -399,6 +402,7 @@ open class Databases: Service { /// - databaseId: String /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.CollectionList /// @@ -406,14 +410,16 @@ open class Databases: Service { open func listCollections( databaseId: String, queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.CollectionList { let apiPath: String = "/databases/{databaseId}/collections" .replacingOccurrences(of: "{databaseId}", with: databaseId) let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -609,6 +615,7 @@ open class Databases: Service { /// - databaseId: String /// - collectionId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeList /// @@ -616,14 +623,16 @@ open class Databases: Service { open func listAttributes( databaseId: String, collectionId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.AttributeList { let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes" .replacingOccurrences(of: "{databaseId}", with: databaseId) .replacingOccurrences(of: "{collectionId}", with: collectionId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] @@ -2083,6 +2092,7 @@ open class Databases: Service { /// - collectionId: String /// - queries: [String] (optional) /// - transactionId: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// @@ -2092,6 +2102,7 @@ open class Databases: Service { collectionId: String, queries: [String]? = nil, transactionId: String? = nil, + total: Bool? = nil, nestedType: T.Type ) async throws -> AppwriteModels.DocumentList { let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents" @@ -2100,7 +2111,8 @@ open class Databases: Service { let apiParams: [String: Any?] = [ "queries": queries, - "transactionId": transactionId + "transactionId": transactionId, + "total": total ] let apiHeaders: [String: String] = [:] @@ -2127,6 +2139,7 @@ open class Databases: Service { /// - collectionId: String /// - queries: [String] (optional) /// - transactionId: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// @@ -2135,13 +2148,15 @@ open class Databases: Service { databaseId: String, collectionId: String, queries: [String]? = nil, - transactionId: String? = nil + transactionId: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> { return try await listDocuments( databaseId: databaseId, collectionId: collectionId, queries: queries, transactionId: transactionId, + total: total, nestedType: [String: AnyCodable].self ) } @@ -3029,6 +3044,7 @@ open class Databases: Service { /// - databaseId: String /// - collectionId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.IndexList /// @@ -3036,14 +3052,16 @@ open class Databases: Service { open func listIndexes( databaseId: String, collectionId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.IndexList { let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/indexes" .replacingOccurrences(of: "{databaseId}", with: databaseId) .replacingOccurrences(of: "{collectionId}", with: collectionId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] diff --git a/Sources/Appwrite/Services/Functions.swift b/Sources/Appwrite/Services/Functions.swift index 881d62f..5174edd 100644 --- a/Sources/Appwrite/Services/Functions.swift +++ b/Sources/Appwrite/Services/Functions.swift @@ -15,18 +15,21 @@ open class Functions: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.FunctionList /// open func list( queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.FunctionList { let apiPath: String = "/functions" let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -375,20 +378,23 @@ open class Functions: Service { /// - functionId: String /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DeploymentList /// open func listDeployments( functionId: String, queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.DeploymentList { let apiPath: String = "/functions/{functionId}/deployments" .replacingOccurrences(of: "{functionId}", with: functionId) let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -755,18 +761,21 @@ open class Functions: Service { /// - Parameters: /// - functionId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.ExecutionList /// open func listExecutions( functionId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.ExecutionList { let apiPath: String = "/functions/{functionId}/executions" .replacingOccurrences(of: "{functionId}", with: functionId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] diff --git a/Sources/Appwrite/Services/Messaging.swift b/Sources/Appwrite/Services/Messaging.swift index 1b97c72..495a3c1 100644 --- a/Sources/Appwrite/Services/Messaging.swift +++ b/Sources/Appwrite/Services/Messaging.swift @@ -14,18 +14,21 @@ open class Messaging: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MessageList /// open func listMessages( queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.MessageList { let apiPath: String = "/messaging/messages" let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -641,18 +644,21 @@ open class Messaging: Service { /// - Parameters: /// - messageId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.LogList /// open func listMessageLogs( messageId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.LogList { let apiPath: String = "/messaging/messages/{messageId}/logs" .replacingOccurrences(of: "{messageId}", with: messageId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] @@ -676,18 +682,21 @@ open class Messaging: Service { /// - Parameters: /// - messageId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.TargetList /// open func listTargets( messageId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.TargetList { let apiPath: String = "/messaging/messages/{messageId}/targets" .replacingOccurrences(of: "{messageId}", with: messageId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] @@ -711,18 +720,21 @@ open class Messaging: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.ProviderList /// open func listProviders( queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.ProviderList { let apiPath: String = "/messaging/providers" let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -1356,6 +1368,116 @@ open class Messaging: Service { ) } + /// + /// Create a new Resend provider. + /// + /// - Parameters: + /// - providerId: String + /// - name: String + /// - apiKey: String (optional) + /// - fromName: String (optional) + /// - fromEmail: String (optional) + /// - replyToName: String (optional) + /// - replyToEmail: String (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider + /// + open func createResendProvider( + providerId: String, + name: String, + apiKey: String? = nil, + fromName: String? = nil, + fromEmail: String? = nil, + replyToName: String? = nil, + replyToEmail: String? = nil, + enabled: Bool? = nil + ) async throws -> AppwriteModels.Provider { + let apiPath: String = "/messaging/providers/resend" + + let apiParams: [String: Any?] = [ + "providerId": providerId, + "name": name, + "apiKey": apiKey, + "fromName": fromName, + "fromEmail": fromEmail, + "replyToName": replyToName, + "replyToEmail": replyToEmail, + "enabled": enabled + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Provider = { response in + return AppwriteModels.Provider.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a Resend provider by its unique ID. + /// + /// - Parameters: + /// - providerId: String + /// - name: String (optional) + /// - enabled: Bool (optional) + /// - apiKey: String (optional) + /// - fromName: String (optional) + /// - fromEmail: String (optional) + /// - replyToName: String (optional) + /// - replyToEmail: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider + /// + open func updateResendProvider( + providerId: String, + name: String? = nil, + enabled: Bool? = nil, + apiKey: String? = nil, + fromName: String? = nil, + fromEmail: String? = nil, + replyToName: String? = nil, + replyToEmail: String? = nil + ) async throws -> AppwriteModels.Provider { + let apiPath: String = "/messaging/providers/resend/{providerId}" + .replacingOccurrences(of: "{providerId}", with: providerId) + + let apiParams: [String: Any?] = [ + "name": name, + "enabled": enabled, + "apiKey": apiKey, + "fromName": fromName, + "fromEmail": fromEmail, + "replyToName": replyToName, + "replyToEmail": replyToEmail + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Provider = { response in + return AppwriteModels.Provider.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Create a new Sendgrid provider. /// @@ -2217,18 +2339,21 @@ open class Messaging: Service { /// - Parameters: /// - providerId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.LogList /// open func listProviderLogs( providerId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.LogList { let apiPath: String = "/messaging/providers/{providerId}/logs" .replacingOccurrences(of: "{providerId}", with: providerId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] @@ -2252,18 +2377,21 @@ open class Messaging: Service { /// - Parameters: /// - subscriberId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.LogList /// open func listSubscriberLogs( subscriberId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.LogList { let apiPath: String = "/messaging/subscribers/{subscriberId}/logs" .replacingOccurrences(of: "{subscriberId}", with: subscriberId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] @@ -2287,18 +2415,21 @@ open class Messaging: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.TopicList /// open func listTopics( queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.TopicList { let apiPath: String = "/messaging/topics" let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -2462,18 +2593,21 @@ open class Messaging: Service { /// - Parameters: /// - topicId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.LogList /// open func listTopicLogs( topicId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.LogList { let apiPath: String = "/messaging/topics/{topicId}/logs" .replacingOccurrences(of: "{topicId}", with: topicId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] @@ -2498,20 +2632,23 @@ open class Messaging: Service { /// - topicId: String /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.SubscriberList /// open func listSubscribers( topicId: String, queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.SubscriberList { let apiPath: String = "/messaging/topics/{topicId}/subscribers" .replacingOccurrences(of: "{topicId}", with: topicId) let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] diff --git a/Sources/Appwrite/Services/Sites.swift b/Sources/Appwrite/Services/Sites.swift index 3fba7ba..328570e 100644 --- a/Sources/Appwrite/Services/Sites.swift +++ b/Sources/Appwrite/Services/Sites.swift @@ -15,18 +15,21 @@ open class Sites: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.SiteList /// open func list( queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.SiteList { let apiPath: String = "/sites" let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -373,20 +376,23 @@ open class Sites: Service { /// - siteId: String /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DeploymentList /// open func listDeployments( siteId: String, queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.DeploymentList { let apiPath: String = "/sites/{siteId}/deployments" .replacingOccurrences(of: "{siteId}", with: siteId) let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -746,18 +752,21 @@ open class Sites: Service { /// - Parameters: /// - siteId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.ExecutionList /// open func listLogs( siteId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.ExecutionList { let apiPath: String = "/sites/{siteId}/logs" .replacingOccurrences(of: "{siteId}", with: siteId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] diff --git a/Sources/Appwrite/Services/Storage.swift b/Sources/Appwrite/Services/Storage.swift index 7852911..e40487f 100644 --- a/Sources/Appwrite/Services/Storage.swift +++ b/Sources/Appwrite/Services/Storage.swift @@ -15,18 +15,21 @@ open class Storage: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.BucketList /// open func listBuckets( queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.BucketList { let apiPath: String = "/storage/buckets" let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -233,20 +236,23 @@ open class Storage: Service { /// - bucketId: String /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.FileList /// open func listFiles( bucketId: String, queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.FileList { let apiPath: String = "/storage/buckets/{bucketId}/files" .replacingOccurrences(of: "{bucketId}", with: bucketId) let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] diff --git a/Sources/Appwrite/Services/TablesDb.swift b/Sources/Appwrite/Services/TablesDb.swift index fcc344d..7aec046 100644 --- a/Sources/Appwrite/Services/TablesDb.swift +++ b/Sources/Appwrite/Services/TablesDb.swift @@ -15,18 +15,21 @@ open class TablesDB: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DatabaseList /// open func list( queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.DatabaseList { let apiPath: String = "/tablesdb" let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -394,20 +397,23 @@ open class TablesDB: Service { /// - databaseId: String /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.TableList /// open func listTables( databaseId: String, queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.TableList { let apiPath: String = "/tablesdb/{databaseId}/tables" .replacingOccurrences(of: "{databaseId}", with: databaseId) let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -599,20 +605,23 @@ open class TablesDB: Service { /// - databaseId: String /// - tableId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.ColumnList /// open func listColumns( databaseId: String, tableId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.ColumnList { let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns" .replacingOccurrences(of: "{databaseId}", with: databaseId) .replacingOccurrences(of: "{tableId}", with: tableId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] @@ -2041,20 +2050,23 @@ open class TablesDB: Service { /// - databaseId: String /// - tableId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.ColumnIndexList /// open func listIndexes( databaseId: String, tableId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.ColumnIndexList { let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/indexes" .replacingOccurrences(of: "{databaseId}", with: databaseId) .replacingOccurrences(of: "{tableId}", with: tableId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] @@ -2205,6 +2217,7 @@ open class TablesDB: Service { /// - tableId: String /// - queries: [String] (optional) /// - transactionId: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.RowList /// @@ -2213,6 +2226,7 @@ open class TablesDB: Service { tableId: String, queries: [String]? = nil, transactionId: String? = nil, + total: Bool? = nil, nestedType: T.Type ) async throws -> AppwriteModels.RowList { let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows" @@ -2221,7 +2235,8 @@ open class TablesDB: Service { let apiParams: [String: Any?] = [ "queries": queries, - "transactionId": transactionId + "transactionId": transactionId, + "total": total ] let apiHeaders: [String: String] = [:] @@ -2248,6 +2263,7 @@ open class TablesDB: Service { /// - tableId: String /// - queries: [String] (optional) /// - transactionId: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.RowList /// @@ -2255,13 +2271,15 @@ open class TablesDB: Service { databaseId: String, tableId: String, queries: [String]? = nil, - transactionId: String? = nil + transactionId: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.RowList<[String: AnyCodable]> { return try await listRows( databaseId: databaseId, tableId: tableId, queries: queries, transactionId: transactionId, + total: total, nestedType: [String: AnyCodable].self ) } diff --git a/Sources/Appwrite/Services/Teams.swift b/Sources/Appwrite/Services/Teams.swift index 5441073..54744d9 100644 --- a/Sources/Appwrite/Services/Teams.swift +++ b/Sources/Appwrite/Services/Teams.swift @@ -15,19 +15,22 @@ open class Teams: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.TeamList /// open func list( queries: [String]? = nil, search: String? = nil, + total: Bool? = nil, nestedType: T.Type ) async throws -> AppwriteModels.TeamList { let apiPath: String = "/teams" let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -52,16 +55,19 @@ open class Teams: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.TeamList /// open func list( queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.TeamList<[String: AnyCodable]> { return try await list( queries: queries, search: search, + total: total, nestedType: [String: AnyCodable].self ) } @@ -278,20 +284,23 @@ open class Teams: Service { /// - teamId: String /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MembershipList /// open func listMemberships( teamId: String, queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.MembershipList { let apiPath: String = "/teams/{teamId}/memberships" .replacingOccurrences(of: "{teamId}", with: teamId) let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] diff --git a/Sources/Appwrite/Services/Tokens.swift b/Sources/Appwrite/Services/Tokens.swift index 02dbc4c..e99c601 100644 --- a/Sources/Appwrite/Services/Tokens.swift +++ b/Sources/Appwrite/Services/Tokens.swift @@ -16,20 +16,23 @@ open class Tokens: Service { /// - bucketId: String /// - fileId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.ResourceTokenList /// open func list( bucketId: String, fileId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.ResourceTokenList { let apiPath: String = "/tokens/buckets/{bucketId}/files/{fileId}" .replacingOccurrences(of: "{bucketId}", with: bucketId) .replacingOccurrences(of: "{fileId}", with: fileId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] diff --git a/Sources/Appwrite/Services/Users.swift b/Sources/Appwrite/Services/Users.swift index e1ea976..6a36657 100644 --- a/Sources/Appwrite/Services/Users.swift +++ b/Sources/Appwrite/Services/Users.swift @@ -15,19 +15,22 @@ open class Users: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.UserList /// open func list( queries: [String]? = nil, search: String? = nil, + total: Bool? = nil, nestedType: T.Type ) async throws -> AppwriteModels.UserList { let apiPath: String = "/users" let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -52,16 +55,19 @@ open class Users: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.UserList /// open func list( queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.UserList<[String: AnyCodable]> { return try await list( queries: queries, search: search, + total: total, nestedType: [String: AnyCodable].self ) } @@ -300,18 +306,21 @@ open class Users: Service { /// - Parameters: /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.IdentityList /// open func listIdentities( queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.IdentityList { let apiPath: String = "/users/identities" let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -1047,18 +1056,21 @@ open class Users: Service { /// - Parameters: /// - userId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.LogList /// open func listLogs( userId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.LogList { let apiPath: String = "/users/{userId}/logs" .replacingOccurrences(of: "{userId}", with: userId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] @@ -1083,20 +1095,23 @@ open class Users: Service { /// - userId: String /// - queries: [String] (optional) /// - search: String (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MembershipList /// open func listMemberships( userId: String, queries: [String]? = nil, - search: String? = nil + search: String? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.MembershipList { let apiPath: String = "/users/{userId}/memberships" .replacingOccurrences(of: "{userId}", with: userId) let apiParams: [String: Any?] = [ "queries": queries, - "search": search + "search": search, + "total": total ] let apiHeaders: [String: String] = [:] @@ -1861,16 +1876,20 @@ open class Users: Service { /// /// - Parameters: /// - userId: String + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.SessionList /// open func listSessions( - userId: String + userId: String, + total: Bool? = nil ) async throws -> AppwriteModels.SessionList { let apiPath: String = "/users/{userId}/sessions" .replacingOccurrences(of: "{userId}", with: userId) - let apiParams: [String: Any] = [:] + let apiParams: [String: Any?] = [ + "total": total + ] let apiHeaders: [String: String] = [:] @@ -2048,18 +2067,21 @@ open class Users: Service { /// - Parameters: /// - userId: String /// - queries: [String] (optional) + /// - total: Bool (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.TargetList /// open func listTargets( userId: String, - queries: [String]? = nil + queries: [String]? = nil, + total: Bool? = nil ) async throws -> AppwriteModels.TargetList { let apiPath: String = "/users/{userId}/targets" .replacingOccurrences(of: "{userId}", with: userId) let apiParams: [String: Any?] = [ - "queries": queries + "queries": queries, + "total": total ] let apiHeaders: [String: String] = [:] diff --git a/Sources/AppwriteEnums/ExecutionStatus.swift b/Sources/AppwriteEnums/ExecutionStatus.swift index 2f167a9..e27392f 100644 --- a/Sources/AppwriteEnums/ExecutionStatus.swift +++ b/Sources/AppwriteEnums/ExecutionStatus.swift @@ -5,6 +5,7 @@ public enum ExecutionStatus: String, CustomStringConvertible { case processing = "processing" case completed = "completed" case failed = "failed" + case scheduled = "scheduled" public var description: String { return rawValue diff --git a/Sources/AppwriteEnums/Framework.swift b/Sources/AppwriteEnums/Framework.swift index 83b61b3..6f9b692 100644 --- a/Sources/AppwriteEnums/Framework.swift +++ b/Sources/AppwriteEnums/Framework.swift @@ -9,6 +9,7 @@ public enum Framework: String, CustomStringConvertible { case vue = "vue" case sveltekit = "sveltekit" case astro = "astro" + case tanstackStart = "tanstack-start" case remix = "remix" case lynx = "lynx" case flutter = "flutter" diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index 47d7734..625fd39 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -47,7 +47,7 @@ open class Execution: Codable { /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. public let trigger: AppwriteEnums.ExecutionTrigger - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. public let status: AppwriteEnums.ExecutionStatus /// HTTP request method type. diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index c7ecff9..89ed893 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -8,6 +8,7 @@ let client = Client() let account = Account(client) let identityList = try await account.listIdentities( - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index 84c3327..e5f993c 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -8,6 +8,7 @@ let client = Client() let account = Account(client) let logList = try await account.listLogs( - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index c3335b4..823913f 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -11,7 +11,7 @@ let collection = try await databases.createCollection( databaseId: "", collectionId: "", name: "", - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional documentSecurity: false, // optional enabled: false // optional ) diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 604bacd..3cb0825 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -18,7 +18,7 @@ let document = try await databases.createDocument( "age": 30, "isAdmin": false ], - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: "" // optional ) diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index b375c87..57b26b3 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -10,6 +10,7 @@ let databases = Databases(client) let attributeList = try await databases.listAttributes( databaseId: "", collectionId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index 10481d9..4fa25c2 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -10,6 +10,7 @@ let databases = Databases(client) let collectionList = try await databases.listCollections( databaseId: "", queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 1147530..8723fe7 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -11,6 +11,7 @@ let documentList = try await databases.listDocuments( databaseId: "", collectionId: "", queries: [], // optional - transactionId: "" // optional + transactionId: "", // optional + total: false // optional ) diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index 691f74b..285e56f 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -10,6 +10,7 @@ let databases = Databases(client) let indexList = try await databases.listIndexes( databaseId: "", collectionId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index f8a2313..b587241 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -9,6 +9,7 @@ let databases = Databases(client) let databaseList = try await databases.list( queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 9109990..d26fbdc 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -11,7 +11,7 @@ let collection = try await databases.updateCollection( databaseId: "", collectionId: "", name: "", - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional documentSecurity: false, // optional enabled: false // optional ) diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index b6260d7..dbb954f 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -12,7 +12,7 @@ let document = try await databases.updateDocument( collectionId: "", documentId: "", data: [:], // optional - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: "" // optional ) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 26897f4..1873d5e 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -12,7 +12,7 @@ let document = try await databases.upsertDocument( collectionId: "", documentId: "", data: [:], - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: "" // optional ) diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index 599f301..de6a738 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -10,6 +10,7 @@ let functions = Functions(client) let deploymentList = try await functions.listDeployments( functionId: "", queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index f0aa857..668aacc 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -9,6 +9,7 @@ let functions = Functions(client) let executionList = try await functions.listExecutions( functionId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index 370b6bd..88fdefc 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -9,6 +9,7 @@ let functions = Functions(client) let functionList = try await functions.list( queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/messaging/create-resend-provider.md b/docs/examples/messaging/create-resend-provider.md new file mode 100644 index 0000000..c43e1e8 --- /dev/null +++ b/docs/examples/messaging/create-resend-provider.md @@ -0,0 +1,20 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let messaging = Messaging(client) + +let provider = try await messaging.createResendProvider( + providerId: "", + name: "", + apiKey: "", // optional + fromName: "", // optional + fromEmail: "email@example.com", // optional + replyToName: "", // optional + replyToEmail: "email@example.com", // optional + enabled: false // optional +) + diff --git a/docs/examples/messaging/list-message-logs.md b/docs/examples/messaging/list-message-logs.md index b7efe6f..34ada0a 100644 --- a/docs/examples/messaging/list-message-logs.md +++ b/docs/examples/messaging/list-message-logs.md @@ -9,6 +9,7 @@ let messaging = Messaging(client) let logList = try await messaging.listMessageLogs( messageId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md index 73832f7..1f461f9 100644 --- a/docs/examples/messaging/list-messages.md +++ b/docs/examples/messaging/list-messages.md @@ -9,6 +9,7 @@ let messaging = Messaging(client) let messageList = try await messaging.listMessages( queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/messaging/list-provider-logs.md b/docs/examples/messaging/list-provider-logs.md index 0633e15..e45d41a 100644 --- a/docs/examples/messaging/list-provider-logs.md +++ b/docs/examples/messaging/list-provider-logs.md @@ -9,6 +9,7 @@ let messaging = Messaging(client) let logList = try await messaging.listProviderLogs( providerId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md index c24af42..1b8bec0 100644 --- a/docs/examples/messaging/list-providers.md +++ b/docs/examples/messaging/list-providers.md @@ -9,6 +9,7 @@ let messaging = Messaging(client) let providerList = try await messaging.listProviders( queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/messaging/list-subscriber-logs.md b/docs/examples/messaging/list-subscriber-logs.md index eab170d..75c62f1 100644 --- a/docs/examples/messaging/list-subscriber-logs.md +++ b/docs/examples/messaging/list-subscriber-logs.md @@ -9,6 +9,7 @@ let messaging = Messaging(client) let logList = try await messaging.listSubscriberLogs( subscriberId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md index a29bcef..b845633 100644 --- a/docs/examples/messaging/list-subscribers.md +++ b/docs/examples/messaging/list-subscribers.md @@ -10,6 +10,7 @@ let messaging = Messaging(client) let subscriberList = try await messaging.listSubscribers( topicId: "", queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md index 974ae4f..eb474c8 100644 --- a/docs/examples/messaging/list-targets.md +++ b/docs/examples/messaging/list-targets.md @@ -9,6 +9,7 @@ let messaging = Messaging(client) let targetList = try await messaging.listTargets( messageId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/messaging/list-topic-logs.md b/docs/examples/messaging/list-topic-logs.md index e6f32ad..5f54670 100644 --- a/docs/examples/messaging/list-topic-logs.md +++ b/docs/examples/messaging/list-topic-logs.md @@ -9,6 +9,7 @@ let messaging = Messaging(client) let logList = try await messaging.listTopicLogs( topicId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md index 13106e9..cd24e5f 100644 --- a/docs/examples/messaging/list-topics.md +++ b/docs/examples/messaging/list-topics.md @@ -9,6 +9,7 @@ let messaging = Messaging(client) let topicList = try await messaging.listTopics( queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/messaging/update-resend-provider.md b/docs/examples/messaging/update-resend-provider.md new file mode 100644 index 0000000..ee392f6 --- /dev/null +++ b/docs/examples/messaging/update-resend-provider.md @@ -0,0 +1,20 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let messaging = Messaging(client) + +let provider = try await messaging.updateResendProvider( + providerId: "", + name: "", // optional + enabled: false, // optional + apiKey: "", // optional + fromName: "", // optional + fromEmail: "email@example.com", // optional + replyToName: "", // optional + replyToEmail: "" // optional +) + diff --git a/docs/examples/sites/list-deployments.md b/docs/examples/sites/list-deployments.md index 5516b74..976023d 100644 --- a/docs/examples/sites/list-deployments.md +++ b/docs/examples/sites/list-deployments.md @@ -10,6 +10,7 @@ let sites = Sites(client) let deploymentList = try await sites.listDeployments( siteId: "", queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/sites/list-logs.md b/docs/examples/sites/list-logs.md index 3eb2a8c..3220df8 100644 --- a/docs/examples/sites/list-logs.md +++ b/docs/examples/sites/list-logs.md @@ -9,6 +9,7 @@ let sites = Sites(client) let executionList = try await sites.listLogs( siteId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/sites/list.md b/docs/examples/sites/list.md index f330c72..414268e 100644 --- a/docs/examples/sites/list.md +++ b/docs/examples/sites/list.md @@ -9,6 +9,7 @@ let sites = Sites(client) let siteList = try await sites.list( queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index a664e14..a97f450 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -11,7 +11,7 @@ let storage = Storage(client) let bucket = try await storage.createBucket( bucketId: "", name: "", - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional fileSecurity: false, // optional enabled: false, // optional maximumFileSize: 1, // optional diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 540c869..612c56f 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -11,6 +11,6 @@ let file = try await storage.createFile( bucketId: "", fileId: "", file: InputFile.fromPath("file.png"), - permissions: ["read("any")"] // optional + permissions: [Permission.read(Role.any())] // optional ) diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md index 957d266..621af7c 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -9,6 +9,7 @@ let storage = Storage(client) let bucketList = try await storage.listBuckets( queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index 103d3c3..d66d91a 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -10,6 +10,7 @@ let storage = Storage(client) let fileList = try await storage.listFiles( bucketId: "", queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index de3b5bf..2d89d7c 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -11,7 +11,7 @@ let storage = Storage(client) let bucket = try await storage.updateBucket( bucketId: "", name: "", - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional fileSecurity: false, // optional enabled: false, // optional maximumFileSize: 1, // optional diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index d4d7484..6c3b388 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -11,6 +11,6 @@ let file = try await storage.updateFile( bucketId: "", fileId: "", name: "", // optional - permissions: ["read("any")"] // optional + permissions: [Permission.read(Role.any())] // optional ) diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 049ef2d..427fc03 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -18,7 +18,7 @@ let row = try await tablesDB.createRow( "age": 30, "isAdmin": false ], - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: "" // optional ) diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md index 11d14e1..a97613e 100644 --- a/docs/examples/tablesdb/create-table.md +++ b/docs/examples/tablesdb/create-table.md @@ -11,7 +11,7 @@ let table = try await tablesDB.createTable( databaseId: "", tableId: "", name: "", - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional rowSecurity: false, // optional enabled: false // optional ) diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md index 271a6d4..dd19948 100644 --- a/docs/examples/tablesdb/list-columns.md +++ b/docs/examples/tablesdb/list-columns.md @@ -10,6 +10,7 @@ let tablesDB = TablesDB(client) let columnList = try await tablesDB.listColumns( databaseId: "", tableId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md index a8e2770..ce090c7 100644 --- a/docs/examples/tablesdb/list-indexes.md +++ b/docs/examples/tablesdb/list-indexes.md @@ -10,6 +10,7 @@ let tablesDB = TablesDB(client) let columnIndexList = try await tablesDB.listIndexes( databaseId: "", tableId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index 92a2813..a07f4f8 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -11,6 +11,7 @@ let rowList = try await tablesDB.listRows( databaseId: "", tableId: "", queries: [], // optional - transactionId: "" // optional + transactionId: "", // optional + total: false // optional ) diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md index 46fcdcf..945a789 100644 --- a/docs/examples/tablesdb/list-tables.md +++ b/docs/examples/tablesdb/list-tables.md @@ -10,6 +10,7 @@ let tablesDB = TablesDB(client) let tableList = try await tablesDB.listTables( databaseId: "", queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md index 6923d8a..bbdaec1 100644 --- a/docs/examples/tablesdb/list.md +++ b/docs/examples/tablesdb/list.md @@ -9,6 +9,7 @@ let tablesDB = TablesDB(client) let databaseList = try await tablesDB.list( queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 3ebd9e0..d13df3a 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -12,7 +12,7 @@ let row = try await tablesDB.updateRow( tableId: "", rowId: "", data: [:], // optional - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: "" // optional ) diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md index 278d6e6..1f843b2 100644 --- a/docs/examples/tablesdb/update-table.md +++ b/docs/examples/tablesdb/update-table.md @@ -11,7 +11,7 @@ let table = try await tablesDB.updateTable( databaseId: "", tableId: "", name: "", - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional rowSecurity: false, // optional enabled: false // optional ) diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 1b07626..e6fec83 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -12,7 +12,7 @@ let row = try await tablesDB.upsertRow( tableId: "", rowId: "", data: [:], // optional - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: "" // optional ) diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 0670d91..329fa7a 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -10,6 +10,7 @@ let teams = Teams(client) let membershipList = try await teams.listMemberships( teamId: "", queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index b5130cb..d4b1604 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -9,6 +9,7 @@ let teams = Teams(client) let teamList = try await teams.list( queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/tokens/list.md b/docs/examples/tokens/list.md index 8438050..8a40d01 100644 --- a/docs/examples/tokens/list.md +++ b/docs/examples/tokens/list.md @@ -10,6 +10,7 @@ let tokens = Tokens(client) let resourceTokenList = try await tokens.list( bucketId: "", fileId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md index 8cbe8a7..18b374f 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -9,6 +9,7 @@ let users = Users(client) let identityList = try await users.listIdentities( queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md index 80d9199..79a9a18 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -9,6 +9,7 @@ let users = Users(client) let logList = try await users.listLogs( userId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md index 0ae34d4..cc84a92 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -10,6 +10,7 @@ let users = Users(client) let membershipList = try await users.listMemberships( userId: "", queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional ) diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index e027827..4712c15 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -8,6 +8,7 @@ let client = Client() let users = Users(client) let sessionList = try await users.listSessions( - userId: "" + userId: "", + total: false // optional ) diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md index b069781..a8008b1 100644 --- a/docs/examples/users/list-targets.md +++ b/docs/examples/users/list-targets.md @@ -9,6 +9,7 @@ let users = Users(client) let targetList = try await users.listTargets( userId: "", - queries: [] // optional + queries: [], // optional + total: false // optional ) diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index 45ccf23..2620f2e 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -9,6 +9,7 @@ let users = Users(client) let userList = try await users.list( queries: [], // optional - search: "" // optional + search: "", // optional + total: false // optional )