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

Migrate cnb_supported to master #87

Merged
merged 4 commits into from
Jul 9, 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
4 changes: 2 additions & 2 deletions lib/jmap/core/method/response/query_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ abstract class QueryResponse extends ResponseRequiringAccountId {
final bool canCalculateChanges;
final UnsignedInt position;
final Set<Id> ids;
final UnsignedInt total;
final UnsignedInt limit;
final UnsignedInt? total;
final UnsignedInt? limit;

QueryResponse(
AccountId accountId,
Expand Down
1 change: 1 addition & 0 deletions lib/jmap/identities/get/get_identity_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class GetIdentityMethod extends GetMethod {

factory GetIdentityMethod.fromJson(Map<String, dynamic> json) => _$GetIdentityMethodFromJson(json);

@override
Map<String, dynamic> toJson() => _$GetIdentityMethodToJson(this);
}
2 changes: 1 addition & 1 deletion lib/jmap/identities/set/set_identity_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SetIdentityMethod extends SetMethod<Identity> {
writeNotNull('update', update
?.map((id, update) => SetMethodPropertiesConverter().fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => IdConverter().toJson(destroyId)).toList());
?.map((destroyId) => const IdConverter().toJson(destroyId)).toList());

return val;
}
Expand Down
11 changes: 8 additions & 3 deletions lib/jmap/jmap_request.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:built_collection/built_collection.dart';
import 'package:dio/dio.dart';
import 'package:jmap_dart_client/http/http_client.dart';
import 'package:jmap_dart_client/jmap/core/request/reference_path.dart';
import 'package:jmap_dart_client/jmap/core/request/result_reference.dart';
Expand All @@ -20,14 +21,18 @@ class JmapRequest {
RequestObject? _requestObject;
RequestObject? get requestObject => _requestObject;

Future<ResponseObject> execute() async {
Future<ResponseObject> execute({CancelToken? cancelToken}) async {
_requestObject = (RequestObject.builder()
..usings(_capabilities.asSet())
..methodCalls(_invocations.values.toList()))
.build();

return _httpClient.post('', data: _requestObject?.toJson())
.then((value) => extractData(value))
return _httpClient.post(
'',
data: _requestObject?.toJson(),
cancelToken: cancelToken
)
.then(extractData)
.catchError((error) => throw error);
}

Expand Down
14 changes: 1 addition & 13 deletions lib/jmap/mail/email/changes/changes_email_response.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 63 additions & 8 deletions lib/jmap/mail/email/email_body_value.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,75 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:jmap_dart_client/http/converter/individual_header_identifier_converter.dart';
import 'package:jmap_dart_client/jmap/mail/email/individual_header_identifier.dart';

part 'email_body_value.g.dart';

@JsonSerializable()
class EmailBodyValue with EquatableMixin {
final String value;
final bool isEncodingProblem;
final bool isTruncated;
final Map<IndividualHeaderIdentifier, String?>? acceptLanguageHeader;
final Map<IndividualHeaderIdentifier, String?>? contentLanguageHeader;

EmailBodyValue({
required this.value,
required this.isEncodingProblem,
required this.isTruncated,
this.acceptLanguageHeader,
this.contentLanguageHeader
});

factory EmailBodyValue.fromJson(Map<String, dynamic> json) {
return EmailBodyValue(
value: json['value'] as String,
isEncodingProblem: json['isEncodingProblem'] as bool,
isTruncated: json['isTruncated'] as bool,
acceptLanguageHeader: IndividualHeaderIdentifierNullableConverter()
.parseEntry(
IndividualHeaderIdentifier.acceptLanguageHeader.value,
json[IndividualHeaderIdentifier.acceptLanguageHeader.value] as String?
),
contentLanguageHeader: IndividualHeaderIdentifierNullableConverter()
.parseEntry(
IndividualHeaderIdentifier.contentLanguageHeader.value,
json[IndividualHeaderIdentifier.contentLanguageHeader.value] as String?
),
);
}

EmailBodyValue(this.value, this.isEncodingProblem, this.isTruncated);
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};

factory EmailBodyValue.fromJson(Map<String, dynamic> json) => _$EmailBodyValueFromJson(json);
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}

Map<String, dynamic> toJson() => _$EmailBodyValueToJson(this);
writeNotNull('value', value);
writeNotNull('isEncodingProblem', isEncodingProblem);
writeNotNull('isTruncated', isTruncated);
writeNotNull(
IndividualHeaderIdentifier.acceptLanguageHeader.value,
IndividualHeaderIdentifierNullableConverter().toJson(
acceptLanguageHeader,
IndividualHeaderIdentifier.acceptLanguageHeader
)
);
writeNotNull(
IndividualHeaderIdentifier.contentLanguageHeader.value,
IndividualHeaderIdentifierNullableConverter().toJson(
contentLanguageHeader,
IndividualHeaderIdentifier.contentLanguageHeader
)
);
return val;
}

@override
List<Object?> get props => [value, isEncodingProblem, isTruncated];
List<Object?> get props => [
value,
isEncodingProblem,
isTruncated,
acceptLanguageHeader,
contentLanguageHeader,
];
}
22 changes: 0 additions & 22 deletions lib/jmap/mail/email/email_body_value.g.dart

