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
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Change Log

## 12.2.0
## 13.0.0

* Added Channel<_Document>.upsert() and Channel<_Row>.upsert() API methods to upsert documents and rows in channels.
* Added new query filters: containsAny(attribute, List<Any>) and containsAll(attribute, List<Any>) for advanced matching on array/relationship attributes.
* Realtime improvements: improved WebSocket lifecycle and connection handling. Introduced generation-based checks to avoid processing messages from stale sockets and ensure sequential socket recreation on reconnects.
* Breaking: Channel factory methods require explicit IDs (no wildcard defaults)
* Added ttl parameter to listDocuments and listRows for caching
* Updated x-sdk-version header to 12.2.1 in Client
* Updated docs and examples to show TTL usage and latest compatibility note
* Updated Document and Row sequence descriptions in models

## 12.1.0

Expand Down
6 changes: 3 additions & 3 deletions 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 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).**
**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).**

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 Android 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)

Expand Down Expand Up @@ -38,7 +38,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:

```groovy
implementation("io.appwrite:sdk-for-android:12.2.0")
implementation("io.appwrite:sdk-for-android:13.0.0")
```

### Maven
Expand All @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-android</artifactId>
<version>12.2.0</version>
<version>13.0.0</version>
</dependency>
</dependencies>
```
Expand Down
1 change: 1 addition & 0 deletions docs/examples/java/databases/list-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ databases.listDocuments(
List.of(), // queries (optional)
"<TRANSACTION_ID>", // transactionId (optional)
false, // total (optional)
0, // ttl (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
Expand Down
1 change: 1 addition & 0 deletions docs/examples/java/tablesdb/list-rows.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tablesDB.listRows(
List.of(), // queries (optional)
"<TRANSACTION_ID>", // transactionId (optional)
false, // total (optional)
0, // ttl (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
Expand Down
1 change: 1 addition & 0 deletions docs/examples/kotlin/databases/list-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ val result = databases.listDocuments(
queries = listOf(), // (optional)
transactionId = "<TRANSACTION_ID>", // (optional)
total = false, // (optional)
ttl = 0, // (optional)
)
```
1 change: 1 addition & 0 deletions docs/examples/kotlin/tablesdb/list-rows.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ val result = tablesDB.listRows(
queries = listOf(), // (optional)
transactionId = "<TRANSACTION_ID>", // (optional)
total = false, // (optional)
ttl = 0, // (optional)
)
```
25 changes: 13 additions & 12 deletions library/src/main/java/io/appwrite/Channel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ typealias Actionable = _Document
*/
private fun normalize(id: String): String {
val trimmed = id.trim()
return if (trimmed.isEmpty()) "*" else trimmed
require(trimmed.isNotEmpty()) { "Channel ID is required." }
return trimmed
}

/**
Expand Down Expand Up @@ -59,25 +60,25 @@ class Channel<out T> private constructor(
override fun toString(): String = segments.joinToString(".")

companion object {
fun database(id: String = "*"): Channel<_Database> =
fun database(id: String): Channel<_Database> =
Channel(listOf("databases", normalize(id)))

fun tablesdb(id: String = "*"): Channel<_TablesDB> =
fun tablesdb(id: String): Channel<_TablesDB> =
Channel(listOf("tablesdb", normalize(id)))

fun bucket(id: String = "*"): Channel<_Bucket> =
fun bucket(id: String): Channel<_Bucket> =
Channel(listOf("buckets", normalize(id)))

fun execution(id: String = "*"): Channel<_Execution> =
fun execution(id: String): Channel<_Execution> =
Channel(listOf("executions", normalize(id)))

fun function(id: String = "*"): Channel<_Func> =
fun function(id: String): Channel<_Func> =
Channel(listOf("functions", normalize(id)))

fun team(id: String = "*"): Channel<_Team> =
fun team(id: String): Channel<_Team> =
Channel(listOf("teams", normalize(id)))

fun membership(id: String = "*"): Channel<_Membership> =
fun membership(id: String): Channel<_Membership> =
Channel(listOf("memberships", normalize(id)))

fun account(): String = "account"
Expand All @@ -98,8 +99,8 @@ class Channel<out T> private constructor(
/**
* Only available on Channel<_Database>
*/
fun Channel<_Database>.collection(id: String? = null): Channel<_Collection> =
this.next("collections", id ?: "*")
fun Channel<_Database>.collection(id: String): Channel<_Collection> =
this.next("collections", id)

/**
* Only available on Channel<_Collection>
Expand All @@ -112,8 +113,8 @@ fun Channel<_Collection>.document(id: String? = null): Channel<_Document> =
/**
* Only available on Channel<_TablesDB>
*/
fun Channel<_TablesDB>.table(id: String? = null): Channel<_Table> =
this.next("tables", id ?: "*")
fun Channel<_TablesDB>.table(id: String): Channel<_Table> =
this.next("tables", id)

/**
* Only available on Channel<_Table>
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor(
"x-sdk-name" to "Android",
"x-sdk-platform" to "client",
"x-sdk-language" to "android",
"x-sdk-version" to "12.2.0",
"x-sdk-version" to "13.0.0",
"x-appwrite-response-format" to "1.8.0"
)
config = mutableMapOf()
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/models/Document.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class Document<T>(
val id: String,

/**
* Document automatically incrementing ID.
* Document sequence ID.
*/
@SerializedName("\$sequence")
val sequence: Long,
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/models/Row.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class Row<T>(
val id: String,

/**
* Row automatically incrementing ID.
* Row sequence ID.
*/
@SerializedName("\$sequence")
val sequence: Long,
Expand Down
6 changes: 6 additions & 0 deletions library/src/main/java/io/appwrite/services/Databases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class Databases(client: Client) : Service(client) {
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @param transactionId Transaction ID to read uncommitted changes within the transaction.
* @param total When set to false, the total count returned will be 0 and will not be calculated.
* @param ttl TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).
* @return [io.appwrite.models.DocumentList<T>]
*/
@Deprecated(
Expand All @@ -233,6 +234,7 @@ class Databases(client: Client) : Service(client) {
queries: List<String>? = null,
transactionId: String? = null,
total: Boolean? = null,
ttl: Long? = null,
nestedType: Class<T>,
): io.appwrite.models.DocumentList<T> {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents"
Expand All @@ -243,6 +245,7 @@ class Databases(client: Client) : Service(client) {
"queries" to queries,
"transactionId" to transactionId,
"total" to total,
"ttl" to ttl,
)
val apiHeaders = mutableMapOf<String, String>(
)
Expand All @@ -268,6 +271,7 @@ class Databases(client: Client) : Service(client) {
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @param transactionId Transaction ID to read uncommitted changes within the transaction.
* @param total When set to false, the total count returned will be 0 and will not be calculated.
* @param ttl TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).
* @return [io.appwrite.models.DocumentList<T>]
*/
@Deprecated(
Expand All @@ -282,12 +286,14 @@ class Databases(client: Client) : Service(client) {
queries: List<String>? = null,
transactionId: String? = null,
total: Boolean? = null,
ttl: Long? = null,
): io.appwrite.models.DocumentList<Map<String, Any>> = listDocuments(
databaseId,
collectionId,
queries,
transactionId,
total,
ttl,
nestedType = classOf(),
)

Expand Down
6 changes: 6 additions & 0 deletions library/src/main/java/io/appwrite/services/TablesDB.kt
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class TablesDB(client: Client) : Service(client) {
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @param transactionId Transaction ID to read uncommitted changes within the transaction.
* @param total When set to false, the total count returned will be 0 and will not be calculated.
* @param ttl TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).
* @return [io.appwrite.models.RowList<T>]
*/
@JvmOverloads
Expand All @@ -229,6 +230,7 @@ class TablesDB(client: Client) : Service(client) {
queries: List<String>? = null,
transactionId: String? = null,
total: Boolean? = null,
ttl: Long? = null,
nestedType: Class<T>,
): io.appwrite.models.RowList<T> {
val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows"
Expand All @@ -239,6 +241,7 @@ class TablesDB(client: Client) : Service(client) {
"queries" to queries,
"transactionId" to transactionId,
"total" to total,
"ttl" to ttl,
)
val apiHeaders = mutableMapOf<String, String>(
)
Expand All @@ -264,6 +267,7 @@ class TablesDB(client: Client) : Service(client) {
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @param transactionId Transaction ID to read uncommitted changes within the transaction.
* @param total When set to false, the total count returned will be 0 and will not be calculated.
* @param ttl TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).
* @return [io.appwrite.models.RowList<T>]
*/
@JvmOverloads
Expand All @@ -274,12 +278,14 @@ class TablesDB(client: Client) : Service(client) {
queries: List<String>? = null,
transactionId: String? = null,
total: Boolean? = null,
ttl: Long? = null,
): io.appwrite.models.RowList<Map<String, Any>> = listRows(
databaseId,
tableId,
queries,
transactionId,
total,
ttl,
nestedType = classOf(),
)

Expand Down
4 changes: 2 additions & 2 deletions library/src/main/java/io/appwrite/services/Teams.kt
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class Teams(client: Client) : Service(client) {
*
*
* @param teamId Team ID.
* @param roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
* @param roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long.
* @param email Email of the new team member.
* @param userId ID of the user to be added to a team.
* @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
Expand Down Expand Up @@ -396,7 +396,7 @@ class Teams(client: Client) : Service(client) {
*
* @param teamId Team ID.
* @param membershipId Membership ID.
* @param roles An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
* @param roles An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long.
* @return [io.appwrite.models.Membership]
*/
suspend fun updateMembership(
Expand Down