Skip to content

Commit e2ba30c

Browse files
Merge pull request #107 from appwrite/dev
feat: Apple SDK update for version 15.0.0
2 parents 4989097 + 5629304 commit e2ba30c

10 files changed

Lines changed: 65 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Change Log
22

3-
## 14.3.0
3+
## 15.0.0
44

5-
* Added upsert() support for RealtimeChannel on both Document and Row variants to perform upsert operations over real-time channels.
6-
* Introduced new Query filter methods: contains(_:, value:), containsAny(_:, value: [Any]), containsAll(_:, value: [Any]) for enhanced querying capabilities (substring and multi-value containment).
7-
* Documentation and packaging updates to align with the new release: README dependency example updated from 14.2.0 to 14.1.0, and server compatibility note updated to indicate Appwrite server version 1.8.x compatibility.
5+
* Breaking: RealtimeChannel API required explicit IDs and threw errors.
6+
* Added ttl parameter to listDocuments and listRows.
7+
* Updated compatibility notes to latest server and SDK version.
8+
* Updated Document and Row comments for clarity.
89

910
## 14.1.0
1011

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
99

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

1212
Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Apple SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1313

@@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:
3131

3232
```swift
3333
dependencies: [
34-
.package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "14.3.0"),
34+
.package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "15.0.0"),
3535
],
3636
```
3737

Sources/Appwrite/Channel.swift

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ public struct _Team {}
1616
public struct _Membership {}
1717
public struct _Resolved {}
1818

