From 0682d786616dc20eba885958436460db473ba79d Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 06:27:53 +0000 Subject: [PATCH] chore: regenerate --- README.md | 6 +- docs/examples/databases/create-document.md | 4 +- .../databases/decrement-document-attribute.md | 16 ++ .../databases/increment-document-attribute.md | 16 ++ docs/examples/databases/upsert-document.md | 6 +- docs/examples/tables/create-row.md | 17 -- docs/examples/tables/create-rows.md | 14 -- docs/examples/tables/delete-row.md | 13 -- docs/examples/tables/get-row.md | 14 -- docs/examples/tables/list-rows.md | 13 -- docs/examples/tables/update-row.md | 15 -- docs/examples/tables/upsert-row.md | 15 -- lib/appwrite.dart | 3 +- lib/models.dart | 2 - lib/services/account.dart | 2 - lib/services/databases.dart | 48 +++- lib/services/tables.dart | 147 ------------ lib/src/client_browser.dart | 4 +- lib/src/client_io.dart | 4 +- lib/src/models/continent_list.dart | 2 +- lib/src/models/country_list.dart | 2 +- lib/src/models/currency_list.dart | 2 +- lib/src/models/document_list.dart | 2 +- lib/src/models/execution_list.dart | 2 +- lib/src/models/file_list.dart | 2 +- lib/src/models/identity_list.dart | 2 +- lib/src/models/language_list.dart | 2 +- lib/src/models/locale_code_list.dart | 2 +- lib/src/models/log_list.dart | 2 +- lib/src/models/membership_list.dart | 2 +- lib/src/models/phone_list.dart | 2 +- lib/src/models/row.dart | 66 ------ lib/src/models/row_list.dart | 32 --- lib/src/models/session_list.dart | 2 +- lib/src/models/team_list.dart | 2 +- pubspec.yaml | 2 +- test/services/databases_test.dart | 53 +++++ test/services/tables_test.dart | 213 ------------------ test/src/models/row_list_test.dart | 20 -- test/src/models/row_test.dart | 31 --- 40 files changed, 153 insertions(+), 651 deletions(-) create mode 100644 docs/examples/databases/decrement-document-attribute.md create mode 100644 docs/examples/databases/increment-document-attribute.md delete mode 100644 docs/examples/tables/create-row.md delete mode 100644 docs/examples/tables/create-rows.md delete mode 100644 docs/examples/tables/delete-row.md delete mode 100644 docs/examples/tables/get-row.md delete mode 100644 docs/examples/tables/list-rows.md delete mode 100644 docs/examples/tables/update-row.md delete mode 100644 docs/examples/tables/upsert-row.md delete mode 100644 lib/services/tables.dart delete mode 100644 lib/src/models/row.dart delete mode 100644 lib/src/models/row_list.dart delete mode 100644 test/services/tables_test.dart delete mode 100644 test/src/models/row_list_test.dart delete mode 100644 test/src/models/row_test.dart diff --git a/README.md b/README.md index 934a01c..b14193b 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ [![pub package](https://img.shields.io/pub/v/appwrite?style=flat-square)](https://pub.dartlang.org/packages/appwrite) ![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.8.x-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.x-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![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-flutter/releases).** +**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).** Appwrite is an open-source backend as a service server that abstract and simplify 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 Flutter 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) @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^18.0.0 + appwrite: ^17.0.2 ``` You can install packages from the command line: diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 4f286ff..27efc34 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,9 +2,7 @@ import 'package:appwrite/appwrite.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // - .setJWT(''); // Your secret JSON Web Token + .setProject(''); // Your project ID Databases databases = Databases(client); diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 0000000..ec0d9ee --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.md @@ -0,0 +1,16 @@ +import 'package:appwrite/appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +Databases databases = Databases(client); + +Document result = await databases.decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: 0, // optional + min: 0, // optional +); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 0000000..78f5b0c --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.md @@ -0,0 +1,16 @@ +import 'package:appwrite/appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +Databases databases = Databases(client); + +Document result = await databases.incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: 0, // optional + max: 0, // optional +); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index ec3af47..398a99c 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -2,9 +2,7 @@ import 'package:appwrite/appwrite.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // - .setJWT(''); // Your secret JSON Web Token + .setProject(''); // Your project ID Databases databases = Databases(client); @@ -12,4 +10,6 @@ Document result = await databases.upsertDocument( databaseId: '', collectionId: '', documentId: '', + data: {}, + permissions: ["read("any")"], // optional ); diff --git a/docs/examples/tables/create-row.md b/docs/examples/tables/create-row.md deleted file mode 100644 index ac9923d..0000000 --- a/docs/examples/tables/create-row.md +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // - .setJWT(''); // Your secret JSON Web Token - -Tables tables = Tables(client); - -Row result = await tables.createRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, - permissions: ["read("any")"], // optional -); diff --git a/docs/examples/tables/create-rows.md b/docs/examples/tables/create-rows.md deleted file mode 100644 index 38c4c75..0000000 --- a/docs/examples/tables/create-rows.md +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setAdmin('') // - .setKey(''); // - -Tables tables = Tables(client); - -RowList result = await tables.createRows( - databaseId: '', - tableId: '', - rows: [], -); diff --git a/docs/examples/tables/delete-row.md b/docs/examples/tables/delete-row.md deleted file mode 100644 index 4187c47..0000000 --- a/docs/examples/tables/delete-row.md +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Tables tables = Tables(client); - -await tables.deleteRow( - databaseId: '', - tableId: '', - rowId: '', -); diff --git a/docs/examples/tables/get-row.md b/docs/examples/tables/get-row.md deleted file mode 100644 index 8d8c52c..0000000 --- a/docs/examples/tables/get-row.md +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Tables tables = Tables(client); - -Row result = await tables.getRow( - databaseId: '', - tableId: '', - rowId: '', - queries: [], // optional -); diff --git a/docs/examples/tables/list-rows.md b/docs/examples/tables/list-rows.md deleted file mode 100644 index f770bbb..0000000 --- a/docs/examples/tables/list-rows.md +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Tables tables = Tables(client); - -RowList result = await tables.listRows( - databaseId: '', - tableId: '', - queries: [], // optional -); diff --git a/docs/examples/tables/update-row.md b/docs/examples/tables/update-row.md deleted file mode 100644 index f43ba5e..0000000 --- a/docs/examples/tables/update-row.md +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Tables tables = Tables(client); - -Row result = await tables.updateRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, // optional - permissions: ["read("any")"], // optional -); diff --git a/docs/examples/tables/upsert-row.md b/docs/examples/tables/upsert-row.md deleted file mode 100644 index 26a872b..0000000 --- a/docs/examples/tables/upsert-row.md +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // - .setJWT(''); // Your secret JSON Web Token - -Tables tables = Tables(client); - -Row result = await tables.upsertRow( - databaseId: '', - tableId: '', - rowId: '', -); diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 6b4dca2..b0c431a 100644 --- a/lib/appwrite.dart +++ b/lib/appwrite.dart @@ -1,6 +1,6 @@ /// Appwrite Flutter SDK /// -/// This SDK is compatible with Appwrite server version 1.8.x. +/// This SDK is compatible with Appwrite server version 1.7.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; @@ -33,7 +33,6 @@ part 'id.dart'; part 'services/account.dart'; part 'services/avatars.dart'; part 'services/databases.dart'; -part 'services/tables.dart'; part 'services/functions.dart'; part 'services/graphql.dart'; part 'services/locale.dart'; diff --git a/lib/models.dart b/lib/models.dart index d4fae41..a6de0d8 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -2,7 +2,6 @@ library appwrite.models; part 'src/models/model.dart'; -part 'src/models/row_list.dart'; part 'src/models/document_list.dart'; part 'src/models/session_list.dart'; part 'src/models/identity_list.dart'; @@ -17,7 +16,6 @@ part 'src/models/language_list.dart'; part 'src/models/currency_list.dart'; part 'src/models/phone_list.dart'; part 'src/models/locale_code_list.dart'; -part 'src/models/row.dart'; part 'src/models/document.dart'; part 'src/models/log.dart'; part 'src/models/user.dart'; diff --git a/lib/services/account.dart b/lib/services/account.dart index 6dc15d1..b1ba4aa 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -586,7 +586,6 @@ class Account extends Service { /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated.') Future updateMagicURLSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/magic-url'; @@ -659,7 +658,6 @@ class Account extends Service { /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated.') Future updatePhoneSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/phone'; diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 57fdf64..ec56086 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -8,7 +8,6 @@ class Databases extends Service { /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead.') Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -30,7 +29,6 @@ class Databases extends Service { /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead.') Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -52,7 +50,6 @@ class Databases extends Service { /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead.') Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); @@ -78,11 +75,12 @@ class Databases extends Service { /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.') - Future upsertDocument({required String databaseId, required String collectionId, required String documentId}) async { + Future upsertDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); final Map apiParams = { + 'data': data, + 'permissions': permissions, }; final Map apiHeaders = { @@ -97,7 +95,6 @@ class Databases extends Service { /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead.') Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); @@ -117,7 +114,6 @@ class Databases extends Service { } /// Delete a document by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Tables.deleteRow` instead.') Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); @@ -133,4 +129,42 @@ class Databases extends Service { return res.data; } + + /// Decrement a specific attribute of a document by a given value. + Future decrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? min}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + + } + + /// Increment a specific attribute of a document by a given value. + Future incrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? max}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + + } } \ No newline at end of file diff --git a/lib/services/tables.dart b/lib/services/tables.dart deleted file mode 100644 index 75874cf..0000000 --- a/lib/services/tables.dart +++ /dev/null @@ -1,147 +0,0 @@ -part of '../appwrite.dart'; - -/// The Tables service allows you to create structured tables of rows, query -/// and filter lists of rows -class Tables extends Service { - /// Initializes a [Tables] service - Tables(super.client); - - /// Get a list of all the user's rows in a given table. You can use the query - /// params to filter your results. - Future listRows({required String databaseId, required String tableId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.RowList.fromMap(res.data); - - } - - /// Create a new Row. Before using this route, you should create a new table - /// resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - /// API or directly from your database console. - Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - - } - - /// Create new Rows. Before using this route, you should create a new table - /// resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - /// API or directly from your database console. - Future createRows({required String databaseId, required String tableId, required List rows}) async { - final String apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rows': rows, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.RowList.fromMap(res.data); - - } - - /// Get a row by its unique ID. This endpoint response returns a JSON object - /// with the row data. - Future getRow({required String databaseId, required String tableId, required String rowId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - - } - - /// Create or update a Row. Before using this route, you should create a new - /// table resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - /// API or directly from your database console. - Future upsertRow({required String databaseId, required String tableId, required String rowId}) async { - final String apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - - } - - /// Update a row by its unique ID. Using the patch method you can pass only - /// specific fields that will get updated. - Future updateRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - - } - - /// Delete a row by its unique ID. - Future deleteRow({required String databaseId, required String tableId, required String rowId}) async { - final String apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - - } -} \ No newline at end of file diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index b06d55b..b4232e4 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -43,8 +43,8 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '18.0.0', - 'X-Appwrite-Response-Format': '1.8.0', + 'x-sdk-version': '17.0.2', + 'X-Appwrite-Response-Format': '1.7.0', }; config = {}; diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index def22ed..edf5ae7 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -64,8 +64,8 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '18.0.0', - 'X-Appwrite-Response-Format' : '1.8.0', + 'x-sdk-version': '17.0.2', + 'X-Appwrite-Response-Format' : '1.7.0', }; config = {}; diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 60b008e..7a1eb84 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Continents List class ContinentList implements Model { - /// Total number of continents rows that matched your query. + /// Total number of continents documents that matched your query. final int total; /// List of continents. diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 3a3acd4..e0b8f29 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Countries List class CountryList implements Model { - /// Total number of countries rows that matched your query. + /// Total number of countries documents that matched your query. final int total; /// List of countries. diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 34274e0..f67049a 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Currencies List class CurrencyList implements Model { - /// Total number of currencies rows that matched your query. + /// Total number of currencies documents that matched your query. final int total; /// List of currencies. diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index 90bce66..8af3425 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Documents List class DocumentList implements Model { - /// Total number of documents rows that matched your query. + /// Total number of documents documents that matched your query. final int total; /// List of documents. diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index c30098a..0bcbad6 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Executions List class ExecutionList implements Model { - /// Total number of executions rows that matched your query. + /// Total number of executions documents that matched your query. final int total; /// List of executions. diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 164a281..28bc6fc 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Files List class FileList implements Model { - /// Total number of files rows that matched your query. + /// Total number of files documents that matched your query. final int total; /// List of files. diff --git a/lib/src/models/identity_list.dart b/lib/src/models/identity_list.dart index 52fa04a..e92e36c 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Identities List class IdentityList implements Model { - /// Total number of identities rows that matched your query. + /// Total number of identities documents that matched your query. final int total; /// List of identities. diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index 755c4e2..fe27111 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Languages List class LanguageList implements Model { - /// Total number of languages rows that matched your query. + /// Total number of languages documents that matched your query. final int total; /// List of languages. diff --git a/lib/src/models/locale_code_list.dart b/lib/src/models/locale_code_list.dart index 9e1e603..839474d 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Locale codes list class LocaleCodeList implements Model { - /// Total number of localeCodes rows that matched your query. + /// Total number of localeCodes documents that matched your query. final int total; /// List of localeCodes. diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 636d916..91d024d 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Logs List class LogList implements Model { - /// Total number of logs rows that matched your query. + /// Total number of logs documents that matched your query. final int total; /// List of logs. diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index 566afb1..409cdbf 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Memberships List class MembershipList implements Model { - /// Total number of memberships rows that matched your query. + /// Total number of memberships documents that matched your query. final int total; /// List of memberships. diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index a40e359..beab76e 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Phones List class PhoneList implements Model { - /// Total number of phones rows that matched your query. + /// Total number of phones documents that matched your query. final int total; /// List of phones. diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart deleted file mode 100644 index 62e69e5..0000000 --- a/lib/src/models/row.dart +++ /dev/null @@ -1,66 +0,0 @@ -part of '../../models.dart'; - -/// Row -class Row implements Model { - /// Row ID. - final String $id; - - /// Row automatically incrementing ID. - final int $sequence; - - /// Table ID. - final String $tableId; - - /// Database ID. - final String $databaseId; - - /// Row creation date in ISO 8601 format. - final String $createdAt; - - /// Row update date in ISO 8601 format. - final String $updatedAt; - - /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; - - final Map data; - - Row({ - required this.$id, - required this.$sequence, - required this.$tableId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); - - factory Row.fromMap(Map map) { - return Row( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } - - T convertTo(T Function(Map) fromJson) => fromJson(data); -} diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart deleted file mode 100644 index 42bdbfe..0000000 --- a/lib/src/models/row_list.dart +++ /dev/null @@ -1,32 +0,0 @@ -part of '../../models.dart'; - -/// Rows List -class RowList implements Model { - /// Total number of rows rows that matched your query. - final int total; - - /// List of rows. - final List rows; - - RowList({ - required this.total, - required this.rows, - }); - - factory RowList.fromMap(Map map) { - return RowList( - total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), - ); - } - - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } - - List convertTo(T Function(Map) fromJson) => - rows.map((d) => d.convertTo(fromJson)).toList(); -} diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index 160cb78..6d26d6a 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Sessions List class SessionList implements Model { - /// Total number of sessions rows that matched your query. + /// Total number of sessions documents that matched your query. final int total; /// List of sessions. diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index 3b8547c..2fb3611 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Teams List class TeamList implements Model { - /// Total number of teams rows that matched your query. + /// Total number of teams documents that matched your query. final int total; /// List of teams. diff --git a/pubspec.yaml b/pubspec.yaml index 8a47f3c..836b069 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 18.0.0 +version: 17.0.2 description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API homepage: https://appwrite.io repository: https://github.com/appwrite/sdk-for-flutter diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index 68844f2..6e55dc2 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -144,6 +144,7 @@ void main() { databaseId: '', collectionId: '', documentId: '', + data: {}, ); expect(response, isA()); @@ -189,5 +190,57 @@ void main() { ); }); + test('test method decrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + + }); + + test('test method incrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + + }); + }); } \ No newline at end of file diff --git a/test/services/tables_test.dart b/test/services/tables_test.dart deleted file mode 100644 index e1cf1f8..0000000 --- a/test/services/tables_test.dart +++ /dev/null @@ -1,213 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; -import 'package:appwrite/models.dart' as models; -import 'package:appwrite/src/enums.dart'; -import 'package:appwrite/src/response.dart'; -import 'dart:typed_data'; -import 'package:appwrite/appwrite.dart'; - -class MockClient extends Mock implements Client { - Map config = {'project': 'testproject'}; - String endPoint = 'https://localhost/v1'; - @override - Future call( - HttpMethod? method, { - String path = '', - Map headers = const {}, - Map params = const {}, - ResponseType? responseType, - }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); - } - - @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); - } - - @override - Future chunkedUpload({ - String? path, - Map? params, - String? paramName, - String? idParamName, - Map? headers, - Function(UploadProgress)? onProgress, - }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); - } -} - -void main() { - group('Tables test', () { - late MockClient client; - late Tables tables; - - setUp(() { - client = MockClient(); - tables = Tables(client); - }); - - test('test method listRows()', () async { - final Map data = { - 'total': 5, - 'rows': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tables.listRows( - databaseId: '', - tableId: '', - ); - expect(response, isA()); - - }); - - test('test method createRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tables.createRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, - ); - expect(response, isA()); - - }); - - test('test method createRows()', () async { - final Map data = { - 'total': 5, - 'rows': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tables.createRows( - databaseId: '', - tableId: '', - rows: [], - ); - expect(response, isA()); - - }); - - test('test method getRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tables.getRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method upsertRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tables.upsertRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method updateRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tables.updateRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteRow()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tables.deleteRow( - databaseId: '', - tableId: '', - rowId: '', - ); - }); - - }); -} \ No newline at end of file diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart deleted file mode 100644 index e5fb112..0000000 --- a/test/src/models/row_list_test.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('RowList', () { - - test('model', () { - final model = RowList( - total: 5, - rows: [], - ); - - final map = model.toMap(); - final result = RowList.fromMap(map); - - expect(result.total, 5); - expect(result.rows, []); - }); - }); -} diff --git a/test/src/models/row_test.dart b/test/src/models/row_test.dart deleted file mode 100644 index 7a7b196..0000000 --- a/test/src/models/row_test.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('Row', () { - - test('model', () { - final model = Row( - $id: '5e5ea5c16897e', - $sequence: 1, - $tableId: '5e5ea5c15117e', - $databaseId: '5e5ea5c15117e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - $permissions: [], - data: {}, - ); - - final map = model.toMap(); - final result = Row.fromMap(map); - - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, 1); - expect(result.$tableId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); - }); -}