Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## 15.1.0

* Add `dart-3.10` and `flutter-3.38` to `BuildRuntime` and `Runtime` enums
* Add `bytesMax` and `bytesUsed` properties to `Collection` and `Table` models
* Fix `Roles` enum removed from Teams service; `roles` parameter now accepts `[String]`
* Added new query filtering helpers: Query.contains(_:, value:), Query.containsAny(_:, value: [Any]), and Query.containsAll(_:, value: [Any]) for string and array attributes.
* Extended Databases and TablesDB attribute creation APIs with an optional encrypt: Bool flag to support encrypted attributes (Longtext, Mediumtext, Text, Varchar) across multiple attribute types.
* Updated README and package manifest references to reflect versioning and compatibility: server compatibility noted as Appwrite server version 1.8.x; package dependency snippet updated from 15.1.0 to 15.0.0.
* Updated Client header x-sdk-version to 15.0.0 to align with the release.
* Removed deprecated/auxiliary CI templates and an autoclose workflow (internal maintenance).
* Add support for the new `Backups` service

## 15.0.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![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)

**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**
**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**

> This is the Swift SDK for integrating with Appwrite from your Swift server-side code. If you're looking for the Apple SDK you should check [appwrite/sdk-for-apple](https://github.com/appwrite/sdk-for-apple)

Expand Down
26 changes: 26 additions & 0 deletions Sources/Appwrite/Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ public struct Query : Codable, CustomStringConvertible {
).description
}

