From 966812233be57c18933a489a9733ddfe34bd7b3b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 3 Nov 2025 16:28:49 +1300 Subject: [PATCH] Add operators --- CHANGELOG.md | 5 + README.md | 4 +- docs/examples/java/account/list-identities.md | 1 + docs/examples/java/account/list-logs.md | 1 + .../java/databases/create-document.md | 4 +- .../examples/java/databases/list-documents.md | 1 + .../java/databases/update-document.md | 4 +- .../java/databases/upsert-document.md | 4 +- .../java/functions/list-executions.md | 1 + docs/examples/java/storage/create-file.md | 4 +- docs/examples/java/storage/list-files.md | 1 + docs/examples/java/storage/update-file.md | 4 +- docs/examples/java/tablesdb/create-row.md | 4 +- docs/examples/java/tablesdb/list-rows.md | 1 + docs/examples/java/tablesdb/update-row.md | 4 +- docs/examples/java/tablesdb/upsert-row.md | 4 +- docs/examples/java/teams/list-memberships.md | 1 + docs/examples/java/teams/list.md | 1 + .../kotlin/account/list-identities.md | 1 + docs/examples/kotlin/account/list-logs.md | 1 + .../kotlin/databases/create-document.md | 4 +- .../kotlin/databases/list-documents.md | 1 + .../kotlin/databases/update-document.md | 4 +- .../kotlin/databases/upsert-document.md | 4 +- .../kotlin/functions/list-executions.md | 1 + docs/examples/kotlin/storage/create-file.md | 4 +- docs/examples/kotlin/storage/list-files.md | 1 + docs/examples/kotlin/storage/update-file.md | 4 +- docs/examples/kotlin/tablesdb/create-row.md | 4 +- docs/examples/kotlin/tablesdb/list-rows.md | 1 + docs/examples/kotlin/tablesdb/update-row.md | 4 +- docs/examples/kotlin/tablesdb/upsert-row.md | 4 +- .../examples/kotlin/teams/list-memberships.md | 1 + docs/examples/kotlin/teams/list.md | 1 + library/src/main/java/io/appwrite/Client.kt | 2 +- library/src/main/java/io/appwrite/Operator.kt | 130 ++++++++++++++++++ library/src/main/java/io/appwrite/Query.kt | 12 +- .../java/io/appwrite/enums/ExecutionStatus.kt | 4 +- .../main/java/io/appwrite/models/Execution.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 6 + .../java/io/appwrite/services/Databases.kt | 6 + .../java/io/appwrite/services/Functions.kt | 3 + .../main/java/io/appwrite/services/Storage.kt | 3 + .../java/io/appwrite/services/TablesDb.kt | 6 + .../main/java/io/appwrite/services/Teams.kt | 9 ++ 45 files changed, 245 insertions(+), 27 deletions(-) create mode 100644 library/src/main/java/io/appwrite/Operator.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index a05da45c..c355a190 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 11.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 + ## 11.2.1 * Add transaction support for Databases and TablesDB diff --git a/README.md b/README.md index 1627e426..ac57221e 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:11.2.1") +implementation("io.appwrite:sdk-for-android:11.3.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 11.2.1 + 11.3.0 ``` diff --git a/docs/examples/java/account/list-identities.md b/docs/examples/java/account/list-identities.md index d4a6f9f3..327fe395 100644 --- a/docs/examples/java/account/list-identities.md +++ b/docs/examples/java/account/list-identities.md @@ -10,6 +10,7 @@ Account account = new Account(client); account.listIdentities( listOf(), // queries (optional) + false, // total (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md index 951a479f..4562ecc3 100644 --- a/docs/examples/java/account/list-logs.md +++ b/docs/examples/java/account/list-logs.md @@ -10,6 +10,7 @@ Account account = new Account(client); account.listLogs( listOf(), // queries (optional) + false, // total (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 694d99a0..bfd4601a 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -1,6 +1,8 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; +import io.appwrite.Permission; +import io.appwrite.Role; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -19,7 +21,7 @@ databases.createDocument( "age" to 30, "isAdmin" to false ), // data - listOf("read("any")"), // permissions (optional) + listOf(Permission.read(Role.any())), // permissions (optional) "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 7b2ba234..e4102ec5 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -13,6 +13,7 @@ databases.listDocuments( "", // collectionId listOf(), // queries (optional) "", // transactionId (optional) + false, // total (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index a6103e44..d3a3967d 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -1,6 +1,8 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; +import io.appwrite.Permission; +import io.appwrite.Role; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,7 +15,7 @@ databases.updateDocument( "", // collectionId "", // documentId mapOf( "a" to "b" ), // data (optional) - listOf("read("any")"), // permissions (optional) + listOf(Permission.read(Role.any())), // permissions (optional) "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/databases/upsert-document.md b/docs/examples/java/databases/upsert-document.md index 52be46eb..e46afa10 100644 --- a/docs/examples/java/databases/upsert-document.md +++ b/docs/examples/java/databases/upsert-document.md @@ -1,6 +1,8 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; +import io.appwrite.Permission; +import io.appwrite.Role; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,7 +15,7 @@ databases.upsertDocument( "", // collectionId "", // documentId mapOf( "a" to "b" ), // data - listOf("read("any")"), // permissions (optional) + listOf(Permission.read(Role.any())), // permissions (optional) "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index 0270cf0e..c9a1df10 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -11,6 +11,7 @@ Functions functions = new Functions(client); functions.listExecutions( "", // functionId listOf(), // queries (optional) + false, // total (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 598e6831..8de00099 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -2,6 +2,8 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.models.InputFile; import io.appwrite.services.Storage; +import io.appwrite.Permission; +import io.appwrite.Role; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,7 +15,7 @@ storage.createFile( "", // bucketId "", // fileId InputFile.fromPath("file.png"), // file - listOf("read("any")"), // permissions (optional) + listOf(Permission.read(Role.any())), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index a87286c6..178027cc 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -12,6 +12,7 @@ storage.listFiles( "", // bucketId listOf(), // queries (optional) "", // search (optional) + false, // total (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 14fa7793..1e21b3fa 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -1,6 +1,8 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; +import io.appwrite.Permission; +import io.appwrite.Role; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -12,7 +14,7 @@ storage.updateFile( "", // bucketId "", // fileId "", // name (optional) - listOf("read("any")"), // permissions (optional) + listOf(Permission.read(Role.any())), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/create-row.md b/docs/examples/java/tablesdb/create-row.md index 92a90584..f7aa10e5 100644 --- a/docs/examples/java/tablesdb/create-row.md +++ b/docs/examples/java/tablesdb/create-row.md @@ -1,6 +1,8 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.TablesDB; +import io.appwrite.Permission; +import io.appwrite.Role; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -19,7 +21,7 @@ tablesDB.createRow( "age" to 30, "isAdmin" to false ), // data - listOf("read("any")"), // permissions (optional) + listOf(Permission.read(Role.any())), // permissions (optional) "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/tablesdb/list-rows.md b/docs/examples/java/tablesdb/list-rows.md index 21f0005b..3bd1e1c7 100644 --- a/docs/examples/java/tablesdb/list-rows.md +++ b/docs/examples/java/tablesdb/list-rows.md @@ -13,6 +13,7 @@ tablesDB.listRows( "", // tableId listOf(), // queries (optional) "", // transactionId (optional) + false, // total (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/update-row.md b/docs/examples/java/tablesdb/update-row.md index cea7baaa..3abaf906 100644 --- a/docs/examples/java/tablesdb/update-row.md +++ b/docs/examples/java/tablesdb/update-row.md @@ -1,6 +1,8 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.TablesDB; +import io.appwrite.Permission; +import io.appwrite.Role; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,7 +15,7 @@ tablesDB.updateRow( "", // tableId "", // rowId mapOf( "a" to "b" ), // data (optional) - listOf("read("any")"), // permissions (optional) + listOf(Permission.read(Role.any())), // permissions (optional) "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/tablesdb/upsert-row.md b/docs/examples/java/tablesdb/upsert-row.md index 9d6323ff..6f979fc1 100644 --- a/docs/examples/java/tablesdb/upsert-row.md +++ b/docs/examples/java/tablesdb/upsert-row.md @@ -1,6 +1,8 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.TablesDB; +import io.appwrite.Permission; +import io.appwrite.Role; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,7 +15,7 @@ tablesDB.upsertRow( "", // tableId "", // rowId mapOf( "a" to "b" ), // data (optional) - listOf("read("any")"), // permissions (optional) + listOf(Permission.read(Role.any())), // permissions (optional) "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index 216ca40e..ae5cc69b 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -12,6 +12,7 @@ teams.listMemberships( "", // teamId listOf(), // queries (optional) "", // search (optional) + false, // total (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index b69f21ed..fff14e29 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -11,6 +11,7 @@ Teams teams = new Teams(client); teams.list( listOf(), // queries (optional) "", // search (optional) + false, // total (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/kotlin/account/list-identities.md b/docs/examples/kotlin/account/list-identities.md index 5908a44a..5ca94c6d 100644 --- a/docs/examples/kotlin/account/list-identities.md +++ b/docs/examples/kotlin/account/list-identities.md @@ -10,4 +10,5 @@ val account = Account(client) val result = account.listIdentities( queries = listOf(), // (optional) + total = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index 385ccc01..3d2cc4b2 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -10,4 +10,5 @@ val account = Account(client) val result = account.listLogs( queries = listOf(), // (optional) + total = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 7d4b04d1..3e27c44a 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -1,6 +1,8 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases +import io.appwrite.Permission +import io.appwrite.Role val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -19,6 +21,6 @@ val result = databases.createDocument( "age" to 30, "isAdmin" to false ), - permissions = listOf("read("any")"), // (optional) + permissions = listOf(Permission.read(Role.any())), // (optional) transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index a2b6e0e0..e653fc16 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -13,4 +13,5 @@ val result = databases.listDocuments( collectionId = "", queries = listOf(), // (optional) transactionId = "", // (optional) + total = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index 2cacce6f..ba6d4d18 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -1,6 +1,8 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases +import io.appwrite.Permission +import io.appwrite.Role val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,6 +15,6 @@ val result = databases.updateDocument( collectionId = "", documentId = "", data = mapOf( "a" to "b" ), // (optional) - permissions = listOf("read("any")"), // (optional) + permissions = listOf(Permission.read(Role.any())), // (optional) transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/upsert-document.md b/docs/examples/kotlin/databases/upsert-document.md index e5ac4375..4d95c9d6 100644 --- a/docs/examples/kotlin/databases/upsert-document.md +++ b/docs/examples/kotlin/databases/upsert-document.md @@ -1,6 +1,8 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases +import io.appwrite.Permission +import io.appwrite.Role val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,6 +15,6 @@ val result = databases.upsertDocument( collectionId = "", documentId = "", data = mapOf( "a" to "b" ), - permissions = listOf("read("any")"), // (optional) + permissions = listOf(Permission.read(Role.any())), // (optional) transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index 37ea8b82..c24a67b2 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -11,4 +11,5 @@ val functions = Functions(client) val result = functions.listExecutions( functionId = "", queries = listOf(), // (optional) + total = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index 1c78c51e..8a454b7e 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -2,6 +2,8 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.models.InputFile import io.appwrite.services.Storage +import io.appwrite.Permission +import io.appwrite.Role val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,5 +15,5 @@ val result = storage.createFile( bucketId = "", fileId = "", file = InputFile.fromPath("file.png"), - permissions = listOf("read("any")"), // (optional) + permissions = listOf(Permission.read(Role.any())), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 06f6cda4..f62ba749 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -12,4 +12,5 @@ val result = storage.listFiles( bucketId = "", queries = listOf(), // (optional) search = "", // (optional) + total = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 116d156e..32c19a82 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -1,6 +1,8 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage +import io.appwrite.Permission +import io.appwrite.Role val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -12,5 +14,5 @@ val result = storage.updateFile( bucketId = "", fileId = "", name = "", // (optional) - permissions = listOf("read("any")"), // (optional) + permissions = listOf(Permission.read(Role.any())), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/create-row.md b/docs/examples/kotlin/tablesdb/create-row.md index f5850b23..5c54cdcd 100644 --- a/docs/examples/kotlin/tablesdb/create-row.md +++ b/docs/examples/kotlin/tablesdb/create-row.md @@ -1,6 +1,8 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.TablesDB +import io.appwrite.Permission +import io.appwrite.Role val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -19,6 +21,6 @@ val result = tablesDB.createRow( "age" to 30, "isAdmin" to false ), - permissions = listOf("read("any")"), // (optional) + permissions = listOf(Permission.read(Role.any())), // (optional) transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/list-rows.md b/docs/examples/kotlin/tablesdb/list-rows.md index 6d2a4b8b..b075e128 100644 --- a/docs/examples/kotlin/tablesdb/list-rows.md +++ b/docs/examples/kotlin/tablesdb/list-rows.md @@ -13,4 +13,5 @@ val result = tablesDB.listRows( tableId = "", queries = listOf(), // (optional) transactionId = "", // (optional) + total = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/update-row.md b/docs/examples/kotlin/tablesdb/update-row.md index a17f2314..91b27090 100644 --- a/docs/examples/kotlin/tablesdb/update-row.md +++ b/docs/examples/kotlin/tablesdb/update-row.md @@ -1,6 +1,8 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.TablesDB +import io.appwrite.Permission +import io.appwrite.Role val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,6 +15,6 @@ val result = tablesDB.updateRow( tableId = "", rowId = "", data = mapOf( "a" to "b" ), // (optional) - permissions = listOf("read("any")"), // (optional) + permissions = listOf(Permission.read(Role.any())), // (optional) transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/upsert-row.md b/docs/examples/kotlin/tablesdb/upsert-row.md index 074fa339..6b1a45e5 100644 --- a/docs/examples/kotlin/tablesdb/upsert-row.md +++ b/docs/examples/kotlin/tablesdb/upsert-row.md @@ -1,6 +1,8 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.TablesDB +import io.appwrite.Permission +import io.appwrite.Role val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,6 +15,6 @@ val result = tablesDB.upsertRow( tableId = "", rowId = "", data = mapOf( "a" to "b" ), // (optional) - permissions = listOf("read("any")"), // (optional) + permissions = listOf(Permission.read(Role.any())), // (optional) transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index e305403a..fd88be47 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -12,4 +12,5 @@ val result = teams.listMemberships( teamId = "", queries = listOf(), // (optional) search = "", // (optional) + total = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index 984858d2..4b092cf3 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -11,4 +11,5 @@ val teams = Teams(client) val result = teams.list( queries = listOf(), // (optional) search = "", // (optional) + total = false, // (optional) ) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 33ac9c2c..f3570fc7 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -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 "11.2.1", + "x-sdk-version" to "11.3.0", "x-appwrite-response-format" to "1.8.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/Operator.kt b/library/src/main/java/io/appwrite/Operator.kt new file mode 100644 index 00000000..578dc087 --- /dev/null +++ b/library/src/main/java/io/appwrite/Operator.kt @@ -0,0 +1,130 @@ +package io.appwrite + +import io.appwrite.extensions.toJson + +enum class Condition(val value: String) { + EQUAL("equal"), + NOT_EQUAL("notEqual"), + GREATER_THAN("greaterThan"), + GREATER_THAN_EQUAL("greaterThanEqual"), + LESS_THAN("lessThan"), + LESS_THAN_EQUAL("lessThanEqual"), + CONTAINS("contains"), + IS_NULL("isNull"), + IS_NOT_NULL("isNotNull"); + + override fun toString() = value +} + +class Operator( + val method: String, + val values: List? = null, +) { + override fun toString() = this.toJson() + + companion object { + fun increment(value: Number = 1, max: Number? = null): String { + require(!value.toDouble().isNaN() && !value.toDouble().isInfinite()) { "Value cannot be NaN or Infinity" } + max?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Max cannot be NaN or Infinity" } } + val values = mutableListOf(value) + max?.let { values.add(it) } + return Operator("increment", values).toJson() + } + + fun decrement(value: Number = 1, min: Number? = null): String { + require(!value.toDouble().isNaN() && !value.toDouble().isInfinite()) { "Value cannot be NaN or Infinity" } + min?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Min cannot be NaN or Infinity" } } + val values = mutableListOf(value) + min?.let { values.add(it) } + return Operator("decrement", values).toJson() + } + + fun multiply(factor: Number, max: Number? = null): String { + require(!factor.toDouble().isNaN() && !factor.toDouble().isInfinite()) { "Factor cannot be NaN or Infinity" } + max?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Max cannot be NaN or Infinity" } } + val values = mutableListOf(factor) + max?.let { values.add(it) } + return Operator("multiply", values).toJson() + } + + fun divide(divisor: Number, min: Number? = null): String { + require(!divisor.toDouble().isNaN() && !divisor.toDouble().isInfinite()) { "Divisor cannot be NaN or Infinity" } + min?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Min cannot be NaN or Infinity" } } + require(divisor.toDouble() != 0.0) { "Divisor cannot be zero" } + val values = mutableListOf(divisor) + min?.let { values.add(it) } + return Operator("divide", values).toJson() + } + + fun modulo(divisor: Number): String { + require(!divisor.toDouble().isNaN() && !divisor.toDouble().isInfinite()) { "Divisor cannot be NaN or Infinity" } + require(divisor.toDouble() != 0.0) { "Divisor cannot be zero" } + return Operator("modulo", listOf(divisor)).toJson() + } + + fun power(exponent: Number, max: Number? = null): String { + require(!exponent.toDouble().isNaN() && !exponent.toDouble().isInfinite()) { "Exponent cannot be NaN or Infinity" } + max?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Max cannot be NaN or Infinity" } } + val values = mutableListOf(exponent) + max?.let { values.add(it) } + return Operator("power", values).toJson() + } + + fun arrayAppend(values: List): String { + return Operator("arrayAppend", values).toJson() + } + + fun arrayPrepend(values: List): String { + return Operator("arrayPrepend", values).toJson() + } + + fun arrayInsert(index: Int, value: Any): String { + return Operator("arrayInsert", listOf(index, value)).toJson() + } + + fun arrayRemove(value: Any): String { + return Operator("arrayRemove", listOf(value)).toJson() + } + + fun arrayUnique(): String { + return Operator("arrayUnique", emptyList()).toJson() + } + + fun arrayIntersect(values: List): String { + return Operator("arrayIntersect", values).toJson() + } + + fun arrayDiff(values: List): String { + return Operator("arrayDiff", values).toJson() + } + + fun arrayFilter(condition: Condition, value: Any? = null): String { + val values = listOf(condition.value, value) + return Operator("arrayFilter", values).toJson() + } + + fun stringConcat(value: Any): String { + return Operator("stringConcat", listOf(value)).toJson() + } + + fun stringReplace(search: String, replace: String): String { + return Operator("stringReplace", listOf(search, replace)).toJson() + } + + fun toggle(): String { + return Operator("toggle", emptyList()).toJson() + } + + fun dateAddDays(days: Int): String { + return Operator("dateAddDays", listOf(days)).toJson() + } + + fun dateSubDays(days: Int): String { + return Operator("dateSubDays", listOf(days)).toJson() + } + + fun dateSetNow(): String { + return Operator("dateSetNow", emptyList()).toJson() + } + } +} diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index e059b91d..c088a795 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -251,7 +251,7 @@ class Query( * @param value The date value to compare against. * @returns The query string. */ - fun createdBefore(value: String) = Query("createdBefore", null, listOf(value)).toJson() + fun createdBefore(value: String) = lessThan("\$createdAt", value) /** * Filter resources where document was created after date. @@ -259,7 +259,7 @@ class Query( * @param value The date value to compare against. * @returns The query string. */ - fun createdAfter(value: String) = Query("createdAfter", null, listOf(value)).toJson() + fun createdAfter(value: String) = greaterThan("\$createdAt", value) /** * Filter resources where document was created between start and end dates (inclusive). @@ -268,7 +268,7 @@ class Query( * @param end The end date value. * @returns The query string. */ - fun createdBetween(start: String, end: String) = Query("createdBetween", null, listOf(start, end)).toJson() + fun createdBetween(start: String, end: String) = between("\$createdAt", start, end) /** * Filter resources where document was updated before date. @@ -276,7 +276,7 @@ class Query( * @param value The date value to compare against. * @returns The query string. */ - fun updatedBefore(value: String) = Query("updatedBefore", null, listOf(value)).toJson() + fun updatedBefore(value: String) = lessThan("\$updatedAt", value) /** * Filter resources where document was updated after date. @@ -284,7 +284,7 @@ class Query( * @param value The date value to compare against. * @returns The query string. */ - fun updatedAfter(value: String) = Query("updatedAfter", null, listOf(value)).toJson() + fun updatedAfter(value: String) = greaterThan("\$updatedAt", value) /** * Filter resources where document was updated between start and end dates (inclusive). @@ -293,7 +293,7 @@ class Query( * @param end The end date value. * @returns The query string. */ - fun updatedBetween(start: String, end: String) = Query("updatedBetween", null, listOf(start, end)).toJson() + fun updatedBetween(start: String, end: String) = between("\$updatedAt", start, end) /** * Combine multiple queries using logical OR operator. diff --git a/library/src/main/java/io/appwrite/enums/ExecutionStatus.kt b/library/src/main/java/io/appwrite/enums/ExecutionStatus.kt index 6944c55f..25a1412d 100644 --- a/library/src/main/java/io/appwrite/enums/ExecutionStatus.kt +++ b/library/src/main/java/io/appwrite/enums/ExecutionStatus.kt @@ -10,7 +10,9 @@ enum class ExecutionStatus(val value: String) { @SerializedName("completed") COMPLETED("completed"), @SerializedName("failed") - FAILED("failed"); + FAILED("failed"), + @SerializedName("scheduled") + SCHEDULED("scheduled"); override fun toString() = value } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 5b9863c0..e77ee1fd 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -52,7 +52,7 @@ data class Execution( val trigger: 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`. */ @SerializedName("status") val status: ExecutionStatus, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 9851a04d..e9e69ad6 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -183,16 +183,19 @@ class Account(client: Client) : Service(client) { * Get the list of identities for the currently logged in user. * * @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. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry + * @param total When set to false, the total count returned will be 0 and will not be calculated. * @return [io.appwrite.models.IdentityList] */ @JvmOverloads suspend fun listIdentities( queries: List? = null, + total: Boolean? = null, ): io.appwrite.models.IdentityList { val apiPath = "/account/identities" val apiParams = mutableMapOf( "queries" to queries, + "total" to total, ) val apiHeaders = mutableMapOf( ) @@ -271,16 +274,19 @@ class Account(client: Client) : Service(client) { * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. * * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param total When set to false, the total count returned will be 0 and will not be calculated. * @return [io.appwrite.models.LogList] */ @JvmOverloads suspend fun listLogs( queries: List? = null, + total: Boolean? = null, ): io.appwrite.models.LogList { val apiPath = "/account/logs" val apiParams = mutableMapOf( "queries" to queries, + "total" to total, ) val apiHeaders = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 417b4ce3..ce73151c 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -219,6 +219,7 @@ class Databases(client: Client) : Service(client) { * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @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. * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -231,6 +232,7 @@ class Databases(client: Client) : Service(client) { collectionId: String, queries: List? = null, transactionId: String? = null, + total: Boolean? = null, nestedType: Class, ): io.appwrite.models.DocumentList { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" @@ -240,6 +242,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, "transactionId" to transactionId, + "total" to total, ) val apiHeaders = mutableMapOf( ) @@ -264,6 +267,7 @@ class Databases(client: Client) : Service(client) { * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @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. * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -277,11 +281,13 @@ class Databases(client: Client) : Service(client) { collectionId: String, queries: List? = null, transactionId: String? = null, + total: Boolean? = null, ): io.appwrite.models.DocumentList> = listDocuments( databaseId, collectionId, queries, transactionId, + total, nestedType = classOf(), ) diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index cadf014c..279d3127 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -19,18 +19,21 @@ class Functions(client: Client) : Service(client) { * * @param functionId Function ID. * @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. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId + * @param total When set to false, the total count returned will be 0 and will not be calculated. * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads suspend fun listExecutions( functionId: String, queries: List? = null, + total: Boolean? = null, ): io.appwrite.models.ExecutionList { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) val apiParams = mutableMapOf( "queries" to queries, + "total" to total, ) val apiHeaders = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index b04c189f..063290f7 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -22,6 +22,7 @@ class Storage(client: Client) : Service(client) { * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @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. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded * @param search Search term to filter your list results. Max length: 256 chars. + * @param total When set to false, the total count returned will be 0 and will not be calculated. * @return [io.appwrite.models.FileList] */ @JvmOverloads @@ -29,6 +30,7 @@ class Storage(client: Client) : Service(client) { bucketId: String, queries: List? = null, search: String? = null, + total: Boolean? = null, ): io.appwrite.models.FileList { val apiPath = "/storage/buckets/{bucketId}/files" .replace("{bucketId}", bucketId) @@ -36,6 +38,7 @@ class Storage(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, "search" to search, + "total" to total, ) val apiHeaders = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/TablesDb.kt b/library/src/main/java/io/appwrite/services/TablesDb.kt index ea65a172..033d3be2 100644 --- a/library/src/main/java/io/appwrite/services/TablesDb.kt +++ b/library/src/main/java/io/appwrite/services/TablesDb.kt @@ -219,6 +219,7 @@ class TablesDB(client: Client) : Service(client) { * @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @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. * @return [io.appwrite.models.RowList] */ @JvmOverloads @@ -227,6 +228,7 @@ class TablesDB(client: Client) : Service(client) { tableId: String, queries: List? = null, transactionId: String? = null, + total: Boolean? = null, nestedType: Class, ): io.appwrite.models.RowList { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" @@ -236,6 +238,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, "transactionId" to transactionId, + "total" to total, ) val apiHeaders = mutableMapOf( ) @@ -260,6 +263,7 @@ class TablesDB(client: Client) : Service(client) { * @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @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. * @return [io.appwrite.models.RowList] */ @JvmOverloads @@ -269,11 +273,13 @@ class TablesDB(client: Client) : Service(client) { tableId: String, queries: List? = null, transactionId: String? = null, + total: Boolean? = null, ): io.appwrite.models.RowList> = listRows( databaseId, tableId, queries, transactionId, + total, nestedType = classOf(), ) diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 64e38c82..5d48f280 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -19,12 +19,14 @@ class Teams(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. You may filter on the following attributes: name, total, billingPlan * @param search Search term to filter your list results. Max length: 256 chars. + * @param total When set to false, the total count returned will be 0 and will not be calculated. * @return [io.appwrite.models.TeamList] */ @JvmOverloads suspend fun list( queries: List? = null, search: String? = null, + total: Boolean? = null, nestedType: Class, ): io.appwrite.models.TeamList { val apiPath = "/teams" @@ -32,6 +34,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, "search" to search, + "total" to total, ) val apiHeaders = mutableMapOf( ) @@ -54,6 +57,7 @@ class Teams(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. You may filter on the following attributes: name, total, billingPlan * @param search Search term to filter your list results. Max length: 256 chars. + * @param total When set to false, the total count returned will be 0 and will not be calculated. * @return [io.appwrite.models.TeamList] */ @JvmOverloads @@ -61,9 +65,11 @@ class Teams(client: Client) : Service(client) { suspend fun list( queries: List? = null, search: String? = null, + total: Boolean? = null, ): io.appwrite.models.TeamList> = list( queries, search, + total, nestedType = classOf(), ) @@ -257,6 +263,7 @@ class Teams(client: Client) : Service(client) { * @param teamId Team ID. * @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. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles * @param search Search term to filter your list results. Max length: 256 chars. + * @param total When set to false, the total count returned will be 0 and will not be calculated. * @return [io.appwrite.models.MembershipList] */ @JvmOverloads @@ -264,6 +271,7 @@ class Teams(client: Client) : Service(client) { teamId: String, queries: List? = null, search: String? = null, + total: Boolean? = null, ): io.appwrite.models.MembershipList { val apiPath = "/teams/{teamId}/memberships" .replace("{teamId}", teamId) @@ -271,6 +279,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, "search" to search, + "total" to total, ) val apiHeaders = mutableMapOf( )