diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..d27a65b5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,16 @@ +name: Analyze and test + +on: pull_request + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dart-lang/setup-dart@v1 + - name: Install dependencies + run: dart pub get + - name: Analyze + run: dart analyze --no-fatal-warnings + - name: Test + run: dart test \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1972a122..9a0b94a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Change Log +## 17.0.0 + +* Support for Appwrite 1.8 +* Added TablesDB service +* Added new query types: + * `notContains` + * `notSearch` + * `notBetween` + * `notStartsWith` + * `notEndsWith` + * `createdBefore` + * `createdAfter` + * `updatedBefore` + * `updatedAfter` +* Deprecated `updateMagicURLSession` +* Deprecated `updatePhoneSession` +* Deprecated Databases service +> The TablesDB service is the new recommended way to work with databases. +> Existing databases/collections/attributes/documents can be managed using the TablesDB service. +> Existing Databases service will continue to work, but new features may only be added to the TablesDB service. + + ## 16.2.0 * Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service diff --git a/README.md b/README.md index b71f7cf8..958295f0 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ [![pub package](https://img.shields.io/pub/v/dart_appwrite.svg?style=flat-square)](https://pub.dartlang.org/packages/dart_appwrite) ![License](https://img.shields.io/github/license/appwrite/sdk-for-dart.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.x-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.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.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dart/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dart/releases).** > This is the Dart SDK for integrating with Appwrite from your Dart server-side code. If you're looking for the Flutter SDK you should check [appwrite/sdk-for-flutter](https://github.com/appwrite/sdk-for-flutter) @@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - dart_appwrite: ^16.2.0 + dart_appwrite: ^17.0.0 ``` You can install packages from the command line: @@ -39,38 +39,29 @@ dart pub add dart_appwrite Once you add the dependencies, its extremely easy to get started with the SDK; All you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example: ```dart -import 'package:dart_appwrite/dart_appwrite.dart'; - -void main() async { - Client client = Client() - .setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible - .setProject('5ff3379a01d25') // Your project ID - .setKey('cd868c7af8bdc893b4...93b7535db89') - .setSelfSigned(); // Use only on dev mode with a self-signed SSL cert - - Users users = Users(client); - - try { - final user = await users.create(userId: ID.unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); - print(user.toMap()); - } on AppwriteException catch(e) { - print(e.message); - } -} +Client client = Client() + .setProject('') + .setKey(''); + +Users users = Users(client); + +User user = await users.create( + userId: ID.unique(), + email: 'email@example.com', + phone: '+123456789', + password: 'password', + name: 'Walter O'Brien' +); ``` ### Error handling The Appwrite Dart SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example. ```dart -Users users = Users(client); - try { - final user = await users.create(userId: ID.unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); - print(user.toMap()); + User user = await users.create(...); } on AppwriteException catch(e) { - //show message to user or do other operation based on error as required - print(e.message); + // Handle the error } ``` diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 00000000..ea2c9e94 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1 @@ +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-jwt.md similarity index 100% rename from docs/examples/account/create-j-w-t.md rename to docs/examples/account/create-jwt.md diff --git a/docs/examples/account/create-magic-u-r-l-token.md b/docs/examples/account/create-magic-url-token.md similarity index 100% rename from docs/examples/account/create-magic-u-r-l-token.md rename to docs/examples/account/create-magic-url-token.md diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index 87797fa6..4dd2191f 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -7,6 +7,6 @@ Client client = Client() Account account = Account(client); -MfaType result = await account.createMfaAuthenticator( +MfaType result = await account.createMFAAuthenticator( type: AuthenticatorType.totp, ); diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index 62f3eaf2..5df3abad 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -6,6 +6,6 @@ Client client = Client() Account account = Account(client); -MfaChallenge result = await account.createMfaChallenge( +MfaChallenge result = await account.createMFAChallenge( factor: AuthenticationFactor.email, ); diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index 5ebe0e9e..1e8d4788 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -7,4 +7,4 @@ Client client = Client() Account account = Account(client); -MfaRecoveryCodes result = await account.createMfaRecoveryCodes(); +MfaRecoveryCodes result = await account.createMFARecoveryCodes(); diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth-2-token.md similarity index 100% rename from docs/examples/account/create-o-auth2token.md rename to docs/examples/account/create-o-auth-2-token.md diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index efd5263e..7f3f4ab1 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -7,6 +7,6 @@ Client client = Client() Account account = Account(client); -await account.deleteMfaAuthenticator( +await account.deleteMFAAuthenticator( type: AuthenticatorType.totp, ); diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index b073d402..5ff858fd 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -7,4 +7,4 @@ Client client = Client() Account account = Account(client); -MfaRecoveryCodes result = await account.getMfaRecoveryCodes(); +MfaRecoveryCodes result = await account.getMFARecoveryCodes(); diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index 32b269fb..083b51d6 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -7,4 +7,4 @@ Client client = Client() Account account = Account(client); -MfaFactors result = await account.listMfaFactors(); +MfaFactors result = await account.listMFAFactors(); diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-url-session.md similarity index 100% rename from docs/examples/account/update-magic-u-r-l-session.md rename to docs/examples/account/update-magic-url-session.md diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index 5a0f98f5..c475d30e 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -7,7 +7,7 @@ Client client = Client() Account account = Account(client); -User result = await account.updateMfaAuthenticator( +User result = await account.updateMFAAuthenticator( type: AuthenticatorType.totp, otp: '', ); diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index 749c4cd6..6cf3bb47 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -7,7 +7,7 @@ Client client = Client() Account account = Account(client); -Session result = await account.updateMfaChallenge( +Session result = await account.updateMFAChallenge( challengeId: '', otp: '', ); diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md index 7e274f0e..10fc77d2 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -7,4 +7,4 @@ Client client = Client() Account account = Account(client); -MfaRecoveryCodes result = await account.updateMfaRecoveryCodes(); +MfaRecoveryCodes result = await account.updateMFARecoveryCodes(); diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-mfa.md similarity index 100% rename from docs/examples/account/update-m-f-a.md rename to docs/examples/account/update-mfa.md diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-qr.md similarity index 100% rename from docs/examples/avatars/get-q-r.md rename to docs/examples/avatars/get-qr.md diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index c8ec38da..e4624487 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -3,7 +3,7 @@ import 'package:dart_appwrite/dart_appwrite.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject('') // Your project ID - .setKey(''); // Your secret API key + .setSession(''); // The user session to authenticate with Databases databases = Databases(client); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index 6e5134b0..a2d26226 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -3,7 +3,7 @@ import 'package:dart_appwrite/dart_appwrite.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject('') // Your project ID - .setKey(''); // Your secret API key + .setSession(''); // The user session to authenticate with Databases databases = Databases(client); diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 2ae64bce..64b28d5f 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -14,5 +14,5 @@ Execution result = await functions.createExecution( path: '', // (optional) method: ExecutionMethod.gET, // (optional) headers: {}, // (optional) - scheduledAt: '', // (optional) + scheduledAt: '', // (optional) ); diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-db.md similarity index 100% rename from docs/examples/health/get-d-b.md rename to docs/examples/health/get-db.md diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-eu.md similarity index 100% rename from docs/examples/locale/list-countries-e-u.md rename to docs/examples/locale/list-countries-eu.md diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md index 82c1eb5d..a4faf2da 100644 --- a/docs/examples/messaging/create-apns-provider.md +++ b/docs/examples/messaging/create-apns-provider.md @@ -7,7 +7,7 @@ Client client = Client() Messaging messaging = Messaging(client); -Provider result = await messaging.createApnsProvider( +Provider result = await messaging.createAPNSProvider( providerId: '', name: '', authKey: '', // (optional) diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md index 25c2cb8c..ce4f810d 100644 --- a/docs/examples/messaging/create-fcm-provider.md +++ b/docs/examples/messaging/create-fcm-provider.md @@ -7,7 +7,7 @@ Client client = Client() Messaging messaging = Messaging(client); -Provider result = await messaging.createFcmProvider( +Provider result = await messaging.createFCMProvider( providerId: '', name: '', serviceAccountJSON: {}, // (optional) diff --git a/docs/examples/messaging/create-msg91provider.md b/docs/examples/messaging/create-msg-91-provider.md similarity index 100% rename from docs/examples/messaging/create-msg91provider.md rename to docs/examples/messaging/create-msg-91-provider.md diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index 04a71587..ca90bc60 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -7,7 +7,7 @@ Client client = Client() Messaging messaging = Messaging(client); -Message result = await messaging.createSms( +Message result = await messaging.createSMS( messageId: '', content: '', topics: [], // (optional) diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md index 6201987f..644d30fa 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -7,7 +7,7 @@ Client client = Client() Messaging messaging = Messaging(client); -Provider result = await messaging.createSmtpProvider( +Provider result = await messaging.createSMTPProvider( providerId: '', name: '', host: '', diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md index edc0a1f7..7f3bc834 100644 --- a/docs/examples/messaging/update-apns-provider.md +++ b/docs/examples/messaging/update-apns-provider.md @@ -7,7 +7,7 @@ Client client = Client() Messaging messaging = Messaging(client); -Provider result = await messaging.updateApnsProvider( +Provider result = await messaging.updateAPNSProvider( providerId: '', name: '', // (optional) enabled: false, // (optional) diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md index 1e2d8a8c..65afba1f 100644 --- a/docs/examples/messaging/update-fcm-provider.md +++ b/docs/examples/messaging/update-fcm-provider.md @@ -7,7 +7,7 @@ Client client = Client() Messaging messaging = Messaging(client); -Provider result = await messaging.updateFcmProvider( +Provider result = await messaging.updateFCMProvider( providerId: '', name: '', // (optional) enabled: false, // (optional) diff --git a/docs/examples/messaging/update-msg91provider.md b/docs/examples/messaging/update-msg-91-provider.md similarity index 100% rename from docs/examples/messaging/update-msg91provider.md rename to docs/examples/messaging/update-msg-91-provider.md diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index f4356dee..26e6649b 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -7,7 +7,7 @@ Client client = Client() Messaging messaging = Messaging(client); -Message result = await messaging.updateSms( +Message result = await messaging.updateSMS( messageId: '', topics: [], // (optional) users: [], // (optional) diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md index 16530c01..911fa144 100644 --- a/docs/examples/messaging/update-smtp-provider.md +++ b/docs/examples/messaging/update-smtp-provider.md @@ -7,7 +7,7 @@ Client client = Client() Messaging messaging = Messaging(client); -Provider result = await messaging.updateSmtpProvider( +Provider result = await messaging.updateSMTPProvider( providerId: '', name: '', // (optional) host: '', // (optional) diff --git a/docs/examples/tablesdb/create-boolean-column.md b/docs/examples/tablesdb/create-boolean-column.md new file mode 100644 index 00000000..aa7b7c59 --- /dev/null +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnBoolean result = await tablesDB.createBooleanColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: false, // (optional) + array: false, // (optional) +); diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md new file mode 100644 index 00000000..10284ddf --- /dev/null +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnDatetime result = await tablesDB.createDatetimeColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: '', // (optional) + array: false, // (optional) +); diff --git a/docs/examples/tablesdb/create-email-column.md b/docs/examples/tablesdb/create-email-column.md new file mode 100644 index 00000000..ec36530e --- /dev/null +++ b/docs/examples/tablesdb/create-email-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnEmail result = await tablesDB.createEmailColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: 'email@example.com', // (optional) + array: false, // (optional) +); diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md new file mode 100644 index 00000000..594376d7 --- /dev/null +++ b/docs/examples/tablesdb/create-enum-column.md @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnEnum result = await tablesDB.createEnumColumn( + databaseId: '', + tableId: '', + key: '', + elements: [], + xrequired: false, + xdefault: '', // (optional) + array: false, // (optional) +); diff --git a/docs/examples/tablesdb/create-float-column.md b/docs/examples/tablesdb/create-float-column.md new file mode 100644 index 00000000..0b970737 --- /dev/null +++ b/docs/examples/tablesdb/create-float-column.md @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnFloat result = await tablesDB.createFloatColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + min: 0, // (optional) + max: 0, // (optional) + xdefault: 0, // (optional) + array: false, // (optional) +); diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md new file mode 100644 index 00000000..64fea757 --- /dev/null +++ b/docs/examples/tablesdb/create-index.md @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnIndex result = await tablesDB.createIndex( + databaseId: '', + tableId: '', + key: '', + type: IndexType.key, + columns: [], + orders: [], // (optional) + lengths: [], // (optional) +); diff --git a/docs/examples/tablesdb/create-integer-column.md b/docs/examples/tablesdb/create-integer-column.md new file mode 100644 index 00000000..d90dca56 --- /dev/null +++ b/docs/examples/tablesdb/create-integer-column.md @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnInteger result = await tablesDB.createIntegerColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + min: 0, // (optional) + max: 0, // (optional) + xdefault: 0, // (optional) + array: false, // (optional) +); diff --git a/docs/examples/tablesdb/create-ip-column.md b/docs/examples/tablesdb/create-ip-column.md new file mode 100644 index 00000000..322776e6 --- /dev/null +++ b/docs/examples/tablesdb/create-ip-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnIp result = await tablesDB.createIpColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: '', // (optional) + array: false, // (optional) +); diff --git a/docs/examples/tablesdb/create-relationship-column.md b/docs/examples/tablesdb/create-relationship-column.md new file mode 100644 index 00000000..3b2ea3d1 --- /dev/null +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnRelationship result = await tablesDB.createRelationshipColumn( + databaseId: '', + tableId: '', + relatedTableId: '', + type: RelationshipType.oneToOne, + twoWay: false, // (optional) + key: '', // (optional) + twoWayKey: '', // (optional) + onDelete: RelationMutate.cascade, // (optional) +); diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md new file mode 100644 index 00000000..15e4f8ea --- /dev/null +++ b/docs/examples/tablesdb/create-row.md @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +TablesDB tablesDB = TablesDB(client); + +Row result = await tablesDB.createRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, + permissions: ["read("any")"], // (optional) +); diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md new file mode 100644 index 00000000..c22fdba5 --- /dev/null +++ b/docs/examples/tablesdb/create-rows.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +RowList result = await tablesDB.createRows( + databaseId: '', + tableId: '', + rows: [], +); diff --git a/docs/examples/tablesdb/create-string-column.md b/docs/examples/tablesdb/create-string-column.md new file mode 100644 index 00000000..6fd0e93a --- /dev/null +++ b/docs/examples/tablesdb/create-string-column.md @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnString result = await tablesDB.createStringColumn( + databaseId: '', + tableId: '', + key: '', + size: 1, + xrequired: false, + xdefault: '', // (optional) + array: false, // (optional) + encrypt: false, // (optional) +); diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md new file mode 100644 index 00000000..c055e93f --- /dev/null +++ b/docs/examples/tablesdb/create-table.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +Table result = await tablesDB.createTable( + databaseId: '', + tableId: '', + name: '', + permissions: ["read("any")"], // (optional) + rowSecurity: false, // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/tablesdb/create-url-column.md b/docs/examples/tablesdb/create-url-column.md new file mode 100644 index 00000000..05c8da80 --- /dev/null +++ b/docs/examples/tablesdb/create-url-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnUrl result = await tablesDB.createUrlColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: 'https://example.com', // (optional) + array: false, // (optional) +); diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md new file mode 100644 index 00000000..6991b910 --- /dev/null +++ b/docs/examples/tablesdb/create.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +Database result = await tablesDB.create( + databaseId: '', + name: '', + enabled: false, // (optional) +); diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md new file mode 100644 index 00000000..8c376563 --- /dev/null +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +TablesDB tablesDB = TablesDB(client); + +Row result = await tablesDB.decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + value: 0, // (optional) + min: 0, // (optional) +); diff --git a/docs/examples/tablesdb/delete-column.md b/docs/examples/tablesdb/delete-column.md new file mode 100644 index 00000000..ebee29e4 --- /dev/null +++ b/docs/examples/tablesdb/delete-column.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +await tablesDB.deleteColumn( + databaseId: '', + tableId: '', + key: '', +); diff --git a/docs/examples/tablesdb/delete-index.md b/docs/examples/tablesdb/delete-index.md new file mode 100644 index 00000000..2b73e25f --- /dev/null +++ b/docs/examples/tablesdb/delete-index.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +await tablesDB.deleteIndex( + databaseId: '', + tableId: '', + key: '', +); diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md new file mode 100644 index 00000000..f3966c09 --- /dev/null +++ b/docs/examples/tablesdb/delete-row.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +TablesDB tablesDB = TablesDB(client); + +await tablesDB.deleteRow( + databaseId: '', + tableId: '', + rowId: '', +); diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md new file mode 100644 index 00000000..eb2aebb3 --- /dev/null +++ b/docs/examples/tablesdb/delete-rows.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +await tablesDB.deleteRows( + databaseId: '', + tableId: '', + queries: [], // (optional) +); diff --git a/docs/examples/tablesdb/delete-table.md b/docs/examples/tablesdb/delete-table.md new file mode 100644 index 00000000..d425cec1 --- /dev/null +++ b/docs/examples/tablesdb/delete-table.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +await tablesDB.deleteTable( + databaseId: '', + tableId: '', +); diff --git a/docs/examples/tablesdb/delete.md b/docs/examples/tablesdb/delete.md new file mode 100644 index 00000000..565f4ef6 --- /dev/null +++ b/docs/examples/tablesdb/delete.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +await tablesDB.delete( + databaseId: '', +); diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md new file mode 100644 index 00000000..437d72e6 --- /dev/null +++ b/docs/examples/tablesdb/get-column.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + + result = await tablesDB.getColumn( + databaseId: '', + tableId: '', + key: '', +); diff --git a/docs/examples/tablesdb/get-index.md b/docs/examples/tablesdb/get-index.md new file mode 100644 index 00000000..ef5f9a0e --- /dev/null +++ b/docs/examples/tablesdb/get-index.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnIndex result = await tablesDB.getIndex( + databaseId: '', + tableId: '', + key: '', +); diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md new file mode 100644 index 00000000..0af17b61 --- /dev/null +++ b/docs/examples/tablesdb/get-row.md @@ -0,0 +1,15 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +TablesDB tablesDB = TablesDB(client); + +Row result = await tablesDB.getRow( + databaseId: '', + tableId: '', + rowId: '', + queries: [], // (optional) +); diff --git a/docs/examples/tablesdb/get-table.md b/docs/examples/tablesdb/get-table.md new file mode 100644 index 00000000..c230f6a1 --- /dev/null +++ b/docs/examples/tablesdb/get-table.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +Table result = await tablesDB.getTable( + databaseId: '', + tableId: '', +); diff --git a/docs/examples/tablesdb/get.md b/docs/examples/tablesdb/get.md new file mode 100644 index 00000000..d147fb1c --- /dev/null +++ b/docs/examples/tablesdb/get.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +Database result = await tablesDB.get( + databaseId: '', +); diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md new file mode 100644 index 00000000..bbe262e5 --- /dev/null +++ b/docs/examples/tablesdb/increment-row-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +TablesDB tablesDB = TablesDB(client); + +Row result = await tablesDB.incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + value: 0, // (optional) + max: 0, // (optional) +); diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md new file mode 100644 index 00000000..2665c0db --- /dev/null +++ b/docs/examples/tablesdb/list-columns.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnList result = await tablesDB.listColumns( + databaseId: '', + tableId: '', + queries: [], // (optional) +); diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md new file mode 100644 index 00000000..5028923d --- /dev/null +++ b/docs/examples/tablesdb/list-indexes.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnIndexList result = await tablesDB.listIndexes( + databaseId: '', + tableId: '', + queries: [], // (optional) +); diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md new file mode 100644 index 00000000..83bbe38f --- /dev/null +++ b/docs/examples/tablesdb/list-rows.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +TablesDB tablesDB = TablesDB(client); + +RowList result = await tablesDB.listRows( + databaseId: '', + tableId: '', + queries: [], // (optional) +); diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md new file mode 100644 index 00000000..ede3f5cd --- /dev/null +++ b/docs/examples/tablesdb/list-tables.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +TableList result = await tablesDB.listTables( + databaseId: '', + queries: [], // (optional) + search: '', // (optional) +); diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md new file mode 100644 index 00000000..e13187de --- /dev/null +++ b/docs/examples/tablesdb/list.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +DatabaseList result = await tablesDB.list( + queries: [], // (optional) + search: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-boolean-column.md b/docs/examples/tablesdb/update-boolean-column.md new file mode 100644 index 00000000..1e6c604a --- /dev/null +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnBoolean result = await tablesDB.updateBooleanColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: false, + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md new file mode 100644 index 00000000..982d8d55 --- /dev/null +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnDatetime result = await tablesDB.updateDatetimeColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: '', + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-email-column.md b/docs/examples/tablesdb/update-email-column.md new file mode 100644 index 00000000..e2f07519 --- /dev/null +++ b/docs/examples/tablesdb/update-email-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnEmail result = await tablesDB.updateEmailColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: 'email@example.com', + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md new file mode 100644 index 00000000..b0ddd485 --- /dev/null +++ b/docs/examples/tablesdb/update-enum-column.md @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnEnum result = await tablesDB.updateEnumColumn( + databaseId: '', + tableId: '', + key: '', + elements: [], + xrequired: false, + xdefault: '', + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-float-column.md b/docs/examples/tablesdb/update-float-column.md new file mode 100644 index 00000000..7239b488 --- /dev/null +++ b/docs/examples/tablesdb/update-float-column.md @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnFloat result = await tablesDB.updateFloatColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: 0, + min: 0, // (optional) + max: 0, // (optional) + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-integer-column.md b/docs/examples/tablesdb/update-integer-column.md new file mode 100644 index 00000000..bb98ad27 --- /dev/null +++ b/docs/examples/tablesdb/update-integer-column.md @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnInteger result = await tablesDB.updateIntegerColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: 0, + min: 0, // (optional) + max: 0, // (optional) + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-ip-column.md b/docs/examples/tablesdb/update-ip-column.md new file mode 100644 index 00000000..21c5f1bc --- /dev/null +++ b/docs/examples/tablesdb/update-ip-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnIp result = await tablesDB.updateIpColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: '', + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-relationship-column.md b/docs/examples/tablesdb/update-relationship-column.md new file mode 100644 index 00000000..95e09d38 --- /dev/null +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnRelationship result = await tablesDB.updateRelationshipColumn( + databaseId: '', + tableId: '', + key: '', + onDelete: RelationMutate.cascade, // (optional) + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md new file mode 100644 index 00000000..d66c24f5 --- /dev/null +++ b/docs/examples/tablesdb/update-row.md @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +TablesDB tablesDB = TablesDB(client); + +Row result = await tablesDB.updateRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, // (optional) + permissions: ["read("any")"], // (optional) +); diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md new file mode 100644 index 00000000..a0973b47 --- /dev/null +++ b/docs/examples/tablesdb/update-rows.md @@ -0,0 +1,15 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +RowList result = await tablesDB.updateRows( + databaseId: '', + tableId: '', + data: {}, // (optional) + queries: [], // (optional) +); diff --git a/docs/examples/tablesdb/update-string-column.md b/docs/examples/tablesdb/update-string-column.md new file mode 100644 index 00000000..bd390dfd --- /dev/null +++ b/docs/examples/tablesdb/update-string-column.md @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnString result = await tablesDB.updateStringColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: '', + size: 1, // (optional) + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md new file mode 100644 index 00000000..fd6646a0 --- /dev/null +++ b/docs/examples/tablesdb/update-table.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +Table result = await tablesDB.updateTable( + databaseId: '', + tableId: '', + name: '', + permissions: ["read("any")"], // (optional) + rowSecurity: false, // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/tablesdb/update-url-column.md b/docs/examples/tablesdb/update-url-column.md new file mode 100644 index 00000000..fcfdfcd1 --- /dev/null +++ b/docs/examples/tablesdb/update-url-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnUrl result = await tablesDB.updateUrlColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: 'https://example.com', + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md new file mode 100644 index 00000000..81d33799 --- /dev/null +++ b/docs/examples/tablesdb/update.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +Database result = await tablesDB.update( + databaseId: '', + name: '', + enabled: false, // (optional) +); diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md new file mode 100644 index 00000000..fbe4d292 --- /dev/null +++ b/docs/examples/tablesdb/upsert-row.md @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +TablesDB tablesDB = TablesDB(client); + +Row result = await tablesDB.upsertRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, // (optional) + permissions: ["read("any")"], // (optional) +); diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md new file mode 100644 index 00000000..031aa50b --- /dev/null +++ b/docs/examples/tablesdb/upsert-rows.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +RowList result = await tablesDB.upsertRows( + databaseId: '', + tableId: '', + rows: [], +); diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon-2-user.md similarity index 100% rename from docs/examples/users/create-argon2user.md rename to docs/examples/users/create-argon-2-user.md diff --git a/docs/examples/users/create-j-w-t.md b/docs/examples/users/create-jwt.md similarity index 100% rename from docs/examples/users/create-j-w-t.md rename to docs/examples/users/create-jwt.md diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-md-5-user.md similarity index 100% rename from docs/examples/users/create-m-d5user.md rename to docs/examples/users/create-md-5-user.md diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md index c2b9562e..12a7e32f 100644 --- a/docs/examples/users/create-mfa-recovery-codes.md +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -7,6 +7,6 @@ Client client = Client() Users users = Users(client); -MfaRecoveryCodes result = await users.createMfaRecoveryCodes( +MfaRecoveryCodes result = await users.createMFARecoveryCodes( userId: '', ); diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-ph-pass-user.md similarity index 100% rename from docs/examples/users/create-p-h-pass-user.md rename to docs/examples/users/create-ph-pass-user.md diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-sha-user.md similarity index 100% rename from docs/examples/users/create-s-h-a-user.md rename to docs/examples/users/create-sha-user.md diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md index eed7dbd4..b5dcc6af 100644 --- a/docs/examples/users/delete-mfa-authenticator.md +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -7,7 +7,7 @@ Client client = Client() Users users = Users(client); -await users.deleteMfaAuthenticator( +await users.deleteMFAAuthenticator( userId: '', type: AuthenticatorType.totp, ); diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md index cf66c676..e16158bf 100644 --- a/docs/examples/users/get-mfa-recovery-codes.md +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -7,6 +7,6 @@ Client client = Client() Users users = Users(client); -MfaRecoveryCodes result = await users.getMfaRecoveryCodes( +MfaRecoveryCodes result = await users.getMFARecoveryCodes( userId: '', ); diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md index 7134ee5d..290109d2 100644 --- a/docs/examples/users/list-mfa-factors.md +++ b/docs/examples/users/list-mfa-factors.md @@ -7,6 +7,6 @@ Client client = Client() Users users = Users(client); -MfaFactors result = await users.listMfaFactors( +MfaFactors result = await users.listMFAFactors( userId: '', ); diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md index 3b7d81f5..a2340ff8 100644 --- a/docs/examples/users/update-mfa-recovery-codes.md +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -7,6 +7,6 @@ Client client = Client() Users users = Users(client); -MfaRecoveryCodes result = await users.updateMfaRecoveryCodes( +MfaRecoveryCodes result = await users.updateMFARecoveryCodes( userId: '', ); diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md index f26b1055..7d3b71d9 100644 --- a/docs/examples/users/update-mfa.md +++ b/docs/examples/users/update-mfa.md @@ -7,7 +7,7 @@ Client client = Client() Users users = Users(client); -User result = await users.updateMfa( +User result = await users.updateMFA( userId: '', mfa: false, ); diff --git a/example/README.md b/example/README.md index fc2c6d09..6de05748 100644 --- a/example/README.md +++ b/example/README.md @@ -1,3 +1,4 @@ +@@ -1,62 +0,0 @@ # Examples Init your Appwrite client: @@ -6,10 +7,8 @@ Init your Appwrite client: Client client = Client(); client - .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint - .setProject('5e8cf4f46b5e8') // Your project ID - .setSelfSigned() // Remove in production -; + .setProject('') + .setKey(''); ``` Create a new user: @@ -18,21 +17,21 @@ Create a new user: Users users = Users(client); User result = await users.create( - userId: ID.unique(), - email: "email@example.com", - phone: "+123456789", - password: "password", - name: "Walter O'Brien" + userId: ID.unique(), + email: "email@example.com", + phone: "+123456789", + password: "password", + name: "Walter O'Brien" ); ``` -Fetch user profile: +Get user: ```dart Users users = Users(client); -User profile = await users.get( - userId: '[USER_ID]', +User user = await users.get( + userId: '[USER_ID]', ); ``` @@ -41,22 +40,19 @@ Upload File: ```dart Storage storage = Storage(client); -InputFile file = InputFile(path: './path-to-file/image.jpg', filename: 'image.jpg'); - -storage.createFile( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', // use 'unique()' to automatically generate a unique ID - file: file, - permissions: [ - Permission.read(Role.any()), - ], -) -.then((response) { - print(response); // File uploaded! -}) -.catchError((error) { - print(error.response); -}); +InputFile input = InputFile( + path: './path-to-file/image.jpg', + filename: 'image.jpg', +); + +File file = await storage.createFile( + bucketId: '', + fileId: ID.unique(), + file: input, + permissions: [ + Permission.read(Role.any()), + ], +); ``` All examples and API features are available at the [official Appwrite docs](https://appwrite.io/docs) diff --git a/lib/dart_appwrite.dart b/lib/dart_appwrite.dart index 0848a050..72488b83 100644 --- a/lib/dart_appwrite.dart +++ b/lib/dart_appwrite.dart @@ -1,6 +1,6 @@ /// Appwrite Dart SDK /// -/// This SDK is compatible with Appwrite server version 1.7.x. +/// This SDK is compatible with Appwrite server version 1.8.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-dart/releases). library dart_appwrite; @@ -37,6 +37,7 @@ part 'services/locale.dart'; part 'services/messaging.dart'; part 'services/sites.dart'; part 'services/storage.dart'; +part 'services/tables_db.dart'; part 'services/teams.dart'; part 'services/tokens.dart'; part 'services/users.dart'; diff --git a/lib/models.dart b/lib/models.dart index 59b862d5..71b1a2fd 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -2,10 +2,13 @@ library dart_appwrite.models; part 'src/models/model.dart'; +part 'src/models/row_list.dart'; part 'src/models/document_list.dart'; +part 'src/models/table_list.dart'; part 'src/models/collection_list.dart'; part 'src/models/database_list.dart'; part 'src/models/index_list.dart'; +part 'src/models/column_index_list.dart'; part 'src/models/user_list.dart'; part 'src/models/session_list.dart'; part 'src/models/identity_list.dart'; @@ -47,7 +50,21 @@ part 'src/models/attribute_ip.dart'; part 'src/models/attribute_url.dart'; part 'src/models/attribute_datetime.dart'; part 'src/models/attribute_relationship.dart'; +part 'src/models/table.dart'; +part 'src/models/column_list.dart'; +part 'src/models/column_string.dart'; +part 'src/models/column_integer.dart'; +part 'src/models/column_float.dart'; +part 'src/models/column_boolean.dart'; +part 'src/models/column_email.dart'; +part 'src/models/column_enum.dart'; +part 'src/models/column_ip.dart'; +part 'src/models/column_url.dart'; +part 'src/models/column_datetime.dart'; +part 'src/models/column_relationship.dart'; part 'src/models/index.dart'; +part 'src/models/column_index.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/query.dart b/lib/query.dart index cfc08c05..c9a2fc91 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -82,6 +82,43 @@ class Query { static String contains(String attribute, dynamic value) => Query._('contains', attribute, value).toString(); + /// Filter resources where [attribute] does not contain [value] + /// [value] can be a single value or a list. + static String notContains(String attribute, dynamic value) => + Query._('notContains', attribute, value).toString(); + + /// Filter resources by searching [attribute] for [value] (inverse of search). + static String notSearch(String attribute, String value) => + Query._('notSearch', attribute, value).toString(); + + /// Filter resources where [attribute] is not between [start] and [end] (exclusive). + static String notBetween(String attribute, dynamic start, dynamic end) => + Query._('notBetween', attribute, [start, end]).toString(); + + /// Filter resources where [attribute] does not start with [value]. + static String notStartsWith(String attribute, String value) => + Query._('notStartsWith', attribute, value).toString(); + + /// Filter resources where [attribute] does not end with [value]. + static String notEndsWith(String attribute, String value) => + Query._('notEndsWith', attribute, value).toString(); + + /// Filter resources where document was created before [value]. + static String createdBefore(String value) => + Query._('createdBefore', null, value).toString(); + + /// Filter resources where document was created after [value]. + static String createdAfter(String value) => + Query._('createdAfter', null, value).toString(); + + /// Filter resources where document was updated before [value]. + static String updatedBefore(String value) => + Query._('updatedBefore', null, value).toString(); + + /// Filter resources where document was updated after [value]. + static String updatedAfter(String value) => + Query._('updatedAfter', null, value).toString(); + static String or(List queries) => Query._( 'or', null, diff --git a/lib/services/account.dart b/lib/services/account.dart index 90e1f03e..d0c820a1 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -189,6 +189,9 @@ class Account extends Service { /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.', + ) Future createMfaAuthenticator({ required enums.AuthenticatorType type, }) async { @@ -211,9 +214,38 @@ class Account extends Service { return models.MfaType.fromMap(res.data); } + /// Add an authenticator app to be used as an MFA factor. Verify the + /// authenticator using the [verify + /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) + /// method. + Future createMFAAuthenticator({ + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaType.fromMap(res.data); + } + /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.', + ) Future updateMfaAuthenticator({ required enums.AuthenticatorType type, required String otp, @@ -237,7 +269,36 @@ class Account extends Service { return models.User.fromMap(res.data); } + /// Verify an authenticator app after adding it using the [add + /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) + /// method. + Future updateMFAAuthenticator({ + required enums.AuthenticatorType type, + required String otp, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {'otp': otp}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.User.fromMap(res.data); + } + /// Delete an authenticator for a user by ID. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.', + ) Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async { final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( '{type}', @@ -258,9 +319,33 @@ class Account extends Service { return res.data; } + /// Delete an authenticator for a user by ID. + Future deleteMFAAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + 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; + } + /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.', + ) Future createMfaChallenge({ required enums.AuthenticationFactor factor, }) async { @@ -280,11 +365,36 @@ class Account extends Service { return models.MfaChallenge.fromMap(res.data); } + /// Begin the process of MFA verification after sign-in. Finish the flow with + /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) + /// method. + Future createMFAChallenge({ + required enums.AuthenticationFactor factor, + }) async { + final String apiPath = '/account/mfa/challenge'; + + final Map apiParams = {'factor': factor.value}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaChallenge.fromMap(res.data); + } + /// Complete the MFA challenge by providing the one-time password. Finish the /// process of MFA verification by providing the one-time password. To begin /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.', + ) Future updateMfaChallenge({ required String challengeId, required String otp, @@ -308,7 +418,38 @@ class Account extends Service { return models.Session.fromMap(res.data); } + /// Complete the MFA challenge by providing the one-time password. Finish the + /// process of MFA verification by providing the one-time password. To begin + /// the flow, use + /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + /// method. + Future updateMFAChallenge({ + required String challengeId, + required String otp, + }) async { + final String apiPath = '/account/mfa/challenge'; + + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Session.fromMap(res.data); + } + /// List the factors available on the account to be used as a MFA challange. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.', + ) Future listMfaFactors() async { final String apiPath = '/account/mfa/factors'; @@ -326,10 +467,31 @@ class Account extends Service { return models.MfaFactors.fromMap(res.data); } + /// List the factors available on the account to be used as a MFA challange. + Future listMFAFactors() async { + final String apiPath = '/account/mfa/factors'; + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaFactors.fromMap(res.data); + } + /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to read recovery codes. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.', + ) Future getMfaRecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; @@ -347,11 +509,35 @@ class Account extends Service { return models.MfaRecoveryCodes.fromMap(res.data); } + /// Get recovery codes that can be used as backup for MFA flow. Before getting + /// codes, they must be generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. An OTP challenge is required to read recovery codes. + Future getMFARecoveryCodes() async { + final String apiPath = '/account/mfa/recovery-codes'; + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaRecoveryCodes.fromMap(res.data); + } + /// Generate recovery codes as backup for MFA flow. It's recommended to /// generate and show then immediately after user successfully adds their /// authehticator. Recovery codes can be used as a MFA verification type in /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.', + ) Future createMfaRecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; @@ -369,10 +555,35 @@ class Account extends Service { return models.MfaRecoveryCodes.fromMap(res.data); } + /// Generate recovery codes as backup for MFA flow. It's recommended to + /// generate and show then immediately after user successfully adds their + /// authehticator. Recovery codes can be used as a MFA verification type in + /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + /// method. + Future createMFARecoveryCodes() async { + final String apiPath = '/account/mfa/recovery-codes'; + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaRecoveryCodes.fromMap(res.data); + } + /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to regenreate recovery codes. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.', + ) Future updateMfaRecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; @@ -390,6 +601,27 @@ class Account extends Service { return models.MfaRecoveryCodes.fromMap(res.data); } + /// Regenerate recovery codes that can be used as backup for MFA flow. Before + /// regenerating codes, they must be first generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. An OTP challenge is required to regenreate recovery codes. + Future updateMFARecoveryCodes() async { + final String apiPath = '/account/mfa/recovery-codes'; + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaRecoveryCodes.fromMap(res.data); + } + /// Update currently logged in user account name. Future updateName({required String name}) async { final String apiPath = '/account/name'; @@ -657,6 +889,7 @@ 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, @@ -680,6 +913,7 @@ 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, @@ -814,8 +1048,11 @@ class Account extends Service { } /// Sends the user an email with a secret key for creating a session. If the - /// provided user ID has not be registered, a new user will be created. Use the - /// returned user ID and secret and submit a request to the [POST + /// email address has never been used, a **new account is created** using the + /// provided `userId`. Otherwise, if the email address is already attached to + /// an account, the **user ID is ignored**. Then, the user will receive an + /// email with the one-time password. Use the returned user ID and secret and + /// submit a request to the [POST /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. @@ -823,6 +1060,7 @@ class Account extends Service { /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). + /// Future createEmailToken({ required String userId, required String email, diff --git a/lib/services/databases.dart b/lib/services/databases.dart index aad77bf2..223f1318 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -7,6 +7,9 @@ class Databases extends Service { /// Get a list of all databases from the current Appwrite project. You can use /// the search parameter to filter your results. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.list` instead.', + ) Future list({ List? queries, String? search, @@ -32,6 +35,9 @@ class Databases extends Service { /// Create a new Database. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createDatabase` instead.', + ) Future create({ required String databaseId, required String name, @@ -59,6 +65,9 @@ class Databases extends Service { /// Get a database by its unique ID. This endpoint response returns a JSON /// object with the database metadata. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.get` instead.', + ) Future get({required String databaseId}) async { final String apiPath = '/databases/{databaseId}'.replaceAll( '{databaseId}', @@ -80,6 +89,9 @@ class Databases extends Service { } /// Update a database by its unique ID. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.update` instead.', + ) Future update({ required String databaseId, required String name, @@ -106,6 +118,9 @@ class Databases extends Service { /// Delete a database by its unique ID. Only API keys with with databases.write /// scope can delete a database. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.delete` instead.', + ) Future delete({required String databaseId}) async { final String apiPath = '/databases/{databaseId}'.replaceAll( '{databaseId}', @@ -128,6 +143,9 @@ class Databases extends Service { /// Get a list of all collections that belong to the provided databaseId. You /// can use the search parameter to filter your results. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listTables` instead.', + ) Future listCollections({ required String databaseId, List? queries, @@ -159,6 +177,9 @@ class Databases extends Service { /// database 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 `TablesDB.createTable` instead.', + ) Future createCollection({ required String databaseId, required String collectionId, @@ -194,6 +215,9 @@ class Databases extends Service { /// Get a collection by its unique ID. This endpoint response returns a JSON /// object with the collection metadata. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getTable` instead.', + ) Future getCollection({ required String databaseId, required String collectionId, @@ -217,6 +241,9 @@ class Databases extends Service { } /// Update a collection by its unique ID. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTable` instead.', + ) Future updateCollection({ required String databaseId, required String collectionId, @@ -250,6 +277,9 @@ class Databases extends Service { /// Delete a collection by its unique ID. Only users with write permissions /// have access to delete this resource. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTable` instead.', + ) Future deleteCollection({ required String databaseId, required String collectionId, @@ -273,6 +303,9 @@ class Databases extends Service { } /// List attributes in the collection. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listColumns` instead.', + ) Future listAttributes({ required String databaseId, required String collectionId, @@ -299,6 +332,9 @@ class Databases extends Service { /// Create a boolean attribute. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createBooleanColumn` instead.', + ) Future createBooleanAttribute({ required String databaseId, required String collectionId, @@ -333,6 +369,9 @@ class Databases extends Service { /// Update a boolean attribute. Changing the `default` value will not update /// already existing documents. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead.', + ) Future updateBooleanAttribute({ required String databaseId, required String collectionId, @@ -366,6 +405,9 @@ class Databases extends Service { } /// Create a date time attribute according to the ISO 8601 standard. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createDatetimeColumn` instead.', + ) Future createDatetimeAttribute({ required String databaseId, required String collectionId, @@ -400,6 +442,9 @@ class Databases extends Service { /// Update a date time attribute. Changing the `default` value will not update /// already existing documents. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead.', + ) Future updateDatetimeAttribute({ required String databaseId, required String collectionId, @@ -434,6 +479,9 @@ class Databases extends Service { /// Create an email attribute. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createEmailColumn` instead.', + ) Future createEmailAttribute({ required String databaseId, required String collectionId, @@ -469,6 +517,9 @@ class Databases extends Service { /// Update an email attribute. Changing the `default` value will not update /// already existing documents. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead.', + ) Future updateEmailAttribute({ required String databaseId, required String collectionId, @@ -501,9 +552,12 @@ class Databases extends Service { return models.AttributeEmail.fromMap(res.data); } - /// Create an enumeration attribute. The `elements` param acts as a white-list - /// of accepted values for this attribute. + /// Create an enum attribute. The `elements` param acts as a white-list of + /// accepted values for this attribute. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createEnumColumn` instead.', + ) Future createEnumAttribute({ required String databaseId, required String collectionId, @@ -541,6 +595,9 @@ class Databases extends Service { /// Update an enum attribute. Changing the `default` value will not update /// already existing documents. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead.', + ) Future updateEnumAttribute({ required String databaseId, required String collectionId, @@ -578,6 +635,9 @@ class Databases extends Service { /// Create a float attribute. Optionally, minimum and maximum values can be /// provided. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createFloatColumn` instead.', + ) Future createFloatAttribute({ required String databaseId, required String collectionId, @@ -617,6 +677,9 @@ class Databases extends Service { /// Update a float attribute. Changing the `default` value will not update /// already existing documents. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead.', + ) Future updateFloatAttribute({ required String databaseId, required String collectionId, @@ -656,6 +719,9 @@ class Databases extends Service { /// Create an integer attribute. Optionally, minimum and maximum values can be /// provided. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createIntegerColumn` instead.', + ) Future createIntegerAttribute({ required String databaseId, required String collectionId, @@ -695,6 +761,9 @@ class Databases extends Service { /// Update an integer attribute. Changing the `default` value will not update /// already existing documents. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead.', + ) Future updateIntegerAttribute({ required String databaseId, required String collectionId, @@ -733,6 +802,9 @@ class Databases extends Service { /// Create IP address attribute. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createIpColumn` instead.', + ) Future createIpAttribute({ required String databaseId, required String collectionId, @@ -768,6 +840,9 @@ class Databases extends Service { /// Update an ip attribute. Changing the `default` value will not update /// already existing documents. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead.', + ) Future updateIpAttribute({ required String databaseId, required String collectionId, @@ -803,6 +878,9 @@ class Databases extends Service { /// Create relationship attribute. [Learn more about relationship /// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createRelationshipColumn` instead.', + ) Future createRelationshipAttribute({ required String databaseId, required String collectionId, @@ -841,6 +919,9 @@ class Databases extends Service { /// Create a string attribute. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createStringColumn` instead.', + ) Future createStringAttribute({ required String databaseId, required String collectionId, @@ -880,6 +961,9 @@ class Databases extends Service { /// Update a string attribute. Changing the `default` value will not update /// already existing documents. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead.', + ) Future updateStringAttribute({ required String databaseId, required String collectionId, @@ -916,6 +1000,9 @@ class Databases extends Service { /// Create a URL attribute. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createUrlColumn` instead.', + ) Future createUrlAttribute({ required String databaseId, required String collectionId, @@ -951,6 +1038,9 @@ class Databases extends Service { /// Update an url attribute. Changing the `default` value will not update /// already existing documents. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead.', + ) Future updateUrlAttribute({ required String databaseId, required String collectionId, @@ -984,6 +1074,9 @@ class Databases extends Service { } /// Get attribute by ID. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getColumn` instead.', + ) Future getAttribute({ required String databaseId, required String collectionId, @@ -1010,6 +1103,9 @@ class Databases extends Service { } /// Deletes an attribute. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteColumn` instead.', + ) Future deleteAttribute({ required String databaseId, required String collectionId, @@ -1038,6 +1134,9 @@ class Databases extends Service { /// Update relationship attribute. [Learn more about relationship /// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead.', + ) Future updateRelationshipAttribute({ required String databaseId, required String collectionId, @@ -1070,6 +1169,9 @@ 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 `TablesDB.listRows` instead.', + ) Future listDocuments({ required String databaseId, required String collectionId, @@ -1098,6 +1200,9 @@ 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 `TablesDB.createRow` instead.', + ) Future createDocument({ required String databaseId, required String collectionId, @@ -1128,14 +1233,13 @@ class Databases extends Service { return models.Document.fromMap(res.data); } - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Create new Documents. Before using this route, you should create a 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 `TablesDB.createRows` instead.', + ) Future createDocuments({ required String databaseId, required String collectionId, @@ -1160,15 +1264,14 @@ class Databases extends Service { return models.DocumentList.fromMap(res.data); } - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Create or update Documents. Before using this route, you should create a /// 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 `TablesDB.upsertRows` instead.', + ) Future upsertDocuments({ required String databaseId, required String collectionId, @@ -1193,13 +1296,12 @@ class Databases extends Service { return models.DocumentList.fromMap(res.data); } - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Update all documents that match your queries, if no queries are submitted /// then all documents are updated. You can pass only specific fields to be /// updated. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead.', + ) Future updateDocuments({ required String databaseId, required String collectionId, @@ -1225,12 +1327,11 @@ class Databases extends Service { return models.DocumentList.fromMap(res.data); } - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Bulk delete documents using queries, if no queries are passed then all /// documents are deleted. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRows` instead.', + ) Future deleteDocuments({ required String databaseId, required String collectionId, @@ -1257,6 +1358,9 @@ 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 `TablesDB.getRow` instead.', + ) Future getDocument({ required String databaseId, required String collectionId, @@ -1283,14 +1387,13 @@ class Databases extends Service { return models.Document.fromMap(res.data); } - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Create or update a Document. Before using this route, you should create a /// 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 `TablesDB.upsertRow` instead.', + ) Future upsertDocument({ required String databaseId, required String collectionId, @@ -1323,6 +1426,9 @@ 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 `TablesDB.updateRow` instead.', + ) Future updateDocument({ required String databaseId, required String collectionId, @@ -1354,6 +1460,9 @@ class Databases extends Service { } /// Delete a document by its unique ID. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.', + ) Future deleteDocument({ required String databaseId, required String collectionId, @@ -1380,6 +1489,9 @@ class Databases extends Service { } /// Decrement a specific attribute of a document by a given value. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.', + ) Future decrementDocumentAttribute({ required String databaseId, required String collectionId, @@ -1410,6 +1522,9 @@ class Databases extends Service { } /// Increment a specific attribute of a document by a given value. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.', + ) Future incrementDocumentAttribute({ required String databaseId, required String collectionId, @@ -1440,6 +1555,9 @@ class Databases extends Service { } /// List indexes in the collection. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listIndexes` instead.', + ) Future listIndexes({ required String databaseId, required String collectionId, @@ -1467,6 +1585,9 @@ class Databases extends Service { /// Creates an index on the attributes listed. Your index should include all /// the attributes you will query in a single request. /// Attributes can be `key`, `fulltext`, and `unique`. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createIndex` instead.', + ) Future createIndex({ required String databaseId, required String collectionId, @@ -1502,6 +1623,9 @@ class Databases extends Service { } /// Get index by ID. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getIndex` instead.', + ) Future getIndex({ required String databaseId, required String collectionId, @@ -1528,6 +1652,9 @@ class Databases extends Service { } /// Delete an index. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteIndex` instead.', + ) Future deleteIndex({ required String databaseId, required String collectionId, diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index afe3ee86..bf5376e5 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -244,6 +244,9 @@ class Messaging extends Service { } /// Create a new SMS message. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead.', + ) Future createSms({ required String messageId, required String content, @@ -277,10 +280,47 @@ class Messaging extends Service { return models.Message.fromMap(res.data); } + /// Create a new SMS message. + Future createSMS({ + required String messageId, + required String content, + List? topics, + List? users, + List? targets, + bool? draft, + String? scheduledAt, + }) async { + final String apiPath = '/messaging/messages/sms'; + + final Map apiParams = { + 'messageId': messageId, + 'content': content, + 'topics': topics, + 'users': users, + 'targets': targets, + 'draft': draft, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Message.fromMap(res.data); + } + /// Update an SMS message by its unique ID. This endpoint only works on /// messages that are in draft status. Messages that are already processing, /// sent, or failed cannot be updated. /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead.', + ) Future updateSms({ required String messageId, List? topics, @@ -316,6 +356,45 @@ class Messaging extends Service { return models.Message.fromMap(res.data); } + /// Update an SMS message by its unique ID. This endpoint only works on + /// messages that are in draft status. Messages that are already processing, + /// sent, or failed cannot be updated. + /// + Future updateSMS({ + required String messageId, + List? topics, + List? users, + List? targets, + String? content, + bool? draft, + String? scheduledAt, + }) async { + final String apiPath = '/messaging/messages/sms/{messageId}'.replaceAll( + '{messageId}', + messageId, + ); + + final Map apiParams = { + 'topics': topics, + 'users': users, + 'targets': targets, + 'content': content, + 'draft': draft, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Message.fromMap(res.data); + } + /// Get a message by its unique ID. /// Future getMessage({required String messageId}) async { @@ -433,6 +512,9 @@ class Messaging extends Service { } /// Create a new Apple Push Notification service provider. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead.', + ) Future createApnsProvider({ required String providerId, required String name, @@ -468,7 +550,46 @@ class Messaging extends Service { return models.Provider.fromMap(res.data); } + /// Create a new Apple Push Notification service provider. + Future createAPNSProvider({ + required String providerId, + required String name, + String? authKey, + String? authKeyId, + String? teamId, + String? bundleId, + bool? sandbox, + bool? enabled, + }) async { + final String apiPath = '/messaging/providers/apns'; + + final Map apiParams = { + 'providerId': providerId, + 'name': name, + 'authKey': authKey, + 'authKeyId': authKeyId, + 'teamId': teamId, + 'bundleId': bundleId, + 'sandbox': sandbox, + 'enabled': enabled, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Provider.fromMap(res.data); + } + /// Update a Apple Push Notification service provider by its unique ID. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead.', + ) Future updateApnsProvider({ required String providerId, String? name, @@ -506,7 +627,48 @@ class Messaging extends Service { return models.Provider.fromMap(res.data); } + /// Update a Apple Push Notification service provider by its unique ID. + Future updateAPNSProvider({ + required String providerId, + String? name, + bool? enabled, + String? authKey, + String? authKeyId, + String? teamId, + String? bundleId, + bool? sandbox, + }) async { + final String apiPath = '/messaging/providers/apns/{providerId}'.replaceAll( + '{providerId}', + providerId, + ); + + final Map apiParams = { + 'name': name, + 'enabled': enabled, + 'authKey': authKey, + 'authKeyId': authKeyId, + 'teamId': teamId, + 'bundleId': bundleId, + 'sandbox': sandbox, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Provider.fromMap(res.data); + } + /// Create a new Firebase Cloud Messaging provider. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead.', + ) Future createFcmProvider({ required String providerId, required String name, @@ -534,7 +696,38 @@ class Messaging extends Service { return models.Provider.fromMap(res.data); } + /// Create a new Firebase Cloud Messaging provider. + Future createFCMProvider({ + required String providerId, + required String name, + Map? serviceAccountJSON, + bool? enabled, + }) async { + final String apiPath = '/messaging/providers/fcm'; + + final Map apiParams = { + 'providerId': providerId, + 'name': name, + 'serviceAccountJSON': serviceAccountJSON, + 'enabled': enabled, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Provider.fromMap(res.data); + } + /// Update a Firebase Cloud Messaging provider by its unique ID. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead.', + ) Future updateFcmProvider({ required String providerId, String? name, @@ -564,6 +757,36 @@ class Messaging extends Service { return models.Provider.fromMap(res.data); } + /// Update a Firebase Cloud Messaging provider by its unique ID. + Future updateFCMProvider({ + required String providerId, + String? name, + bool? enabled, + Map? serviceAccountJSON, + }) async { + final String apiPath = '/messaging/providers/fcm/{providerId}'.replaceAll( + '{providerId}', + providerId, + ); + + final Map apiParams = { + 'name': name, + 'enabled': enabled, + 'serviceAccountJSON': serviceAccountJSON, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Provider.fromMap(res.data); + } + /// Create a new Mailgun provider. Future createMailgunProvider({ required String providerId, @@ -783,6 +1006,9 @@ class Messaging extends Service { } /// Create a new SMTP provider. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead.', + ) Future createSmtpProvider({ required String providerId, required String name, @@ -830,7 +1056,58 @@ class Messaging extends Service { return models.Provider.fromMap(res.data); } + /// Create a new SMTP provider. + Future createSMTPProvider({ + required String providerId, + required String name, + required String host, + int? port, + String? username, + String? password, + enums.SmtpEncryption? encryption, + bool? autoTLS, + String? mailer, + String? fromName, + String? fromEmail, + String? replyToName, + String? replyToEmail, + bool? enabled, + }) async { + final String apiPath = '/messaging/providers/smtp'; + + final Map apiParams = { + 'providerId': providerId, + 'name': name, + 'host': host, + 'port': port, + 'username': username, + 'password': password, + 'encryption': encryption?.value, + 'autoTLS': autoTLS, + 'mailer': mailer, + 'fromName': fromName, + 'fromEmail': fromEmail, + 'replyToName': replyToName, + 'replyToEmail': replyToEmail, + 'enabled': enabled, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Provider.fromMap(res.data); + } + /// Update a SMTP provider by its unique ID. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead.', + ) Future updateSmtpProvider({ required String providerId, String? name, @@ -880,6 +1157,56 @@ class Messaging extends Service { return models.Provider.fromMap(res.data); } + /// Update a SMTP provider by its unique ID. + Future updateSMTPProvider({ + required String providerId, + String? name, + String? host, + int? port, + String? username, + String? password, + enums.SmtpEncryption? encryption, + bool? autoTLS, + String? mailer, + String? fromName, + String? fromEmail, + String? replyToName, + String? replyToEmail, + bool? enabled, + }) async { + final String apiPath = '/messaging/providers/smtp/{providerId}'.replaceAll( + '{providerId}', + providerId, + ); + + final Map apiParams = { + 'name': name, + 'host': host, + 'port': port, + 'username': username, + 'password': password, + 'encryption': encryption?.value, + 'autoTLS': autoTLS, + 'mailer': mailer, + 'fromName': fromName, + 'fromEmail': fromEmail, + 'replyToName': replyToName, + 'replyToEmail': replyToEmail, + 'enabled': enabled, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Provider.fromMap(res.data); + } + /// Create a new Telesign provider. Future createTelesignProvider({ required String providerId, diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart new file mode 100644 index 00000000..f9d86004 --- /dev/null +++ b/lib/services/tables_db.dart @@ -0,0 +1,1520 @@ +part of '../dart_appwrite.dart'; + +class TablesDB extends Service { + TablesDB(super.client); + + /// Get a list of all databases from the current Appwrite project. You can use + /// the search parameter to filter your results. + Future list({ + List? queries, + String? search, + }) async { + final String apiPath = '/tablesdb'; + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DatabaseList.fromMap(res.data); + } + + /// Create a new Database. + /// + Future create({ + required String databaseId, + required String name, + bool? enabled, + }) async { + final String apiPath = '/tablesdb'; + + final Map apiParams = { + 'databaseId': databaseId, + 'name': name, + 'enabled': enabled, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Database.fromMap(res.data); + } + + /// Get a database by its unique ID. This endpoint response returns a JSON + /// object with the database metadata. + Future get({required String databaseId}) async { + final String apiPath = '/tablesdb/{databaseId}'.replaceAll( + '{databaseId}', + databaseId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Database.fromMap(res.data); + } + + /// Update a database by its unique ID. + Future update({ + required String databaseId, + required String name, + bool? enabled, + }) async { + final String apiPath = '/tablesdb/{databaseId}'.replaceAll( + '{databaseId}', + databaseId, + ); + + final Map apiParams = {'name': name, 'enabled': enabled}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Database.fromMap(res.data); + } + + /// Delete a database by its unique ID. Only API keys with with databases.write + /// scope can delete a database. + Future delete({required String databaseId}) async { + final String apiPath = '/tablesdb/{databaseId}'.replaceAll( + '{databaseId}', + databaseId, + ); + + 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; + } + + /// Get a list of all tables that belong to the provided databaseId. You can + /// use the search parameter to filter your results. + Future listTables({ + required String databaseId, + List? queries, + String? search, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables'.replaceAll( + '{databaseId}', + databaseId, + ); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.TableList.fromMap(res.data); + } + + /// Create a new Table. Before using this route, you should create a new + /// database resource using either a [server + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + /// API or directly from your database console. + Future createTable({ + required String databaseId, + required String tableId, + required String name, + List? permissions, + bool? rowSecurity, + bool? enabled, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables'.replaceAll( + '{databaseId}', + databaseId, + ); + + final Map apiParams = { + 'tableId': tableId, + 'name': name, + 'permissions': permissions, + 'rowSecurity': rowSecurity, + 'enabled': enabled, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Table.fromMap(res.data); + } + + /// Get a table by its unique ID. This endpoint response returns a JSON object + /// with the table metadata. + Future getTable({ + required String databaseId, + required String tableId, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Table.fromMap(res.data); + } + + /// Update a table by its unique ID. + Future updateTable({ + required String databaseId, + required String tableId, + required String name, + List? permissions, + bool? rowSecurity, + bool? enabled, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'name': name, + 'permissions': permissions, + 'rowSecurity': rowSecurity, + 'enabled': enabled, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Table.fromMap(res.data); + } + + /// Delete a table by its unique ID. Only users with write permissions have + /// access to delete this resource. + Future deleteTable({ + required String databaseId, + required String tableId, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + 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; + } + + /// List columns in the table. + Future listColumns({ + required String databaseId, + required String tableId, + List? queries, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns' + .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.ColumnList.fromMap(res.data); + } + + /// Create a boolean column. + /// + Future createBooleanColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + bool? xdefault, + bool? array, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'default': xdefault, + 'array': array, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnBoolean.fromMap(res.data); + } + + /// Update a boolean column. Changing the `default` value will not update + /// already existing rows. + Future updateBooleanColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + required bool? xdefault, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnBoolean.fromMap(res.data); + } + + /// Create a date time column according to the ISO 8601 standard. + Future createDatetimeColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + String? xdefault, + bool? array, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'default': xdefault, + 'array': array, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnDatetime.fromMap(res.data); + } + + /// Update a date time column. Changing the `default` value will not update + /// already existing rows. + Future updateDatetimeColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + required String? xdefault, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnDatetime.fromMap(res.data); + } + + /// Create an email column. + /// + Future createEmailColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + String? xdefault, + bool? array, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/email' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'default': xdefault, + 'array': array, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnEmail.fromMap(res.data); + } + + /// Update an email column. Changing the `default` value will not update + /// already existing rows. + /// + Future updateEmailColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + required String? xdefault, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnEmail.fromMap(res.data); + } + + /// Create an enumeration column. The `elements` param acts as a white-list of + /// accepted values for this column. + Future createEnumColumn({ + required String databaseId, + required String tableId, + required String key, + required List elements, + required bool xrequired, + String? xdefault, + bool? array, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'elements': elements, + 'required': xrequired, + 'default': xdefault, + 'array': array, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnEnum.fromMap(res.data); + } + + /// Update an enum column. Changing the `default` value will not update already + /// existing rows. + /// + Future updateEnumColumn({ + required String databaseId, + required String tableId, + required String key, + required List elements, + required bool xrequired, + required String? xdefault, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'elements': elements, + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnEnum.fromMap(res.data); + } + + /// Create a float column. Optionally, minimum and maximum values can be + /// provided. + /// + Future createFloatColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + double? min, + double? max, + double? xdefault, + bool? array, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/float' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'min': min, + 'max': max, + 'default': xdefault, + 'array': array, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnFloat.fromMap(res.data); + } + + /// Update a float column. Changing the `default` value will not update already + /// existing rows. + /// + Future updateFloatColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + required double? xdefault, + double? min, + double? max, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'min': min, + 'max': max, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnFloat.fromMap(res.data); + } + + /// Create an integer column. Optionally, minimum and maximum values can be + /// provided. + /// + Future createIntegerColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + int? min, + int? max, + int? xdefault, + bool? array, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'min': min, + 'max': max, + 'default': xdefault, + 'array': array, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnInteger.fromMap(res.data); + } + + /// Update an integer column. Changing the `default` value will not update + /// already existing rows. + /// + Future updateIntegerColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + required int? xdefault, + int? min, + int? max, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'min': min, + 'max': max, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnInteger.fromMap(res.data); + } + + /// Create IP address column. + /// + Future createIpColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + String? xdefault, + bool? array, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'default': xdefault, + 'array': array, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnIp.fromMap(res.data); + } + + /// Update an ip column. Changing the `default` value will not update already + /// existing rows. + /// + Future updateIpColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + required String? xdefault, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnIp.fromMap(res.data); + } + + /// Create relationship column. [Learn more about relationship + /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + /// + Future createRelationshipColumn({ + required String databaseId, + required String tableId, + required String relatedTableId, + required enums.RelationshipType type, + bool? twoWay, + String? key, + String? twoWayKey, + enums.RelationMutate? onDelete, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'relatedTableId': relatedTableId, + 'type': type.value, + 'twoWay': twoWay, + 'key': key, + 'twoWayKey': twoWayKey, + 'onDelete': onDelete?.value, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnRelationship.fromMap(res.data); + } + + /// Create a string column. + /// + Future createStringColumn({ + required String databaseId, + required String tableId, + required String key, + required int size, + required bool xrequired, + String? xdefault, + bool? array, + bool? encrypt, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/string' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'size': size, + 'required': xrequired, + 'default': xdefault, + 'array': array, + 'encrypt': encrypt, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnString.fromMap(res.data); + } + + /// Update a string column. Changing the `default` value will not update + /// already existing rows. + /// + Future updateStringColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + required String? xdefault, + int? size, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'size': size, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnString.fromMap(res.data); + } + + /// Create a URL column. + /// + Future createUrlColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + String? xdefault, + bool? array, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/url' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'default': xdefault, + 'array': array, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnUrl.fromMap(res.data); + } + + /// Update an url column. Changing the `default` value will not update already + /// existing rows. + /// + Future updateUrlColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + required String? xdefault, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnUrl.fromMap(res.data); + } + + /// Get column by ID. + Future getColumn({ + required String databaseId, + required String tableId, + required String key, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; + } + + /// Deletes a column. + Future deleteColumn({ + required String databaseId, + required String tableId, + required String key, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + 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; + } + + /// Update relationship column. [Learn more about relationship + /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + /// + Future updateRelationshipColumn({ + required String databaseId, + required String tableId, + required String key, + enums.RelationMutate? onDelete, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'onDelete': onDelete?.value, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnRelationship.fromMap(res.data); + } + + /// List indexes on the table. + Future listIndexes({ + required String databaseId, + required String tableId, + List? queries, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .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.ColumnIndexList.fromMap(res.data); + } + + /// Creates an index on the columns listed. Your index should include all the + /// columns you will query in a single request. + /// Type can be `key`, `fulltext`, or `unique`. + Future createIndex({ + required String databaseId, + required String tableId, + required String key, + required enums.IndexType type, + required List columns, + List? orders, + List? lengths, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'type': type.value, + 'columns': columns, + 'orders': orders, + 'lengths': lengths, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnIndex.fromMap(res.data); + } + + /// Get index by ID. + Future getIndex({ + required String databaseId, + required String tableId, + required String key, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnIndex.fromMap(res.data); + } + + /// Delete an index. + Future deleteIndex({ + required String databaseId, + required String tableId, + required String key, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + 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; + } + + /// 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 = '/tablesdb/{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/tablesdb#tablesDBCreateTable) + /// 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 = '/tablesdb/{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/tablesdb#tablesDBCreateTable) + /// API or directly from your database console. + Future createRows({ + required String databaseId, + required String tableId, + required List rows, + }) async { + final String apiPath = '/tablesdb/{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); + } + + /// Create or update Rows. Before using this route, you should create a new + /// table resource using either a [server + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + /// API or directly from your database console. + /// + Future upsertRows({ + required String databaseId, + required String tableId, + required List rows, + }) async { + final String apiPath = '/tablesdb/{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.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.RowList.fromMap(res.data); + } + + /// Update all rows that match your queries, if no queries are submitted then + /// all rows are updated. You can pass only specific fields to be updated. + Future updateRows({ + required String databaseId, + required String tableId, + Map? data, + List? queries, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = {'data': data, 'queries': queries}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.RowList.fromMap(res.data); + } + + /// Bulk delete rows using queries, if no queries are passed then all rows are + /// deleted. + Future deleteRows({ + required String databaseId, + required String tableId, + List? queries, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + 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 = + '/tablesdb/{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/tablesdb#tablesDBCreateTable) + /// API or directly from your database console. + Future upsertRow({ + required String databaseId, + required String tableId, + required String rowId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/tablesdb/{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.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 = + '/tablesdb/{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 = + '/tablesdb/{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; + } + + /// Decrement a specific column of a row by a given value. + Future decrementRowColumn({ + required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? min, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + 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.Row.fromMap(res.data); + } + + /// Increment a specific column of a row by a given value. + Future incrementRowColumn({ + required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? max, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + 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.Row.fromMap(res.data); + } +} diff --git a/lib/services/users.dart b/lib/services/users.dart index c98182b7..eda483bb 100644 --- a/lib/services/users.dart +++ b/lib/services/users.dart @@ -514,6 +514,9 @@ class Users extends Service { } /// Enable or disable MFA on a user account. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Users.updateMFA` instead.', + ) Future updateMfa({ required String userId, required bool mfa, @@ -534,7 +537,31 @@ class Users extends Service { return models.User.fromMap(res.data); } + /// Enable or disable MFA on a user account. + Future updateMFA({ + required String userId, + required bool mfa, + }) async { + final String apiPath = '/users/{userId}/mfa'.replaceAll('{userId}', userId); + + final Map apiParams = {'mfa': mfa}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.User.fromMap(res.data); + } + /// Delete an authenticator app. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Users.deleteMFAAuthenticator` instead.', + ) Future deleteMfaAuthenticator({ required String userId, required enums.AuthenticatorType type, @@ -557,7 +584,33 @@ class Users extends Service { return res.data; } + /// Delete an authenticator app. + Future deleteMFAAuthenticator({ + required String userId, + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/users/{userId}/mfa/authenticators/{type}' + .replaceAll('{userId}', userId) + .replaceAll('{type}', type.value); + + 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; + } + /// List the factors available on the account to be used as a MFA challange. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Users.listMFAFactors` instead.', + ) Future listMfaFactors({required String userId}) async { final String apiPath = '/users/{userId}/mfa/factors'.replaceAll( '{userId}', @@ -578,10 +631,34 @@ class Users extends Service { return models.MfaFactors.fromMap(res.data); } + /// List the factors available on the account to be used as a MFA challange. + Future listMFAFactors({required String userId}) async { + final String apiPath = '/users/{userId}/mfa/factors'.replaceAll( + '{userId}', + userId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaFactors.fromMap(res.data); + } + /// Get recovery codes that can be used as backup for MFA flow by User ID. /// Before getting codes, they must be generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Users.getMFARecoveryCodes` instead.', + ) Future getMfaRecoveryCodes({ required String userId, }) async { @@ -604,10 +681,39 @@ class Users extends Service { return models.MfaRecoveryCodes.fromMap(res.data); } + /// Get recovery codes that can be used as backup for MFA flow by User ID. + /// Before getting codes, they must be generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. + Future getMFARecoveryCodes({ + required String userId, + }) async { + final String apiPath = '/users/{userId}/mfa/recovery-codes'.replaceAll( + '{userId}', + userId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaRecoveryCodes.fromMap(res.data); + } + /// Regenerate recovery codes that can be used as backup for MFA flow by User /// ID. Before regenerating codes, they must be first generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Users.updateMFARecoveryCodes` instead.', + ) Future updateMfaRecoveryCodes({ required String userId, }) async { @@ -630,10 +736,39 @@ class Users extends Service { return models.MfaRecoveryCodes.fromMap(res.data); } + /// Regenerate recovery codes that can be used as backup for MFA flow by User + /// ID. Before regenerating codes, they must be first generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. + Future updateMFARecoveryCodes({ + required String userId, + }) async { + final String apiPath = '/users/{userId}/mfa/recovery-codes'.replaceAll( + '{userId}', + userId, + ); + + 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.MfaRecoveryCodes.fromMap(res.data); + } + /// Generate recovery codes used as backup for MFA flow for User ID. Recovery /// codes can be used as a MFA verification type in /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method by client SDK. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Users.createMFARecoveryCodes` instead.', + ) Future createMfaRecoveryCodes({ required String userId, }) async { @@ -656,6 +791,32 @@ class Users extends Service { return models.MfaRecoveryCodes.fromMap(res.data); } + /// Generate recovery codes used as backup for MFA flow for User ID. Recovery + /// codes can be used as a MFA verification type in + /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + /// method by client SDK. + Future createMFARecoveryCodes({ + required String userId, + }) async { + final String apiPath = '/users/{userId}/mfa/recovery-codes'.replaceAll( + '{userId}', + userId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaRecoveryCodes.fromMap(res.data); + } + /// Update the user name by its unique ID. Future updateName({ required String userId, diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index d84f7f78..c961873f 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -30,8 +30,8 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '16.2.0', - 'X-Appwrite-Response-Format': '1.7.0', + 'x-sdk-version': '17.0.0', + 'X-Appwrite-Response-Format': '1.8.0', }; config = {}; diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 544bd12f..2bd7d639 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -36,10 +36,10 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '16.2.0', + 'x-sdk-version': '17.0.0', 'user-agent': - 'AppwriteDartSDK/16.2.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', - 'X-Appwrite-Response-Format': '1.7.0', + 'AppwriteDartSDK/17.0.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', + 'X-Appwrite-Response-Format': '1.8.0', }; config = {}; diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 08fd6068..0f250ea3 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -16,6 +16,6 @@ enum ResponseType { /// Transform the response data to a String encoded with UTF8. plain, - /// Get original bytes, the type of response will be List + /// Get original bytes, the type of response will be `List` bytes, } diff --git a/lib/src/enums/adapter.dart b/lib/src/enums/adapter.dart index d1af0722..b63e686c 100644 --- a/lib/src/enums/adapter.dart +++ b/lib/src/enums/adapter.dart @@ -1,7 +1,7 @@ part of '../../enums.dart'; enum Adapter { - static(value: 'static'), + xstatic(value: 'static'), ssr(value: 'ssr'); const Adapter({required this.value}); diff --git a/lib/src/models/bucket_list.dart b/lib/src/models/bucket_list.dart index 224c910d..66e58c20 100644 --- a/lib/src/models/bucket_list.dart +++ b/lib/src/models/bucket_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Buckets List class BucketList implements Model { - /// Total number of buckets documents that matched your query. + /// Total number of buckets that matched your query. final int total; /// List of buckets. diff --git a/lib/src/models/collection_list.dart b/lib/src/models/collection_list.dart index 49785e2b..5322aaab 100644 --- a/lib/src/models/collection_list.dart +++ b/lib/src/models/collection_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Collections List class CollectionList implements Model { - /// Total number of collections documents that matched your query. + /// Total number of collections that matched your query. final int total; /// List of collections. diff --git a/lib/src/models/column_boolean.dart b/lib/src/models/column_boolean.dart new file mode 100644 index 00000000..9d5013c0 --- /dev/null +++ b/lib/src/models/column_boolean.dart @@ -0,0 +1,71 @@ +part of '../../models.dart'; + +/// ColumnBoolean +class ColumnBoolean implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// Default value for column when not provided. Cannot be set when column is required. + final bool? xdefault; + + ColumnBoolean({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + this.xdefault, + }); + + factory ColumnBoolean.fromMap(Map map) { + return ColumnBoolean( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + xdefault: map['default'], + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/column_datetime.dart b/lib/src/models/column_datetime.dart new file mode 100644 index 00000000..2341fc3b --- /dev/null +++ b/lib/src/models/column_datetime.dart @@ -0,0 +1,77 @@ +part of '../../models.dart'; + +/// ColumnDatetime +class ColumnDatetime implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// ISO 8601 format. + final String format; + + /// Default value for column when not provided. Only null is optional + final String? xdefault; + + ColumnDatetime({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + required this.format, + this.xdefault, + }); + + factory ColumnDatetime.fromMap(Map map) { + return ColumnDatetime( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + format: map['format'].toString(), + xdefault: map['default']?.toString(), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "format": format, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/column_email.dart b/lib/src/models/column_email.dart new file mode 100644 index 00000000..a822c4e5 --- /dev/null +++ b/lib/src/models/column_email.dart @@ -0,0 +1,77 @@ +part of '../../models.dart'; + +/// ColumnEmail +class ColumnEmail implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// String format. + final String format; + + /// Default value for column when not provided. Cannot be set when column is required. + final String? xdefault; + + ColumnEmail({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + required this.format, + this.xdefault, + }); + + factory ColumnEmail.fromMap(Map map) { + return ColumnEmail( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + format: map['format'].toString(), + xdefault: map['default']?.toString(), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "format": format, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/column_enum.dart b/lib/src/models/column_enum.dart new file mode 100644 index 00000000..115108a4 --- /dev/null +++ b/lib/src/models/column_enum.dart @@ -0,0 +1,83 @@ +part of '../../models.dart'; + +/// ColumnEnum +class ColumnEnum implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// Array of elements in enumerated type. + final List elements; + + /// String format. + final String format; + + /// Default value for column when not provided. Cannot be set when column is required. + final String? xdefault; + + ColumnEnum({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + required this.elements, + required this.format, + this.xdefault, + }); + + factory ColumnEnum.fromMap(Map map) { + return ColumnEnum( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + elements: List.from(map['elements'] ?? []), + format: map['format'].toString(), + xdefault: map['default']?.toString(), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "elements": elements, + "format": format, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/column_float.dart b/lib/src/models/column_float.dart new file mode 100644 index 00000000..a3a4e3b7 --- /dev/null +++ b/lib/src/models/column_float.dart @@ -0,0 +1,83 @@ +part of '../../models.dart'; + +/// ColumnFloat +class ColumnFloat implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// Minimum value to enforce for new documents. + final double? min; + + /// Maximum value to enforce for new documents. + final double? max; + + /// Default value for column when not provided. Cannot be set when column is required. + final double? xdefault; + + ColumnFloat({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + this.min, + this.max, + this.xdefault, + }); + + factory ColumnFloat.fromMap(Map map) { + return ColumnFloat( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + min: map['min']?.toDouble(), + max: map['max']?.toDouble(), + xdefault: map['default']?.toDouble(), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "min": min, + "max": max, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/column_index.dart b/lib/src/models/column_index.dart new file mode 100644 index 00000000..9d637d92 --- /dev/null +++ b/lib/src/models/column_index.dart @@ -0,0 +1,77 @@ +part of '../../models.dart'; + +/// Index +class ColumnIndex implements Model { + /// Index ID. + final String $id; + + /// Index creation date in ISO 8601 format. + final String $createdAt; + + /// Index update date in ISO 8601 format. + final String $updatedAt; + + /// Index Key. + final String key; + + /// Index type. + final String type; + + /// Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an index. + final String error; + + /// Index columns. + final List columns; + + /// Index columns length. + final List lengths; + + /// Index orders. + final List? orders; + + ColumnIndex({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.key, + required this.type, + required this.status, + required this.error, + required this.columns, + required this.lengths, + this.orders, + }); + + factory ColumnIndex.fromMap(Map map) { + return ColumnIndex( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + columns: List.from(map['columns'] ?? []), + lengths: List.from(map['lengths'] ?? []), + orders: List.from(map['orders'] ?? []), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "key": key, + "type": type, + "status": status, + "error": error, + "columns": columns, + "lengths": lengths, + "orders": orders, + }; + } +} diff --git a/lib/src/models/column_index_list.dart b/lib/src/models/column_index_list.dart new file mode 100644 index 00000000..a7983a62 --- /dev/null +++ b/lib/src/models/column_index_list.dart @@ -0,0 +1,25 @@ +part of '../../models.dart'; + +/// Column Indexes List +class ColumnIndexList implements Model { + /// Total number of indexes that matched your query. + final int total; + + /// List of indexes. + final List indexes; + + ColumnIndexList({required this.total, required this.indexes}); + + factory ColumnIndexList.fromMap(Map map) { + return ColumnIndexList( + total: map['total'], + indexes: List.from( + map['indexes'].map((p) => ColumnIndex.fromMap(p)), + ), + ); + } + + Map toMap() { + return {"total": total, "indexes": indexes.map((p) => p.toMap()).toList()}; + } +} diff --git a/lib/src/models/column_integer.dart b/lib/src/models/column_integer.dart new file mode 100644 index 00000000..82bf6734 --- /dev/null +++ b/lib/src/models/column_integer.dart @@ -0,0 +1,83 @@ +part of '../../models.dart'; + +/// ColumnInteger +class ColumnInteger implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// Minimum value to enforce for new documents. + final int? min; + + /// Maximum value to enforce for new documents. + final int? max; + + /// Default value for column when not provided. Cannot be set when column is required. + final int? xdefault; + + ColumnInteger({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + this.min, + this.max, + this.xdefault, + }); + + factory ColumnInteger.fromMap(Map map) { + return ColumnInteger( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + min: map['min'], + max: map['max'], + xdefault: map['default'], + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "min": min, + "max": max, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/column_ip.dart b/lib/src/models/column_ip.dart new file mode 100644 index 00000000..13bb322c --- /dev/null +++ b/lib/src/models/column_ip.dart @@ -0,0 +1,77 @@ +part of '../../models.dart'; + +/// ColumnIP +class ColumnIp implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// String format. + final String format; + + /// Default value for column when not provided. Cannot be set when column is required. + final String? xdefault; + + ColumnIp({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + required this.format, + this.xdefault, + }); + + factory ColumnIp.fromMap(Map map) { + return ColumnIp( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + format: map['format'].toString(), + xdefault: map['default']?.toString(), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "format": format, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/column_list.dart b/lib/src/models/column_list.dart new file mode 100644 index 00000000..8eb0171f --- /dev/null +++ b/lib/src/models/column_list.dart @@ -0,0 +1,23 @@ +part of '../../models.dart'; + +/// Columns List +class ColumnList implements Model { + /// Total number of columns in the given table. + final int total; + + /// List of columns. + final List columns; + + ColumnList({required this.total, required this.columns}); + + factory ColumnList.fromMap(Map map) { + return ColumnList( + total: map['total'], + columns: List.from(map['columns'] ?? []), + ); + } + + Map toMap() { + return {"total": total, "columns": columns}; + } +} diff --git a/lib/src/models/column_relationship.dart b/lib/src/models/column_relationship.dart new file mode 100644 index 00000000..6221c01e --- /dev/null +++ b/lib/src/models/column_relationship.dart @@ -0,0 +1,101 @@ +part of '../../models.dart'; + +/// ColumnRelationship +class ColumnRelationship implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// The ID of the related table. + final String relatedTable; + + /// The type of the relationship. + final String relationType; + + /// Is the relationship two-way? + final bool twoWay; + + /// The key of the two-way relationship. + final String twoWayKey; + + /// How deleting the parent document will propagate to child documents. + final String onDelete; + + /// Whether this is the parent or child side of the relationship + final String side; + + ColumnRelationship({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + required this.relatedTable, + required this.relationType, + required this.twoWay, + required this.twoWayKey, + required this.onDelete, + required this.side, + }); + + factory ColumnRelationship.fromMap(Map map) { + return ColumnRelationship( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + relatedTable: map['relatedTable'].toString(), + relationType: map['relationType'].toString(), + twoWay: map['twoWay'], + twoWayKey: map['twoWayKey'].toString(), + onDelete: map['onDelete'].toString(), + side: map['side'].toString(), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "relatedTable": relatedTable, + "relationType": relationType, + "twoWay": twoWay, + "twoWayKey": twoWayKey, + "onDelete": onDelete, + "side": side, + }; + } +} diff --git a/lib/src/models/column_string.dart b/lib/src/models/column_string.dart new file mode 100644 index 00000000..7b560989 --- /dev/null +++ b/lib/src/models/column_string.dart @@ -0,0 +1,83 @@ +part of '../../models.dart'; + +/// ColumnString +class ColumnString implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// Column size. + final int size; + + /// Default value for column when not provided. Cannot be set when column is required. + final String? xdefault; + + /// Defines whether this column is encrypted or not. + final bool? encrypt; + + ColumnString({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + required this.size, + this.xdefault, + this.encrypt, + }); + + factory ColumnString.fromMap(Map map) { + return ColumnString( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + size: map['size'], + xdefault: map['default']?.toString(), + encrypt: map['encrypt'], + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "size": size, + "default": xdefault, + "encrypt": encrypt, + }; + } +} diff --git a/lib/src/models/column_url.dart b/lib/src/models/column_url.dart new file mode 100644 index 00000000..66c0ce7b --- /dev/null +++ b/lib/src/models/column_url.dart @@ -0,0 +1,77 @@ +part of '../../models.dart'; + +/// ColumnURL +class ColumnUrl implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// String format. + final String format; + + /// Default value for column when not provided. Cannot be set when column is required. + final String? xdefault; + + ColumnUrl({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + required this.format, + this.xdefault, + }); + + factory ColumnUrl.fromMap(Map map) { + return ColumnUrl( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + format: map['format'].toString(), + xdefault: map['default']?.toString(), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "format": format, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 2c605d3b..ec2c0755 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 documents that matched your query. + /// Total number of continents 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 6ef8ec42..65e13be3 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 documents that matched your query. + /// Total number of countries 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 acb515e3..7a957f1a 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 documents that matched your query. + /// Total number of currencies that matched your query. final int total; /// List of currencies. diff --git a/lib/src/models/database.dart b/lib/src/models/database.dart index 298a46a3..8d79e052 100644 --- a/lib/src/models/database.dart +++ b/lib/src/models/database.dart @@ -17,12 +17,16 @@ class Database implements Model { /// If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the database is inaccessible to users, but remains accessible to Server SDKs using API keys. final bool enabled; + /// Database type. + final String type; + Database({ required this.$id, required this.name, required this.$createdAt, required this.$updatedAt, required this.enabled, + required this.type, }); factory Database.fromMap(Map map) { @@ -32,6 +36,7 @@ class Database implements Model { $createdAt: map['\$createdAt'].toString(), $updatedAt: map['\$updatedAt'].toString(), enabled: map['enabled'], + type: map['type'].toString(), ); } @@ -42,6 +47,7 @@ class Database implements Model { "\$createdAt": $createdAt, "\$updatedAt": $updatedAt, "enabled": enabled, + "type": type, }; } } diff --git a/lib/src/models/database_list.dart b/lib/src/models/database_list.dart index 5b6df8d4..5afa7932 100644 --- a/lib/src/models/database_list.dart +++ b/lib/src/models/database_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Databases List class DatabaseList implements Model { - /// Total number of databases documents that matched your query. + /// Total number of databases that matched your query. final int total; /// List of databases. diff --git a/lib/src/models/deployment_list.dart b/lib/src/models/deployment_list.dart index 15a93ef4..df81710a 100644 --- a/lib/src/models/deployment_list.dart +++ b/lib/src/models/deployment_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Deployments List class DeploymentList implements Model { - /// Total number of deployments documents that matched your query. + /// Total number of deployments that matched your query. final int total; /// List of deployments. diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index 126ad805..4065e17b 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 documents that matched your query. + /// Total number of documents that matched your query. final int total; /// List of documents. diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 8618bcd6..8dfbeab6 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -8,7 +8,7 @@ class Execution implements Model { /// Execution creation date in ISO 8601 format. final String $createdAt; - /// Execution upate date in ISO 8601 format. + /// Execution update date in ISO 8601 format. final String $updatedAt; /// Execution roles. @@ -17,6 +17,9 @@ class Execution implements Model { /// Function ID. final String functionId; + /// Function's deployment ID used to create the execution. + final String deploymentId; + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. final String trigger; @@ -59,6 +62,7 @@ class Execution implements Model { required this.$updatedAt, required this.$permissions, required this.functionId, + required this.deploymentId, required this.trigger, required this.status, required this.requestMethod, @@ -80,6 +84,7 @@ class Execution implements Model { $updatedAt: map['\$updatedAt'].toString(), $permissions: List.from(map['\$permissions'] ?? []), functionId: map['functionId'].toString(), + deploymentId: map['deploymentId'].toString(), trigger: map['trigger'].toString(), status: map['status'].toString(), requestMethod: map['requestMethod'].toString(), @@ -106,6 +111,7 @@ class Execution implements Model { "\$updatedAt": $updatedAt, "\$permissions": $permissions, "functionId": functionId, + "deploymentId": deploymentId, "trigger": trigger, "status": status, "requestMethod": requestMethod, diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index 2a2ef056..4ed73943 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 documents that matched your query. + /// Total number of executions 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 9f01530b..63f49abc 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 documents that matched your query. + /// Total number of files that matched your query. final int total; /// List of files. diff --git a/lib/src/models/framework_list.dart b/lib/src/models/framework_list.dart index 266d8edf..eb8145d4 100644 --- a/lib/src/models/framework_list.dart +++ b/lib/src/models/framework_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Frameworks List class FrameworkList implements Model { - /// Total number of frameworks documents that matched your query. + /// Total number of frameworks that matched your query. final int total; /// List of frameworks. diff --git a/lib/src/models/function_list.dart b/lib/src/models/function_list.dart index c37f0615..34d7225c 100644 --- a/lib/src/models/function_list.dart +++ b/lib/src/models/function_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Functions List class FunctionList implements Model { - /// Total number of functions documents that matched your query. + /// Total number of functions that matched your query. final int total; /// List of functions. diff --git a/lib/src/models/identity_list.dart b/lib/src/models/identity_list.dart index f38eaf66..b4c63f7d 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 documents that matched your query. + /// Total number of identities that matched your query. final int total; /// List of identities. diff --git a/lib/src/models/index.dart b/lib/src/models/index.dart index 961b9e5e..9d6d7aec 100644 --- a/lib/src/models/index.dart +++ b/lib/src/models/index.dart @@ -2,7 +2,16 @@ part of '../../models.dart'; /// Index class Index implements Model { - /// Index Key. + /// Index ID. + final String $id; + + /// Index creation date in ISO 8601 format. + final String $createdAt; + + /// Index update date in ISO 8601 format. + final String $updatedAt; + + /// Index key. final String key; /// Index type. @@ -23,13 +32,10 @@ class Index implements Model { /// Index orders. final List? orders; - /// Index creation date in ISO 8601 format. - final String $createdAt; - - /// Index update date in ISO 8601 format. - final String $updatedAt; - Index({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, required this.key, required this.type, required this.status, @@ -37,12 +43,13 @@ class Index implements Model { required this.attributes, required this.lengths, this.orders, - required this.$createdAt, - required this.$updatedAt, }); factory Index.fromMap(Map map) { return Index( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), @@ -50,13 +57,14 @@ class Index implements Model { attributes: List.from(map['attributes'] ?? []), lengths: List.from(map['lengths'] ?? []), orders: List.from(map['orders'] ?? []), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), ); } Map toMap() { return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, "key": key, "type": type, "status": status, @@ -64,8 +72,6 @@ class Index implements Model { "attributes": attributes, "lengths": lengths, "orders": orders, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, }; } } diff --git a/lib/src/models/index_list.dart b/lib/src/models/index_list.dart index dc759dfb..6d285a6a 100644 --- a/lib/src/models/index_list.dart +++ b/lib/src/models/index_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Indexes List class IndexList implements Model { - /// Total number of indexes documents that matched your query. + /// Total number of indexes that matched your query. final int total; /// List of indexes. diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index 046b879e..2e65839e 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 documents that matched your query. + /// Total number of languages 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 662fee4f..be6ddb1f 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 documents that matched your query. + /// Total number of localeCodes 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 628237fa..22273a8c 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 documents that matched your query. + /// Total number of logs 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 46468a3a..a4d39dca 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 documents that matched your query. + /// Total number of memberships that matched your query. final int total; /// List of memberships. diff --git a/lib/src/models/message_list.dart b/lib/src/models/message_list.dart index 7bd0891f..15ddf642 100644 --- a/lib/src/models/message_list.dart +++ b/lib/src/models/message_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Message list class MessageList implements Model { - /// Total number of messages documents that matched your query. + /// Total number of messages that matched your query. final int total; /// List of messages. diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 18d2803d..879edbc4 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 documents that matched your query. + /// Total number of phones that matched your query. final int total; /// List of phones. diff --git a/lib/src/models/provider_list.dart b/lib/src/models/provider_list.dart index aeb28ecd..9347fefb 100644 --- a/lib/src/models/provider_list.dart +++ b/lib/src/models/provider_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Provider list class ProviderList implements Model { - /// Total number of providers documents that matched your query. + /// Total number of providers that matched your query. final int total; /// List of providers. diff --git a/lib/src/models/resource_token_list.dart b/lib/src/models/resource_token_list.dart index f30531f4..2283653f 100644 --- a/lib/src/models/resource_token_list.dart +++ b/lib/src/models/resource_token_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Resource Tokens List class ResourceTokenList implements Model { - /// Total number of tokens documents that matched your query. + /// Total number of tokens that matched your query. final int total; /// List of tokens. diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart new file mode 100644 index 00000000..3700e577 --- /dev/null +++ b/lib/src/models/row.dart @@ -0,0 +1,66 @@ +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 new file mode 100644 index 00000000..01f046c6 --- /dev/null +++ b/lib/src/models/row_list.dart @@ -0,0 +1,26 @@ +part of '../../models.dart'; + +/// Rows List +class RowList implements Model { + /// Total number of 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/runtime_list.dart b/lib/src/models/runtime_list.dart index 02c7b2e5..64bc2e08 100644 --- a/lib/src/models/runtime_list.dart +++ b/lib/src/models/runtime_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Runtimes List class RuntimeList implements Model { - /// Total number of runtimes documents that matched your query. + /// Total number of runtimes that matched your query. final int total; /// List of runtimes. diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index 479272b9..e9c478af 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 documents that matched your query. + /// Total number of sessions that matched your query. final int total; /// List of sessions. diff --git a/lib/src/models/site_list.dart b/lib/src/models/site_list.dart index a403dd5b..e74b0d81 100644 --- a/lib/src/models/site_list.dart +++ b/lib/src/models/site_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Sites List class SiteList implements Model { - /// Total number of sites documents that matched your query. + /// Total number of sites that matched your query. final int total; /// List of sites. diff --git a/lib/src/models/specification_list.dart b/lib/src/models/specification_list.dart index e4bef89b..de4957d2 100644 --- a/lib/src/models/specification_list.dart +++ b/lib/src/models/specification_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Specifications List class SpecificationList implements Model { - /// Total number of specifications documents that matched your query. + /// Total number of specifications that matched your query. final int total; /// List of specifications. diff --git a/lib/src/models/subscriber_list.dart b/lib/src/models/subscriber_list.dart index 7030fa0a..6a135b92 100644 --- a/lib/src/models/subscriber_list.dart +++ b/lib/src/models/subscriber_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Subscriber list class SubscriberList implements Model { - /// Total number of subscribers documents that matched your query. + /// Total number of subscribers that matched your query. final int total; /// List of subscribers. diff --git a/lib/src/models/table.dart b/lib/src/models/table.dart new file mode 100644 index 00000000..7ce86b9d --- /dev/null +++ b/lib/src/models/table.dart @@ -0,0 +1,79 @@ +part of '../../models.dart'; + +/// Table +class Table implements Model { + /// Table ID. + final String $id; + + /// Table creation date in ISO 8601 format. + final String $createdAt; + + /// Table update date in ISO 8601 format. + final String $updatedAt; + + /// Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; + + /// Database ID. + final String databaseId; + + /// Table name. + final String name; + + /// Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. + final bool enabled; + + /// Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + final bool rowSecurity; + + /// Table columns. + final List columns; + + /// Table indexes. + final List indexes; + + Table({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.databaseId, + required this.name, + required this.enabled, + required this.rowSecurity, + required this.columns, + required this.indexes, + }); + + factory Table.fromMap(Map map) { + return Table( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + databaseId: map['databaseId'].toString(), + name: map['name'].toString(), + enabled: map['enabled'], + rowSecurity: map['rowSecurity'], + columns: List.from(map['columns'] ?? []), + indexes: List.from( + map['indexes'].map((p) => ColumnIndex.fromMap(p)), + ), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "databaseId": databaseId, + "name": name, + "enabled": enabled, + "rowSecurity": rowSecurity, + "columns": columns, + "indexes": indexes.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/table_list.dart b/lib/src/models/table_list.dart new file mode 100644 index 00000000..ebe15c71 --- /dev/null +++ b/lib/src/models/table_list.dart @@ -0,0 +1,23 @@ +part of '../../models.dart'; + +/// Tables List +class TableList implements Model { + /// Total number of tables that matched your query. + final int total; + + /// List of tables. + final List tables; + + TableList({required this.total, required this.tables}); + + factory TableList.fromMap(Map map) { + return TableList( + total: map['total'], + tables: List
.from(map['tables'].map((p) => Table.fromMap(p))), + ); + } + + Map toMap() { + return {"total": total, "tables": tables.map((p) => p.toMap()).toList()}; + } +} diff --git a/lib/src/models/target_list.dart b/lib/src/models/target_list.dart index 1042e5a2..84233d1d 100644 --- a/lib/src/models/target_list.dart +++ b/lib/src/models/target_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Target list class TargetList implements Model { - /// Total number of targets documents that matched your query. + /// Total number of targets that matched your query. final int total; /// List of targets. diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index e604f192..a3994c06 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 documents that matched your query. + /// Total number of teams that matched your query. final int total; /// List of teams. diff --git a/lib/src/models/topic_list.dart b/lib/src/models/topic_list.dart index a4d1f44f..eefc62b6 100644 --- a/lib/src/models/topic_list.dart +++ b/lib/src/models/topic_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Topic list class TopicList implements Model { - /// Total number of topics documents that matched your query. + /// Total number of topics that matched your query. final int total; /// List of topics. diff --git a/lib/src/models/user_list.dart b/lib/src/models/user_list.dart index 03e55cc6..2419d818 100644 --- a/lib/src/models/user_list.dart +++ b/lib/src/models/user_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Users List class UserList implements Model { - /// Total number of users documents that matched your query. + /// Total number of users that matched your query. final int total; /// List of users. diff --git a/lib/src/models/variable_list.dart b/lib/src/models/variable_list.dart index 4ff3e189..ffa58eef 100644 --- a/lib/src/models/variable_list.dart +++ b/lib/src/models/variable_list.dart @@ -2,7 +2,7 @@ part of '../../models.dart'; /// Variables List class VariableList implements Model { - /// Total number of variables documents that matched your query. + /// Total number of variables that matched your query. final int total; /// List of variables. diff --git a/pubspec.yaml b/pubspec.yaml index b05f52ae..9d102b91 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: dart_appwrite -version: 16.2.0 +version: 17.0.0 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-dart @@ -11,6 +11,6 @@ dependencies: http: '>=0.13.6 <2.0.0' dev_dependencies: - lints: ^4.0.0 + lints: ^6.0.0 test: ^1.25.8 mockito: ^5.4.4 diff --git a/test/query_test.dart b/test/query_test.dart index 71d1cf23..737a82b3 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -1,10 +1,12 @@ +import 'dart:convert'; + import 'package:dart_appwrite/dart_appwrite.dart'; import 'package:test/test.dart'; -class BasicFilterQueryTest { +class BasicFilterQueryTest { final String description; - final dynamic value; - final String expectedValues; + final T value; + final List expectedValues; BasicFilterQueryTest({ required this.description, @@ -19,7 +21,7 @@ void main() { BasicFilterQueryTest( description: 'with a string', value: 's', - expectedValues: ["s"], + expectedValues: ['s'], ), BasicFilterQueryTest( description: 'with an integer', @@ -44,14 +46,14 @@ void main() { BasicFilterQueryTest( description: 'with a list', value: ['a', 'b', 'c'], - expectedValues: ["a","b","c"], + expectedValues: ['a', 'b', 'c'], ), ]; group('equal()', () { for (var t in tests) { test(t.description, () { - final query = Query.equal('attr', t.value).toJson(); + final query = jsonDecode(Query.equal('attr', t.value)); expect(query['attribute'], 'attr'); expect(query['values'], t.expectedValues); expect(query['method'], 'equal'); @@ -61,19 +63,23 @@ void main() { group('notEqual()', () { for (var t in tests) { - test(t.description, () { - final query = Query.notEqual('attr', t.value).toJson(); - expect(query['attribute'], 'attr'); - expect(query['values'], t.expectedValues); - expect(query['method'], 'notEqual'); - }); + test( + t.description, + () { + final query = jsonDecode(Query.notEqual('attr', t.value)); + expect(query['attribute'], 'attr'); + expect(query['values'], t.expectedValues); + expect(query['method'], 'notEqual'); + }, + skip: t.value is List, + ); } }); group('lessThan()', () { for (var t in tests) { test(t.description, () { - final query = Query.lessThan('attr', t.value).toJson(); + final query = jsonDecode(Query.lessThan('attr', t.value)); expect(query['attribute'], 'attr'); expect(query['values'], t.expectedValues); expect(query['method'], 'lessThan'); @@ -84,7 +90,7 @@ void main() { group('lessThanEqual()', () { for (var t in tests) { test(t.description, () { - final query = Query.lessThanEqual('attr', t.value).toJson(); + final query = jsonDecode(Query.lessThanEqual('attr', t.value)); expect(query['attribute'], 'attr'); expect(query['values'], t.expectedValues); expect(query['method'], 'lessThanEqual'); @@ -95,7 +101,7 @@ void main() { group('greaterThan()', () { for (var t in tests) { test(t.description, () { - final query = Query.greaterThan('attr', t.value).toJson(); + final query = jsonDecode(Query.greaterThan('attr', t.value)); expect(query['attribute'], 'attr'); expect(query['values'], t.expectedValues); expect(query['method'], 'greaterThan'); @@ -106,7 +112,7 @@ void main() { group('greaterThanEqual()', () { for (var t in tests) { test(t.description, () { - final query = Query.greaterThanEqual('attr', t.value).toJson(); + final query = jsonDecode(Query.greaterThanEqual('attr', t.value)); expect(query['attribute'], 'attr'); expect(query['values'], t.expectedValues); expect(query['method'], 'greaterThanEqual'); @@ -116,21 +122,21 @@ void main() { }); test('returns search', () { - final query = Query.search('attr', 'keyword1 keyword2').toJson(); + final query = jsonDecode(Query.search('attr', 'keyword1 keyword2')); expect(query['attribute'], 'attr'); expect(query['values'], ['keyword1 keyword2']); expect(query['method'], 'search'); }); test('returns isNull', () { - final query = Query.isNull('attr').toJson(); + final query = jsonDecode(Query.isNull('attr')); expect(query['attribute'], 'attr'); expect(query['values'], null); expect(query['method'], 'isNull'); }); test('returns isNotNull', () { - final query = Query.isNotNull('attr', 'keyword1 keyword2').toJson(); + final query = jsonDecode(Query.isNotNull('attr')); expect(query['attribute'], 'attr'); expect(query['values'], null); expect(query['method'], 'isNotNull'); @@ -138,21 +144,21 @@ void main() { group('between()', () { test('with integers', () { - final query = Query.between('attr', 1, 2).toJson(); + final query = jsonDecode(Query.between('attr', 1, 2)); expect(query['attribute'], 'attr'); expect(query['values'], [1, 2]); expect(query['method'], 'between'); }); test('with doubles', () { - final query = Query.between('attr', 1.0, 2.0).toJson(); + final query = jsonDecode(Query.between('attr', 1.0, 2.0)); expect(query['attribute'], 'attr'); expect(query['values'], [1.0, 2.0]); expect(query['method'], 'between'); }); test('with strings', () { - final query = Query.between('attr', 'a', 'z').toJson(); + final query = jsonDecode(Query.between('attr', 'a', 'z')); expect(query['attribute'], 'attr'); expect(query['values'], ['a', 'z']); expect(query['method'], 'between'); @@ -160,52 +166,131 @@ void main() { }); test('returns select', () { - final query = Query.select(['attr1', 'attr2']).toJson(); + final query = jsonDecode(Query.select(['attr1', 'attr2'])); expect(query['attribute'], null); expect(query['values'], ['attr1', 'attr2']); expect(query['method'], 'select'); }); test('returns orderAsc', () { - final query = Query.orderAsc('attr').toJson(); + final query = jsonDecode(Query.orderAsc('attr')); expect(query['attribute'], 'attr'); expect(query['values'], null); expect(query['method'], 'orderAsc'); }); test('returns orderDesc', () { - final query = Query.orderDesc('attr').toJson(); + final query = jsonDecode(Query.orderDesc('attr')); expect(query['attribute'], 'attr'); expect(query['values'], null); expect(query['method'], 'orderDesc'); }); test('returns cursorBefore', () { - final query = Query.cursorBefore('custom').toJson(); + final query = jsonDecode(Query.cursorBefore('custom')); expect(query['attribute'], null); - expect(query['values'], 'custom'); + expect(query['values'], ['custom']); expect(query['method'], 'cursorBefore'); }); test('returns cursorAfter', () { - final query = Query.cursorAfter('custom').toJson(); + final query = jsonDecode(Query.cursorAfter('custom')); expect(query['attribute'], null); - expect(query['values'], 'custom'); + expect(query['values'], ['custom']); expect(query['method'], 'cursorAfter'); }); test('returns limit', () { - final query = Query.limit(1).toJson(); + final query = jsonDecode(Query.limit(1)); expect(query['attribute'], null); - expect(query['values'], 1); + expect(query['values'], [1]); expect(query['method'], 'limit'); }); test('returns offset', () { - final query = Query.offset(1).toJson(); + final query = jsonDecode(Query.offset(1)); expect(query['attribute'], null); - expect(query['values'], 1); + expect(query['values'], [1]); expect(query['method'], 'offset'); }); + + test('returns notContains', () { + final query = jsonDecode(Query.notContains('attr', 'value')); + expect(query['attribute'], 'attr'); + expect(query['values'], ['value']); + expect(query['method'], 'notContains'); + }); + + test('returns notSearch', () { + final query = jsonDecode(Query.notSearch('attr', 'keyword1 keyword2')); + expect(query['attribute'], 'attr'); + expect(query['values'], ['keyword1 keyword2']); + expect(query['method'], 'notSearch'); + }); + + group('notBetween()', () { + test('with integers', () { + final query = jsonDecode(Query.notBetween('attr', 1, 2)); + expect(query['attribute'], 'attr'); + expect(query['values'], [1, 2]); + expect(query['method'], 'notBetween'); + }); + + test('with doubles', () { + final query = jsonDecode(Query.notBetween('attr', 1.0, 2.0)); + expect(query['attribute'], 'attr'); + expect(query['values'], [1.0, 2.0]); + expect(query['method'], 'notBetween'); + }); + + test('with strings', () { + final query = jsonDecode(Query.notBetween('attr', 'a', 'z')); + expect(query['attribute'], 'attr'); + expect(query['values'], ['a', 'z']); + expect(query['method'], 'notBetween'); + }); + }); + + test('returns notStartsWith', () { + final query = jsonDecode(Query.notStartsWith('attr', 'prefix')); + expect(query['attribute'], 'attr'); + expect(query['values'], ['prefix']); + expect(query['method'], 'notStartsWith'); + }); + + test('returns notEndsWith', () { + final query = jsonDecode(Query.notEndsWith('attr', 'suffix')); + expect(query['attribute'], 'attr'); + expect(query['values'], ['suffix']); + expect(query['method'], 'notEndsWith'); + }); + + test('returns createdBefore', () { + final query = jsonDecode(Query.createdBefore('2023-01-01')); + expect(query['attribute'], null); + expect(query['values'], ['2023-01-01']); + expect(query['method'], 'createdBefore'); + }); + + test('returns createdAfter', () { + final query = jsonDecode(Query.createdAfter('2023-01-01')); + expect(query['attribute'], null); + expect(query['values'], ['2023-01-01']); + expect(query['method'], 'createdAfter'); + }); + + test('returns updatedBefore', () { + final query = jsonDecode(Query.updatedBefore('2023-01-01')); + expect(query['attribute'], null); + expect(query['values'], ['2023-01-01']); + expect(query['method'], 'updatedBefore'); + }); + + test('returns updatedAfter', () { + final query = jsonDecode(Query.updatedAfter('2023-01-01')); + expect(query['attribute'], null); + expect(query['values'], ['2023-01-01']); + expect(query['method'], 'updatedAfter'); + }); } diff --git a/test/services/account_test.dart b/test/services/account_test.dart index 55679f3f..5f8488fe 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @@ -259,7 +255,25 @@ void main() { final response = await account.createMfaAuthenticator( - type: 'totp', + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + + }); + + test('test method createMFAAuthenticator()', () async { + final Map data = { + 'secret': '1', + 'uri': '1',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMFAAuthenticator( + type: enums.AuthenticatorType.totp, ); expect(response, isA()); @@ -291,7 +305,40 @@ void main() { final response = await account.updateMfaAuthenticator( - type: 'totp', + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); + + }); + + test('test method updateMFAAuthenticator()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMFAAuthenticator( + type: enums.AuthenticatorType.totp, otp: '', ); expect(response, isA()); @@ -307,7 +354,20 @@ void main() { final response = await account.deleteMfaAuthenticator( - type: 'totp', + type: enums.AuthenticatorType.totp, + ); + }); + + test('test method deleteMFAAuthenticator()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteMFAAuthenticator( + type: enums.AuthenticatorType.totp, ); }); @@ -325,7 +385,27 @@ void main() { final response = await account.createMfaChallenge( - factor: 'email', + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + + }); + + test('test method createMFAChallenge()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMFAChallenge( + factor: enums.AuthenticationFactor.email, ); expect(response, isA()); @@ -377,6 +457,52 @@ void main() { }); + test('test method updateMFAChallenge()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMFAChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); + + }); + test('test method listMfaFactors()', () async { final Map data = { 'totp': true, @@ -396,6 +522,25 @@ void main() { }); + test('test method listMFAFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listMFAFactors( + ); + expect(response, isA()); + + }); + test('test method getMfaRecoveryCodes()', () async { final Map data = { 'recoveryCodes': [],}; @@ -412,6 +557,22 @@ void main() { }); + test('test method getMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getMFARecoveryCodes( + ); + expect(response, isA()); + + }); + test('test method createMfaRecoveryCodes()', () async { final Map data = { 'recoveryCodes': [],}; @@ -428,6 +589,22 @@ void main() { }); + test('test method createMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMFARecoveryCodes( + ); + expect(response, isA()); + + }); + test('test method updateMfaRecoveryCodes()', () async { final Map data = { 'recoveryCodes': [],}; @@ -444,6 +621,22 @@ void main() { }); + test('test method updateMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMFARecoveryCodes( + ); + expect(response, isA()); + + }); + test('test method updateName()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -1080,7 +1273,7 @@ void main() { final response = await account.createOAuth2Token( - provider: 'amazon', + provider: enums.OAuthProvider.amazon, ); }); diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index aaf84313..062e484e 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @@ -62,7 +58,7 @@ void main() { final response = await avatars.getBrowser( - code: 'aa', + code: enums.Browser.avantBrowser, ); expect(response, isA()); @@ -76,7 +72,7 @@ void main() { final response = await avatars.getCreditCard( - code: 'amex', + code: enums.CreditCard.americanExpress, ); expect(response, isA()); @@ -104,7 +100,7 @@ void main() { final response = await avatars.getFlag( - code: 'af', + code: enums.Flag.afghanistan, ); expect(response, isA()); diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index 1c2652ef..eeab4468 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @@ -77,7 +73,8 @@ void main() { 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true,}; + 'enabled': true, + 'type': 'legacy',}; when(client.call( @@ -99,7 +96,8 @@ void main() { 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true,}; + 'enabled': true, + 'type': 'legacy',}; when(client.call( @@ -120,7 +118,8 @@ void main() { 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true,}; + 'enabled': true, + 'type': 'legacy',}; when(client.call( @@ -692,7 +691,7 @@ void main() { databaseId: '', collectionId: '', relatedCollectionId: '', - type: 'oneToOne', + type: enums.RelationshipType.oneToOne, ); expect(response, isA()); @@ -1157,14 +1156,15 @@ void main() { test('test method createIndex()', () async { final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'key': 'index1', 'type': 'primary', 'status': 'available', 'error': 'string', 'attributes': [], - 'lengths': [], - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + 'lengths': [],}; when(client.call( @@ -1176,7 +1176,7 @@ void main() { databaseId: '', collectionId: '', key: '', - type: 'key', + type: enums.IndexType.key, attributes: [], ); expect(response, isA()); @@ -1185,14 +1185,15 @@ void main() { test('test method getIndex()', () async { final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'key': 'index1', 'type': 'primary', 'status': 'available', 'error': 'string', 'attributes': [], - 'lengths': [], - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + 'lengths': [],}; when(client.call( diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index f42bd078..c7eac047 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @@ -111,7 +107,7 @@ void main() { final response = await functions.create( functionId: '', name: '', - runtime: 'node-14.5', + runtime: enums.Runtime.node145, ); expect(response, isA()); @@ -494,7 +490,7 @@ void main() { final response = await functions.createVcsDeployment( functionId: '', - type: 'branch', + type: enums.VCSDeploymentType.branch, reference: '', ); expect(response, isA()); @@ -643,6 +639,7 @@ void main() { '\$updatedAt': '2020-10-15T06:38:00.000+00:00', '\$permissions': [], 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', 'trigger': 'http', 'status': 'processing', 'requestMethod': 'GET', @@ -675,6 +672,7 @@ void main() { '\$updatedAt': '2020-10-15T06:38:00.000+00:00', '\$permissions': [], 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', 'trigger': 'http', 'status': 'processing', 'requestMethod': 'GET', diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index 20ace7b1..26d79d42 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } diff --git a/test/services/health_test.dart b/test/services/health_test.dart index 6a1dae9e..e60505df 100644 --- a/test/services/health_test.dart +++ b/test/services/health_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @@ -239,7 +235,7 @@ void main() { final response = await health.getFailedJobs( - name: 'v1-database', + name: enums.Name.v1Database, ); expect(response, isA()); diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index 795c9f03..3536cee0 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index eacea811..459dc2d4 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @@ -204,6 +200,33 @@ void main() { }); + test('test method createSMS()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createSMS( + messageId: '', + content: '', + ); + expect(response, isA()); + + }); + test('test method updateSms()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -230,6 +253,32 @@ void main() { }); + test('test method updateSMS()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateSMS( + messageId: '', + ); + expect(response, isA()); + + }); + test('test method getMessage()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -347,6 +396,31 @@ void main() { }); + test('test method createAPNSProvider()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createAPNSProvider( + providerId: '', + name: '', + ); + expect(response, isA()); + + }); + test('test method updateApnsProvider()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -371,6 +445,30 @@ void main() { }); + test('test method updateAPNSProvider()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateAPNSProvider( + providerId: '', + ); + expect(response, isA()); + + }); + test('test method createFcmProvider()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -396,6 +494,31 @@ void main() { }); + test('test method createFCMProvider()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createFCMProvider( + providerId: '', + name: '', + ); + expect(response, isA()); + + }); + test('test method updateFcmProvider()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -420,6 +543,30 @@ void main() { }); + test('test method updateFCMProvider()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateFCMProvider( + providerId: '', + ); + expect(response, isA()); + + }); + test('test method createMailgunProvider()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -593,6 +740,32 @@ void main() { }); + test('test method createSMTPProvider()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createSMTPProvider( + providerId: '', + name: '', + host: '', + ); + expect(response, isA()); + + }); + test('test method updateSmtpProvider()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -617,6 +790,30 @@ void main() { }); + test('test method updateSMTPProvider()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateSMTPProvider( + providerId: '', + ); + expect(response, isA()); + + }); + test('test method createTelesignProvider()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -1031,7 +1228,16 @@ void main() { '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'targetId': '259125845563242502', - 'target': {}, + 'target': { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }, 'userId': '5e5ea5c16897e', 'userName': 'Aegon Targaryen', 'topicId': '259125845563242502', @@ -1058,7 +1264,16 @@ void main() { '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'targetId': '259125845563242502', - 'target': {}, + 'target': { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }, 'userId': '5e5ea5c16897e', 'userName': 'Aegon Targaryen', 'topicId': '259125845563242502', diff --git a/test/services/sites_test.dart b/test/services/sites_test.dart index be65bbf9..e10012eb 100644 --- a/test/services/sites_test.dart +++ b/test/services/sites_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @@ -112,8 +108,8 @@ void main() { final response = await sites.create( siteId: '', name: '', - framework: 'analog', - buildRuntime: 'node-14.5', + framework: enums.Framework.analog, + buildRuntime: enums.BuildRuntime.node145, ); expect(response, isA()); @@ -239,7 +235,7 @@ void main() { final response = await sites.update( siteId: '', name: '', - framework: 'analog', + framework: enums.Framework.analog, ); expect(response, isA()); @@ -500,7 +496,7 @@ void main() { final response = await sites.createVcsDeployment( siteId: '', - type: 'branch', + type: enums.VCSDeploymentType.branch, reference: '', ); expect(response, isA()); @@ -649,6 +645,7 @@ void main() { '\$updatedAt': '2020-10-15T06:38:00.000+00:00', '\$permissions': [], 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', 'trigger': 'http', 'status': 'processing', 'requestMethod': 'GET', diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index c2a81fab..27f51037 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart new file mode 100644 index 00000000..6122fd6a --- /dev/null +++ b/test/services/tables_db_test.dart @@ -0,0 +1,1228 @@ +import 'package:test/test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; +import 'package:dart_appwrite/src/enums.dart'; +import 'package:dart_appwrite/src/response.dart'; +import 'dart:typed_data'; +import 'package:dart_appwrite/dart_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) 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('TablesDB test', () { + late MockClient client; + late TablesDB tablesDB; + + setUp(() { + client = MockClient(); + tablesDB = TablesDB(client); + }); + + test('test method list()', () async { + final Map data = { + 'total': 5, + 'databases': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.list( + ); + expect(response, isA()); + + }); + + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.create( + databaseId: '', + name: '', + ); + expect(response, isA()); + + }); + + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.get( + databaseId: '', + ); + expect(response, isA()); + + }); + + test('test method update()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.update( + databaseId: '', + name: '', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.delete( + databaseId: '', + ); + }); + + test('test method listTables()', () async { + final Map data = { + 'total': 5, + 'tables': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.listTables( + databaseId: '', + ); + expect(response, isA()); + + }); + + test('test method createTable()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createTable( + databaseId: '', + tableId: '', + name: '', + ); + expect(response, isA()); + + }); + + test('test method getTable()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.getTable( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + + }); + + test('test method updateTable()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateTable( + databaseId: '', + tableId: '', + name: '', + ); + expect(response, isA()); + + }); + + test('test method deleteTable()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteTable( + databaseId: '', + tableId: '', + ); + }); + + test('test method listColumns()', () async { + final Map data = { + 'total': 5, + 'columns': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.listColumns( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + + }); + + test('test method createBooleanColumn()', () async { + final Map data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createBooleanColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateBooleanColumn()', () async { + final Map data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateBooleanColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + xdefault: true, + ); + expect(response, isA()); + + }); + + test('test method createDatetimeColumn()', () async { + final Map data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'datetime',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createDatetimeColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateDatetimeColumn()', () async { + final Map data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'datetime',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateDatetimeColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + xdefault: '', + ); + expect(response, isA()); + + }); + + test('test method createEmailColumn()', () async { + final Map data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'email',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createEmailColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateEmailColumn()', () async { + final Map data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'email',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateEmailColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + xdefault: 'email@example.com', + ); + expect(response, isA()); + + }); + + test('test method createEnumColumn()', () async { + final Map data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'elements': [], + 'format': 'enum',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createEnumColumn( + databaseId: '', + tableId: '', + key: '', + elements: [], + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateEnumColumn()', () async { + final Map data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'elements': [], + 'format': 'enum',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateEnumColumn( + databaseId: '', + tableId: '', + key: '', + elements: [], + xrequired: true, + xdefault: '', + ); + expect(response, isA()); + + }); + + test('test method createFloatColumn()', () async { + final Map data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createFloatColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateFloatColumn()', () async { + final Map data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateFloatColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + xdefault: 1.0, + ); + expect(response, isA()); + + }); + + test('test method createIntegerColumn()', () async { + final Map data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createIntegerColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateIntegerColumn()', () async { + final Map data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateIntegerColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + xdefault: 1, + ); + expect(response, isA()); + + }); + + test('test method createIpColumn()', () async { + final Map data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'ip',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createIpColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateIpColumn()', () async { + final Map data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'ip',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateIpColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + xdefault: '', + ); + expect(response, isA()); + + }); + + test('test method createRelationshipColumn()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'relatedTable': 'table', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createRelationshipColumn( + databaseId: '', + tableId: '', + relatedTableId: '', + type: enums.RelationshipType.oneToOne, + ); + expect(response, isA()); + + }); + + test('test method createStringColumn()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createStringColumn( + databaseId: '', + tableId: '', + key: '', + size: 1, + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateStringColumn()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateStringColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + xdefault: '', + ); + expect(response, isA()); + + }); + + test('test method createUrlColumn()', () async { + final Map data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'url',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createUrlColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateUrlColumn()', () async { + final Map data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'url',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateUrlColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + xdefault: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method getColumn()', () async { + final data = ''; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.getColumn( + databaseId: '', + tableId: '', + key: '', + ); + }); + + test('test method deleteColumn()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteColumn( + databaseId: '', + tableId: '', + key: '', + ); + }); + + test('test method updateRelationshipColumn()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'relatedTable': 'table', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateRelationshipColumn( + databaseId: '', + tableId: '', + key: '', + ); + expect(response, isA()); + + }); + + test('test method listIndexes()', () async { + final Map data = { + 'total': 5, + 'indexes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.listIndexes( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + + }); + + test('test method createIndex()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'columns': [], + 'lengths': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createIndex( + databaseId: '', + tableId: '', + key: '', + type: enums.IndexType.key, + columns: [], + ); + expect(response, isA()); + + }); + + test('test method getIndex()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'columns': [], + 'lengths': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.getIndex( + databaseId: '', + tableId: '', + key: '', + ); + expect(response, isA()); + + }); + + test('test method deleteIndex()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteIndex( + databaseId: '', + tableId: '', + key: '', + ); + }); + + test('test method listRows()', () async { + final Map data = { + 'total': 5, + 'rows': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.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 tablesDB.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 tablesDB.createRows( + databaseId: '', + tableId: '', + rows: [], + ); + expect(response, isA()); + + }); + + test('test method upsertRows()', () async { + final Map data = { + 'total': 5, + 'rows': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.upsertRows( + databaseId: '', + tableId: '', + rows: [], + ); + expect(response, isA()); + + }); + + test('test method updateRows()', () async { + final Map data = { + 'total': 5, + 'rows': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateRows( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteRows()', () async { + final Map data = { + 'total': 5, + 'rows': [],}; + + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteRows( + databaseId: '', + tableId: '', + ); + 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 tablesDB.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 tablesDB.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 tablesDB.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 tablesDB.deleteRow( + databaseId: '', + tableId: '', + rowId: '', + ); + }); + + test('test method decrementRowColumn()', () 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 tablesDB.decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + + }); + + test('test method incrementRowColumn()', () 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 tablesDB.incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + + }); + + }); +} \ No newline at end of file diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index 891610e1..3248d30b 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } diff --git a/test/services/tokens_test.dart b/test/services/tokens_test.dart index 66aec103..1560cb59 100644 --- a/test/services/tokens_test.dart +++ b/test/services/tokens_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } diff --git a/test/services/users_test.dart b/test/services/users_test.dart index 9f05493d..e0207a53 100644 --- a/test/services/users_test.dart +++ b/test/services/users_test.dart @@ -1,6 +1,7 @@ import 'package:test/test.dart'; import 'package:mockito/mockito.dart'; import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; import 'package:dart_appwrite/src/enums.dart'; import 'package:dart_appwrite/src/response.dart'; import 'dart:typed_data'; @@ -22,12 +23,7 @@ class MockClient extends Mock implements Client { } @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { + Future webAuth(Uri url) async { return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @@ -576,6 +572,39 @@ void main() { }); + test('test method updateMFA()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updateMFA( + userId: '', + mfa: true, + ); + expect(response, isA()); + + }); + test('test method deleteMfaAuthenticator()', () async { final data = ''; @@ -586,7 +615,21 @@ void main() { final response = await users.deleteMfaAuthenticator( userId: '', - type: 'totp', + type: enums.AuthenticatorType.totp, + ); + }); + + test('test method deleteMFAAuthenticator()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.deleteMFAAuthenticator( + userId: '', + type: enums.AuthenticatorType.totp, ); }); @@ -610,6 +653,26 @@ void main() { }); + test('test method listMFAFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.listMFAFactors( + userId: '', + ); + expect(response, isA()); + + }); + test('test method getMfaRecoveryCodes()', () async { final Map data = { 'recoveryCodes': [],}; @@ -627,6 +690,23 @@ void main() { }); + test('test method getMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.getMFARecoveryCodes( + userId: '', + ); + expect(response, isA()); + + }); + test('test method updateMfaRecoveryCodes()', () async { final Map data = { 'recoveryCodes': [],}; @@ -644,6 +724,23 @@ void main() { }); + test('test method updateMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updateMFARecoveryCodes( + userId: '', + ); + expect(response, isA()); + + }); + test('test method createMfaRecoveryCodes()', () async { final Map data = { 'recoveryCodes': [],}; @@ -661,6 +758,23 @@ void main() { }); + test('test method createMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createMFARecoveryCodes( + userId: '', + ); + expect(response, isA()); + + }); + test('test method updateName()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -954,7 +1068,7 @@ void main() { final response = await users.createTarget( userId: '', targetId: '', - providerType: 'email', + providerType: enums.MessagingProviderType.email, identifier: '', ); expect(response, isA()); diff --git a/test/src/enums_test.dart b/test/src/enums_test.dart index 120ab2c9..b44b0124 100644 --- a/test/src/enums_test.dart +++ b/test/src/enums_test.dart @@ -4,9 +4,15 @@ import 'package:test/test.dart'; void main() { group('name()', () { for (final method in HttpMethod.values) { - test('returns ${method.toString().split('.').last.toUpperCase()} for $method', () { - expect(method.name(), method.toString().split('.').last.toUpperCase()); - }); + test( + 'returns ${method.toString().split('.').last.toUpperCase()} for $method', + () { + expect( + method.name(), + method.toString().split('.').last.toUpperCase(), + ); + }, + ); } }); -} \ No newline at end of file +} diff --git a/test/src/exception_test.dart b/test/src/exception_test.dart index f55782cf..6b051375 100644 --- a/test/src/exception_test.dart +++ b/test/src/exception_test.dart @@ -8,10 +8,22 @@ void main() { expect(exception1.toString(), equals('AppwriteException')); final exception2 = AppwriteException('Some error message'); - expect(exception2.toString(), equals('AppwriteException: , Some error message (0)')); + expect( + exception2.toString(), + equals('AppwriteException: , Some error message (0)'), + ); - final exception3 = AppwriteException('Invalid request', 400, 'ValidationError'); - expect(exception3.toString(), equals('AppwriteException: ValidationError, Invalid request (400)')); + final exception3 = AppwriteException( + 'Invalid request', + 400, + 'ValidationError', + ); + expect( + exception3.toString(), + equals( + 'AppwriteException: ValidationError, Invalid request (400)', + ), + ); }); }); } diff --git a/test/src/input_file_test.dart b/test/src/input_file_test.dart index ccbd4387..876921e6 100644 --- a/test/src/input_file_test.dart +++ b/test/src/input_file_test.dart @@ -36,7 +36,10 @@ void main() { }); test('creates InputFile from bytes', () { - final inputFile = InputFile.fromBytes(bytes: [1, 2, 3], filename: 'file.txt'); + final inputFile = InputFile.fromBytes( + bytes: [1, 2, 3], + filename: 'file.txt', + ); expect(inputFile.path, isNull); expect(inputFile.filename, 'file.txt'); diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart index 13a1bbb0..8e579a4a 100644 --- a/test/src/models/algo_argon2_test.dart +++ b/test/src/models/algo_argon2_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AlgoArgon2', () { - test('model', () { final model = AlgoArgon2( type: 'argon2', @@ -15,10 +14,10 @@ void main() { final map = model.toMap(); final result = AlgoArgon2.fromMap(map); - expect(result.type, 'argon2'); - expect(result.memoryCost, 65536); - expect(result.timeCost, 4); - expect(result.threads, 3); - }); + expect(result.type, 'argon2'); + expect(result.memoryCost, 65536); + expect(result.timeCost, 4); + expect(result.threads, 3); + }); }); } diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 3b3735a8..9d9117ac 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AlgoBcrypt', () { - test('model', () { final model = AlgoBcrypt( type: 'bcrypt', @@ -12,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); - expect(result.type, 'bcrypt'); - }); + expect(result.type, 'bcrypt'); + }); }); } diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index beb757ab..a8074312 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AlgoMd5', () { - test('model', () { final model = AlgoMd5( type: 'md5', @@ -12,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoMd5.fromMap(map); - expect(result.type, 'md5'); - }); + expect(result.type, 'md5'); + }); }); } diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 4dd25578..414d5658 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AlgoPhpass', () { - test('model', () { final model = AlgoPhpass( type: 'phpass', @@ -12,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoPhpass.fromMap(map); - expect(result.type, 'phpass'); - }); + expect(result.type, 'phpass'); + }); }); } diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index fe32160d..53596100 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AlgoScryptModified', () { - test('model', () { final model = AlgoScryptModified( type: 'scryptMod', @@ -15,10 +14,10 @@ void main() { final map = model.toMap(); final result = AlgoScryptModified.fromMap(map); - expect(result.type, 'scryptMod'); - expect(result.salt, 'UxLMreBr6tYyjQ=='); - expect(result.saltSeparator, 'Bw=='); - expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); - }); + expect(result.type, 'scryptMod'); + expect(result.salt, 'UxLMreBr6tYyjQ=='); + expect(result.saltSeparator, 'Bw=='); + expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + }); }); } diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart index 12ea9fa2..ead39885 100644 --- a/test/src/models/algo_scrypt_test.dart +++ b/test/src/models/algo_scrypt_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AlgoScrypt', () { - test('model', () { final model = AlgoScrypt( type: 'scrypt', @@ -16,11 +15,11 @@ void main() { final map = model.toMap(); final result = AlgoScrypt.fromMap(map); - expect(result.type, 'scrypt'); - expect(result.costCpu, 8); - expect(result.costMemory, 14); - expect(result.costParallel, 1); - expect(result.length, 64); - }); + expect(result.type, 'scrypt'); + expect(result.costCpu, 8); + expect(result.costMemory, 14); + expect(result.costParallel, 1); + expect(result.length, 64); + }); }); } diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index 1f7a7817..ff27754e 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AlgoSha', () { - test('model', () { final model = AlgoSha( type: 'sha', @@ -12,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoSha.fromMap(map); - expect(result.type, 'sha'); - }); + expect(result.type, 'sha'); + }); }); } diff --git a/test/src/models/attribute_boolean_test.dart b/test/src/models/attribute_boolean_test.dart index 58c7a3c1..39319182 100644 --- a/test/src/models/attribute_boolean_test.dart +++ b/test/src/models/attribute_boolean_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AttributeBoolean', () { - test('model', () { final model = AttributeBoolean( key: 'isEnabled', @@ -18,13 +17,13 @@ void main() { final map = model.toMap(); final result = AttributeBoolean.fromMap(map); - expect(result.key, 'isEnabled'); - expect(result.type, 'boolean'); - expect(result.status, 'available'); - expect(result.error, 'string'); - expect(result.xrequired, true); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.key, 'isEnabled'); + expect(result.type, 'boolean'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/attribute_datetime_test.dart b/test/src/models/attribute_datetime_test.dart index c5e91ad7..42ae6cc6 100644 --- a/test/src/models/attribute_datetime_test.dart +++ b/test/src/models/attribute_datetime_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AttributeDatetime', () { - test('model', () { final model = AttributeDatetime( key: 'birthDay', @@ -19,14 +18,14 @@ void main() { final map = model.toMap(); final result = AttributeDatetime.fromMap(map); - expect(result.key, 'birthDay'); - expect(result.type, 'datetime'); - expect(result.status, 'available'); - expect(result.error, 'string'); - expect(result.xrequired, true); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.format, 'datetime'); - }); + expect(result.key, 'birthDay'); + expect(result.type, 'datetime'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.format, 'datetime'); + }); }); } diff --git a/test/src/models/attribute_email_test.dart b/test/src/models/attribute_email_test.dart index b13a4f56..8bff3e81 100644 --- a/test/src/models/attribute_email_test.dart +++ b/test/src/models/attribute_email_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AttributeEmail', () { - test('model', () { final model = AttributeEmail( key: 'userEmail', @@ -19,14 +18,14 @@ void main() { final map = model.toMap(); final result = AttributeEmail.fromMap(map); - expect(result.key, 'userEmail'); - expect(result.type, 'string'); - expect(result.status, 'available'); - expect(result.error, 'string'); - expect(result.xrequired, true); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.format, 'email'); - }); + expect(result.key, 'userEmail'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.format, 'email'); + }); }); } diff --git a/test/src/models/attribute_enum_test.dart b/test/src/models/attribute_enum_test.dart index b7952fb6..cf741a60 100644 --- a/test/src/models/attribute_enum_test.dart +++ b/test/src/models/attribute_enum_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AttributeEnum', () { - test('model', () { final model = AttributeEnum( key: 'status', @@ -20,15 +19,15 @@ void main() { final map = model.toMap(); final result = AttributeEnum.fromMap(map); - expect(result.key, 'status'); - expect(result.type, 'string'); - expect(result.status, 'available'); - expect(result.error, 'string'); - expect(result.xrequired, true); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.elements, []); - expect(result.format, 'enum'); - }); + expect(result.key, 'status'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.elements, []); + expect(result.format, 'enum'); + }); }); } diff --git a/test/src/models/attribute_float_test.dart b/test/src/models/attribute_float_test.dart index 359784b7..1dbf3078 100644 --- a/test/src/models/attribute_float_test.dart +++ b/test/src/models/attribute_float_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AttributeFloat', () { - test('model', () { final model = AttributeFloat( key: 'percentageCompleted', @@ -18,13 +17,13 @@ void main() { final map = model.toMap(); final result = AttributeFloat.fromMap(map); - expect(result.key, 'percentageCompleted'); - expect(result.type, 'double'); - expect(result.status, 'available'); - expect(result.error, 'string'); - expect(result.xrequired, true); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.key, 'percentageCompleted'); + expect(result.type, 'double'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/attribute_integer_test.dart b/test/src/models/attribute_integer_test.dart index 4ccb94f0..9baa191f 100644 --- a/test/src/models/attribute_integer_test.dart +++ b/test/src/models/attribute_integer_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AttributeInteger', () { - test('model', () { final model = AttributeInteger( key: 'count', @@ -18,13 +17,13 @@ void main() { final map = model.toMap(); final result = AttributeInteger.fromMap(map); - expect(result.key, 'count'); - expect(result.type, 'integer'); - expect(result.status, 'available'); - expect(result.error, 'string'); - expect(result.xrequired, true); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.key, 'count'); + expect(result.type, 'integer'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/attribute_ip_test.dart b/test/src/models/attribute_ip_test.dart index 42a23d9f..f1e7c993 100644 --- a/test/src/models/attribute_ip_test.dart +++ b/test/src/models/attribute_ip_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AttributeIp', () { - test('model', () { final model = AttributeIp( key: 'ipAddress', @@ -19,14 +18,14 @@ void main() { final map = model.toMap(); final result = AttributeIp.fromMap(map); - expect(result.key, 'ipAddress'); - expect(result.type, 'string'); - expect(result.status, 'available'); - expect(result.error, 'string'); - expect(result.xrequired, true); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.format, 'ip'); - }); + expect(result.key, 'ipAddress'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.format, 'ip'); + }); }); } diff --git a/test/src/models/attribute_list_test.dart b/test/src/models/attribute_list_test.dart index e4af0248..3b2384ff 100644 --- a/test/src/models/attribute_list_test.dart +++ b/test/src/models/attribute_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AttributeList', () { - test('model', () { final model = AttributeList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = AttributeList.fromMap(map); - expect(result.total, 5); - expect(result.attributes, []); - }); + expect(result.total, 5); + expect(result.attributes, []); + }); }); } diff --git a/test/src/models/attribute_relationship_test.dart b/test/src/models/attribute_relationship_test.dart index 1a75dbdd..4ee29944 100644 --- a/test/src/models/attribute_relationship_test.dart +++ b/test/src/models/attribute_relationship_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AttributeRelationship', () { - test('model', () { final model = AttributeRelationship( key: 'fullName', @@ -24,19 +23,19 @@ void main() { final map = model.toMap(); final result = AttributeRelationship.fromMap(map); - expect(result.key, 'fullName'); - expect(result.type, 'string'); - expect(result.status, 'available'); - expect(result.error, 'string'); - expect(result.xrequired, true); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.relatedCollection, 'collection'); - expect(result.relationType, 'oneToOne|oneToMany|manyToOne|manyToMany'); - expect(result.twoWay, true); - expect(result.twoWayKey, 'string'); - expect(result.onDelete, 'restrict|cascade|setNull'); - expect(result.side, 'parent|child'); - }); + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.relatedCollection, 'collection'); + expect(result.relationType, 'oneToOne|oneToMany|manyToOne|manyToMany'); + expect(result.twoWay, true); + expect(result.twoWayKey, 'string'); + expect(result.onDelete, 'restrict|cascade|setNull'); + expect(result.side, 'parent|child'); + }); }); } diff --git a/test/src/models/attribute_string_test.dart b/test/src/models/attribute_string_test.dart index ca1008ac..f5e93640 100644 --- a/test/src/models/attribute_string_test.dart +++ b/test/src/models/attribute_string_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AttributeString', () { - test('model', () { final model = AttributeString( key: 'fullName', @@ -19,14 +18,14 @@ void main() { final map = model.toMap(); final result = AttributeString.fromMap(map); - expect(result.key, 'fullName'); - expect(result.type, 'string'); - expect(result.status, 'available'); - expect(result.error, 'string'); - expect(result.xrequired, true); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.size, 128); - }); + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.size, 128); + }); }); } diff --git a/test/src/models/attribute_url_test.dart b/test/src/models/attribute_url_test.dart index 3ef3e40a..4cfdbc40 100644 --- a/test/src/models/attribute_url_test.dart +++ b/test/src/models/attribute_url_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('AttributeUrl', () { - test('model', () { final model = AttributeUrl( key: 'githubUrl', @@ -19,14 +18,14 @@ void main() { final map = model.toMap(); final result = AttributeUrl.fromMap(map); - expect(result.key, 'githubUrl'); - expect(result.type, 'string'); - expect(result.status, 'available'); - expect(result.error, 'string'); - expect(result.xrequired, true); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.format, 'url'); - }); + expect(result.key, 'githubUrl'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.format, 'url'); + }); }); } diff --git a/test/src/models/bucket_list_test.dart b/test/src/models/bucket_list_test.dart index 3290c390..b1200cb6 100644 --- a/test/src/models/bucket_list_test.dart +++ b/test/src/models/bucket_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('BucketList', () { - test('model', () { final model = BucketList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = BucketList.fromMap(map); - expect(result.total, 5); - expect(result.buckets, []); - }); + expect(result.total, 5); + expect(result.buckets, []); + }); }); } diff --git a/test/src/models/bucket_test.dart b/test/src/models/bucket_test.dart index 3ead5259..f1686882 100644 --- a/test/src/models/bucket_test.dart +++ b/test/src/models/bucket_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Bucket', () { - test('model', () { final model = Bucket( $id: '5e5ea5c16897e', @@ -23,18 +22,18 @@ void main() { final map = model.toMap(); final result = Bucket.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - 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, []); - expect(result.fileSecurity, true); - expect(result.name, 'Documents'); - expect(result.enabled, true); - expect(result.maximumFileSize, 100); - expect(result.allowedFileExtensions, []); - expect(result.compression, 'gzip'); - expect(result.encryption, true); - expect(result.antivirus, true); - }); + expect(result.$id, '5e5ea5c16897e'); + 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, []); + expect(result.fileSecurity, true); + expect(result.name, 'Documents'); + expect(result.enabled, true); + expect(result.maximumFileSize, 100); + expect(result.allowedFileExtensions, []); + expect(result.compression, 'gzip'); + expect(result.encryption, true); + expect(result.antivirus, true); + }); }); } diff --git a/test/src/models/collection_list_test.dart b/test/src/models/collection_list_test.dart index 0842a382..4ba89d51 100644 --- a/test/src/models/collection_list_test.dart +++ b/test/src/models/collection_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('CollectionList', () { - test('model', () { final model = CollectionList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = CollectionList.fromMap(map); - expect(result.total, 5); - expect(result.collections, []); - }); + expect(result.total, 5); + expect(result.collections, []); + }); }); } diff --git a/test/src/models/collection_test.dart b/test/src/models/collection_test.dart index 9eeb507f..4a7e4277 100644 --- a/test/src/models/collection_test.dart +++ b/test/src/models/collection_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Collection', () { - test('model', () { final model = Collection( $id: '5e5ea5c16897e', @@ -21,16 +20,16 @@ void main() { final map = model.toMap(); final result = Collection.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - 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, []); - expect(result.databaseId, '5e5ea5c16897e'); - expect(result.name, 'My Collection'); - expect(result.enabled, true); - expect(result.documentSecurity, true); - expect(result.attributes, []); - expect(result.indexes, []); - }); + expect(result.$id, '5e5ea5c16897e'); + 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, []); + expect(result.databaseId, '5e5ea5c16897e'); + expect(result.name, 'My Collection'); + expect(result.enabled, true); + expect(result.documentSecurity, true); + expect(result.attributes, []); + expect(result.indexes, []); + }); }); } diff --git a/test/src/models/column_boolean_test.dart b/test/src/models/column_boolean_test.dart new file mode 100644 index 00000000..578d1ffc --- /dev/null +++ b/test/src/models/column_boolean_test.dart @@ -0,0 +1,29 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnBoolean', () { + test('model', () { + final model = ColumnBoolean( + key: 'isEnabled', + type: 'boolean', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = ColumnBoolean.fromMap(map); + + expect(result.key, 'isEnabled'); + expect(result.type, 'boolean'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); + }); +} diff --git a/test/src/models/column_datetime_test.dart b/test/src/models/column_datetime_test.dart new file mode 100644 index 00000000..9efa877f --- /dev/null +++ b/test/src/models/column_datetime_test.dart @@ -0,0 +1,31 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnDatetime', () { + test('model', () { + final model = ColumnDatetime( + key: 'birthDay', + type: 'datetime', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + format: 'datetime', + ); + + final map = model.toMap(); + final result = ColumnDatetime.fromMap(map); + + expect(result.key, 'birthDay'); + expect(result.type, 'datetime'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.format, 'datetime'); + }); + }); +} diff --git a/test/src/models/column_email_test.dart b/test/src/models/column_email_test.dart new file mode 100644 index 00000000..6af65d64 --- /dev/null +++ b/test/src/models/column_email_test.dart @@ -0,0 +1,31 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnEmail', () { + test('model', () { + final model = ColumnEmail( + key: 'userEmail', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + format: 'email', + ); + + final map = model.toMap(); + final result = ColumnEmail.fromMap(map); + + expect(result.key, 'userEmail'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.format, 'email'); + }); + }); +} diff --git a/test/src/models/column_enum_test.dart b/test/src/models/column_enum_test.dart new file mode 100644 index 00000000..8d4f4772 --- /dev/null +++ b/test/src/models/column_enum_test.dart @@ -0,0 +1,33 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnEnum', () { + test('model', () { + final model = ColumnEnum( + key: 'status', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + elements: [], + format: 'enum', + ); + + final map = model.toMap(); + final result = ColumnEnum.fromMap(map); + + expect(result.key, 'status'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.elements, []); + expect(result.format, 'enum'); + }); + }); +} diff --git a/test/src/models/column_float_test.dart b/test/src/models/column_float_test.dart new file mode 100644 index 00000000..316b566b --- /dev/null +++ b/test/src/models/column_float_test.dart @@ -0,0 +1,29 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnFloat', () { + test('model', () { + final model = ColumnFloat( + key: 'percentageCompleted', + type: 'double', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = ColumnFloat.fromMap(map); + + expect(result.key, 'percentageCompleted'); + expect(result.type, 'double'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); + }); +} diff --git a/test/src/models/column_index_list_test.dart b/test/src/models/column_index_list_test.dart new file mode 100644 index 00000000..571793aa --- /dev/null +++ b/test/src/models/column_index_list_test.dart @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnIndexList', () { + test('model', () { + final model = ColumnIndexList( + total: 5, + indexes: [], + ); + + final map = model.toMap(); + final result = ColumnIndexList.fromMap(map); + + expect(result.total, 5); + expect(result.indexes, []); + }); + }); +} diff --git a/test/src/models/column_index_test.dart b/test/src/models/column_index_test.dart new file mode 100644 index 00000000..daa40c71 --- /dev/null +++ b/test/src/models/column_index_test.dart @@ -0,0 +1,33 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnIndex', () { + test('model', () { + final model = ColumnIndex( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + key: 'index1', + type: 'primary', + status: 'available', + error: 'string', + columns: [], + lengths: [], + ); + + final map = model.toMap(); + final result = ColumnIndex.fromMap(map); + + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.key, 'index1'); + expect(result.type, 'primary'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.columns, []); + expect(result.lengths, []); + }); + }); +} diff --git a/test/src/models/column_integer_test.dart b/test/src/models/column_integer_test.dart new file mode 100644 index 00000000..911588d3 --- /dev/null +++ b/test/src/models/column_integer_test.dart @@ -0,0 +1,29 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnInteger', () { + test('model', () { + final model = ColumnInteger( + key: 'count', + type: 'integer', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = ColumnInteger.fromMap(map); + + expect(result.key, 'count'); + expect(result.type, 'integer'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); + }); +} diff --git a/test/src/models/column_ip_test.dart b/test/src/models/column_ip_test.dart new file mode 100644 index 00000000..a1153e85 --- /dev/null +++ b/test/src/models/column_ip_test.dart @@ -0,0 +1,31 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnIp', () { + test('model', () { + final model = ColumnIp( + key: 'ipAddress', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + format: 'ip', + ); + + final map = model.toMap(); + final result = ColumnIp.fromMap(map); + + expect(result.key, 'ipAddress'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.format, 'ip'); + }); + }); +} diff --git a/test/src/models/column_list_test.dart b/test/src/models/column_list_test.dart new file mode 100644 index 00000000..6d8be211 --- /dev/null +++ b/test/src/models/column_list_test.dart @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnList', () { + test('model', () { + final model = ColumnList( + total: 5, + columns: [], + ); + + final map = model.toMap(); + final result = ColumnList.fromMap(map); + + expect(result.total, 5); + expect(result.columns, []); + }); + }); +} diff --git a/test/src/models/column_relationship_test.dart b/test/src/models/column_relationship_test.dart new file mode 100644 index 00000000..3de4bc71 --- /dev/null +++ b/test/src/models/column_relationship_test.dart @@ -0,0 +1,41 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnRelationship', () { + test('model', () { + final model = ColumnRelationship( + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + relatedTable: 'table', + relationType: 'oneToOne|oneToMany|manyToOne|manyToMany', + twoWay: true, + twoWayKey: 'string', + onDelete: 'restrict|cascade|setNull', + side: 'parent|child', + ); + + final map = model.toMap(); + final result = ColumnRelationship.fromMap(map); + + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.relatedTable, 'table'); + expect(result.relationType, 'oneToOne|oneToMany|manyToOne|manyToMany'); + expect(result.twoWay, true); + expect(result.twoWayKey, 'string'); + expect(result.onDelete, 'restrict|cascade|setNull'); + expect(result.side, 'parent|child'); + }); + }); +} diff --git a/test/src/models/column_string_test.dart b/test/src/models/column_string_test.dart new file mode 100644 index 00000000..e6c11716 --- /dev/null +++ b/test/src/models/column_string_test.dart @@ -0,0 +1,31 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnString', () { + test('model', () { + final model = ColumnString( + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + size: 128, + ); + + final map = model.toMap(); + final result = ColumnString.fromMap(map); + + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.size, 128); + }); + }); +} diff --git a/test/src/models/column_url_test.dart b/test/src/models/column_url_test.dart new file mode 100644 index 00000000..ad8cde9f --- /dev/null +++ b/test/src/models/column_url_test.dart @@ -0,0 +1,31 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnUrl', () { + test('model', () { + final model = ColumnUrl( + key: 'githubUrl', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + format: 'url', + ); + + final map = model.toMap(); + final result = ColumnUrl.fromMap(map); + + expect(result.key, 'githubUrl'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.format, 'url'); + }); + }); +} diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart index 095989f7..2f78416f 100644 --- a/test/src/models/continent_list_test.dart +++ b/test/src/models/continent_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('ContinentList', () { - test('model', () { final model = ContinentList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = ContinentList.fromMap(map); - expect(result.total, 5); - expect(result.continents, []); - }); + expect(result.total, 5); + expect(result.continents, []); + }); }); } diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index 90b1a6bd..1cf934a3 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Continent', () { - test('model', () { final model = Continent( name: 'Europe', @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = Continent.fromMap(map); - expect(result.name, 'Europe'); - expect(result.code, 'EU'); - }); + expect(result.name, 'Europe'); + expect(result.code, 'EU'); + }); }); } diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart index 5aa53423..1c5ee7cc 100644 --- a/test/src/models/country_list_test.dart +++ b/test/src/models/country_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('CountryList', () { - test('model', () { final model = CountryList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = CountryList.fromMap(map); - expect(result.total, 5); - expect(result.countries, []); - }); + expect(result.total, 5); + expect(result.countries, []); + }); }); } diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index 2465bbd3..f41d3cdb 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Country', () { - test('model', () { final model = Country( name: 'United States', @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = Country.fromMap(map); - expect(result.name, 'United States'); - expect(result.code, 'US'); - }); + expect(result.name, 'United States'); + expect(result.code, 'US'); + }); }); } diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart index 93215f53..3612e8b0 100644 --- a/test/src/models/currency_list_test.dart +++ b/test/src/models/currency_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('CurrencyList', () { - test('model', () { final model = CurrencyList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = CurrencyList.fromMap(map); - expect(result.total, 5); - expect(result.currencies, []); - }); + expect(result.total, 5); + expect(result.currencies, []); + }); }); } diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart index 1fa35e61..35e511f9 100644 --- a/test/src/models/currency_test.dart +++ b/test/src/models/currency_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Currency', () { - test('model', () { final model = Currency( symbol: '\$', @@ -18,13 +17,13 @@ void main() { final map = model.toMap(); final result = Currency.fromMap(map); - expect(result.symbol, '\$'); - expect(result.name, 'US dollar'); - expect(result.symbolNative, '\$'); - expect(result.decimalDigits, 2); - expect(result.rounding, 0); - expect(result.code, 'USD'); - expect(result.namePlural, 'US dollars'); - }); + expect(result.symbol, '\$'); + expect(result.name, 'US dollar'); + expect(result.symbolNative, '\$'); + expect(result.decimalDigits, 2); + expect(result.rounding, 0); + expect(result.code, 'USD'); + expect(result.namePlural, 'US dollars'); + }); }); } diff --git a/test/src/models/database_list_test.dart b/test/src/models/database_list_test.dart index eaa0cb53..15e44083 100644 --- a/test/src/models/database_list_test.dart +++ b/test/src/models/database_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('DatabaseList', () { - test('model', () { final model = DatabaseList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = DatabaseList.fromMap(map); - expect(result.total, 5); - expect(result.databases, []); - }); + expect(result.total, 5); + expect(result.databases, []); + }); }); } diff --git a/test/src/models/database_test.dart b/test/src/models/database_test.dart index 17fdef8c..191a10fd 100644 --- a/test/src/models/database_test.dart +++ b/test/src/models/database_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Database', () { - test('model', () { final model = Database( $id: '5e5ea5c16897e', @@ -11,16 +10,18 @@ void main() { $createdAt: '2020-10-15T06:38:00.000+00:00', $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, + type: 'legacy', ); final map = model.toMap(); final result = Database.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.name, 'My Database'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.enabled, true); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.name, 'My Database'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.enabled, true); + expect(result.type, 'legacy'); + }); }); } diff --git a/test/src/models/deployment_list_test.dart b/test/src/models/deployment_list_test.dart index 1021fb7b..a0689888 100644 --- a/test/src/models/deployment_list_test.dart +++ b/test/src/models/deployment_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('DeploymentList', () { - test('model', () { final model = DeploymentList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = DeploymentList.fromMap(map); - expect(result.total, 5); - expect(result.deployments, []); - }); + expect(result.total, 5); + expect(result.deployments, []); + }); }); } diff --git a/test/src/models/deployment_test.dart b/test/src/models/deployment_test.dart index 46d7200c..80c2c9b9 100644 --- a/test/src/models/deployment_test.dart +++ b/test/src/models/deployment_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Deployment', () { - test('model', () { final model = Deployment( $id: '5e5ea5c16897e', @@ -38,33 +37,33 @@ void main() { final map = model.toMap(); final result = Deployment.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.type, 'vcs'); - expect(result.resourceId, '5e5ea6g16897e'); - expect(result.resourceType, 'functions'); - expect(result.entrypoint, 'index.js'); - expect(result.sourceSize, 128); - expect(result.buildSize, 128); - expect(result.totalSize, 128); - expect(result.buildId, '5e5ea5c16897e'); - expect(result.activate, true); - expect(result.screenshotLight, '5e5ea5c16897e'); - expect(result.screenshotDark, '5e5ea5c16897e'); - expect(result.status, 'ready'); - expect(result.buildLogs, 'Compiling source files...'); - expect(result.buildDuration, 128); - expect(result.providerRepositoryName, 'database'); - expect(result.providerRepositoryOwner, 'utopia'); - expect(result.providerRepositoryUrl, 'https://github.com/vermakhushboo/g4-node-function'); - expect(result.providerBranch, '0.7.x'); - expect(result.providerCommitHash, '7c3f25d'); - expect(result.providerCommitAuthorUrl, 'https://github.com/vermakhushboo'); - expect(result.providerCommitAuthor, 'Khushboo Verma'); - expect(result.providerCommitMessage, 'Update index.js'); - expect(result.providerCommitUrl, 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb'); - expect(result.providerBranchUrl, 'https://github.com/vermakhushboo/appwrite/tree/0.7.x'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.type, 'vcs'); + expect(result.resourceId, '5e5ea6g16897e'); + expect(result.resourceType, 'functions'); + expect(result.entrypoint, 'index.js'); + expect(result.sourceSize, 128); + expect(result.buildSize, 128); + expect(result.totalSize, 128); + expect(result.buildId, '5e5ea5c16897e'); + expect(result.activate, true); + expect(result.screenshotLight, '5e5ea5c16897e'); + expect(result.screenshotDark, '5e5ea5c16897e'); + expect(result.status, 'ready'); + expect(result.buildLogs, 'Compiling source files...'); + expect(result.buildDuration, 128); + expect(result.providerRepositoryName, 'database'); + expect(result.providerRepositoryOwner, 'utopia'); + expect(result.providerRepositoryUrl, 'https://github.com/vermakhushboo/g4-node-function'); + expect(result.providerBranch, '0.7.x'); + expect(result.providerCommitHash, '7c3f25d'); + expect(result.providerCommitAuthorUrl, 'https://github.com/vermakhushboo'); + expect(result.providerCommitAuthor, 'Khushboo Verma'); + expect(result.providerCommitMessage, 'Update index.js'); + expect(result.providerCommitUrl, 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb'); + expect(result.providerBranchUrl, 'https://github.com/vermakhushboo/appwrite/tree/0.7.x'); + }); }); } diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart index f25a98fc..b2dab5c4 100644 --- a/test/src/models/document_list_test.dart +++ b/test/src/models/document_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('DocumentList', () { - test('model', () { final model = DocumentList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = DocumentList.fromMap(map); - expect(result.total, 5); - expect(result.documents, []); - }); + expect(result.total, 5); + expect(result.documents, []); + }); }); } diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart index 487a1b6e..b86aebbd 100644 --- a/test/src/models/document_test.dart +++ b/test/src/models/document_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Document', () { - test('model', () { final model = Document( $id: '5e5ea5c16897e', @@ -19,13 +18,13 @@ void main() { final map = model.toMap(); final result = Document.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, 1); - expect(result.$collectionId, '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, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, 1); + expect(result.$collectionId, '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, []); + }); }); } diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart index fe10bf3f..6bda2fa5 100644 --- a/test/src/models/execution_list_test.dart +++ b/test/src/models/execution_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('ExecutionList', () { - test('model', () { final model = ExecutionList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = ExecutionList.fromMap(map); - expect(result.total, 5); - expect(result.executions, []); - }); + expect(result.total, 5); + expect(result.executions, []); + }); }); } diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index 67e108b0..01ff6290 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Execution', () { - test('model', () { final model = Execution( $id: '5e5ea5c16897e', @@ -11,6 +10,7 @@ void main() { $updatedAt: '2020-10-15T06:38:00.000+00:00', $permissions: [], functionId: '5e5ea6g16897e', + deploymentId: '5e5ea5c16897e', trigger: 'http', status: 'processing', requestMethod: 'GET', @@ -27,22 +27,23 @@ void main() { final map = model.toMap(); final result = Execution.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - 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, []); - expect(result.functionId, '5e5ea6g16897e'); - expect(result.trigger, 'http'); - expect(result.status, 'processing'); - expect(result.requestMethod, 'GET'); - expect(result.requestPath, '/articles?id=5'); - expect(result.requestHeaders, []); - expect(result.responseStatusCode, 200); - expect(result.responseBody, ''); - expect(result.responseHeaders, []); - expect(result.logs, ''); - expect(result.errors, ''); - expect(result.duration, 0.4); - }); + expect(result.$id, '5e5ea5c16897e'); + 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, []); + expect(result.functionId, '5e5ea6g16897e'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.trigger, 'http'); + expect(result.status, 'processing'); + expect(result.requestMethod, 'GET'); + expect(result.requestPath, '/articles?id=5'); + expect(result.requestHeaders, []); + expect(result.responseStatusCode, 200); + expect(result.responseBody, ''); + expect(result.responseHeaders, []); + expect(result.logs, ''); + expect(result.errors, ''); + expect(result.duration, 0.4); + }); }); } diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart index 5bd1c5ad..c60fac86 100644 --- a/test/src/models/file_list_test.dart +++ b/test/src/models/file_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('FileList', () { - test('model', () { final model = FileList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = FileList.fromMap(map); - expect(result.total, 5); - expect(result.files, []); - }); + expect(result.total, 5); + expect(result.files, []); + }); }); } diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart index 8d1321ea..f89314f0 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('File', () { - test('model', () { final model = File( $id: '5e5ea5c16897e', @@ -22,17 +21,17 @@ void main() { final map = model.toMap(); final result = File.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.bucketId, '5e5ea5c16897e'); - 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, []); - expect(result.name, 'Pink.png'); - expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); - expect(result.mimeType, 'image/png'); - expect(result.sizeOriginal, 17890); - expect(result.chunksTotal, 17890); - expect(result.chunksUploaded, 17890); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.bucketId, '5e5ea5c16897e'); + 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, []); + expect(result.name, 'Pink.png'); + expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); + expect(result.mimeType, 'image/png'); + expect(result.sizeOriginal, 17890); + expect(result.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + }); }); } diff --git a/test/src/models/framework_adapter_test.dart b/test/src/models/framework_adapter_test.dart index bf7e3ff3..a7b5ed65 100644 --- a/test/src/models/framework_adapter_test.dart +++ b/test/src/models/framework_adapter_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('FrameworkAdapter', () { - test('model', () { final model = FrameworkAdapter( key: 'static', @@ -16,11 +15,11 @@ void main() { final map = model.toMap(); final result = FrameworkAdapter.fromMap(map); - expect(result.key, 'static'); - expect(result.installCommand, 'npm install'); - expect(result.buildCommand, 'npm run build'); - expect(result.outputDirectory, './dist'); - expect(result.fallbackFile, 'index.html'); - }); + expect(result.key, 'static'); + expect(result.installCommand, 'npm install'); + expect(result.buildCommand, 'npm run build'); + expect(result.outputDirectory, './dist'); + expect(result.fallbackFile, 'index.html'); + }); }); } diff --git a/test/src/models/framework_list_test.dart b/test/src/models/framework_list_test.dart index aeade175..7b2a29b8 100644 --- a/test/src/models/framework_list_test.dart +++ b/test/src/models/framework_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('FrameworkList', () { - test('model', () { final model = FrameworkList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = FrameworkList.fromMap(map); - expect(result.total, 5); - expect(result.frameworks, []); - }); + expect(result.total, 5); + expect(result.frameworks, []); + }); }); } diff --git a/test/src/models/framework_test.dart b/test/src/models/framework_test.dart index 48ea96d2..20744ab0 100644 --- a/test/src/models/framework_test.dart +++ b/test/src/models/framework_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Framework', () { - test('model', () { final model = Framework( key: 'sveltekit', @@ -16,11 +15,11 @@ void main() { final map = model.toMap(); final result = Framework.fromMap(map); - expect(result.key, 'sveltekit'); - expect(result.name, 'SvelteKit'); - expect(result.buildRuntime, 'node-22'); - expect(result.runtimes, []); - expect(result.adapters, []); - }); + expect(result.key, 'sveltekit'); + expect(result.name, 'SvelteKit'); + expect(result.buildRuntime, 'node-22'); + expect(result.runtimes, []); + expect(result.adapters, []); + }); }); } diff --git a/test/src/models/function_list_test.dart b/test/src/models/function_list_test.dart index 4ed251f5..2d4d974d 100644 --- a/test/src/models/function_list_test.dart +++ b/test/src/models/function_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('FunctionList', () { - test('model', () { final model = FunctionList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = FunctionList.fromMap(map); - expect(result.total, 5); - expect(result.functions, []); - }); + expect(result.total, 5); + expect(result.functions, []); + }); }); } diff --git a/test/src/models/function_test.dart b/test/src/models/function_test.dart index 653aadce..58116683 100644 --- a/test/src/models/function_test.dart +++ b/test/src/models/function_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Func', () { - test('model', () { final model = Func( $id: '5e5ea5c16897e', @@ -39,34 +38,34 @@ void main() { final map = model.toMap(); final result = Func.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.execute, []); - expect(result.name, 'My Function'); - expect(result.enabled, true); - expect(result.live, true); - expect(result.logging, true); - expect(result.runtime, 'python-3.8'); - expect(result.deploymentId, '5e5ea5c16897e'); - expect(result.deploymentCreatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.latestDeploymentId, '5e5ea5c16897e'); - expect(result.latestDeploymentCreatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.latestDeploymentStatus, 'ready'); - expect(result.scopes, []); - expect(result.vars, []); - expect(result.events, []); - expect(result.schedule, '5 4 * * *'); - expect(result.timeout, 300); - expect(result.entrypoint, 'index.js'); - expect(result.commands, 'npm install'); - expect(result.version, 'v2'); - expect(result.installationId, '6m40at4ejk5h2u9s1hboo'); - expect(result.providerRepositoryId, 'appwrite'); - expect(result.providerBranch, 'main'); - expect(result.providerRootDirectory, 'functions/helloWorld'); - expect(result.providerSilentMode, true); - expect(result.specification, 's-1vcpu-512mb'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.execute, []); + expect(result.name, 'My Function'); + expect(result.enabled, true); + expect(result.live, true); + expect(result.logging, true); + expect(result.runtime, 'python-3.8'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.deploymentCreatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.latestDeploymentId, '5e5ea5c16897e'); + expect(result.latestDeploymentCreatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.latestDeploymentStatus, 'ready'); + expect(result.scopes, []); + expect(result.vars, []); + expect(result.events, []); + expect(result.schedule, '5 4 * * *'); + expect(result.timeout, 300); + expect(result.entrypoint, 'index.js'); + expect(result.commands, 'npm install'); + expect(result.version, 'v2'); + expect(result.installationId, '6m40at4ejk5h2u9s1hboo'); + expect(result.providerRepositoryId, 'appwrite'); + expect(result.providerBranch, 'main'); + expect(result.providerRootDirectory, 'functions/helloWorld'); + expect(result.providerSilentMode, true); + expect(result.specification, 's-1vcpu-512mb'); + }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 2791e126..d3abb67f 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Headers', () { - test('model', () { final model = Headers( name: 'Content-Type', @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = Headers.fromMap(map); - expect(result.name, 'Content-Type'); - expect(result.value, 'application/json'); - }); + expect(result.name, 'Content-Type'); + expect(result.value, 'application/json'); + }); }); } diff --git a/test/src/models/health_antivirus_test.dart b/test/src/models/health_antivirus_test.dart index 38209b33..56e3d755 100644 --- a/test/src/models/health_antivirus_test.dart +++ b/test/src/models/health_antivirus_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('HealthAntivirus', () { - test('model', () { final model = HealthAntivirus( version: '1.0.0', @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = HealthAntivirus.fromMap(map); - expect(result.version, '1.0.0'); - expect(result.status, 'online'); - }); + expect(result.version, '1.0.0'); + expect(result.status, 'online'); + }); }); } diff --git a/test/src/models/health_certificate_test.dart b/test/src/models/health_certificate_test.dart index 2277d92f..9915fd80 100644 --- a/test/src/models/health_certificate_test.dart +++ b/test/src/models/health_certificate_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('HealthCertificate', () { - test('model', () { final model = HealthCertificate( name: '/CN=www.google.com', @@ -17,12 +16,12 @@ void main() { final map = model.toMap(); final result = HealthCertificate.fromMap(map); - expect(result.name, '/CN=www.google.com'); - expect(result.subjectSN, ''); - expect(result.issuerOrganisation, ''); - expect(result.validFrom, '1704200998'); - expect(result.validTo, '1711458597'); - expect(result.signatureTypeSN, 'RSA-SHA256'); - }); + expect(result.name, '/CN=www.google.com'); + expect(result.subjectSN, ''); + expect(result.issuerOrganisation, ''); + expect(result.validFrom, '1704200998'); + expect(result.validTo, '1711458597'); + expect(result.signatureTypeSN, 'RSA-SHA256'); + }); }); } diff --git a/test/src/models/health_queue_test.dart b/test/src/models/health_queue_test.dart index 934df1bf..ab040ebd 100644 --- a/test/src/models/health_queue_test.dart +++ b/test/src/models/health_queue_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('HealthQueue', () { - test('model', () { final model = HealthQueue( size: 8, @@ -12,7 +11,7 @@ void main() { final map = model.toMap(); final result = HealthQueue.fromMap(map); - expect(result.size, 8); - }); + expect(result.size, 8); + }); }); } diff --git a/test/src/models/health_status_test.dart b/test/src/models/health_status_test.dart index bb01aa46..36be52ad 100644 --- a/test/src/models/health_status_test.dart +++ b/test/src/models/health_status_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('HealthStatus', () { - test('model', () { final model = HealthStatus( name: 'database', @@ -14,9 +13,9 @@ void main() { final map = model.toMap(); final result = HealthStatus.fromMap(map); - expect(result.name, 'database'); - expect(result.ping, 128); - expect(result.status, 'pass'); - }); + expect(result.name, 'database'); + expect(result.ping, 128); + expect(result.status, 'pass'); + }); }); } diff --git a/test/src/models/health_time_test.dart b/test/src/models/health_time_test.dart index a6c8d853..2455d9cd 100644 --- a/test/src/models/health_time_test.dart +++ b/test/src/models/health_time_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('HealthTime', () { - test('model', () { final model = HealthTime( remoteTime: 1639490751, @@ -14,9 +13,9 @@ void main() { final map = model.toMap(); final result = HealthTime.fromMap(map); - expect(result.remoteTime, 1639490751); - expect(result.localTime, 1639490844); - expect(result.diff, 93); - }); + expect(result.remoteTime, 1639490751); + expect(result.localTime, 1639490844); + expect(result.diff, 93); + }); }); } diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart index 1ecb0831..d3d477be 100644 --- a/test/src/models/identity_list_test.dart +++ b/test/src/models/identity_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('IdentityList', () { - test('model', () { final model = IdentityList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = IdentityList.fromMap(map); - expect(result.total, 5); - expect(result.identities, []); - }); + expect(result.total, 5); + expect(result.identities, []); + }); }); } diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart index 14e8ee4b..3826d358 100644 --- a/test/src/models/identity_test.dart +++ b/test/src/models/identity_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Identity', () { - test('model', () { final model = Identity( $id: '5e5ea5c16897e', @@ -21,16 +20,16 @@ void main() { final map = model.toMap(); final result = Identity.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.provider, 'email'); - expect(result.providerUid, '5e5bb8c16897e'); - expect(result.providerEmail, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.provider, 'email'); + expect(result.providerUid, '5e5bb8c16897e'); + expect(result.providerEmail, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + }); }); } diff --git a/test/src/models/index_list_test.dart b/test/src/models/index_list_test.dart index 83f5900c..fb68500c 100644 --- a/test/src/models/index_list_test.dart +++ b/test/src/models/index_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('IndexList', () { - test('model', () { final model = IndexList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = IndexList.fromMap(map); - expect(result.total, 5); - expect(result.indexes, []); - }); + expect(result.total, 5); + expect(result.indexes, []); + }); }); } diff --git a/test/src/models/index_test.dart b/test/src/models/index_test.dart index fd8b9fc9..54733385 100644 --- a/test/src/models/index_test.dart +++ b/test/src/models/index_test.dart @@ -3,30 +3,31 @@ import 'package:test/test.dart'; void main() { group('Index', () { - test('model', () { final model = Index( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', key: 'index1', type: 'primary', status: 'available', error: 'string', attributes: [], lengths: [], - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', ); final map = model.toMap(); final result = Index.fromMap(map); - expect(result.key, 'index1'); - expect(result.type, 'primary'); - expect(result.status, 'available'); - expect(result.error, 'string'); - expect(result.attributes, []); - expect(result.lengths, []); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.key, 'index1'); + expect(result.type, 'primary'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.attributes, []); + expect(result.lengths, []); + }); }); } diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index db56a032..a45857b3 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Jwt', () { - test('model', () { final model = Jwt( jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', @@ -12,7 +11,7 @@ void main() { final map = model.toMap(); final result = Jwt.fromMap(map); - expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); - }); + expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + }); }); } diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart index 8b39a179..fe8fd5ad 100644 --- a/test/src/models/language_list_test.dart +++ b/test/src/models/language_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('LanguageList', () { - test('model', () { final model = LanguageList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = LanguageList.fromMap(map); - expect(result.total, 5); - expect(result.languages, []); - }); + expect(result.total, 5); + expect(result.languages, []); + }); }); } diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart index 214a6ee8..b8c302be 100644 --- a/test/src/models/language_test.dart +++ b/test/src/models/language_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Language', () { - test('model', () { final model = Language( name: 'Italian', @@ -14,9 +13,9 @@ void main() { final map = model.toMap(); final result = Language.fromMap(map); - expect(result.name, 'Italian'); - expect(result.code, 'it'); - expect(result.nativeName, 'Italiano'); - }); + expect(result.name, 'Italian'); + expect(result.code, 'it'); + expect(result.nativeName, 'Italiano'); + }); }); } diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart index 54826544..0f1be0d2 100644 --- a/test/src/models/locale_code_list_test.dart +++ b/test/src/models/locale_code_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('LocaleCodeList', () { - test('model', () { final model = LocaleCodeList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCodeList.fromMap(map); - expect(result.total, 5); - expect(result.localeCodes, []); - }); + expect(result.total, 5); + expect(result.localeCodes, []); + }); }); } diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index 579c254a..bf3b0c2c 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('LocaleCode', () { - test('model', () { final model = LocaleCode( code: 'en-us', @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCode.fromMap(map); - expect(result.code, 'en-us'); - expect(result.name, 'US'); - }); + expect(result.code, 'en-us'); + expect(result.name, 'US'); + }); }); } diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart index 55515a36..3def85b0 100644 --- a/test/src/models/locale_test.dart +++ b/test/src/models/locale_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Locale', () { - test('model', () { final model = Locale( ip: '127.0.0.1', @@ -18,13 +17,13 @@ void main() { final map = model.toMap(); final result = Locale.fromMap(map); - expect(result.ip, '127.0.0.1'); - expect(result.countryCode, 'US'); - expect(result.country, 'United States'); - expect(result.continentCode, 'NA'); - expect(result.continent, 'North America'); - expect(result.eu, true); - expect(result.currency, 'USD'); - }); + expect(result.ip, '127.0.0.1'); + expect(result.countryCode, 'US'); + expect(result.country, 'United States'); + expect(result.continentCode, 'NA'); + expect(result.continent, 'North America'); + expect(result.eu, true); + expect(result.currency, 'USD'); + }); }); } diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart index cb84b9f8..c308bc58 100644 --- a/test/src/models/log_list_test.dart +++ b/test/src/models/log_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('LogList', () { - test('model', () { final model = LogList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = LogList.fromMap(map); - expect(result.total, 5); - expect(result.logs, []); - }); + expect(result.total, 5); + expect(result.logs, []); + }); }); } diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart index f1fe1e97..1a1464ef 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Log', () { - test('model', () { final model = Log( event: 'account.sessions.create', @@ -32,27 +31,27 @@ void main() { final map = model.toMap(); final result = Log.fromMap(map); - expect(result.event, 'account.sessions.create'); - expect(result.userId, '610fc2f985ee0'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userName, 'John Doe'); - expect(result.mode, 'admin'); - expect(result.ip, '127.0.0.1'); - expect(result.time, '2020-10-15T06:38:00.000+00:00'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.event, 'account.sessions.create'); + expect(result.userId, '610fc2f985ee0'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userName, 'John Doe'); + expect(result.mode, 'admin'); + expect(result.ip, '127.0.0.1'); + expect(result.time, '2020-10-15T06:38:00.000+00:00'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart index 47bec4b8..dd9dab7c 100644 --- a/test/src/models/membership_list_test.dart +++ b/test/src/models/membership_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('MembershipList', () { - test('model', () { final model = MembershipList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = MembershipList.fromMap(map); - expect(result.total, 5); - expect(result.memberships, []); - }); + expect(result.total, 5); + expect(result.memberships, []); + }); }); } diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index 23cfbd6c..21718671 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Membership', () { - test('model', () { final model = Membership( $id: '5e5ea5c16897e', @@ -24,19 +23,19 @@ void main() { final map = model.toMap(); final result = Membership.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'John Doe'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.teamId, '5e5ea5c16897e'); - expect(result.teamName, 'VIP'); - expect(result.invited, '2020-10-15T06:38:00.000+00:00'); - expect(result.joined, '2020-10-15T06:38:00.000+00:00'); - expect(result.confirm, true); - expect(result.mfa, true); - expect(result.roles, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'John Doe'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.teamId, '5e5ea5c16897e'); + expect(result.teamName, 'VIP'); + expect(result.invited, '2020-10-15T06:38:00.000+00:00'); + expect(result.joined, '2020-10-15T06:38:00.000+00:00'); + expect(result.confirm, true); + expect(result.mfa, true); + expect(result.roles, []); + }); }); } diff --git a/test/src/models/message_list_test.dart b/test/src/models/message_list_test.dart index 73cbf14f..cb972d14 100644 --- a/test/src/models/message_list_test.dart +++ b/test/src/models/message_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('MessageList', () { - test('model', () { final model = MessageList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = MessageList.fromMap(map); - expect(result.total, 5); - expect(result.messages, []); - }); + expect(result.total, 5); + expect(result.messages, []); + }); }); } diff --git a/test/src/models/message_test.dart b/test/src/models/message_test.dart index 44125833..64b2feac 100644 --- a/test/src/models/message_test.dart +++ b/test/src/models/message_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Message', () { - test('model', () { final model = Message( $id: '5e5ea5c16897e', @@ -21,16 +20,16 @@ void main() { final map = model.toMap(); final result = Message.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerType, 'email'); - expect(result.topics, []); - expect(result.users, []); - expect(result.targets, []); - expect(result.deliveredTotal, 1); - expect(result.data, {}); - expect(result.status, 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerType, 'email'); + expect(result.topics, []); + expect(result.users, []); + expect(result.targets, []); + expect(result.deliveredTotal, 1); + expect(result.data, {}); + expect(result.status, 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.'); + }); }); } diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart index fff934ef..e5a9e0f1 100644 --- a/test/src/models/mfa_challenge_test.dart +++ b/test/src/models/mfa_challenge_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('MfaChallenge', () { - test('model', () { final model = MfaChallenge( $id: 'bb8ea5c16897e', @@ -15,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaChallenge.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart index 59eaa005..799dd80e 100644 --- a/test/src/models/mfa_factors_test.dart +++ b/test/src/models/mfa_factors_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('MfaFactors', () { - test('model', () { final model = MfaFactors( totp: true, @@ -15,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaFactors.fromMap(map); - expect(result.totp, true); - expect(result.phone, true); - expect(result.email, true); - expect(result.recoveryCode, true); - }); + expect(result.totp, true); + expect(result.phone, true); + expect(result.email, true); + expect(result.recoveryCode, true); + }); }); } diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart index 56555ca6..759cb0f6 100644 --- a/test/src/models/mfa_recovery_codes_test.dart +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('MfaRecoveryCodes', () { - test('model', () { final model = MfaRecoveryCodes( recoveryCodes: [], @@ -12,7 +11,7 @@ void main() { final map = model.toMap(); final result = MfaRecoveryCodes.fromMap(map); - expect(result.recoveryCodes, []); - }); + expect(result.recoveryCodes, []); + }); }); } diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index cbb9e4ee..0b99593b 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('MfaType', () { - test('model', () { final model = MfaType( secret: '1', @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '1'); - expect(result.uri, '1'); - }); + expect(result.secret, '1'); + expect(result.uri, '1'); + }); }); } diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart index 1ee77396..63e07b8c 100644 --- a/test/src/models/phone_list_test.dart +++ b/test/src/models/phone_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('PhoneList', () { - test('model', () { final model = PhoneList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = PhoneList.fromMap(map); - expect(result.total, 5); - expect(result.phones, []); - }); + expect(result.total, 5); + expect(result.phones, []); + }); }); } diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart index 64ff093a..e65d3c59 100644 --- a/test/src/models/phone_test.dart +++ b/test/src/models/phone_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Phone', () { - test('model', () { final model = Phone( code: '+1', @@ -14,9 +13,9 @@ void main() { final map = model.toMap(); final result = Phone.fromMap(map); - expect(result.code, '+1'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.code, '+1'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart index f2e654dc..7f0e6ba0 100644 --- a/test/src/models/preferences_test.dart +++ b/test/src/models/preferences_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Preferences', () { - test('model', () { final model = Preferences( data: {}, diff --git a/test/src/models/provider_list_test.dart b/test/src/models/provider_list_test.dart index 954c442d..22860b71 100644 --- a/test/src/models/provider_list_test.dart +++ b/test/src/models/provider_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('ProviderList', () { - test('model', () { final model = ProviderList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = ProviderList.fromMap(map); - expect(result.total, 5); - expect(result.providers, []); - }); + expect(result.total, 5); + expect(result.providers, []); + }); }); } diff --git a/test/src/models/provider_test.dart b/test/src/models/provider_test.dart index a1ecd414..e1e5a13f 100644 --- a/test/src/models/provider_test.dart +++ b/test/src/models/provider_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Provider', () { - test('model', () { final model = Provider( $id: '5e5ea5c16897e', @@ -19,14 +18,14 @@ void main() { final map = model.toMap(); final result = Provider.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Mailgun'); - expect(result.provider, 'mailgun'); - expect(result.enabled, true); - expect(result.type, 'sms'); - expect(result.credentials, {}); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Mailgun'); + expect(result.provider, 'mailgun'); + expect(result.enabled, true); + expect(result.type, 'sms'); + expect(result.credentials, {}); + }); }); } diff --git a/test/src/models/resource_token_list_test.dart b/test/src/models/resource_token_list_test.dart index 1c1cd293..f087996a 100644 --- a/test/src/models/resource_token_list_test.dart +++ b/test/src/models/resource_token_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('ResourceTokenList', () { - test('model', () { final model = ResourceTokenList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = ResourceTokenList.fromMap(map); - expect(result.total, 5); - expect(result.tokens, []); - }); + expect(result.total, 5); + expect(result.tokens, []); + }); }); } diff --git a/test/src/models/resource_token_test.dart b/test/src/models/resource_token_test.dart index 1334f1e0..e8f7bd34 100644 --- a/test/src/models/resource_token_test.dart +++ b/test/src/models/resource_token_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('ResourceToken', () { - test('model', () { final model = ResourceToken( $id: 'bb8ea5c16897e', @@ -18,13 +17,13 @@ void main() { final map = model.toMap(); final result = ResourceToken.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.resourceId, '5e5ea5c168bb8:5e5ea5c168bb8'); - expect(result.resourceType, 'files'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.secret, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.resourceId, '5e5ea5c168bb8:5e5ea5c168bb8'); + expect(result.resourceType, 'files'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.secret, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart new file mode 100644 index 00000000..b803a52f --- /dev/null +++ b/test/src/models/row_list_test.dart @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/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 new file mode 100644 index 00000000..8b5e00f0 --- /dev/null +++ b/test/src/models/row_test.dart @@ -0,0 +1,30 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/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, []); + }); + }); +} diff --git a/test/src/models/runtime_list_test.dart b/test/src/models/runtime_list_test.dart index 1a5a266e..020b8f17 100644 --- a/test/src/models/runtime_list_test.dart +++ b/test/src/models/runtime_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('RuntimeList', () { - test('model', () { final model = RuntimeList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = RuntimeList.fromMap(map); - expect(result.total, 5); - expect(result.runtimes, []); - }); + expect(result.total, 5); + expect(result.runtimes, []); + }); }); } diff --git a/test/src/models/runtime_test.dart b/test/src/models/runtime_test.dart index 47b66744..75bda837 100644 --- a/test/src/models/runtime_test.dart +++ b/test/src/models/runtime_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Runtime', () { - test('model', () { final model = Runtime( $id: 'python-3.8', @@ -19,14 +18,14 @@ void main() { final map = model.toMap(); final result = Runtime.fromMap(map); - expect(result.$id, 'python-3.8'); - expect(result.key, 'python'); - expect(result.name, 'Python'); - expect(result.version, '3.8'); - expect(result.base, 'python:3.8-alpine'); - expect(result.image, 'appwrite\/runtime-for-python:3.8'); - expect(result.logo, 'python.png'); - expect(result.supports, []); - }); + expect(result.$id, 'python-3.8'); + expect(result.key, 'python'); + expect(result.name, 'Python'); + expect(result.version, '3.8'); + expect(result.base, 'python:3.8-alpine'); + expect(result.image, 'appwrite\/runtime-for-python:3.8'); + expect(result.logo, 'python.png'); + expect(result.supports, []); + }); }); } diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart index 1430b151..5d675fd9 100644 --- a/test/src/models/session_list_test.dart +++ b/test/src/models/session_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('SessionList', () { - test('model', () { final model = SessionList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = SessionList.fromMap(map); - expect(result.total, 5); - expect(result.sessions, []); - }); + expect(result.total, 5); + expect(result.sessions, []); + }); }); } diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index aba72b36..a52c9cf0 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Session', () { - test('model', () { final model = Session( $id: '5e5ea5c16897e', @@ -40,35 +39,35 @@ void main() { final map = model.toMap(); final result = Session.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.provider, 'email'); - expect(result.providerUid, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.ip, '127.0.0.1'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - expect(result.current, true); - expect(result.factors, []); - expect(result.secret, '5e5bb8c16897e'); - expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.provider, 'email'); + expect(result.providerUid, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.ip, '127.0.0.1'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + expect(result.current, true); + expect(result.factors, []); + expect(result.secret, '5e5bb8c16897e'); + expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/site_list_test.dart b/test/src/models/site_list_test.dart index 8aa8e225..288619b8 100644 --- a/test/src/models/site_list_test.dart +++ b/test/src/models/site_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('SiteList', () { - test('model', () { final model = SiteList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = SiteList.fromMap(map); - expect(result.total, 5); - expect(result.sites, []); - }); + expect(result.total, 5); + expect(result.sites, []); + }); }); } diff --git a/test/src/models/site_test.dart b/test/src/models/site_test.dart index 234eef88..a1e95c50 100644 --- a/test/src/models/site_test.dart +++ b/test/src/models/site_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Site', () { - test('model', () { final model = Site( $id: '5e5ea5c16897e', @@ -40,35 +39,35 @@ void main() { final map = model.toMap(); final result = Site.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'My Site'); - expect(result.enabled, true); - expect(result.live, true); - expect(result.logging, true); - expect(result.framework, 'react'); - expect(result.deploymentId, '5e5ea5c16897e'); - expect(result.deploymentCreatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.deploymentScreenshotLight, '5e5ea5c16897e'); - expect(result.deploymentScreenshotDark, '5e5ea5c16897e'); - expect(result.latestDeploymentId, '5e5ea5c16897e'); - expect(result.latestDeploymentCreatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.latestDeploymentStatus, 'ready'); - expect(result.vars, []); - expect(result.timeout, 300); - expect(result.installCommand, 'npm install'); - expect(result.buildCommand, 'npm run build'); - expect(result.outputDirectory, 'build'); - expect(result.installationId, '6m40at4ejk5h2u9s1hboo'); - expect(result.providerRepositoryId, 'appwrite'); - expect(result.providerBranch, 'main'); - expect(result.providerRootDirectory, 'sites/helloWorld'); - expect(result.providerSilentMode, true); - expect(result.specification, 's-1vcpu-512mb'); - expect(result.buildRuntime, 'node-22'); - expect(result.adapter, 'static'); - expect(result.fallbackFile, 'index.html'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'My Site'); + expect(result.enabled, true); + expect(result.live, true); + expect(result.logging, true); + expect(result.framework, 'react'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.deploymentCreatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.deploymentScreenshotLight, '5e5ea5c16897e'); + expect(result.deploymentScreenshotDark, '5e5ea5c16897e'); + expect(result.latestDeploymentId, '5e5ea5c16897e'); + expect(result.latestDeploymentCreatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.latestDeploymentStatus, 'ready'); + expect(result.vars, []); + expect(result.timeout, 300); + expect(result.installCommand, 'npm install'); + expect(result.buildCommand, 'npm run build'); + expect(result.outputDirectory, 'build'); + expect(result.installationId, '6m40at4ejk5h2u9s1hboo'); + expect(result.providerRepositoryId, 'appwrite'); + expect(result.providerBranch, 'main'); + expect(result.providerRootDirectory, 'sites/helloWorld'); + expect(result.providerSilentMode, true); + expect(result.specification, 's-1vcpu-512mb'); + expect(result.buildRuntime, 'node-22'); + expect(result.adapter, 'static'); + expect(result.fallbackFile, 'index.html'); + }); }); } diff --git a/test/src/models/specification_list_test.dart b/test/src/models/specification_list_test.dart index 57892bf1..7e2f821d 100644 --- a/test/src/models/specification_list_test.dart +++ b/test/src/models/specification_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('SpecificationList', () { - test('model', () { final model = SpecificationList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = SpecificationList.fromMap(map); - expect(result.total, 5); - expect(result.specifications, []); - }); + expect(result.total, 5); + expect(result.specifications, []); + }); }); } diff --git a/test/src/models/specification_test.dart b/test/src/models/specification_test.dart index a70667d1..b61ff9e4 100644 --- a/test/src/models/specification_test.dart +++ b/test/src/models/specification_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Specification', () { - test('model', () { final model = Specification( memory: 512, @@ -15,10 +14,10 @@ void main() { final map = model.toMap(); final result = Specification.fromMap(map); - expect(result.memory, 512); - expect(result.cpus, 1); - expect(result.enabled, true); - expect(result.slug, 's-1vcpu-512mb'); - }); + expect(result.memory, 512); + expect(result.cpus, 1); + expect(result.enabled, true); + expect(result.slug, 's-1vcpu-512mb'); + }); }); } diff --git a/test/src/models/subscriber_list_test.dart b/test/src/models/subscriber_list_test.dart index d46f0559..401a785e 100644 --- a/test/src/models/subscriber_list_test.dart +++ b/test/src/models/subscriber_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('SubscriberList', () { - test('model', () { final model = SubscriberList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = SubscriberList.fromMap(map); - expect(result.total, 5); - expect(result.subscribers, []); - }); + expect(result.total, 5); + expect(result.subscribers, []); + }); }); } diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart index ed906512..32d1f9e1 100644 --- a/test/src/models/subscriber_test.dart +++ b/test/src/models/subscriber_test.dart @@ -3,14 +3,22 @@ import 'package:test/test.dart'; void main() { group('Subscriber', () { - test('model', () { final model = Subscriber( $id: '259125845563242502', $createdAt: '2020-10-15T06:38:00.000+00:00', $updatedAt: '2020-10-15T06:38:00.000+00:00', targetId: '259125845563242502', - target: {}, + target: Target( + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + ), userId: '5e5ea5c16897e', userName: 'Aegon Targaryen', topicId: '259125845563242502', @@ -20,15 +28,14 @@ void main() { final map = model.toMap(); final result = Subscriber.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.targetId, '259125845563242502'); - expect(result.target, {}); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'Aegon Targaryen'); - expect(result.topicId, '259125845563242502'); - expect(result.providerType, 'email'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.targetId, '259125845563242502'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'Aegon Targaryen'); + expect(result.topicId, '259125845563242502'); + expect(result.providerType, 'email'); + }); }); } diff --git a/test/src/models/table_list_test.dart b/test/src/models/table_list_test.dart new file mode 100644 index 00000000..f06d5fc6 --- /dev/null +++ b/test/src/models/table_list_test.dart @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('TableList', () { + test('model', () { + final model = TableList( + total: 5, + tables: [], + ); + + final map = model.toMap(); + final result = TableList.fromMap(map); + + expect(result.total, 5); + expect(result.tables, []); + }); + }); +} diff --git a/test/src/models/table_test.dart b/test/src/models/table_test.dart new file mode 100644 index 00000000..fa7e754e --- /dev/null +++ b/test/src/models/table_test.dart @@ -0,0 +1,35 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Table', () { + test('model', () { + final model = Table( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + $permissions: [], + databaseId: '5e5ea5c16897e', + name: 'My Table', + enabled: true, + rowSecurity: true, + columns: [], + indexes: [], + ); + + final map = model.toMap(); + final result = Table.fromMap(map); + + expect(result.$id, '5e5ea5c16897e'); + 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, []); + expect(result.databaseId, '5e5ea5c16897e'); + expect(result.name, 'My Table'); + expect(result.enabled, true); + expect(result.rowSecurity, true); + expect(result.columns, []); + expect(result.indexes, []); + }); + }); +} diff --git a/test/src/models/target_list_test.dart b/test/src/models/target_list_test.dart index 5f96366d..0db975ff 100644 --- a/test/src/models/target_list_test.dart +++ b/test/src/models/target_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('TargetList', () { - test('model', () { final model = TargetList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = TargetList.fromMap(map); - expect(result.total, 5); - expect(result.targets, []); - }); + expect(result.total, 5); + expect(result.targets, []); + }); }); } diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart index 891a939b..6f864758 100644 --- a/test/src/models/target_test.dart +++ b/test/src/models/target_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Target', () { - test('model', () { final model = Target( $id: '259125845563242502', @@ -19,14 +18,14 @@ void main() { final map = model.toMap(); final result = Target.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Apple iPhone 12'); - expect(result.userId, '259125845563242502'); - expect(result.providerType, 'email'); - expect(result.identifier, 'token'); - expect(result.expired, true); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Apple iPhone 12'); + expect(result.userId, '259125845563242502'); + expect(result.providerType, 'email'); + expect(result.identifier, 'token'); + expect(result.expired, true); + }); }); } diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart index f2f044d9..f358a3c9 100644 --- a/test/src/models/team_list_test.dart +++ b/test/src/models/team_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('TeamList', () { - test('model', () { final model = TeamList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = TeamList.fromMap(map); - expect(result.total, 5); - expect(result.teams, []); - }); + expect(result.total, 5); + expect(result.teams, []); + }); }); } diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart index 904f0eea..6285fe54 100644 --- a/test/src/models/team_test.dart +++ b/test/src/models/team_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Team', () { - test('model', () { final model = Team( $id: '5e5ea5c16897e', @@ -17,12 +16,11 @@ void main() { final map = model.toMap(); final result = Team.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'VIP'); - expect(result.total, 7); - expect(result.prefs.data, {"data": {}}); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'VIP'); + expect(result.total, 7); + }); }); } diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 9e6cdb54..01cb97ff 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Token', () { - test('model', () { final model = Token( $id: 'bb8ea5c16897e', @@ -17,12 +16,12 @@ void main() { final map = model.toMap(); final result = Token.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.secret, ''); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.phrase, 'Golden Fox'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.secret, ''); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.phrase, 'Golden Fox'); + }); }); } diff --git a/test/src/models/topic_list_test.dart b/test/src/models/topic_list_test.dart index 4d4fc12d..617e46d3 100644 --- a/test/src/models/topic_list_test.dart +++ b/test/src/models/topic_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('TopicList', () { - test('model', () { final model = TopicList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = TopicList.fromMap(map); - expect(result.total, 5); - expect(result.topics, []); - }); + expect(result.total, 5); + expect(result.topics, []); + }); }); } diff --git a/test/src/models/topic_test.dart b/test/src/models/topic_test.dart index 666097f3..1c244535 100644 --- a/test/src/models/topic_test.dart +++ b/test/src/models/topic_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Topic', () { - test('model', () { final model = Topic( $id: '259125845563242502', @@ -19,14 +18,14 @@ void main() { final map = model.toMap(); final result = Topic.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'events'); - expect(result.emailTotal, 100); - expect(result.smsTotal, 100); - expect(result.pushTotal, 100); - expect(result.subscribe, []); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'events'); + expect(result.emailTotal, 100); + expect(result.smsTotal, 100); + expect(result.pushTotal, 100); + expect(result.subscribe, []); + }); }); } diff --git a/test/src/models/user_list_test.dart b/test/src/models/user_list_test.dart index 954daa37..61b350b8 100644 --- a/test/src/models/user_list_test.dart +++ b/test/src/models/user_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('UserList', () { - test('model', () { final model = UserList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = UserList.fromMap(map); - expect(result.total, 5); - expect(result.users, []); - }); + expect(result.total, 5); + expect(result.users, []); + }); }); } diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index 1f411e3d..47e85f4b 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('User', () { - test('model', () { final model = User( $id: '5e5ea5c16897e', @@ -27,22 +26,21 @@ void main() { final map = model.toMap(); final result = User.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'John Doe'); - expect(result.registration, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, true); - expect(result.labels, []); - expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); - expect(result.email, 'john@appwrite.io'); - expect(result.phone, '+4930901820'); - expect(result.emailVerification, true); - expect(result.phoneVerification, true); - expect(result.mfa, true); - expect(result.prefs.data, {"data": {}}); - expect(result.targets, []); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'John Doe'); + expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, true); + expect(result.labels, []); + expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); + expect(result.email, 'john@appwrite.io'); + expect(result.phone, '+4930901820'); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.mfa, true); + expect(result.targets, []); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/variable_list_test.dart b/test/src/models/variable_list_test.dart index 55e8f4ab..1ed9a0d3 100644 --- a/test/src/models/variable_list_test.dart +++ b/test/src/models/variable_list_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('VariableList', () { - test('model', () { final model = VariableList( total: 5, @@ -13,8 +12,8 @@ void main() { final map = model.toMap(); final result = VariableList.fromMap(map); - expect(result.total, 5); - expect(result.variables, []); - }); + expect(result.total, 5); + expect(result.variables, []); + }); }); } diff --git a/test/src/models/variable_test.dart b/test/src/models/variable_test.dart index 0d86ef00..5e2d0344 100644 --- a/test/src/models/variable_test.dart +++ b/test/src/models/variable_test.dart @@ -3,7 +3,6 @@ import 'package:test/test.dart'; void main() { group('Variable', () { - test('model', () { final model = Variable( $id: '5e5ea5c16897e', @@ -19,14 +18,14 @@ void main() { final map = model.toMap(); final result = Variable.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.key, 'API_KEY'); - expect(result.value, 'myPa\$\$word1'); - expect(result.secret, true); - expect(result.resourceType, 'function'); - expect(result.resourceId, 'myAwesomeFunction'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.key, 'API_KEY'); + expect(result.value, 'myPa\$\$word1'); + expect(result.secret, true); + expect(result.resourceType, 'function'); + expect(result.resourceId, 'myAwesomeFunction'); + }); }); } diff --git a/test/src/response_test.dart b/test/src/response_test.dart index 8accb45f..32b4c58f 100644 --- a/test/src/response_test.dart +++ b/test/src/response_test.dart @@ -15,4 +15,4 @@ void main() { expect(response.toString(), '{"x":1}'); }); }); -} \ No newline at end of file +}