This file was deleted.

2 changes: 2 additions & 0 deletions lib/jmap/mail/email/individual_header_identifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class IndividualHeaderIdentifier with EquatableMixin {
static final headerUserAgent = IndividualHeaderIdentifier('header:User-Agent:asText');
static final headerMdn = IndividualHeaderIdentifier('header:Disposition-Notification-To:asText');
static final headerCalendarEvent = IndividualHeaderIdentifier('header:X-MEETING-UID:asText');
static final acceptLanguageHeader = IndividualHeaderIdentifier('header:Accept-Language:asText');
static final contentLanguageHeader = IndividualHeaderIdentifier('header:Content-Language:asText');

final String value;

Expand Down
5 changes: 3 additions & 2 deletions lib/jmap/mail/email/query/query_email_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:jmap_dart_client/http/converter/account_id_converter.dart';
import 'package:jmap_dart_client/http/converter/id_converter.dart';
import 'package:jmap_dart_client/http/converter/state_converter.dart';
import 'package:jmap_dart_client/http/converter/unsigned_int_converter.dart';
import 'package:jmap_dart_client/http/converter/unsigned_int_nullable_converter.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/core/method/response/query_response.dart';
Expand All @@ -24,8 +25,8 @@ class QueryEmailResponse extends QueryResponse {
bool canCalculateChanges,
UnsignedInt position,
Set<Id> ids,
UnsignedInt total,
UnsignedInt limit,
UnsignedInt? total,
UnsignedInt? limit,
) : super(accountId, queryState, canCalculateChanges, position, ids, total, limit);

factory QueryEmailResponse.fromJson(Map<String, dynamic> json) => _$QueryEmailResponseFromJson(json);
Expand Down
8 changes: 4 additions & 4 deletions lib/jmap/mail/email/query/query_email_response.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/jmap/mail/email/set/set_email_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SetEmailMethod extends SetMethod<Email> {
?.map((id, update) => SetMethodPropertiesConverter()
.fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => IdConverter()
?.map((destroyId) => const IdConverter()
.toJson(destroyId)).toList());

return val;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class SetEmailSubmissionMethod extends SetMethod<EmailSubmission> with OptionalO
?.map((id, update) => SetMethodPropertiesConverter()
.fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => IdConverter()
?.map((destroyId) => const IdConverter()
.toJson(destroyId)).toList());
writeNotNull('onSuccessUpdateEmail', onSuccessUpdateEmail
?.map((id, update) => SetMethodPropertiesConverter()
.fromMapEmailSubmissionIdToJson(id, update)));
writeNotNull('onSuccessDestroyEmail', onSuccessDestroyEmail
?.map((destroyId) => ReferencesEmailSubmissionIdConverter()
?.map((destroyId) => const ReferencesEmailSubmissionIdConverter()
.toJson(destroyId)).toList());

return val;
Expand All @@ -66,9 +66,7 @@ mixin OptionalOnSuccessUpdateEmail {
Map<EmailSubmissionId, PatchObject>? onSuccessUpdateEmail;

void addOnSuccessUpdateEmail(Map<EmailSubmissionId, PatchObject> values) {
if (onSuccessUpdateEmail == null) {
onSuccessUpdateEmail = Map<EmailSubmissionId, PatchObject>();
}
onSuccessUpdateEmail ??= <EmailSubmissionId, PatchObject>{};
onSuccessUpdateEmail?.addAll(values);
}
}
Expand All @@ -78,9 +76,7 @@ mixin OptionalOnSuccessDestroyEmail {
Set<EmailSubmissionId>? onSuccessDestroyEmail;

void addOnSuccessDestroyEmail(Set<EmailSubmissionId> values) {
if (onSuccessDestroyEmail == null) {
onSuccessDestroyEmail = Set();
}
onSuccessDestroyEmail ??= <EmailSubmissionId>{};
onSuccessDestroyEmail?.addAll(values);
}
}
1 change: 1 addition & 0 deletions lib/jmap/mail/mailbox/get/get_mailbox_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class GetMailboxMethod extends GetMethod {

factory GetMailboxMethod.fromJson(Map<String, dynamic> json) => _$GetMailboxMethodFromJson(json);

@override
Map<String, dynamic> toJson() => _$GetMailboxMethodToJson(this);
}
2 changes: 2 additions & 0 deletions lib/jmap/mail/mailbox/mailbox_rights.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class MailboxRights with EquatableMixin {
return _$MailboxRightsFromJson(json);
}

Map<String, dynamic> toJson() => _$MailboxRightsToJson(this);

@override
List<Object?> get props => [mayReadItems, mayAddItems, mayRemoveItems, maySetSeen,
maySetKeywords, mayCreateChild, mayRename, mayDelete, maySubmit];
Expand Down
5 changes: 3 additions & 2 deletions lib/jmap/mail/mailbox/query/query_mailbox_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:jmap_dart_client/http/converter/account_id_converter.dart';
import 'package:jmap_dart_client/http/converter/id_converter.dart';
import 'package:jmap_dart_client/http/converter/state_converter.dart';
import 'package:jmap_dart_client/http/converter/unsigned_int_converter.dart';
import 'package:jmap_dart_client/http/converter/unsigned_int_nullable_converter.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/core/method/response/query_response.dart';
Expand All @@ -24,8 +25,8 @@ class QueryMailboxResponse extends QueryResponse {
bool canCalculateChanges,
UnsignedInt position,
Set<Id> ids,
UnsignedInt total,
UnsignedInt limit,
UnsignedInt? total,
UnsignedInt? limit,
) : super(accountId, queryState, canCalculateChanges, position, ids, total, limit);

factory QueryMailboxResponse.fromJson(Map<String, dynamic> json) => _$QueryMailboxResponseFromJson(json);
Expand Down
8 changes: 4 additions & 4 deletions lib/jmap/mail/mailbox/query/query_mailbox_response.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/jmap/mail/mailbox/set/set_mailbox_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SetMailboxMethod extends SetMethod<Mailbox> with OptionalOnDestroyRemoveEm
writeNotNull('update', update
?.map((id, update) => SetMethodPropertiesConverter().fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => IdConverter().toJson(destroyId)).toList());
?.map((destroyId) => const IdConverter().toJson(destroyId)).toList());
writeNotNull('onDestroyRemoveEmails', onDestroyRemoveEmails);

return val;
Expand Down
1 change: 1 addition & 0 deletions lib/jmap/mail/vacation/get/get_vacation_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ class GetVacationMethod extends GetMethod {
factory GetVacationMethod.fromJson(Map<String, dynamic> json) =>
_$GetVacationMethodFromJson(json);

@override
Map<String, dynamic> toJson() => _$GetVacationMethodToJson(this);
}
4 changes: 2 additions & 2 deletions lib/jmap/mdn/send/mdn_send_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class MDNSendResponse extends SendResponse<MDN> {
const AccountIdConverter().fromJson(json['accountId'] as String),
sent: (json['sent'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
IdConverter().fromJson(key),
const IdConverter().fromJson(key),
MDN.fromJson(value as Map<String, dynamic>))),
notSent: (json['notSent'] as Map<String, dynamic>?)
?.map((key, value) => MapEntry(
IdConverter().fromJson(key),
const IdConverter().fromJson(key),
SetError.fromJson(value))),
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/jmap/push/get/get_push_subscription_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ class GetPushSubscriptionMethod extends GetMethodNoNeedAccountId {

factory GetPushSubscriptionMethod.fromJson(Map<String, dynamic> json) => _$GetPushSubscriptionMethodFromJson(json);

@override
Map<String, dynamic> toJson() => _$GetPushSubscriptionMethodToJson(this);
}
2 changes: 1 addition & 1 deletion lib/jmap/push/set/set_push_subscription_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SetPushSubscriptionMethod extends SetMethodNoNeedAccountId<PushSubscriptio
writeNotNull('update', update
?.map((id, update) => SetMethodPropertiesConverter().fromMapIdToJson(id, update.toJson())));
writeNotNull('destroy', destroy
?.map((destroyId) => IdConverter().toJson(destroyId)).toList());
?.map((destroyId) => const IdConverter().toJson(destroyId)).toList());

return val;
}
Expand Down
Loading
Loading