Skip to content
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

Fix for realtime subscriptions #196

Merged
merged 1 commit into from
Apr 25, 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: ^12.0.1
appwrite: ^12.0.2
```

You can install packages from the command line:
Expand Down
1 change: 1 addition & 0 deletions lib/appwrite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
library appwrite;

import 'dart:async';
import 'dart:math';
import 'dart:typed_data';
import 'dart:convert';

Expand Down
31 changes: 26 additions & 5 deletions lib/id.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
part of appwrite;
part of 'appwrite.dart';

/// Helper class to generate ID strings for resources.
class ID {
ID._();

/// Have Appwrite generate a unique ID for you.
static String unique() {
return 'unique()';
// Generate an hex ID based on timestamp
// Recreated from https://www.php.net/manual/en/function.uniqid.php
static String _hexTimestamp() {
final now = DateTime.now();
final sec = (now.millisecondsSinceEpoch / 1000).floor();
final usec = now.microsecondsSinceEpoch - (sec * 1000000);
return sec.toRadixString(16) +
usec.toRadixString(16).padLeft(5, '0');
}

// Generate a unique ID with padding to have a longer ID
static String unique({int padding = 7}) {
String id = _hexTimestamp();

if (padding > 0) {
StringBuffer sb = StringBuffer();
for (var i = 0; i < padding; i++) {
sb.write(Random().nextInt(16).toRadixString(16));
}

id += sb.toString();
}

return id;
}

/// Uses [id] as the ID for the resource.
static String custom(String id) {
return id;
}
}
}
2 changes: 1 addition & 1 deletion lib/permission.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of 'appwrite.dart';

/// Helper class to generate permission strings for resources.
class Permission {
Expand Down
2 changes: 1 addition & 1 deletion lib/query.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of 'appwrite.dart';


/// Helper class to generate query strings.
Expand Down
2 changes: 1 addition & 1 deletion lib/role.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of 'appwrite.dart';

/// Helper class to generate role strings for [Permission].
class Role {
Expand Down
6 changes: 3 additions & 3 deletions lib/services/account.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of '../appwrite.dart';

/// The Account service allows you to authenticate and manage a user account.
class Account extends Service {
Expand Down Expand Up @@ -231,7 +231,7 @@ class Account extends Service {
/// Delete Authenticator
///
/// Delete an authenticator for a user by ID.
Future<models.User> deleteMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async {
Future deleteMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async {
final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value);

final Map<String, dynamic> apiParams = {
Expand All @@ -244,7 +244,7 @@ class Account extends Service {

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

return models.User.fromMap(res.data);
return res.data;

}

Expand Down
2 changes: 1 addition & 1 deletion lib/services/avatars.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of '../appwrite.dart';

/// The Avatars service aims to help you complete everyday tasks related to
/// your app image, icons, and avatars.
Expand Down
2 changes: 1 addition & 1 deletion lib/services/databases.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of '../appwrite.dart';

/// The Databases service allows you to create structured collections of
/// documents, query and filter lists of documents
Expand Down
2 changes: 1 addition & 1 deletion lib/services/functions.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of '../appwrite.dart';

/// The Functions Service allows you view, create and manage your Cloud
/// Functions.
Expand Down
2 changes: 1 addition & 1 deletion lib/services/graphql.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of '../appwrite.dart';

/// The GraphQL API allows you to query and mutate your Appwrite server using
/// GraphQL.
Expand Down
2 changes: 1 addition & 1 deletion lib/services/locale.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of '../appwrite.dart';

/// The Locale service allows you to customize your app based on your users&#039;
/// location.
Expand Down
2 changes: 1 addition & 1 deletion lib/services/messaging.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of '../appwrite.dart';

/// The Messaging service allows you to send messages to any provider type
/// (SMTP, push notification, SMS, etc.).
Expand Down
2 changes: 1 addition & 1 deletion lib/services/storage.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of '../appwrite.dart';

/// The Storage service allows you to manage your project files.
class Storage extends Service {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/teams.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite;
part of '../appwrite.dart';

/// The Teams service allows you to group users of your project and to enable
/// them to share read and write access to your project resources
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': '12.0.1',
'x-sdk-version': '12.0.2',
'X-Appwrite-Response-Format': '1.5.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': '12.0.1',
'x-sdk-version': '12.0.2',
'X-Appwrite-Response-Format' : '1.5.0',
};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/enums/authentication_factor.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.enums;
part of '../../enums.dart';

enum AuthenticationFactor {
email(value: 'email'),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/enums/authenticator_type.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.enums;
part of '../../enums.dart';

enum AuthenticatorType {
totp(value: 'totp');
Expand Down
2 changes: 1 addition & 1 deletion lib/src/enums/browser.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.enums;
part of '../../enums.dart';

enum Browser {
avantBrowser(value: 'aa'),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/enums/credit_card.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.enums;
part of '../../enums.dart';

enum CreditCard {
americanExpress(value: 'amex'),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/enums/execution_method.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.enums;
part of '../../enums.dart';

enum ExecutionMethod {
gET(value: 'GET'),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/enums/flag.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.enums;
part of '../../enums.dart';

enum Flag {
afghanistan(value: 'af'),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/enums/image_format.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.enums;
part of '../../enums.dart';

enum ImageFormat {
jpg(value: 'jpg'),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/enums/image_gravity.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.enums;
part of '../../enums.dart';

enum ImageGravity {
center(value: 'center'),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/enums/o_auth_provider.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.enums;
part of '../../enums.dart';

enum OAuthProvider {
amazon(value: 'amazon'),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/algo_argon2.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// AlgoArgon2
class AlgoArgon2 implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/algo_bcrypt.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// AlgoBcrypt
class AlgoBcrypt implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/algo_md5.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// AlgoMD5
class AlgoMd5 implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/algo_phpass.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// AlgoPHPass
class AlgoPhpass implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/algo_scrypt.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// AlgoScrypt
class AlgoScrypt implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/algo_scrypt_modified.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// AlgoScryptModified
class AlgoScryptModified implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/algo_sha.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// AlgoSHA
class AlgoSha implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/continent.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Continent
class Continent implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/continent_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Continents List
class ContinentList implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/country.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Country
class Country implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/country_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Countries List
class CountryList implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/currency.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Currency
class Currency implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/currency_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Currencies List
class CurrencyList implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/document.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Document
class Document implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/document_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Documents List
class DocumentList implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/execution.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Execution
class Execution implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/execution_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Executions List
class ExecutionList implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/file.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// File
class File implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/file_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Files List
class FileList implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/headers.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Headers
class Headers implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/identity.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Identity
class Identity implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/identity_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Identities List
class IdentityList implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/jwt.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// JWT
class Jwt implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/language.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Language
class Language implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/language_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Languages List
class LanguageList implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/locale.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Locale
class Locale implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/locale_code.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// LocaleCode
class LocaleCode implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/locale_code_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Locale codes list
class LocaleCodeList implements Model {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/log.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of appwrite.models;
part of '../../models.dart';

/// Log
class Log implements Model {
Expand Down
Loading