19+
public enum ChannelValidationError: Swift.Error {
20+
case invalidID
21+
}
22+
1923
// Helper for normalizing IDs
20-
private func normalize(_ id: String) -> String {
24+
private func normalize(_ id: String) throws -> String {
2125
let trimmed = id.trimmingCharacters(in: .whitespacesAndNewlines)
22-
return trimmed.isEmpty ? "*" : trimmed
26+
guard !trimmed.isEmpty else {
27+
throw ChannelValidationError.invalidID
28+
}
29+
return trimmed
2330
}
2431

2532
/// Channel class with generic type parameter for type-safe method chaining
@@ -31,9 +38,9 @@ public class RealtimeChannel<T> {
3138
}
3239

3340
/// Internal helper to transition to next state with segment and optional ID
34-
internal func next<N>(_ segment: String, _ id: String? = nil) -> RealtimeChannel<N> {
41+
internal func next<N>(_ segment: String, _ id: String? = nil) throws -> RealtimeChannel<N> {
3542
if let id = id {
36-
return RealtimeChannel<N>(segments + [segment, normalize(id)])
43+
return RealtimeChannel<N>(segments + [segment, try normalize(id)])
3744
}
3845

3946
return RealtimeChannel<N>(segments + [segment])
@@ -55,32 +62,32 @@ public enum Channel {
5562

5663
// MARK: - Root Factories
5764

58-
public static func database(_ id: String = "*") -> RealtimeChannel<_Database> {
59-
return RealtimeChannel<_Database>(["databases", normalize(id)])
65+
public static func database(_ id: String) throws -> RealtimeChannel<_Database> {
66+
return RealtimeChannel<_Database>(["databases", try normalize(id)])
6067
}
6168

62-
public static func tablesdb(_ id: String = "*") -> RealtimeChannel<_TablesDB> {
63-
return RealtimeChannel<_TablesDB>(["tablesdb", normalize(id)])
69+
public static func tablesdb(_ id: String) throws -> RealtimeChannel<_TablesDB> {
70+
return RealtimeChannel<_TablesDB>(["tablesdb", try normalize(id)])
6471
}
6572

66-
public static func bucket(_ id: String = "*") -> RealtimeChannel<_Bucket> {
67-
return RealtimeChannel<_Bucket>(["buckets", normalize(id)])
73+
public static func bucket(_ id: String) throws -> RealtimeChannel<_Bucket> {
74+
return RealtimeChannel<_Bucket>(["buckets", try normalize(id)])
6875
}
6976

70-
public static func function(_ id: String = "*") -> RealtimeChannel<_Func> {
71-
return RealtimeChannel<_Func>(["functions", normalize(id)])
77+
public static func function(_ id: String) throws -> RealtimeChannel<_Func> {
78+
return RealtimeChannel<_Func>(["functions", try normalize(id)])
7279
}
7380

74-
public static func execution(_ id: String = "*") -> RealtimeChannel<_Execution> {
75-
return RealtimeChannel<_Execution>(["executions", normalize(id)])
81+
public static func execution(_ id: String) throws -> RealtimeChannel<_Execution> {
82+
return RealtimeChannel<_Execution>(["executions", try normalize(id)])
7683
}
7784

78-
public static func team(_ id: String = "*") -> RealtimeChannel<_Team> {
79-
return RealtimeChannel<_Team>(["teams", normalize(id)])
85+
public static func team(_ id: String) throws -> RealtimeChannel<_Team> {
86+
return RealtimeChannel<_Team>(["teams", try normalize(id)])
8087
}
8188

82-
public static func membership(_ id: String = "*") -> RealtimeChannel<_Membership> {
83-
return RealtimeChannel<_Membership>(["memberships", normalize(id)])
89+
public static func membership(_ id: String) throws -> RealtimeChannel<_Membership> {
90+
return RealtimeChannel<_Membership>(["memberships", try normalize(id)])
8491
}
8592

8693
public static func account() -> String {
@@ -101,40 +108,40 @@ public enum Channel {
101108

102109
/// Only available on RealtimeChannel<_Database>
103110
extension RealtimeChannel where T == _Database {
104-
public func collection(_ id: String? = nil) -> RealtimeChannel<_Collection> {
105-
return self.next("collections", id ?? "*")
111+
public func collection(_ id: String) throws -> RealtimeChannel<_Collection> {
112+
return try self.next("collections", id)
106113
}
107114
}
108115

109116
/// Only available on RealtimeChannel<_Collection>
110117
extension RealtimeChannel where T == _Collection {
111-
public func document(_ id: String? = nil) -> RealtimeChannel<_Document> {
112-
return self.next("documents", id)
118+
public func document(_ id: String? = nil) throws -> RealtimeChannel<_Document> {
119+
return try self.next("documents", id)
113120
}
114121
}
115122

116123
// MARK: - TABLESDB ROUTE
117124

118125
/// Only available on RealtimeChannel<_TablesDB>
119126
extension RealtimeChannel where T == _TablesDB {
120-
public func table(_ id: String? = nil) -> RealtimeChannel<_Table> {
121-
return self.next("tables", id ?? "*")
127+
public func table(_ id: String) throws -> RealtimeChannel<_Table> {
128+
return try self.next("tables", id)
122129
}
123130
}
124131

125132
/// Only available on RealtimeChannel<_Table>
126133
extension RealtimeChannel where T == _Table {
127-
public func row(_ id: String? = nil) -> RealtimeChannel<_Row> {
128-
return self.next("rows", id)
134+
public func row(_ id: String? = nil) throws -> RealtimeChannel<_Row> {
135+
return try self.next("rows", id)
129136
}
130137
}
131138

132139
// MARK: - BUCKET ROUTE
133140

134141
/// Only available on RealtimeChannel<_Bucket>
135142
extension RealtimeChannel where T == _Bucket {
136-
public func file(_ id: String? = nil) -> RealtimeChannel<_File> {
137-
return self.next("files", id)
143+
public func file(_ id: String? = nil) throws -> RealtimeChannel<_File> {
144+
return try self.next("files", id)
138145
}
139146
}
140147

Sources/Appwrite/Client.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ open class Client {
2424
"x-sdk-name": "Apple",
2525
"x-sdk-platform": "client",
2626
"x-sdk-language": "apple",
27-
"x-sdk-version": "14.3.0",
27+
"x-sdk-version": "15.0.0",
2828
"x-appwrite-response-format": "1.8.0"
2929
]
3030

Sources/Appwrite/Services/Databases.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ open class Databases: Service {
219219
/// - queries: [String] (optional)
220220
/// - transactionId: String (optional)
221221
/// - total: Bool (optional)
222+
/// - ttl: Int (optional)
222223
/// - Throws: Exception if the request fails
223224
/// - Returns: AppwriteModels.DocumentList<T>
224225
///
@@ -229,6 +230,7 @@ open class Databases: Service {
229230
queries: [String]? = nil,
230231
transactionId: String? = nil,
231232
total: Bool? = nil,
233+
ttl: Int? = nil,
232234
nestedType: T.Type
233235
) async throws -> AppwriteModels.DocumentList<T> {
234236
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents"
@@ -238,7 +240,8 @@ open class Databases: Service {
238240
let apiParams: [String: Any?] = [
239241
"queries": queries,
240242
"transactionId": transactionId,
241-
"total": total
243+
"total": total,
244+
"ttl": ttl
242245
]
243246

244247
let apiHeaders: [String: String] = [:]
@@ -266,6 +269,7 @@ open class Databases: Service {
266269
/// - queries: [String] (optional)
267270
/// - transactionId: String (optional)
268271
/// - total: Bool (optional)
272+
/// - ttl: Int (optional)
269273
/// - Throws: Exception if the request fails
270274
/// - Returns: AppwriteModels.DocumentList<T>
271275
///
@@ -275,14 +279,16 @@ open class Databases: Service {
275279
collectionId: String,
276280
queries: [String]? = nil,
277281
transactionId: String? = nil,
278-
total: Bool? = nil
282+
total: Bool? = nil,
283+
ttl: Int? = nil
279284
) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> {
280285
return try await listDocuments(
281286
databaseId: databaseId,
282287
collectionId: collectionId,
283288
queries: queries,
284289
transactionId: transactionId,
285290
total: total,
291+
ttl: ttl,
286292
nestedType: [String: AnyCodable].self
287293
)
288294
}

Sources/Appwrite/Services/TablesDB.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ open class TablesDB: Service {
219219
/// - queries: [String] (optional)
220220
/// - transactionId: String (optional)
221221
/// - total: Bool (optional)
222+
/// - ttl: Int (optional)
222223
/// - Throws: Exception if the request fails
223224
/// - Returns: AppwriteModels.RowList<T>
224225
///
@@ -228,6 +229,7 @@ open class TablesDB: Service {
228229
queries: [String]? = nil,
229230
transactionId: String? = nil,
230231
total: Bool? = nil,
232+
ttl: Int? = nil,
231233
nestedType: T.Type
232234
) async throws -> AppwriteModels.RowList<T> {
233235
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows"
@@ -237,7 +239,8 @@ open class TablesDB: Service {
237239
let apiParams: [String: Any?] = [
238240
"queries": queries,
239241
"transactionId": transactionId,
240-
"total": total
242+
"total": total,
243+
"ttl": ttl
241244
]
242245

243246
let apiHeaders: [String: String] = [:]
@@ -265,6 +268,7 @@ open class TablesDB: Service {
265268
/// - queries: [String] (optional)
266269
/// - transactionId: String (optional)
267270
/// - total: Bool (optional)
271+
/// - ttl: Int (optional)
268272
/// - Throws: Exception if the request fails
269273
/// - Returns: AppwriteModels.RowList<T>
270274
///
@@ -273,14 +277,16 @@ open class TablesDB: Service {
273277
tableId: String,
274278
queries: [String]? = nil,
275279
transactionId: String? = nil,
276-
total: Bool? = nil
280+
total: Bool? = nil,
281+
ttl: Int? = nil
277282
) async throws -> AppwriteModels.RowList<[String: AnyCodable]> {
278283
return try await listRows(
279284
databaseId: databaseId,
280285
tableId: tableId,
281286
queries: queries,
282287
transactionId: transactionId,
283288
total: total,
289+
ttl: ttl,
284290
nestedType: [String: AnyCodable].self
285291
)
286292
}

Sources/AppwriteModels/Document.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ open class Document<T : Codable>: Codable {
1717

1818
/// Document ID.
1919
public let id: String
20-
/// Document automatically incrementing ID.
20+
/// Document sequence ID.
2121
public let sequence: Int
2222
/// Collection ID.
2323
public let collectionId: String

Sources/AppwriteModels/Row.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ open class Row<T : Codable>: Codable {
1717

1818
/// Row ID.
1919
public let id: String
20-
/// Row automatically incrementing ID.
20+
/// Row sequence ID.
2121
public let sequence: Int
2222
/// Table ID.
2323
public let tableId: String

docs/examples/databases/list-documents.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ let documentList = try await databases.listDocuments(
1212
collectionId: "<COLLECTION_ID>",
1313
queries: [], // optional
1414
transactionId: "<TRANSACTION_ID>", // optional
15-
total: false // optional
15+
total: false, // optional
16+
ttl: 0 // optional
1617
)
1718

1819
```

docs/examples/tablesdb/list-rows.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ let rowList = try await tablesDB.listRows(
1212
tableId: "<TABLE_ID>",
1313
queries: [], // optional
1414
transactionId: "<TRANSACTION_ID>", // optional
15-
total: false // optional
15+
total: false, // optional
16+
ttl: 0 // optional
1617
)
1718

1819
```

0 commit comments

Comments
 (0)