/// Filter resources where attribute contains the specified value.
/// For string attributes, checks if the string contains the substring.
///
/// - Note: For array attributes, use ``containsAny(_:value:)`` or ``containsAll(_:value:)`` instead.
public static func contains(_ attribute: String, value: Any) -> String {
return Query(
method: "contains",
Expand All @@ -358,6 +362,28 @@ public struct Query : Codable, CustomStringConvertible {
).description
}

/// Filter resources where attribute contains ANY of the specified values.
/// For array and relationship attributes, matches documents where the attribute
/// contains at least one of the given values.
public static func containsAny(_ attribute: String, value: [Any]) -> String {
return Query(
method: "containsAny",
attribute: attribute,
values: value
).description
}

/// Filter resources where attribute contains ALL of the specified values.
/// For array and relationship attributes, matches documents where the attribute
/// contains every one of the given values.
public static func containsAll(_ attribute: String, value: [Any]) -> String {
return Query(
method: "containsAll",
attribute: attribute,
values: value
).description
}

public static func notContains(_ attribute: String, value: Any) -> String {
return Query(
method: "notContains",
Expand Down
76 changes: 76 additions & 0 deletions Sources/Appwrite/Services/Activities.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import AsyncHTTPClient
import Foundation
import NIO
import JSONCodable
import AppwriteEnums
import AppwriteModels

///
open class Activities: Service {

///
/// List all events for selected filters.
///
/// - Parameters:
/// - queries: String (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.ActivityEventList
///
open func listEvents(
queries: String? = nil
) async throws -> AppwriteModels.ActivityEventList {
let apiPath: String = "/activities/events"

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

let apiHeaders: [String: String] = [:]

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

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

///
/// Get event by ID.
///
///
/// - Parameters:
/// - eventId: String
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.ActivityEvent
///
open func getEvent(
eventId: String
) async throws -> AppwriteModels.ActivityEvent {
let apiPath: String = "/activities/events/{eventId}"
.replacingOccurrences(of: "{eventId}", with: eventId)

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

let apiHeaders: [String: String] = [:]

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

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


}
28 changes: 20 additions & 8 deletions Sources/Appwrite/Services/Databases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,7 @@ open class Databases: Service {
/// - required: Bool
/// - default: String (optional)
/// - array: Bool (optional)
/// - encrypt: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.AttributeLongtext
///
Expand All @@ -1525,7 +1526,8 @@ open class Databases: Service {
key: String,
`required`: Bool,
`default`: String? = nil,
array: Bool? = nil
array: Bool? = nil,
encrypt: Bool? = nil
) async throws -> AppwriteModels.AttributeLongtext {
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext"
.replacingOccurrences(of: "{databaseId}", with: databaseId)
Expand All @@ -1535,7 +1537,8 @@ open class Databases: Service {
"key": key,
"required": `required`,
"default": `default`,
"array": array
"array": array,
"encrypt": encrypt
]

let apiHeaders: [String: String] = [
Expand Down Expand Up @@ -1617,6 +1620,7 @@ open class Databases: Service {
/// - required: Bool
/// - default: String (optional)
/// - array: Bool (optional)
/// - encrypt: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.AttributeMediumtext
///
Expand All @@ -1626,7 +1630,8 @@ open class Databases: Service {
key: String,
`required`: Bool,
`default`: String? = nil,
array: Bool? = nil
array: Bool? = nil,
encrypt: Bool? = nil
) async throws -> AppwriteModels.AttributeMediumtext {
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext"
.replacingOccurrences(of: "{databaseId}", with: databaseId)
Expand All @@ -1636,7 +1641,8 @@ open class Databases: Service {
"key": key,
"required": `required`,
"default": `default`,
"array": array
"array": array,
"encrypt": encrypt
]

let apiHeaders: [String: String] = [
Expand Down Expand Up @@ -2084,6 +2090,7 @@ open class Databases: Service {
/// - required: Bool
/// - default: String (optional)
/// - array: Bool (optional)
/// - encrypt: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.AttributeText
///
Expand All @@ -2093,7 +2100,8 @@ open class Databases: Service {
key: String,
`required`: Bool,
`default`: String? = nil,
array: Bool? = nil
array: Bool? = nil,
encrypt: Bool? = nil
) async throws -> AppwriteModels.AttributeText {
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/text"
.replacingOccurrences(of: "{databaseId}", with: databaseId)
Expand All @@ -2103,7 +2111,8 @@ open class Databases: Service {
"key": key,
"required": `required`,
"default": `default`,
"array": array
"array": array,
"encrypt": encrypt
]

let apiHeaders: [String: String] = [
Expand Down Expand Up @@ -2289,6 +2298,7 @@ open class Databases: Service {
/// - required: Bool
/// - default: String (optional)
/// - array: Bool (optional)
/// - encrypt: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.AttributeVarchar
///
Expand All @@ -2299,7 +2309,8 @@ open class Databases: Service {
size: Int,
`required`: Bool,
`default`: String? = nil,
array: Bool? = nil
array: Bool? = nil,
encrypt: Bool? = nil
) async throws -> AppwriteModels.AttributeVarchar {
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar"
.replacingOccurrences(of: "{databaseId}", with: databaseId)
Expand All @@ -2310,7 +2321,8 @@ open class Databases: Service {
"size": size,
"required": `required`,
"default": `default`,
"array": array
"array": array,
"encrypt": encrypt
]

let apiHeaders: [String: String] = [
Expand Down
28 changes: 20 additions & 8 deletions Sources/Appwrite/Services/TablesDB.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,7 @@ open class TablesDB: Service {
/// - required: Bool
/// - default: String (optional)
/// - array: Bool (optional)
/// - encrypt: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.ColumnLongtext
///
Expand All @@ -1497,7 +1498,8 @@ open class TablesDB: Service {
key: String,
`required`: Bool,
`default`: String? = nil,
array: Bool? = nil
array: Bool? = nil,
encrypt: Bool? = nil
) async throws -> AppwriteModels.ColumnLongtext {
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext"
.replacingOccurrences(of: "{databaseId}", with: databaseId)
Expand All @@ -1507,7 +1509,8 @@ open class TablesDB: Service {
"key": key,
"required": `required`,
"default": `default`,
"array": array
"array": array,
"encrypt": encrypt
]

let apiHeaders: [String: String] = [
Expand Down Expand Up @@ -1589,6 +1592,7 @@ open class TablesDB: Service {
/// - required: Bool
/// - default: String (optional)
/// - array: Bool (optional)
/// - encrypt: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.ColumnMediumtext
///
Expand All @@ -1598,7 +1602,8 @@ open class TablesDB: Service {
key: String,
`required`: Bool,
`default`: String? = nil,
array: Bool? = nil
array: Bool? = nil,
encrypt: Bool? = nil
) async throws -> AppwriteModels.ColumnMediumtext {
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext"
.replacingOccurrences(of: "{databaseId}", with: databaseId)
Expand All @@ -1608,7 +1613,8 @@ open class TablesDB: Service {
"key": key,
"required": `required`,
"default": `default`,
"array": array
"array": array,
"encrypt": encrypt
]

let apiHeaders: [String: String] = [
Expand Down Expand Up @@ -2051,6 +2057,7 @@ open class TablesDB: Service {
/// - required: Bool
/// - default: String (optional)
/// - array: Bool (optional)
/// - encrypt: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.ColumnText
///
Expand All @@ -2060,7 +2067,8 @@ open class TablesDB: Service {
key: String,
`required`: Bool,
`default`: String? = nil,
array: Bool? = nil
array: Bool? = nil,
encrypt: Bool? = nil
) async throws -> AppwriteModels.ColumnText {
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/text"
.replacingOccurrences(of: "{databaseId}", with: databaseId)
Expand All @@ -2070,7 +2078,8 @@ open class TablesDB: Service {
"key": key,
"required": `required`,
"default": `default`,
"array": array
"array": array,
"encrypt": encrypt
]

let apiHeaders: [String: String] = [
Expand Down Expand Up @@ -2254,6 +2263,7 @@ open class TablesDB: Service {
/// - required: Bool
/// - default: String (optional)
/// - array: Bool (optional)
/// - encrypt: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.ColumnVarchar
///
Expand All @@ -2264,7 +2274,8 @@ open class TablesDB: Service {
size: Int,
`required`: Bool,
`default`: String? = nil,
array: Bool? = nil
array: Bool? = nil,
encrypt: Bool? = nil
) async throws -> AppwriteModels.ColumnVarchar {
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar"
.replacingOccurrences(of: "{databaseId}", with: databaseId)
Expand All @@ -2275,7 +2286,8 @@ open class TablesDB: Service {
"size": size,
"required": `required`,
"default": `default`,
"array": array
"array": array,
"encrypt": encrypt
]

let apiHeaders: [String: String] = [
Expand Down
Loading