Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
45 changes: 18 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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:
Expand All @@ -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 protected]", phone: "+123456789", password: "password", name: "Walter O'Brien");
print(user.toMap());
} on AppwriteException catch(e) {
print(e.message);
}
}
Client client = Client()
.setProject('<YOUR_PROJECT_ID>')
.setKey('<YOUR_API_KEY>');

Users users = Users(client);

User user = await users.create(
userId: ID.unique(),
email: '[email protected]',
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 protected]", 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
}
```

Expand Down
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:lints/recommended.yaml
2 changes: 1 addition & 1 deletion docs/examples/account/create-mfa-authenticator.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Client client = Client()

Account account = Account(client);

MfaType result = await account.createMfaAuthenticator(
MfaType result = await account.createMFAAuthenticator(
type: AuthenticatorType.totp,
);
2 changes: 1 addition & 1 deletion docs/examples/account/create-mfa-challenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Client client = Client()

Account account = Account(client);

MfaChallenge result = await account.createMfaChallenge(
MfaChallenge result = await account.createMFAChallenge(
factor: AuthenticationFactor.email,
);
2 changes: 1 addition & 1 deletion docs/examples/account/create-mfa-recovery-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Client client = Client()

Account account = Account(client);

MfaRecoveryCodes result = await account.createMfaRecoveryCodes();
MfaRecoveryCodes result = await account.createMFARecoveryCodes();
2 changes: 1 addition & 1 deletion docs/examples/account/delete-mfa-authenticator.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Client client = Client()

Account account = Account(client);

await account.deleteMfaAuthenticator(
await account.deleteMFAAuthenticator(
type: AuthenticatorType.totp,
);
2 changes: 1 addition & 1 deletion docs/examples/account/get-mfa-recovery-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Client client = Client()

Account account = Account(client);

MfaRecoveryCodes result = await account.getMfaRecoveryCodes();
MfaRecoveryCodes result = await account.getMFARecoveryCodes();
2 changes: 1 addition & 1 deletion docs/examples/account/list-mfa-factors.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Client client = Client()

Account account = Account(client);

MfaFactors result = await account.listMfaFactors();
MfaFactors result = await account.listMFAFactors();
2 changes: 1 addition & 1 deletion docs/examples/account/update-mfa-authenticator.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<OTP>',
);
2 changes: 1 addition & 1 deletion docs/examples/account/update-mfa-challenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Client client = Client()

Account account = Account(client);

Session result = await account.updateMfaChallenge(
Session result = await account.updateMFAChallenge(
challengeId: '<CHALLENGE_ID>',
otp: '<OTP>',
);
2 changes: 1 addition & 1 deletion docs/examples/account/update-mfa-recovery-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Client client = Client()

Account account = Account(client);

MfaRecoveryCodes result = await account.updateMfaRecoveryCodes();
MfaRecoveryCodes result = await account.updateMFARecoveryCodes();
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/examples/databases/decrement-document-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
.setSession(''); // The user session to authenticate with

Databases databases = Databases(client);

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/databases/increment-document-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
.setSession(''); // The user session to authenticate with

Databases databases = Databases(client);

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/functions/create-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Execution result = await functions.createExecution(
path: '<PATH>', // (optional)
method: ExecutionMethod.gET, // (optional)
headers: {}, // (optional)
scheduledAt: '', // (optional)
scheduledAt: '<SCHEDULED_AT>', // (optional)
);
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/examples/messaging/create-apns-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Client client = Client()

Messaging messaging = Messaging(client);

Provider result = await messaging.createApnsProvider(
Provider result = await messaging.createAPNSProvider(
providerId: '<PROVIDER_ID>',
name: '<NAME>',
authKey: '<AUTH_KEY>', // (optional)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/create-fcm-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Client client = Client()

Messaging messaging = Messaging(client);

Provider result = await messaging.createFcmProvider(
Provider result = await messaging.createFCMProvider(
providerId: '<PROVIDER_ID>',
name: '<NAME>',
serviceAccountJSON: {}, // (optional)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/create-sms.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Client client = Client()

Messaging messaging = Messaging(client);

Message result = await messaging.createSms(
Message result = await messaging.createSMS(
messageId: '<MESSAGE_ID>',
content: '<CONTENT>',
topics: [], // (optional)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/create-smtp-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Client client = Client()

Messaging messaging = Messaging(client);

Provider result = await messaging.createSmtpProvider(
Provider result = await messaging.createSMTPProvider(
providerId: '<PROVIDER_ID>',
name: '<NAME>',
host: '<HOST>',
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/update-apns-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Client client = Client()

Messaging messaging = Messaging(client);

Provider result = await messaging.updateApnsProvider(
Provider result = await messaging.updateAPNSProvider(
providerId: '<PROVIDER_ID>',
name: '<NAME>', // (optional)
enabled: false, // (optional)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/update-fcm-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Client client = Client()

Messaging messaging = Messaging(client);

Provider result = await messaging.updateFcmProvider(
Provider result = await messaging.updateFCMProvider(
providerId: '<PROVIDER_ID>',
name: '<NAME>', // (optional)
enabled: false, // (optional)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/update-sms.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Client client = Client()

Messaging messaging = Messaging(client);

Message result = await messaging.updateSms(
Message result = await messaging.updateSMS(
messageId: '<MESSAGE_ID>',
topics: [], // (optional)
users: [], // (optional)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/update-smtp-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Client client = Client()

Messaging messaging = Messaging(client);

Provider result = await messaging.updateSmtpProvider(
Provider result = await messaging.updateSMTPProvider(
providerId: '<PROVIDER_ID>',
name: '<NAME>', // (optional)
host: '<HOST>', // (optional)
Expand Down
17 changes: 17 additions & 0 deletions docs/examples/tablesdb/create-boolean-column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

TablesDB tablesDB = TablesDB(client);

ColumnBoolean result = await tablesDB.createBooleanColumn(
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
key: '',
xrequired: false,
xdefault: false, // (optional)
array: false, // (optional)
);
17 changes: 17 additions & 0 deletions docs/examples/tablesdb/create-datetime-column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

TablesDB tablesDB = TablesDB(client);

ColumnDatetime result = await tablesDB.createDatetimeColumn(
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
key: '',
xrequired: false,
xdefault: '', // (optional)
array: false, // (optional)
);
17 changes: 17 additions & 0 deletions docs/examples/tablesdb/create-email-column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

TablesDB tablesDB = TablesDB(client);

ColumnEmail result = await tablesDB.createEmailColumn(
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
key: '',
xrequired: false,
xdefault: '[email protected]', // (optional)
array: false, // (optional)
);
18 changes: 18 additions & 0 deletions docs/examples/tablesdb/create-enum-column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

TablesDB tablesDB = TablesDB(client);

ColumnEnum result = await tablesDB.createEnumColumn(
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
key: '',
elements: [],
xrequired: false,
xdefault: '<DEFAULT>', // (optional)
array: false, // (optional)
);
19 changes: 19 additions & 0 deletions docs/examples/tablesdb/create-float-column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

TablesDB tablesDB = TablesDB(client);

ColumnFloat result = await tablesDB.createFloatColumn(
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
key: '',
xrequired: false,
min: 0, // (optional)
max: 0, // (optional)
xdefault: 0, // (optional)
array: false, // (optional)
);
Loading