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
6 changes: 3 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: true
ref: ${{ github.event.pull_request.head.ref }}

- name: Install Flutter
uses: subosito/flutter-action@v2
uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2
with:
channel: stable

Expand All @@ -33,7 +33,7 @@ jobs:
run: git config --global --add safe.directory /__w/sdk-for-flutter/sdk-for-flutter # required to fix dubious ownership

- name: Add & Commit
uses: EndBug/add-and-commit@v9.1.4
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4
with:
add: '["lib", "test"]'

6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Flutter
uses: subosito/flutter-action@v2
uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2
with:
channel: stable
- name: Install dependencies
run: flutter pub get
- uses: dart-lang/setup-dart@v1
- uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260 # v1.7.2
- name: Publish
run: dart pub publish --force
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Flutter
uses: subosito/flutter-action@v2
uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2
with:
channel: stable
- run: flutter pub get
- run: flutter analyze --no-fatal-infos --no-fatal-warnings
- run: flutter test
- run: flutter test
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# Change Log

## 24.1.0

* Added: Realtime `presences` channel and `RealtimePresence` types for presence subscriptions
* Added: `Advisor` and `Presences` services
* Added: `Insight`, `Presence`, and `Report` models with list variants
* Added: `fusionauth`, `keycloak`, and `kick` providers to `OAuthProvider` enum
* Updated: `X-Appwrite-Response-Format` header to `1.9.5`

## 24.0.0

* Breaking: Added `unsubscribe()`, `update()`, and `close()` for Realtime subscription lifecycle.
* Added: Added `userPhone` to the `Membership` model.
* Updated: Updated `X-Appwrite-Response-Format` header to `1.9.2`.
* Breaking: Added `unsubscribe()`, `update()`, and `close()` to Realtime subscriptions
* Added: Added `userPhone` field to `Membership` model
* Updated: Updated `X-Appwrite-Response-Format` header to `1.9.2`

## 23.1.0

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Add this to your package's `pubspec.yaml` file:

```yml
dependencies:
appwrite: ^24.0.0
appwrite: ^24.1.0
```

You can install packages from the command line:
Expand Down
14 changes: 14 additions & 0 deletions docs/examples/advisor/get-insight.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```dart
import 'package:appwrite/appwrite.dart';

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

Advisor advisor = Advisor(client);

Insight result = await advisor.getInsight(
reportId: '<REPORT_ID>',
insightId: '<INSIGHT_ID>',
);
```
13 changes: 13 additions & 0 deletions docs/examples/advisor/get-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
```dart
import 'package:appwrite/appwrite.dart';

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

Advisor advisor = Advisor(client);

Report result = await advisor.getReport(
reportId: '<REPORT_ID>',
);
```
15 changes: 15 additions & 0 deletions docs/examples/advisor/list-insights.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```dart
import 'package:appwrite/appwrite.dart';

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

Advisor advisor = Advisor(client);

InsightList result = await advisor.listInsights(
reportId: '<REPORT_ID>',
queries: [], // optional
total: false, // optional
);
```
14 changes: 14 additions & 0 deletions docs/examples/advisor/list-reports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```dart
import 'package:appwrite/appwrite.dart';

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

Advisor advisor = Advisor(client);

ReportList result = await advisor.listReports(
queries: [], // optional
total: false, // optional
);
```
13 changes: 13 additions & 0 deletions docs/examples/presences/delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
```dart
import 'package:appwrite/appwrite.dart';

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

Presences presences = Presences(client);

await presences.delete(
presenceId: '<PRESENCE_ID>',
);
```
13 changes: 13 additions & 0 deletions docs/examples/presences/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
```dart
import 'package:appwrite/appwrite.dart';
Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
Presences presences = Presences(client);
Presence result = await presences.get(
presenceId: '<PRESENCE_ID>',
);
```
15 changes: 15 additions & 0 deletions docs/examples/presences/list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```dart
import 'package:appwrite/appwrite.dart';

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

Presences presences = Presences(client);

PresenceList result = await presences.list(
queries: [], // optional
total: false, // optional
ttl: 0, // optional
);
```
20 changes: 20 additions & 0 deletions docs/examples/presences/update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
```dart
import 'package:appwrite/appwrite.dart';
import 'package:appwrite/permission.dart';
import 'package:appwrite/role.dart';

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

Presences presences = Presences(client);

Presence result = await presences.update(
presenceId: '<PRESENCE_ID>',
status: '<STATUS>', // optional
expiresAt: '2020-10-15T06:38:00.000+00:00', // optional
metadata: {}, // optional
permissions: [Permission.read(Role.any())], // optional
purge: false, // optional
);
```
19 changes: 19 additions & 0 deletions docs/examples/presences/upsert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```dart
import 'package:appwrite/appwrite.dart';
import 'package:appwrite/permission.dart';
import 'package:appwrite/role.dart';

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

Presences presences = Presences(client);

Presence result = await presences.upsert(
presenceId: '<PRESENCE_ID>',
status: '<STATUS>',
permissions: [Permission.read(Role.any())], // optional
expiresAt: '2020-10-15T06:38:00.000+00:00', // optional
metadata: {}, // optional
);
```
2 changes: 2 additions & 0 deletions lib/appwrite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ part 'services/functions.dart';
part 'services/graphql.dart';
part 'services/locale.dart';
part 'services/messaging.dart';
part 'services/presences.dart';
part 'services/advisor.dart';
part 'services/storage.dart';
part 'services/tables_db.dart';
part 'services/teams.dart';
14 changes: 14 additions & 0 deletions lib/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class _Team {}

