Skip to content

release: sdk #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 18, 2024
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file:

```yml
dependencies:
appwrite: ^13.0.0
appwrite: ^13.1.0
```

You can install packages from the command line:
Expand Down
20 changes: 10 additions & 10 deletions lib/services/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Account extends Service {
return models.User.fromMap(res.data);
}

/// List Identities
/// List identities
///
/// Get the list of identities for the currently logged in user.
Future<models.IdentityList> listIdentities({List<String>? queries}) async {
Expand Down Expand Up @@ -187,7 +187,7 @@ class Account extends Service {
return models.User.fromMap(res.data);
}

/// Create Authenticator
/// Create authenticator
///
/// Add an authenticator app to be used as an MFA factor. Verify the
/// authenticator using the [verify
Expand All @@ -210,7 +210,7 @@ class Account extends Service {
return models.MfaType.fromMap(res.data);
}

/// Verify Authenticator
/// Verify authenticator
///
/// Verify an authenticator app after adding it using the [add
/// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
Expand All @@ -234,7 +234,7 @@ class Account extends Service {
return models.User.fromMap(res.data);
}

/// Delete Authenticator
/// Delete authenticator
///
/// Delete an authenticator for a user by ID.
Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async {
Expand All @@ -253,7 +253,7 @@ class Account extends Service {
return res.data;
}

/// Create MFA Challenge
/// Create MFA challenge
///
/// Begin the process of MFA verification after sign-in. Finish the flow with
/// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
Expand All @@ -276,7 +276,7 @@ class Account extends Service {
return models.MfaChallenge.fromMap(res.data);
}

/// Create MFA Challenge (confirmation)
/// Create MFA challenge (confirmation)
///
/// Complete the MFA challenge by providing the one-time password. Finish the
/// process of MFA verification by providing the one-time password. To begin
Expand All @@ -302,7 +302,7 @@ class Account extends Service {
return res.data;
}

/// List Factors
/// List factors
///
/// List the factors available on the account to be used as a MFA challange.
Future<models.MfaFactors> listMfaFactors() async {
Expand All @@ -320,7 +320,7 @@ class Account extends Service {
return models.MfaFactors.fromMap(res.data);
}

/// Get MFA Recovery Codes
/// Get MFA recovery codes
///
/// Get recovery codes that can be used as backup for MFA flow. Before getting
/// codes, they must be generated using
Expand All @@ -341,7 +341,7 @@ class Account extends Service {
return models.MfaRecoveryCodes.fromMap(res.data);
}

/// Create MFA Recovery Codes
/// Create MFA recovery codes
///
/// Generate recovery codes as backup for MFA flow. It's recommended to
/// generate and show then immediately after user successfully adds their
Expand All @@ -363,7 +363,7 @@ class Account extends Service {
return models.MfaRecoveryCodes.fromMap(res.data);
}

/// Regenerate MFA Recovery Codes
/// Regenerate MFA recovery codes
///
/// Regenerate recovery codes that can be used as backup for MFA flow. Before
/// regenerating codes, they must be first generated using
Expand Down
2 changes: 1 addition & 1 deletion lib/services/locale.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Locale extends Service {
return models.Locale.fromMap(res.data);
}

/// List Locale Codes
/// List locale codes
///
/// List of all locale codes in [ISO
/// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
Expand Down
2 changes: 1 addition & 1 deletion lib/services/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Storage extends Service {
return models.File.fromMap(res.data);
}

/// Delete File
/// Delete file
///
/// Delete a file by its unique ID. Only users with write permissions have
/// access to delete this resource.
Expand Down
6 changes: 4 additions & 2 deletions lib/services/teams.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ class Teams extends Service {
/// List team memberships
///
/// Use this endpoint to list a team's members using the team's ID. All team
/// members have read access to this endpoint.
/// members have read access to this endpoint. Hide sensitive attributes from
/// the response by toggling membership privacy in the Console.
Future<models.MembershipList> listMemberships(
{required String teamId, List<String>? queries, String? search}) async {
final String apiPath =
Expand Down Expand Up @@ -193,7 +194,8 @@ class Teams extends Service {
/// Get team membership
///
/// Get a team member by the membership unique id. All team members have read
/// access for this resource.
/// access for this resource. Hide sensitive attributes from the response by
/// toggling membership privacy in the Console.
Future<models.Membership> getMembership(
{required String teamId, required String membershipId}) async {
final String apiPath = '/teams/{teamId}/memberships/{membershipId}'
Expand Down
2 changes: 1 addition & 1 deletion lib/src/client_browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
'x-sdk-name': 'Flutter',
'x-sdk-platform': 'client',
'x-sdk-language': 'flutter',
'x-sdk-version': '13.0.0',
'x-sdk-version': '13.1.0',
'X-Appwrite-Response-Format': '1.6.0',
};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/client_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ClientIO extends ClientBase with ClientMixin {
'x-sdk-name': 'Flutter',
'x-sdk-platform': 'client',
'x-sdk-language': 'flutter',
'x-sdk-version': '13.0.0',
'x-sdk-version': '13.1.0',
'X-Appwrite-Response-Format': '1.6.0',
};

Expand Down
3 changes: 2 additions & 1 deletion lib/src/enums/image_format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ enum ImageFormat {
jpeg(value: 'jpeg'),
gif(value: 'gif'),
png(value: 'png'),
webp(value: 'webp');
webp(value: 'webp'),
avif(value: 'avif');

const ImageFormat({required this.value});

Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Document implements Model {
final String $updatedAt;

/// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
final List $permissions;
final List<String> $permissions;
final Map<String, dynamic> data;

Document({
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/execution.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Execution implements Model {
final String $updatedAt;

/// Execution roles.
final List $permissions;
final List<String> $permissions;

/// Function ID.
final String functionId;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class File implements Model {
final String $updatedAt;

/// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
final List $permissions;
final List<String> $permissions;

/// File name.
final String name;
Expand Down
8 changes: 4 additions & 4 deletions lib/src/models/membership.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class Membership implements Model {
/// User ID.
final String userId;

/// User name.
/// User name. Hide this attribute by toggling membership privacy in the Console.
final String userName;

/// User email address.
/// User email address. Hide this attribute by toggling membership privacy in the Console.
final String userEmail;

/// Team ID.
Expand All @@ -35,11 +35,11 @@ class Membership implements Model {
/// User confirmation status, true if the user has joined the team or false otherwise.
final bool confirm;

/// Multi factor authentication status, true if the user has MFA enabled or false otherwise.
/// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console.
final bool mfa;

/// User list of roles
final List roles;
final List<String> roles;

Membership({
required this.$id,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/mfa_recovery_codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ part of '../../models.dart';
/// MFA Recovery Codes
class MfaRecoveryCodes implements Model {
/// Recovery codes.
final List recoveryCodes;
final List<String> recoveryCodes;

MfaRecoveryCodes({
required this.recoveryCodes,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Session implements Model {
final bool current;

/// Returns a list of active session factors.
final List factors;
final List<String> factors;

/// Secret used to authenticate the user. Only included if the request was made with an API key
final String secret;
Expand Down
6 changes: 6 additions & 0 deletions lib/src/models/target.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Target implements Model {
/// The target identifier.
final String identifier;

/// Is the target expired.
final bool expired;

Target({
required this.$id,
required this.$createdAt,
Expand All @@ -35,6 +38,7 @@ class Target implements Model {
this.providerId,
required this.providerType,
required this.identifier,
required this.expired,
});

factory Target.fromMap(Map<String, dynamic> map) {
Expand All @@ -47,6 +51,7 @@ class Target implements Model {
providerId: map['providerId']?.toString(),
providerType: map['providerType'].toString(),
identifier: map['identifier'].toString(),
expired: map['expired'],
);
}

Expand All @@ -60,6 +65,7 @@ class Target implements Model {
"providerId": providerId,
"providerType": providerType,
"identifier": identifier,
"expired": expired,
};
}
}
2 changes: 1 addition & 1 deletion lib/src/models/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class User implements Model {
final bool status;

/// Labels for the user.
final List labels;
final List<String> labels;

/// Password update time in ISO 8601 format.
final String passwordUpdate;
Expand Down
22 changes: 22 additions & 0 deletions lib/src/realtime_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,31 @@ mixin RealtimeMixin {
int _retries = 0;
StreamSubscription? _websocketSubscription;
bool _creatingSocket = false;
Timer? _heartbeatTimer;

Future<dynamic> _closeConnection() async {
_stopHeartbeat();
await _websocketSubscription?.cancel();
await _websok?.sink.close(status.normalClosure, 'Ending session');
_lastUrl = null;
_retries = 0;
_reconnect = false;
}

void _startHeartbeat() {
_stopHeartbeat();
_heartbeatTimer = Timer.periodic(Duration(seconds: 20), (_) {
if (_websok != null) {
_websok!.sink.add(jsonEncode({"type": "ping"}));
}
});
}

void _stopHeartbeat() {
_heartbeatTimer?.cancel();
_heartbeatTimer = null;
}

_createSocket() async {
if (_creatingSocket || _channels.isEmpty) return;
_creatingSocket = true;
Expand Down Expand Up @@ -78,6 +94,10 @@ mixin RealtimeMixin {
}));
}
}
_startHeartbeat(); // Start heartbeat after successful connection
break;
case 'pong':
debugPrint('Received heartbeat response from realtime server');
break;
case 'event':
final message = RealtimeMessage.fromMap(data.data);
Expand All @@ -91,8 +111,10 @@ mixin RealtimeMixin {
break;
}
}, onDone: () {
_stopHeartbeat();
_retry();
}, onError: (err, stack) {
_stopHeartbeat();
for (var subscription in _subscriptions.values) {
subscription.controller.addError(err, stack);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: appwrite
version: 13.0.0
version: 13.1.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-flutter
Expand Down
10 changes: 6 additions & 4 deletions test/services/account_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1011,10 +1011,11 @@ void main() {
'\$id': '259125845563242502',
'\$createdAt': '2020-10-15T06:38:00.000+00:00',
'\$updatedAt': '2020-10-15T06:38:00.000+00:00',
'name': 'Aegon apple token',
'name': 'Apple iPhone 12',
'userId': '259125845563242502',
'providerType': 'email',
'identifier': 'token',};
'identifier': 'token',
'expired': true,};


when(client.call(
Expand All @@ -1035,10 +1036,11 @@ void main() {
'\$id': '259125845563242502',
'\$createdAt': '2020-10-15T06:38:00.000+00:00',
'\$updatedAt': '2020-10-15T06:38:00.000+00:00',
'name': 'Aegon apple token',
'name': 'Apple iPhone 12',
'userId': '259125845563242502',
'providerType': 'email',
'identifier': 'token',};
'identifier': 'token',
'expired': true,};


when(client.call(
Expand Down
4 changes: 2 additions & 2 deletions test/services/functions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void main() {
'requestPath': '/articles?id=5',
'requestHeaders': [],
'responseStatusCode': 200,
'responseBody': 'Developers are awesome.',
'responseBody': '',
'responseHeaders': [],
'logs': '',
'errors': '',
Expand Down Expand Up @@ -117,7 +117,7 @@ void main() {
'requestPath': '/articles?id=5',
'requestHeaders': [],
'responseStatusCode': 200,
'responseBody': 'Developers are awesome.',
'responseBody': '',
'responseHeaders': [],
'logs': '',
'errors': '',
Expand Down
Loading