diff --git a/CHANGELOG.md b/CHANGELOG.md index c93400f5..82fdf212 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 10.0.1 + +* Added a new `label` function to the `Role` helper class +* Update internal variable names to prevent name collision +* Fix: content range header inconsistency in chunked uploads [#648](https://github.com/appwrite/sdk-generator/pull/648) + ## 10.0.0 * Support for Appwrite 1.4.0 diff --git a/README.md b/README.md index 0efa67e4..9e1422a2 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^10.0.0 + appwrite: ^10.0.1 ``` You can install packages from the command line: diff --git a/lib/role.dart b/lib/role.dart index 9289d690..f042f14f 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -58,4 +58,9 @@ class Role { static String member(String id) { return 'member:$id'; } + + /// Grants access to a user with the specified label. + static String label(String name) { + return 'label:$name'; + } } \ No newline at end of file diff --git a/lib/services/account.dart b/lib/services/account.dart index dacdfc0a..0d411e44 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -11,14 +11,14 @@ class Account extends Service { Future get() async { const String apiPath = '/account'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -35,18 +35,18 @@ class Account extends Service { Future create({required String userId, required String email, required String password, String? name}) async { const String apiPath = '/account'; - final Map params = { + final Map apiParams = { 'userId': userId, 'email': email, 'password': password, 'name': name, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -65,16 +65,16 @@ class Account extends Service { Future updateEmail({required String email, required String password}) async { const String apiPath = '/account/email'; - final Map params = { + final Map apiParams = { 'email': email, 'password': password, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -86,15 +86,15 @@ class Account extends Service { Future listIdentities({String? queries}) async { const String apiPath = '/account/identities'; - final Map params = { + final Map apiParams = { 'queries': queries, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.IdentityList.fromMap(res.data); @@ -106,14 +106,14 @@ class Account extends Service { Future deleteIdentity({required String identityId}) async { final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -129,14 +129,14 @@ class Account extends Service { Future createJWT() async { const String apiPath = '/account/jwt'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Jwt.fromMap(res.data); @@ -149,15 +149,15 @@ class Account extends Service { Future listLogs({List? queries}) async { const String apiPath = '/account/logs'; - final Map params = { + final Map apiParams = { 'queries': queries, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.LogList.fromMap(res.data); @@ -169,15 +169,15 @@ class Account extends Service { Future updateName({required String name}) async { const String apiPath = '/account/name'; - final Map params = { + final Map apiParams = { 'name': name, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -191,16 +191,16 @@ class Account extends Service { Future updatePassword({required String password, String? oldPassword}) async { const String apiPath = '/account/password'; - final Map params = { + final Map apiParams = { 'password': password, 'oldPassword': oldPassword, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -216,16 +216,16 @@ class Account extends Service { Future updatePhone({required String phone, required String password}) async { const String apiPath = '/account/phone'; - final Map params = { + final Map apiParams = { 'phone': phone, 'password': password, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -237,14 +237,14 @@ class Account extends Service { Future getPrefs() async { const String apiPath = '/account/prefs'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); @@ -258,15 +258,15 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { const String apiPath = '/account/prefs'; - final Map params = { + final Map apiParams = { 'prefs': prefs, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -285,16 +285,16 @@ class Account extends Service { Future createRecovery({required String email, required String url}) async { const String apiPath = '/account/recovery'; - final Map params = { + final Map apiParams = { 'email': email, 'url': url, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -314,18 +314,18 @@ class Account extends Service { Future updateRecovery({required String userId, required String secret, required String password, required String passwordAgain}) async { const String apiPath = '/account/recovery'; - final Map params = { + final Map apiParams = { 'userId': userId, 'secret': secret, 'password': password, 'passwordAgain': passwordAgain, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -338,14 +338,14 @@ class Account extends Service { Future listSessions() async { const String apiPath = '/account/sessions'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.SessionList.fromMap(res.data); @@ -358,14 +358,14 @@ class Account extends Service { Future deleteSessions() async { const String apiPath = '/account/sessions'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -382,14 +382,14 @@ class Account extends Service { Future createAnonymousSession() async { const String apiPath = '/account/sessions/anonymous'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); @@ -405,16 +405,16 @@ class Account extends Service { Future createEmailSession({required String email, required String password}) async { const String apiPath = '/account/sessions/email'; - final Map params = { + final Map apiParams = { 'email': email, 'password': password, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); @@ -440,17 +440,17 @@ class Account extends Service { Future createMagicURLSession({required String userId, required String email, String? url}) async { const String apiPath = '/account/sessions/magic-url'; - final Map params = { + final Map apiParams = { 'userId': userId, 'email': email, 'url': url, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -472,16 +472,16 @@ class Account extends Service { Future updateMagicURLSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/magic-url'; - final Map params = { + final Map apiParams = { 'userId': userId, 'secret': secret, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); @@ -553,16 +553,16 @@ class Account extends Service { Future createPhoneSession({required String userId, required String phone}) async { const String apiPath = '/account/sessions/phone'; - final Map params = { + final Map apiParams = { 'userId': userId, 'phone': phone, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -578,16 +578,16 @@ class Account extends Service { Future updatePhoneSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/phone'; - final Map params = { + final Map apiParams = { 'userId': userId, 'secret': secret, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); @@ -600,14 +600,14 @@ class Account extends Service { Future getSession({required String sessionId}) async { final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); @@ -621,14 +621,14 @@ class Account extends Service { Future updateSession({required String sessionId}) async { final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); @@ -643,14 +643,14 @@ class Account extends Service { Future deleteSession({required String sessionId}) async { final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -664,14 +664,14 @@ class Account extends Service { Future updateStatus() async { const String apiPath = '/account/status'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -697,15 +697,15 @@ class Account extends Service { Future createVerification({required String url}) async { const String apiPath = '/account/verification'; - final Map params = { + final Map apiParams = { 'url': url, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -720,16 +720,16 @@ class Account extends Service { Future updateVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification'; - final Map params = { + final Map apiParams = { 'userId': userId, 'secret': secret, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -746,14 +746,14 @@ class Account extends Service { Future createPhoneVerification() async { const String apiPath = '/account/verification/phone'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -768,16 +768,16 @@ class Account extends Service { Future updatePhoneVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification/phone'; - final Map params = { + final Map apiParams = { 'userId': userId, 'secret': secret, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 4be1e6ba..d3470f1c 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -13,15 +13,15 @@ class Databases extends Service { 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); - final Map params = { + final Map apiParams = { 'queries': queries, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.DocumentList.fromMap(res.data); @@ -36,17 +36,17 @@ class Databases extends Service { 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); - final Map params = { + final Map apiParams = { 'documentId': documentId, 'data': data, 'permissions': permissions, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); @@ -59,15 +59,15 @@ class Databases extends Service { 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); - final Map params = { + final Map apiParams = { 'queries': queries, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); @@ -80,16 +80,16 @@ class Databases extends Service { 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); - final Map params = { + final Map apiParams = { 'data': data, 'permissions': permissions, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); @@ -101,14 +101,14 @@ class Databases extends Service { 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); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 8f0b7bd8..e4f0389b 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -13,16 +13,16 @@ class Functions extends Service { Future listExecutions({required String functionId, List? queries, String? search}) async { final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.ExecutionList.fromMap(res.data); @@ -37,7 +37,7 @@ class Functions extends Service { Future createExecution({required String functionId, String? body, bool? xasync, String? path, String? method, Map? headers}) async { final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - final Map params = { + final Map apiParams = { 'body': body, 'async': xasync, 'path': path, @@ -45,11 +45,11 @@ class Functions extends Service { 'headers': headers, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Execution.fromMap(res.data); @@ -61,14 +61,14 @@ class Functions extends Service { Future getExecution({required String functionId, required String executionId}) async { final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Execution.fromMap(res.data); diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index f7f7349e..743a9233 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -12,15 +12,15 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map params = { + final Map apiParams = { 'query': query, }; - final Map headers = { + final Map apiHeaders = { 'x-sdk-graphql': 'true', 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -32,15 +32,15 @@ class Graphql extends Service { Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map params = { + final Map apiParams = { 'query': query, }; - final Map headers = { + final Map apiHeaders = { 'x-sdk-graphql': 'true', 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; diff --git a/lib/services/locale.dart b/lib/services/locale.dart index 8f63b4cb..869c8e1d 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -17,14 +17,14 @@ class Locale extends Service { Future get() async { const String apiPath = '/locale'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Locale.fromMap(res.data); @@ -37,14 +37,14 @@ class Locale extends Service { Future listCodes() async { const String apiPath = '/locale/codes'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.LocaleCodeList.fromMap(res.data); @@ -57,14 +57,14 @@ class Locale extends Service { Future listContinents() async { const String apiPath = '/locale/continents'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.ContinentList.fromMap(res.data); @@ -77,14 +77,14 @@ class Locale extends Service { Future listCountries() async { const String apiPath = '/locale/countries'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.CountryList.fromMap(res.data); @@ -97,14 +97,14 @@ class Locale extends Service { Future listCountriesEU() async { const String apiPath = '/locale/countries/eu'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.CountryList.fromMap(res.data); @@ -117,14 +117,14 @@ class Locale extends Service { Future listCountriesPhones() async { const String apiPath = '/locale/countries/phones'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.PhoneList.fromMap(res.data); @@ -138,14 +138,14 @@ class Locale extends Service { Future listCurrencies() async { const String apiPath = '/locale/currencies'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.CurrencyList.fromMap(res.data); @@ -158,14 +158,14 @@ class Locale extends Service { Future listLanguages() async { const String apiPath = '/locale/languages'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.LanguageList.fromMap(res.data); diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 6da80663..17072606 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -12,16 +12,16 @@ class Storage extends Service { Future listFiles({required String bucketId, List? queries, String? search}) async { final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.FileList.fromMap(res.data); @@ -50,7 +50,7 @@ class Storage extends Service { Future createFile({required String bucketId, required String fileId, required InputFile file, List? permissions, Function(UploadProgress)? onProgress}) async { final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - final Map params = { + final Map apiParams = { 'fileId': fileId, @@ -58,7 +58,7 @@ class Storage extends Service { 'permissions': permissions, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'multipart/form-data', }; @@ -67,10 +67,10 @@ class Storage extends Service { final paramName = 'file'; final res = await client.chunkedUpload( path: apiPath, - params: params, + params: apiParams, paramName: paramName, idParamName: idParamName, - headers: headers, + headers: apiHeaders, onProgress: onProgress, ); @@ -85,14 +85,14 @@ class Storage extends Service { Future getFile({required String bucketId, required String fileId}) async { final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.File.fromMap(res.data); @@ -105,16 +105,16 @@ class Storage extends Service { Future updateFile({required String bucketId, required String fileId, String? name, List? permissions}) async { final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - final Map params = { + final Map apiParams = { 'name': name, 'permissions': permissions, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.File.fromMap(res.data); @@ -127,14 +127,14 @@ class Storage extends Service { Future deleteFile({required String bucketId, required String fileId}) async { final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 06fa4eba..6a0d0f40 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -13,16 +13,16 @@ class Teams extends Service { Future list({List? queries, String? search}) async { const String apiPath = '/teams'; - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.TeamList.fromMap(res.data); @@ -36,17 +36,17 @@ class Teams extends Service { Future create({required String teamId, required String name, List? roles}) async { const String apiPath = '/teams'; - final Map params = { + final Map apiParams = { 'teamId': teamId, 'name': name, 'roles': roles, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); @@ -58,14 +58,14 @@ class Teams extends Service { Future get({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); @@ -77,15 +77,15 @@ class Teams extends Service { Future updateName({required String teamId, required String name}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { 'name': name, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); @@ -98,14 +98,14 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -118,16 +118,16 @@ class Teams extends Service { Future listMemberships({required String teamId, List? queries, String? search}) async { final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.MembershipList.fromMap(res.data); @@ -159,7 +159,7 @@ class Teams extends Service { Future createMembership({required String teamId, required List roles, required String url, String? email, String? userId, String? phone, String? name}) async { final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { 'email': email, 'userId': userId, 'phone': phone, @@ -168,11 +168,11 @@ class Teams extends Service { 'name': name, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); @@ -185,14 +185,14 @@ class Teams extends Service { Future getMembership({required String teamId, required String membershipId}) async { final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); @@ -207,15 +207,15 @@ class Teams extends Service { Future updateMembership({required String teamId, required String membershipId, required List roles}) async { final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - final Map params = { + final Map apiParams = { 'roles': roles, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); @@ -229,14 +229,14 @@ class Teams extends Service { Future deleteMembership({required String teamId, required String membershipId}) async { final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -254,16 +254,16 @@ class Teams extends Service { Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - final Map params = { + final Map apiParams = { 'userId': userId, 'secret': secret, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); @@ -277,14 +277,14 @@ class Teams extends Service { Future getPrefs({required String teamId}) async { final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); @@ -298,15 +298,15 @@ class Teams extends Service { Future updatePrefs({required String teamId, required Map prefs}) async { final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { 'prefs': prefs, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: apiPath, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 91a1b348..1fff3de6 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -43,7 +43,7 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '10.0.0', + 'x-sdk-version': '10.0.1', 'X-Appwrite-Response-Format': '1.4.0', }; @@ -150,18 +150,18 @@ class ClientBrowser extends ClientBase with ClientMixin { headers: headers, ); final int chunksUploaded = res.data['chunksUploaded'] as int; - offset = min(size, chunksUploaded * CHUNK_SIZE); + offset = chunksUploaded * CHUNK_SIZE; } on AppwriteException catch (_) {} } while (offset < size) { var chunk; - final end = min(offset + CHUNK_SIZE, size); + final end = min(offset + CHUNK_SIZE - 1, size - 1); chunk = file.bytes!.getRange(offset, end).toList(); params[paramName] = http.MultipartFile.fromBytes(paramName, chunk, filename: file.filename); headers['content-range'] = - 'bytes $offset-${min(((offset + CHUNK_SIZE) - 1), size)}/$size'; + 'bytes $offset-${min((offset + CHUNK_SIZE - 1), size - 1)}/$size'; res = await call(HttpMethod.post, path: path, headers: headers, params: params); offset += CHUNK_SIZE; @@ -170,8 +170,8 @@ class ClientBrowser extends ClientBase with ClientMixin { } final progress = UploadProgress( $id: res.data['\$id'] ?? '', - progress: min(offset - 1, size) / size * 100, - sizeUploaded: min(offset - 1, size), + progress: min(offset, size) / size * 100, + sizeUploaded: min(offset, size), chunksTotal: res.data['chunksTotal'] ?? 0, chunksUploaded: res.data['chunksUploaded'] ?? 0, ); diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index a5465cd5..10ae3ada 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -64,7 +64,7 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '10.0.0', + 'x-sdk-version': '10.0.1', 'X-Appwrite-Response-Format' : '1.4.0', }; @@ -270,7 +270,7 @@ class ClientIO extends ClientBase with ClientMixin { headers: headers, ); final int chunksUploaded = res.data['chunksUploaded'] as int; - offset = min(size, chunksUploaded * CHUNK_SIZE); + offset = chunksUploaded * CHUNK_SIZE; } on AppwriteException catch (_) {} } @@ -283,7 +283,7 @@ class ClientIO extends ClientBase with ClientMixin { while (offset < size) { List chunk = []; if (file.bytes != null) { - final end = min(offset + CHUNK_SIZE-1, size-1); + final end = min(offset + CHUNK_SIZE - 1, size - 1); chunk = file.bytes!.getRange(offset, end).toList(); } else { raf!.setPositionSync(offset); @@ -292,7 +292,7 @@ class ClientIO extends ClientBase with ClientMixin { params[paramName] = http.MultipartFile.fromBytes(paramName, chunk, filename: file.filename); headers['content-range'] = - 'bytes $offset-${min(((offset + CHUNK_SIZE) - 1), size)}/$size'; + 'bytes $offset-${min((offset + CHUNK_SIZE - 1), size - 1)}/$size'; res = await call(HttpMethod.post, path: path, headers: headers, params: params); offset += CHUNK_SIZE; @@ -301,8 +301,8 @@ class ClientIO extends ClientBase with ClientMixin { } final progress = UploadProgress( $id: res.data['\$id'] ?? '', - progress: min(offset - 1, size) / size * 100, - sizeUploaded: min(offset - 1, size), + progress: min(offset, size) / size * 100, + sizeUploaded: min(offset, size), chunksTotal: res.data['chunksTotal'] ?? 0, chunksUploaded: res.data['chunksUploaded'] ?? 0, ); diff --git a/pubspec.yaml b/pubspec.yaml index 0098f48b..b3e4f863 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 10.0.0 +version: 10.0.1 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/role_test.dart b/test/role_test.dart index e237ef88..3cc4ac80 100644 --- a/test/role_test.dart +++ b/test/role_test.dart @@ -49,4 +49,10 @@ void main() { expect(Role.member('custom'), 'member:custom'); }); }); + + group('label()', () { + test('returns label', () { + expect(Role.label('admin'), 'label:admin'); + }); + }); }