Skip to content

Commit cd1cb3d

Browse files
Merge pull request #72 from appwrite/dev
fix: pong response & chunked upload
2 parents 8b6eb0c + 5cf5046 commit cd1cb3d

31 files changed

+116
-61
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors.
1+
Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file:
2323

2424
```yml
2525
dependencies:
26-
dart_appwrite: ^12.2.0
26+
dart_appwrite: ^13.0.0
2727
```
2828
2929
You can install packages from the command line:

docs/examples/account/update-mfa-challenge.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Client client = Client()
77

88
Account account = Account(client);
99

10-
result = await account.updateMfaChallenge(
10+
Session result = await account.updateMfaChallenge(
1111
challengeId: '<CHALLENGE_ID>',
1212
otp: '<OTP>',
1313
);

lib/services/account.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class Account extends Service {
282282
/// the flow, use
283283
/// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
284284
/// method.
285-
Future updateMfaChallenge(
285+
Future<models.Session> updateMfaChallenge(
286286
{required String challengeId, required String otp}) async {
287287
final String apiPath = '/account/mfa/challenge';
288288

@@ -298,7 +298,7 @@ class Account extends Service {
298298
final res = await client.call(HttpMethod.put,
299299
path: apiPath, params: apiParams, headers: apiHeaders);
300300

301-
return res.data;
301+
return models.Session.fromMap(res.data);
302302
}
303303

304304
/// List factors

lib/services/functions.dart

+10
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,11 @@ class Functions extends Service {
364364

365365
/// Rebuild deployment
366366
///
367+
/// Create a new build for an existing function deployment. This endpoint
368+
/// allows you to rebuild a deployment with the updated function configuration,
369+
/// including its entrypoint and build commands if they have been modified The
370+
/// build process will be queued and executed asynchronously. The original
371+
/// deployment's code will be preserved and used for the new build.
367372
Future createBuild(
368373
{required String functionId,
369374
required String deploymentId,
@@ -389,6 +394,11 @@ class Functions extends Service {
389394

390395
/// Cancel deployment
391396
///
397+
/// Cancel an ongoing function deployment build. If the build is already in
398+
/// progress, it will be stopped and marked as canceled. If the build hasn't
399+
/// started yet, it will be marked as canceled without executing. You cannot
400+
/// cancel builds that have already completed (status 'ready') or failed. The
401+
/// response includes the final build status and details.
392402
Future<models.Build> updateDeploymentBuild(
393403
{required String functionId, required String deploymentId}) async {
394404
final String apiPath =

lib/services/messaging.dart

+9-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ class Messaging extends Service {
7272

7373
/// Update email
7474
///
75-
/// Update an email message by its unique ID.
75+
/// Update an email message by its unique ID. This endpoint only works on
76+
/// messages that are in draft status. Messages that are already processing,
77+
/// sent, or failed cannot be updated.
7678
///
7779
Future<models.Message> updateEmail(
7880
{required String messageId,
@@ -173,7 +175,9 @@ class Messaging extends Service {
173175

174176
/// Update push notification
175177
///
176-
/// Update a push notification by its unique ID.
178+
/// Update a push notification by its unique ID. This endpoint only works on
179+
/// messages that are in draft status. Messages that are already processing,
180+
/// sent, or failed cannot be updated.
177181
///
178182
Future<models.Message> updatePush(
179183
{required String messageId,
@@ -264,7 +268,9 @@ class Messaging extends Service {
264268

265269
/// Update SMS
266270
///
267-
/// Update an email message by its unique ID.
271+
/// Update an SMS message by its unique ID. This endpoint only works on
272+
/// messages that are in draft status. Messages that are already processing,
273+
/// sent, or failed cannot be updated.
268274
///
269275
Future<models.Message> updateSms(
270276
{required String messageId,

lib/services/users.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ class Users extends Service {
506506
/// Delete authenticator
507507
///
508508
/// Delete an authenticator app.
509-
Future<models.User> deleteMfaAuthenticator(
509+
Future deleteMfaAuthenticator(
510510
{required String userId, required enums.AuthenticatorType type}) async {
511511
final String apiPath = '/users/{userId}/mfa/authenticators/{type}'
512512
.replaceAll('{userId}', userId)
@@ -521,7 +521,7 @@ class Users extends Service {
521521
final res = await client.call(HttpMethod.delete,
522522
path: apiPath, params: apiParams, headers: apiHeaders);
523523

524-
return models.User.fromMap(res.data);
524+
return res.data;
525525
}
526526

527527
/// List factors

lib/src/client.dart

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ abstract class Client {
6767
/// Add headers that should be sent with all API calls.
6868
Client addHeader(String key, String value);
6969

70+
/// Sends a "ping" request to Appwrite to verify connectivity.
71+
Future<String> ping();
72+
7073
/// Upload a file in chunks.
7174
Future<Response> chunkedUpload({
7275
required String path,

lib/src/client_base.dart

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ abstract class ClientBase implements Client {
3434
@override
3535
ClientBase addHeader(String key, String value);
3636

37+
@override
38+
Future<String> ping();
39+
3740
@override
3841
Future<Response> call(
3942
HttpMethod method, {

lib/src/client_browser.dart

+11-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
3333
'x-sdk-name': 'Dart',
3434
'x-sdk-platform': 'server',
3535
'x-sdk-language': 'dart',
36-
'x-sdk-version': '12.2.0',
36+
'x-sdk-version': '13.0.0',
3737
'X-Appwrite-Response-Format': '1.6.0',
3838
};
3939

@@ -110,6 +110,15 @@ class ClientBrowser extends ClientBase with ClientMixin {
110110
return this;
111111
}
112112

113+
@override
114+
Future<String> ping() async {
115+
final String apiPath = '/ping';
116+
final response = await call(HttpMethod.get,
117+
path: apiPath, responseType: ResponseType.plain);
118+
119+
return response.data;
120+
}
121+
113122
@override
114123
Future<String?> webAuth(Uri url) async {
115124
final request = http.Request('GET', url);
@@ -147,7 +156,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
147156
}
148157

149158
var offset = 0;
150-
if (idParamName.isNotEmpty && params[idParamName] != 'unique()') {
159+
if (idParamName.isNotEmpty) {
151160
//make a request to check if a file already exists
152161
try {
153162
res = await call(

lib/src/client_io.dart

+12-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class ClientIO extends ClientBase with ClientMixin {
4242
'x-sdk-name': 'Dart',
4343
'x-sdk-platform': 'server',
4444
'x-sdk-language': 'dart',
45-
'x-sdk-version': '12.2.0',
45+
'x-sdk-version': '13.0.0',
4646
'user-agent':
47-
'AppwriteDartSDK/12.2.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
47+
'AppwriteDartSDK/13.0.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
4848
'X-Appwrite-Response-Format': '1.6.0',
4949
};
5050

@@ -123,6 +123,15 @@ class ClientIO extends ClientBase with ClientMixin {
123123
return this;
124124
}
125125

126+
@override
127+
Future<String> ping() async {
128+
final String apiPath = '/ping';
129+
final response = await call(HttpMethod.get,
130+
path: apiPath, responseType: ResponseType.plain);
131+
132+
return response.data;
133+
}
134+
126135
@override
127136
Future<Response> chunkedUpload({
128137
required String path,
@@ -168,7 +177,7 @@ class ClientIO extends ClientBase with ClientMixin {
168177
}
169178

170179
var offset = 0;
171-
if (idParamName.isNotEmpty && params[idParamName] != 'unique()') {
180+
if (idParamName.isNotEmpty) {
172181
//make a request to check if a file already exists
173182
try {
174183
res = await call(

lib/src/enums/image_format.dart

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ enum ImageFormat {
66
gif(value: 'gif'),
77
png(value: 'png'),
88
webp(value: 'webp'),
9+
heic(value: 'heic'),
910
avif(value: 'avif');
1011

1112
const ImageFormat({required this.value});

lib/src/models/attribute_enum.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class AttributeEnum implements Model {
5959
array: map['array'],
6060
$createdAt: map['\$createdAt'].toString(),
6161
$updatedAt: map['\$updatedAt'].toString(),
62-
elements: map['elements'] ?? [],
62+
elements: List.from(map['elements'] ?? []),
6363
format: map['format'].toString(),
6464
xdefault: map['default']?.toString(),
6565
);

lib/src/models/attribute_list.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AttributeList implements Model {
1616
factory AttributeList.fromMap(Map<String, dynamic> map) {
1717
return AttributeList(
1818
total: map['total'],
19-
attributes: map['attributes'] ?? [],
19+
attributes: List.from(map['attributes'] ?? []),
2020
);
2121
}
2222

lib/src/models/bucket.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ class Bucket implements Model {
5858
$id: map['\$id'].toString(),
5959
$createdAt: map['\$createdAt'].toString(),
6060
$updatedAt: map['\$updatedAt'].toString(),
61-
$permissions: map['\$permissions'] ?? [],
61+
$permissions: List.from(map['\$permissions'] ?? []),
6262
fileSecurity: map['fileSecurity'],
6363
name: map['name'].toString(),
6464
enabled: map['enabled'],
6565
maximumFileSize: map['maximumFileSize'],
66-
allowedFileExtensions: map['allowedFileExtensions'] ?? [],
66+
allowedFileExtensions: List.from(map['allowedFileExtensions'] ?? []),
6767
compression: map['compression'].toString(),
6868
encryption: map['encryption'],
6969
antivirus: map['antivirus'],

lib/src/models/collection.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ class Collection implements Model {
5050
$id: map['\$id'].toString(),
5151
$createdAt: map['\$createdAt'].toString(),
5252
$updatedAt: map['\$updatedAt'].toString(),
53-
$permissions: map['\$permissions'] ?? [],
53+
$permissions: List.from(map['\$permissions'] ?? []),
5454
databaseId: map['databaseId'].toString(),
5555
name: map['name'].toString(),
5656
enabled: map['enabled'],
5757
documentSecurity: map['documentSecurity'],
58-
attributes: map['attributes'] ?? [],
58+
attributes: List.from(map['attributes'] ?? []),
5959
indexes: List<Index>.from(map['indexes'].map((p) => Index.fromMap(p))),
6060
);
6161
}

lib/src/models/document.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Document implements Model {
1919

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

2425
Document({
@@ -38,7 +39,7 @@ class Document implements Model {
3839
$databaseId: map['\$databaseId'].toString(),
3940
$createdAt: map['\$createdAt'].toString(),
4041
$updatedAt: map['\$updatedAt'].toString(),
41-
$permissions: map['\$permissions'] ?? [],
42+
$permissions: List.from(map['\$permissions'] ?? []),
4243
data: map,
4344
);
4445
}

lib/src/models/execution.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class Execution implements Model {
7878
$id: map['\$id'].toString(),
7979
$createdAt: map['\$createdAt'].toString(),
8080
$updatedAt: map['\$updatedAt'].toString(),
81-
$permissions: map['\$permissions'] ?? [],
81+
$permissions: List.from(map['\$permissions'] ?? []),
8282
functionId: map['functionId'].toString(),
8383
trigger: map['trigger'].toString(),
8484
status: map['status'].toString(),

lib/src/models/file.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class File implements Model {
5555
bucketId: map['bucketId'].toString(),
5656
$createdAt: map['\$createdAt'].toString(),
5757
$updatedAt: map['\$updatedAt'].toString(),
58-
$permissions: map['\$permissions'] ?? [],
58+
$permissions: List.from(map['\$permissions'] ?? []),
5959
name: map['name'].toString(),
6060
signature: map['signature'].toString(),
6161
mimeType: map['mimeType'].toString(),

lib/src/models/function.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ class Func implements Model {
106106
$id: map['\$id'].toString(),
107107
$createdAt: map['\$createdAt'].toString(),
108108
$updatedAt: map['\$updatedAt'].toString(),
109-
execute: map['execute'] ?? [],
109+
execute: List.from(map['execute'] ?? []),
110110
name: map['name'].toString(),
111111
enabled: map['enabled'],
112112
live: map['live'],
113113
logging: map['logging'],
114114
runtime: map['runtime'].toString(),
115115
deployment: map['deployment'].toString(),
116-
scopes: map['scopes'] ?? [],
116+
scopes: List.from(map['scopes'] ?? []),
117117
vars: List<Variable>.from(map['vars'].map((p) => Variable.fromMap(p))),
118-
events: map['events'] ?? [],
118+
events: List.from(map['events'] ?? []),
119119
schedule: map['schedule'].toString(),
120120
timeout: map['timeout'],
121121
entrypoint: map['entrypoint'].toString(),

lib/src/models/index.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class Index implements Model {
4343
type: map['type'].toString(),
4444
status: map['status'].toString(),
4545
error: map['error'].toString(),
46-
attributes: map['attributes'] ?? [],
47-
orders: map['orders'],
46+
attributes: List.from(map['attributes'] ?? []),
47+
orders: List.from(map['orders'] ?? []),
4848
$createdAt: map['\$createdAt'].toString(),
4949
$updatedAt: map['\$updatedAt'].toString(),
5050
);

lib/src/models/membership.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class Membership implements Model {
7171
joined: map['joined'].toString(),
7272
confirm: map['confirm'],
7373
mfa: map['mfa'],
74-
roles: map['roles'] ?? [],
74+
roles: List.from(map['roles'] ?? []),
7575
);
7676
}
7777

lib/src/models/message.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ class Message implements Model {
6363
$createdAt: map['\$createdAt'].toString(),
6464
$updatedAt: map['\$updatedAt'].toString(),
6565
providerType: map['providerType'].toString(),
66-
topics: map['topics'] ?? [],
67-
users: map['users'] ?? [],
68-
targets: map['targets'] ?? [],
66+
topics: List.from(map['topics'] ?? []),
67+
users: List.from(map['users'] ?? []),
68+
targets: List.from(map['targets'] ?? []),
6969
scheduledAt: map['scheduledAt']?.toString(),
7070
deliveredAt: map['deliveredAt']?.toString(),
71-
deliveryErrors: map['deliveryErrors'],
71+
deliveryErrors: List.from(map['deliveryErrors'] ?? []),
7272
deliveredTotal: map['deliveredTotal'],
7373
data: map['data'],
7474
status: map['status'].toString(),

lib/src/models/mfa_recovery_codes.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class MfaRecoveryCodes implements Model {
1111

1212
factory MfaRecoveryCodes.fromMap(Map<String, dynamic> map) {
1313
return MfaRecoveryCodes(
14-
recoveryCodes: map['recoveryCodes'] ?? [],
14+
recoveryCodes: List.from(map['recoveryCodes'] ?? []),
1515
);
1616
}
1717

lib/src/models/runtime.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Runtime implements Model {
4646
base: map['base'].toString(),
4747
image: map['image'].toString(),
4848
logo: map['logo'].toString(),
49-
supports: map['supports'] ?? [],
49+
supports: List.from(map['supports'] ?? []),
5050
);
5151
}
5252

lib/src/models/session.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class Session implements Model {
149149
countryCode: map['countryCode'].toString(),
150150
countryName: map['countryName'].toString(),
151151
current: map['current'],
152-
factors: map['factors'] ?? [],
152+
factors: List.from(map['factors'] ?? []),
153153
secret: map['secret'].toString(),
154154
mfaUpdatedAt: map['mfaUpdatedAt'].toString(),
155155
);

lib/src/models/topic.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Topic implements Model {
4646
emailTotal: map['emailTotal'],
4747
smsTotal: map['smsTotal'],
4848
pushTotal: map['pushTotal'],
49-
subscribe: map['subscribe'] ?? [],
49+
subscribe: List.from(map['subscribe'] ?? []),
5050
);
5151
}
5252

0 commit comments

Comments
 (0)