class _Membership {}

class _Presence {}

class _Resolved {}

// Helper function for normalizing ID
Expand Down Expand Up @@ -85,6 +87,9 @@ class Channel<T> {
static Channel<_Membership> membership(String id) =>
Channel<_Membership>._(['memberships', _normalize(id)]);

static Channel<_Presence> presence(String id) =>
Channel<_Presence>._(['presences', _normalize(id)]);

static String account() => 'account';

// Global events
Expand All @@ -94,6 +99,7 @@ class Channel<T> {
static String executions() => 'executions';
static String teams() => 'teams';
static String memberships() => 'memberships';
static String presences() => 'presences';
}

// --- DATABASE ROUTE ---
Expand Down Expand Up @@ -169,3 +175,11 @@ extension MembershipChannel on Channel<_Membership> {
Channel<_Resolved> update() => _resolve('update');
Channel<_Resolved> delete() => _resolve('delete');
}

/// Only available on Channel<_Presence>
extension PresenceChannel on Channel<_Presence> {
Channel<_Resolved> create() => _resolve('create');
Channel<_Resolved> upsert() => _resolve('upsert');
Channel<_Resolved> update() => _resolve('update');
Channel<_Resolved> delete() => _resolve('delete');
}
7 changes: 7 additions & 0 deletions lib/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'enums.dart' as enums;
part 'src/models/model.dart';
part 'src/models/row_list.dart';
part 'src/models/document_list.dart';
part 'src/models/presence_list.dart';
part 'src/models/session_list.dart';
part 'src/models/identity_list.dart';
part 'src/models/log_list.dart';
Expand All @@ -20,8 +21,11 @@ part 'src/models/currency_list.dart';
part 'src/models/phone_list.dart';
part 'src/models/locale_code_list.dart';
part 'src/models/transaction_list.dart';
part 'src/models/insight_list.dart';
part 'src/models/report_list.dart';
part 'src/models/row.dart';
part 'src/models/document.dart';
part 'src/models/presence.dart';
part 'src/models/log.dart';
part 'src/models/user.dart';
part 'src/models/algo_md5.dart';
Expand Down Expand Up @@ -55,3 +59,6 @@ part 'src/models/mfa_factors.dart';
part 'src/models/transaction.dart';
part 'src/models/subscriber.dart';
part 'src/models/target.dart';
part 'src/models/insight.dart';
part 'src/models/insight_cta.dart';
part 'src/models/report.dart';
82 changes: 82 additions & 0 deletions lib/services/advisor.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
part of '../appwrite.dart';

class Advisor extends Service {
/// Initializes a [Advisor] service
Advisor(super.client);

/// Get a list of all the project's analyzer reports. You can use the query
/// params to filter your results.
///
Future<models.ReportList> listReports(
{List<String>? queries, bool? total}) async {
const String apiPath = '/reports';

final Map<String, dynamic> apiParams = {
if (queries != null) 'queries': queries,
if (total != null) 'total': total,
};

final Map<String, String> apiHeaders = {};

final res = await client.call(HttpMethod.get,
path: apiPath, params: apiParams, headers: apiHeaders);

return models.ReportList.fromMap(res.data);
}

/// Get an analyzer report by its unique ID. The response includes the report's
/// metadata and the nested insights it produced.
///
Future<models.Report> getReport({required String reportId}) async {
final String apiPath =
'/reports/{reportId}'.replaceAll('{reportId}', reportId);

final Map<String, dynamic> apiParams = {};

final Map<String, String> apiHeaders = {};

final res = await client.call(HttpMethod.get,
path: apiPath, params: apiParams, headers: apiHeaders);

return models.Report.fromMap(res.data);
}

/// List the insights produced under a single analyzer report. You can use the
/// query params to filter your results further.
///
Future<models.InsightList> listInsights(
{required String reportId, List<String>? queries, bool? total}) async {
final String apiPath =
'/reports/{reportId}/insights'.replaceAll('{reportId}', reportId);

final Map<String, dynamic> apiParams = {
if (queries != null) 'queries': queries,
if (total != null) 'total': total,
};

final Map<String, String> apiHeaders = {};

final res = await client.call(HttpMethod.get,
path: apiPath, params: apiParams, headers: apiHeaders);

return models.InsightList.fromMap(res.data);
}

/// Get an insight by its unique ID, scoped to its parent report.
///
Future<models.Insight> getInsight(
{required String reportId, required String insightId}) async {
final String apiPath = '/reports/{reportId}/insights/{insightId}'
.replaceAll('{reportId}', reportId)
.replaceAll('{insightId}', insightId);

final Map<String, dynamic> apiParams = {};

final Map<String, String> apiHeaders = {};

final res = await client.call(HttpMethod.get,
path: apiPath, params: apiParams, headers: apiHeaders);

return models.Insight.fromMap(res.data);
}
}
Loading