Skip to content

chore: regenerate sdk #85

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 10 commits into from
Jul 26, 2025
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: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 16.2.0

* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
* Add `encrypt` support to string attribute model
* Add `sequence` support to `Document` model

## 16.1.0

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

```yml
dependencies:
dart_appwrite: ^16.1.0
dart_appwrite: ^16.2.0
```

You can install packages from the command line:
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/databases/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setSession('') // The user session to authenticate with
.setKey('<YOUR_API_KEY>') // Your secret API key
.setJWT('<YOUR_JWT>'); // Your secret JSON Web Token
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

Databases databases = Databases(client);

Expand Down
1 change: 1 addition & 0 deletions docs/examples/databases/create-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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

Databases databases = Databases(client);
Expand Down
17 changes: 17 additions & 0 deletions docs/examples/databases/decrement-document-attribute.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

Databases databases = Databases(client);

Document result = await databases.decrementDocumentAttribute(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
attribute: '',
value: 0, // (optional)
min: 0, // (optional)
);
17 changes: 17 additions & 0 deletions docs/examples/databases/increment-document-attribute.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

Databases databases = Databases(client);

Document result = await databases.incrementDocumentAttribute(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
attribute: '',
value: 0, // (optional)
max: 0, // (optional)
);
61 changes: 61 additions & 0 deletions lib/services/databases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ class Databases extends Service {
/// new collection resource using either a [server
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
/// API or directly from your database console.
///
Future<models.DocumentList> upsertDocuments({
required String databaseId,
required String collectionId,
Expand Down Expand Up @@ -1378,6 +1379,66 @@ class Databases extends Service {
return res.data;
}

/// Decrement a specific attribute of a document by a given value.
Future<models.Document> decrementDocumentAttribute({
required String databaseId,
required String collectionId,
required String documentId,
required String attribute,
double? value,
double? min,
}) async {
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'
.replaceAll('{databaseId}', databaseId)
.replaceAll('{collectionId}', collectionId)
.replaceAll('{documentId}', documentId)
.replaceAll('{attribute}', attribute);

final Map<String, dynamic> apiParams = {'value': value, 'min': min};

final Map<String, String> apiHeaders = {'content-type': 'application/json'};

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

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

/// Increment a specific attribute of a document by a given value.
Future<models.Document> incrementDocumentAttribute({
required String databaseId,
required String collectionId,
required String documentId,
required String attribute,
double? value,
double? max,
}) async {
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'
.replaceAll('{databaseId}', databaseId)
.replaceAll('{collectionId}', collectionId)
.replaceAll('{documentId}', documentId)
.replaceAll('{attribute}', attribute);

final Map<String, dynamic> apiParams = {'value': value, 'max': max};

final Map<String, String> apiHeaders = {'content-type': 'application/json'};

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

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

/// List indexes in the collection.
Future<models.IndexList> listIndexes({
required String databaseId,
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 @@ -30,7 +30,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
'x-sdk-name': 'Dart',
'x-sdk-platform': 'server',
'x-sdk-language': 'dart',
'x-sdk-version': '16.1.0',
'x-sdk-version': '16.2.0',
'X-Appwrite-Response-Format': '1.7.0',
};

Expand Down
4 changes: 2 additions & 2 deletions lib/src/client_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class ClientIO extends ClientBase with ClientMixin {
'x-sdk-name': 'Dart',
'x-sdk-platform': 'server',
'x-sdk-language': 'dart',
'x-sdk-version': '16.1.0',
'x-sdk-version': '16.2.0',
'user-agent':
'AppwriteDartSDK/16.1.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
'AppwriteDartSDK/16.2.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
'X-Appwrite-Response-Format': '1.7.0',
};

Expand Down
6 changes: 6 additions & 0 deletions lib/src/models/attribute_string.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class AttributeString implements Model {
/// Default value for attribute when not provided. Cannot be set when attribute is required.
final String? xdefault;

/// Defines whether this attribute is encrypted or not.
final bool? encrypt;

AttributeString({
required this.key,
required this.type,
Expand All @@ -43,6 +46,7 @@ class AttributeString implements Model {
required this.$updatedAt,
required this.size,
this.xdefault,
this.encrypt,
});

factory AttributeString.fromMap(Map<String, dynamic> map) {
Expand All @@ -57,6 +61,7 @@ class AttributeString implements Model {
$updatedAt: map['\$updatedAt'].toString(),
size: map['size'],
xdefault: map['default']?.toString(),
encrypt: map['encrypt'],
);
}

Expand All @@ -72,6 +77,7 @@ class AttributeString implements Model {
"\$updatedAt": $updatedAt,
"size": size,
"default": xdefault,
"encrypt": encrypt,
};
}
}
6 changes: 6 additions & 0 deletions lib/src/models/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class Document implements Model {
/// Document ID.
final String $id;

/// Document automatically incrementing ID.
final int $sequence;

/// Collection ID.
final String $collectionId;

Expand All @@ -24,6 +27,7 @@ class Document implements Model {

Document({
required this.$id,
required this.$sequence,
required this.$collectionId,
required this.$databaseId,
required this.$createdAt,
Expand All @@ -35,6 +39,7 @@ class Document implements Model {
factory Document.fromMap(Map<String, dynamic> map) {
return Document(
$id: map['\$id'].toString(),
$sequence: map['\$sequence'],
$collectionId: map['\$collectionId'].toString(),
$databaseId: map['\$databaseId'].toString(),
$createdAt: map['\$createdAt'].toString(),
Expand All @@ -47,6 +52,7 @@ class Document implements Model {
Map<String, dynamic> toMap() {
return {
"\$id": $id,
"\$sequence": $sequence,
"\$collectionId": $collectionId,
"\$databaseId": $databaseId,
"\$createdAt": $createdAt,
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: dart_appwrite
version: 16.1.0
version: 16.2.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
Expand Down
56 changes: 56 additions & 0 deletions test/services/databases_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ void main() {
test('test method createDocument()', () async {
final Map<String, dynamic> data = {
'\$id': '5e5ea5c16897e',
'\$sequence': 1,
'\$collectionId': '5e5ea5c15117e',
'\$databaseId': '5e5ea5c15117e',
'\$createdAt': '2020-10-15T06:38:00.000+00:00',
Expand Down Expand Up @@ -995,6 +996,7 @@ void main() {
test('test method getDocument()', () async {
final Map<String, dynamic> data = {
'\$id': '5e5ea5c16897e',
'\$sequence': 1,
'\$collectionId': '5e5ea5c15117e',
'\$databaseId': '5e5ea5c15117e',
'\$createdAt': '2020-10-15T06:38:00.000+00:00',
Expand All @@ -1019,6 +1021,7 @@ void main() {
test('test method upsertDocument()', () async {
final Map<String, dynamic> data = {
'\$id': '5e5ea5c16897e',
'\$sequence': 1,
'\$collectionId': '5e5ea5c15117e',
'\$databaseId': '5e5ea5c15117e',
'\$createdAt': '2020-10-15T06:38:00.000+00:00',
Expand All @@ -1044,6 +1047,7 @@ void main() {
test('test method updateDocument()', () async {
final Map<String, dynamic> data = {
'\$id': '5e5ea5c16897e',
'\$sequence': 1,
'\$collectionId': '5e5ea5c15117e',
'\$databaseId': '5e5ea5c15117e',
'\$createdAt': '2020-10-15T06:38:00.000+00:00',
Expand Down Expand Up @@ -1080,6 +1084,58 @@ void main() {
);
});

test('test method decrementDocumentAttribute()', () async {
final Map<String, dynamic> data = {
'\$id': '5e5ea5c16897e',
'\$sequence': 1,
'\$collectionId': '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 databases.decrementDocumentAttribute(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
attribute: '',
);
expect(response, isA<models.Document>());

});

test('test method incrementDocumentAttribute()', () async {
final Map<String, dynamic> data = {
'\$id': '5e5ea5c16897e',
'\$sequence': 1,
'\$collectionId': '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 databases.incrementDocumentAttribute(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
attribute: '',
);
expect(response, isA<models.Document>());

});

test('test method listIndexes()', () async {
final Map<String, dynamic> data = {
'total': 5,
Expand Down
2 changes: 2 additions & 0 deletions test/src/models/document_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ void main() {
test('model', () {
final model = Document(
$id: '5e5ea5c16897e',
$sequence: 1,
$collectionId: '5e5ea5c15117e',
$databaseId: '5e5ea5c15117e',
$createdAt: '2020-10-15T06:38:00.000+00:00',
Expand All @@ -19,6 +20,7 @@ void main() {
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');
Expand Down