diff --git a/.github/dependency-review-config.yml b/.github/dependency-review-config.yml index a9fdf480b6..13ec757209 100644 --- a/.github/dependency-review-config.yml +++ b/.github/dependency-review-config.yml @@ -41,11 +41,17 @@ allow_licenses: # build is verifiably BSD-3-Clause: # https://pub.dev/packages/build/license # +# dart_style and pub_semver are verifiably BSD-3-Clause: +# https://pub.dev/packages/dart_style/license +# https://pub.dev/packages/pub_semver/license +# # Remove once the upstream parser normalizes license casing: # https://github.com/actions/dependency-review-action allow_dependencies_licenses: - "pkg:pub/flutter_secure_storage" - "pkg:pub/build" + - "pkg:pub/dart_style" + - "pkg:pub/pub_semver" # sharp's prebuilt libvips binaries (LGPL-3.0-or-later). They reach the # lockfile only through the hosting test apps (next in test-apps/hosting-ssr, diff --git a/native/codegen-fixtures/01-primitives/dart/client.dart b/native/codegen-fixtures/01-primitives/dart/client.dart index 8d8579d5de..8b767adfec 100644 --- a/native/codegen-fixtures/01-primitives/dart/client.dart +++ b/native/codegen-fixtures/01-primitives/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -34,12 +44,7 @@ class EchoResult { } Map toJson() { - return { - 'text': text, - 'count': count, - 'score': score, - 'enabled': enabled, - }; + return {'text': text, 'count': count, 'score': score, 'enabled': enabled}; } @override @@ -55,27 +60,26 @@ class EchoResult { int get hashCode => Object.hash(text, count, score, enabled); @override - String toString() => 'EchoResult(text: $text, count: $count, score: $score, enabled: $enabled)'; + String toString() => + 'EchoResult(text: $text, count: $count, score: $score, enabled: $enabled)'; } - class Api { final BlocksClient _client; Api(this._client); - Future echo({required String text, required int count, required num score, required bool enabled}) async { - final params = [ - text, - count, - score, - enabled, - ]; + Future echo({ + required String text, + required int count, + required num score, + required bool enabled, + }) async { + final params = [text, count, score, enabled]; final result = await _client.call('api.echo', params); return EchoResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -93,4 +97,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/02-objects-and-refs/dart/client.dart b/native/codegen-fixtures/02-objects-and-refs/dart/client.dart index 12f737aada..9227bd3d8a 100644 --- a/native/codegen-fixtures/02-objects-and-refs/dart/client.dart +++ b/native/codegen-fixtures/02-objects-and-refs/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -34,12 +44,7 @@ class Todo { } Map toJson() { - return { - 'id': id, - 'title': title, - 'done': done, - 'priority': priority, - }; + return {'id': id, 'title': title, 'done': done, 'priority': priority}; } @override @@ -55,18 +60,15 @@ class Todo { int get hashCode => Object.hash(id, title, done, priority); @override - String toString() => 'Todo(id: $id, title: $title, done: $done, priority: $priority)'; + String toString() => + 'Todo(id: $id, title: $title, done: $done, priority: $priority)'; } - class ApiCreateTodoInput { final String title; final int priority; - const ApiCreateTodoInput({ - required this.title, - required this.priority, - }); + const ApiCreateTodoInput({required this.title, required this.priority}); factory ApiCreateTodoInput.fromJson(Map json) { return ApiCreateTodoInput( @@ -76,10 +78,7 @@ class ApiCreateTodoInput { } Map toJson() { - return { - 'title': title, - 'priority': priority, - }; + return {'title': title, 'priority': priority}; } @override @@ -96,29 +95,23 @@ class ApiCreateTodoInput { String toString() => 'ApiCreateTodoInput(title: $title, priority: $priority)'; } - class Api { final BlocksClient _client; Api(this._client); Future getTodo({required String id}) async { - final params = [ - id, - ]; + final params = [id]; final result = await _client.call('api.getTodo', params); return Todo.fromJson(result as Map); } Future createTodo({required ApiCreateTodoInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('api.createTodo', params); return Todo.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -136,4 +129,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/03-nullable/dart/client.dart b/native/codegen-fixtures/03-nullable/dart/client.dart index 81739feeb0..601418cdef 100644 --- a/native/codegen-fixtures/03-nullable/dart/client.dart +++ b/native/codegen-fixtures/03-nullable/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -16,11 +26,7 @@ class GetProfileResult { final String? bio; final int? age; - const GetProfileResult({ - required this.name, - this.bio, - this.age, - }); + const GetProfileResult({required this.name, this.bio, this.age}); factory GetProfileResult.fromJson(Map json) { return GetProfileResult( @@ -53,21 +59,17 @@ class GetProfileResult { String toString() => 'GetProfileResult(name: $name, bio: $bio, age: $age)'; } - class Api { final BlocksClient _client; Api(this._client); Future getProfile({required String userId}) async { - final params = [ - userId, - ]; + final params = [userId]; final result = await _client.call('api.getProfile', params); return GetProfileResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -85,4 +87,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/04-arrays/dart/client.dart b/native/codegen-fixtures/04-arrays/dart/client.dart index 000ea34d9e..c26b213de4 100644 --- a/native/codegen-fixtures/04-arrays/dart/client.dart +++ b/native/codegen-fixtures/04-arrays/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -15,10 +25,7 @@ class ListItemsResult { final String id; final String name; - const ListItemsResult({ - required this.id, - required this.name, - }); + const ListItemsResult({required this.id, required this.name}); factory ListItemsResult.fromJson(Map json) { return ListItemsResult( @@ -28,18 +35,13 @@ class ListItemsResult { } Map toJson() { - return { - 'id': id, - 'name': name, - }; + return {'id': id, 'name': name}; } @override bool operator ==(Object other) => identical(this, other) || - other is ListItemsResult && - id == other.id && - name == other.name; + other is ListItemsResult && id == other.id && name == other.name; @override int get hashCode => Object.hash(id, name); @@ -48,7 +50,6 @@ class ListItemsResult { String toString() => 'ListItemsResult(id: $id, name: $name)'; } - class Api { final BlocksClient _client; Api(this._client); @@ -60,11 +61,12 @@ class Api { Future> listItems() async { final result = await _client.call('api.listItems', const []); - return (result as List).map((e) => ListItemsResult.fromJson(e as Map)).toList(); + return (result as List) + .map((e) => ListItemsResult.fromJson(e as Map)) + .toList(); } } - // --- Blocks Client --- class Blocks { @@ -82,4 +84,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/05-enums/dart/client.dart b/native/codegen-fixtures/05-enums/dart/client.dart index 66b1999abb..79e8d027b5 100644 --- a/native/codegen-fixtures/05-enums/dart/client.dart +++ b/native/codegen-fixtures/05-enums/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -14,17 +24,18 @@ sealed class SetStatusResultStatus { static const inactive = SetStatusResultStatusKnown.inactive; static const pending = SetStatusResultStatusKnown.pending; static const values = SetStatusResultStatusKnown.values; - static final Map _byJson = SetStatusResultStatusKnown.values.asNameMap(); + static final Map _byJson = + SetStatusResultStatusKnown.values.asNameMap(); String toJson(); - static SetStatusResultStatus fromJson(String json) => _byJson[json] ?? SetStatusResultStatusUnknown(json); + static SetStatusResultStatus fromJson(String json) => + _byJson[json] ?? SetStatusResultStatusUnknown(json); } enum SetStatusResultStatusKnown implements SetStatusResultStatus { active, inactive, - pending -; + pending; @override String toJson() => name; @@ -46,31 +57,27 @@ final class SetStatusResultStatusUnknown implements SetStatusResultStatus { int get hashCode => value.hashCode; @override - String toString() => 'SetStatusResultStatusUnknown' '($value)'; + String toString() => + 'SetStatusResultStatusUnknown' + '($value)'; } - // --- API Namespaces --- enum ApiSetStatusStatus { active, inactive, - pending -; + pending; String toJson() => name; static ApiSetStatusStatus fromJson(String json) => values.byName(json); } - class SetStatusResult { final SetStatusResultStatus status; final String updatedAt; - const SetStatusResult({ - required this.status, - required this.updatedAt, - }); + const SetStatusResult({required this.status, required this.updatedAt}); factory SetStatusResult.fromJson(Map json) { return SetStatusResult( @@ -80,10 +87,7 @@ class SetStatusResult { } Map toJson() { - return { - 'status': status.toJson(), - 'updatedAt': updatedAt, - }; + return {'status': status.toJson(), 'updatedAt': updatedAt}; } @override @@ -97,24 +101,23 @@ class SetStatusResult { int get hashCode => Object.hash(status, updatedAt); @override - String toString() => 'SetStatusResult(status: $status, updatedAt: $updatedAt)'; + String toString() => + 'SetStatusResult(status: $status, updatedAt: $updatedAt)'; } - class Api { final BlocksClient _client; Api(this._client); - Future setStatus({required ApiSetStatusStatus status}) async { - final params = [ - status.toJson(), - ]; + Future setStatus({ + required ApiSetStatusStatus status, + }) async { + final params = [status.toJson()]; final result = await _client.call('api.setStatus', params); return SetStatusResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -132,4 +135,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/06-format-types/dart/client.dart b/native/codegen-fixtures/06-format-types/dart/client.dart index 08a7d6e475..73729bceba 100644 --- a/native/codegen-fixtures/06-format-types/dart/client.dart +++ b/native/codegen-fixtures/06-format-types/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -65,24 +75,21 @@ class GetEventResult { int get hashCode => Object.hash(id, createdAt, date, time, url, email); @override - String toString() => 'GetEventResult(id: $id, createdAt: $createdAt, date: $date, time: $time, url: $url, email: $email)'; + String toString() => + 'GetEventResult(id: $id, createdAt: $createdAt, date: $date, time: $time, url: $url, email: $email)'; } - class Api { final BlocksClient _client; Api(this._client); Future getEvent({required String id}) async { - final params = [ - id, - ]; + final params = [id]; final result = await _client.call('api.getEvent', params); return GetEventResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -100,4 +107,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/07-maps-and-records/dart/client.dart b/native/codegen-fixtures/07-maps-and-records/dart/client.dart index dec0242428..4cb85543e3 100644 --- a/native/codegen-fixtures/07-maps-and-records/dart/client.dart +++ b/native/codegen-fixtures/07-maps-and-records/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -28,7 +38,8 @@ class ApiSignUpInput { username: json['username'] as String, password: json['password'] as String, additionalProperties: Map.fromEntries( - json.entries.where((e) => !knownKeys.contains(e.key)) + json.entries + .where((e) => !knownKeys.contains(e.key)) .map((e) => MapEntry(e.key, e.value as String)), ), ); @@ -52,37 +63,30 @@ class ApiSignUpInput { blocksDeepEquals(additionalProperties, other.additionalProperties); @override - int get hashCode => Object.hash(username, password, blocksDeepHash(additionalProperties)); + int get hashCode => + Object.hash(username, password, blocksDeepHash(additionalProperties)); @override - String toString() => 'ApiSignUpInput(username: $username, password: $password, additionalProperties: $additionalProperties)'; + String toString() => + 'ApiSignUpInput(username: $username, password: $password, additionalProperties: $additionalProperties)'; } - class SignUpResult { final bool ok; - const SignUpResult({ - required this.ok, - }); + const SignUpResult({required this.ok}); factory SignUpResult.fromJson(Map json) { - return SignUpResult( - ok: json['ok'] as bool, - ); + return SignUpResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is SignUpResult && - ok == other.ok; + identical(this, other) || other is SignUpResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -91,26 +95,24 @@ class SignUpResult { String toString() => 'SignUpResult(ok: $ok)'; } - class Api { final BlocksClient _client; Api(this._client); Future> getScores() async { final result = await _client.call('api.getScores', const []); - return (result as Map).map((k, v) => MapEntry(k, v as num)); + return (result as Map).map( + (k, v) => MapEntry(k, v as num), + ); } Future signUp({required ApiSignUpInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('api.signUp', params); return SignUpResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -128,4 +130,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/08-discriminated-union/dart/client.dart b/native/codegen-fixtures/08-discriminated-union/dart/client.dart index 7e7e83a72a..e684deef84 100644 --- a/native/codegen-fixtures/08-discriminated-union/dart/client.dart +++ b/native/codegen-fixtures/08-discriminated-union/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -16,10 +26,14 @@ sealed class ApiDoActionInput { Map toJson(); static ApiDoActionInput fromJson(Map json) { switch (json['action'] as String) { - case 'create': return CreateInput.fromJson(json); - case 'delete': return DeleteInput.fromJson(json); - case 'update': return UpdateInput.fromJson(json); - default: throw ArgumentError('Unknown action: ${json['action']}'); + case 'create': + return CreateInput.fromJson(json); + case 'delete': + return DeleteInput.fromJson(json); + case 'update': + return UpdateInput.fromJson(json); + default: + throw ArgumentError('Unknown action: ${json['action']}'); } } } @@ -27,29 +41,20 @@ sealed class ApiDoActionInput { class CreateInput extends ApiDoActionInput { final String title; - const CreateInput({ - required this.title, - }); + const CreateInput({required this.title}); factory CreateInput.fromJson(Map json) { - return CreateInput( - title: json['title'] as String, - ); + return CreateInput(title: json['title'] as String); } @override Map toJson() { - return { - 'action': 'create', - 'title': title, - }; + return {'action': 'create', 'title': title}; } @override bool operator ==(Object other) => - identical(this, other) || - other is CreateInput && - title == other.title; + identical(this, other) || other is CreateInput && title == other.title; @override int get hashCode => title.hashCode; @@ -61,29 +66,20 @@ class CreateInput extends ApiDoActionInput { class DeleteInput extends ApiDoActionInput { final String id; - const DeleteInput({ - required this.id, - }); + const DeleteInput({required this.id}); factory DeleteInput.fromJson(Map json) { - return DeleteInput( - id: json['id'] as String, - ); + return DeleteInput(id: json['id'] as String); } @override Map toJson() { - return { - 'action': 'delete', - 'id': id, - }; + return {'action': 'delete', 'id': id}; } @override bool operator ==(Object other) => - identical(this, other) || - other is DeleteInput && - id == other.id; + identical(this, other) || other is DeleteInput && id == other.id; @override int get hashCode => id.hashCode; @@ -96,10 +92,7 @@ class UpdateInput extends ApiDoActionInput { final String id; final String title; - const UpdateInput({ - required this.id, - required this.title, - }); + const UpdateInput({required this.id, required this.title}); factory UpdateInput.fromJson(Map json) { return UpdateInput( @@ -110,19 +103,13 @@ class UpdateInput extends ApiDoActionInput { @override Map toJson() { - return { - 'action': 'update', - 'id': id, - 'title': title, - }; + return {'action': 'update', 'id': id, 'title': title}; } @override bool operator ==(Object other) => identical(this, other) || - other is UpdateInput && - id == other.id && - title == other.title; + other is UpdateInput && id == other.id && title == other.title; @override int get hashCode => Object.hash(id, title); @@ -131,32 +118,22 @@ class UpdateInput extends ApiDoActionInput { String toString() => 'UpdateInput(id: $id, title: $title)'; } - - class DoActionResult { final bool ok; - const DoActionResult({ - required this.ok, - }); + const DoActionResult({required this.ok}); factory DoActionResult.fromJson(Map json) { - return DoActionResult( - ok: json['ok'] as bool, - ); + return DoActionResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is DoActionResult && - ok == other.ok; + identical(this, other) || other is DoActionResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -165,21 +142,17 @@ class DoActionResult { String toString() => 'DoActionResult(ok: $ok)'; } - class Api { final BlocksClient _client; Api(this._client); Future doAction({required ApiDoActionInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('api.doAction', params); return DoActionResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -197,4 +170,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/09-anyof-union/dart/client.dart b/native/codegen-fixtures/09-anyof-union/dart/client.dart index e2ea2932e2..f6557eed1f 100644 --- a/native/codegen-fixtures/09-anyof-union/dart/client.dart +++ b/native/codegen-fixtures/09-anyof-union/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -14,27 +24,19 @@ export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksCli class SearchResult { final int count; - const SearchResult({ - required this.count, - }); + const SearchResult({required this.count}); factory SearchResult.fromJson(Map json) { - return SearchResult( - count: (json['count'] as num).toInt(), - ); + return SearchResult(count: (json['count'] as num).toInt()); } Map toJson() { - return { - 'count': count, - }; + return {'count': count}; } @override bool operator ==(Object other) => - identical(this, other) || - other is SearchResult && - count == other.count; + identical(this, other) || other is SearchResult && count == other.count; @override int get hashCode => count.hashCode; @@ -43,15 +45,12 @@ class SearchResult { String toString() => 'SearchResult(count: $count)'; } - class Api { final BlocksClient _client; Api(this._client); Future search({required dynamic query}) async { - final params = [ - query, - ]; + final params = [query]; final result = await _client.call('api.search', params); return SearchResult.fromJson(result as Map); } @@ -62,7 +61,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -80,4 +78,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/10-const-literal/dart/client.dart b/native/codegen-fixtures/10-const-literal/dart/client.dart index caa37c7558..1684ec968e 100644 --- a/native/codegen-fixtures/10-const-literal/dart/client.dart +++ b/native/codegen-fixtures/10-const-literal/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -14,27 +24,19 @@ export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksCli class DoActionResult { final bool ok; - const DoActionResult({ - required this.ok, - }); + const DoActionResult({required this.ok}); factory DoActionResult.fromJson(Map json) { - return DoActionResult( - ok: json['ok'] as bool, - ); + return DoActionResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is DoActionResult && - ok == other.ok; + identical(this, other) || other is DoActionResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -43,21 +45,17 @@ class DoActionResult { String toString() => 'DoActionResult(ok: $ok)'; } - class Api { final BlocksClient _client; Api(this._client); Future doAction({required dynamic input}) async { - final params = [ - input, - ]; + final params = [input]; final result = await _client.call('api.doAction', params); return DoActionResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -75,4 +73,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/11-tuples/dart/client.dart b/native/codegen-fixtures/11-tuples/dart/client.dart index b188460ee0..a40f78116a 100644 --- a/native/codegen-fixtures/11-tuples/dart/client.dart +++ b/native/codegen-fixtures/11-tuples/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,20 +6,30 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- class QueryRangeResultWhere { final (String, String) between; - const QueryRangeResultWhere({ - required this.between, - }); + const QueryRangeResultWhere({required this.between}); factory QueryRangeResultWhere.fromJson(Map json) { return QueryRangeResultWhere( - between: ((json['between'] as List)[0] as String, (json['between'] as List)[1] as String), + between: ( + (json['between'] as List)[0] as String, + (json['between'] as List)[1] as String, + ), ); } @@ -31,8 +42,7 @@ class QueryRangeResultWhere { @override bool operator ==(Object other) => identical(this, other) || - other is QueryRangeResultWhere && - between == other.between; + other is QueryRangeResultWhere && between == other.between; @override int get hashCode => between.hashCode; @@ -41,22 +51,27 @@ class QueryRangeResultWhere { String toString() => 'QueryRangeResultWhere(between: $between)'; } - // --- API Namespaces --- class QueryRangeResult { final QueryRangeResultWhere where; final List<(String, int)> pairs; - const QueryRangeResult({ - required this.where, - required this.pairs, - }); + const QueryRangeResult({required this.where, required this.pairs}); factory QueryRangeResult.fromJson(Map json) { return QueryRangeResult( - where: QueryRangeResultWhere.fromJson(json['where'] as Map), - pairs: (json['pairs'] as List).map((e) => ((e as List)[0] as String, ((e as List)[1] as num).toInt())).toList(), + where: QueryRangeResultWhere.fromJson( + json['where'] as Map, + ), + pairs: (json['pairs'] as List) + .map( + (e) => ( + (e as List)[0] as String, + ((e as List)[1] as num).toInt(), + ), + ) + .toList(), ); } @@ -81,23 +96,27 @@ class QueryRangeResult { String toString() => 'QueryRangeResult(where: $where, pairs: $pairs)'; } - class GetShortTuplesResult { final List one; final (String, int?) short; - GetShortTuplesResult({ - required this.one, - required this.short, - }) { - if (!(one.length >= 1)) throw ArgumentError('one must have at least 1 items'); - if (!(one.length <= 1)) throw ArgumentError('one must have at most 1 items'); + GetShortTuplesResult({required this.one, required this.short}) { + if (!(one.length >= 1)) + throw ArgumentError('one must have at least 1 items'); + if (!(one.length <= 1)) + throw ArgumentError('one must have at most 1 items'); } factory GetShortTuplesResult.fromJson(Map json) { return GetShortTuplesResult( one: (json['one'] as List).cast(), - short: ((json['short'] as List)[0] as String, ((json['short'] as List).length > 1 ? (json['short'] as List)[1] : null) as int?), + short: ( + (json['short'] as List)[0] as String, + ((json['short'] as List).length > 1 + ? (json['short'] as List)[1] + : null) + as int?, + ), ); } @@ -122,22 +141,31 @@ class GetShortTuplesResult { String toString() => 'GetShortTuplesResult(one: $one, short: $short)'; } - class Api { final BlocksClient _client; Api(this._client); Future<(num, num, String)> getCoords() async { final result = await _client.call('api.getCoords', const []); - return ((result as List)[0] as num, (result as List)[1] as num, (result as List)[2] as String); + return ( + (result as List)[0] as num, + (result as List)[1] as num, + (result as List)[2] as String, + ); } Future<(String, int)> getPair() async { final result = await _client.call('api.getPair', const []); - return ((result as List)[0] as String, ((result as List)[1] as num).toInt()); + return ( + (result as List)[0] as String, + ((result as List)[1] as num).toInt(), + ); } - Future queryRange({required (num, num) range, (String, int?)? cursor}) async { + Future queryRange({ + required (num, num) range, + (String, int?)? cursor, + }) async { final params = [ [range.$1, range.$2], if (cursor != null) [cursor.$1, cursor.$2], @@ -146,16 +174,15 @@ class Api { return QueryRangeResult.fromJson(result as Map); } - Future getShortTuples({required List one}) async { - final params = [ - one, - ]; + Future getShortTuples({ + required List one, + }) async { + final params = [one]; final result = await _client.call('api.getShortTuples', params); return GetShortTuplesResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -173,4 +200,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/12-defaults/dart/client.dart b/native/codegen-fixtures/12-defaults/dart/client.dart index 78a0f208f0..35f3ed32a2 100644 --- a/native/codegen-fixtures/12-defaults/dart/client.dart +++ b/native/codegen-fixtures/12-defaults/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -31,11 +41,7 @@ class CreateItemResult { } Map toJson() { - return { - 'role': role, - 'active': active, - 'retries': retries, - }; + return {'role': role, 'active': active, 'retries': retries}; } @override @@ -50,10 +56,10 @@ class CreateItemResult { int get hashCode => Object.hash(role, active, retries); @override - String toString() => 'CreateItemResult(role: $role, active: $active, retries: $retries)'; + String toString() => + 'CreateItemResult(role: $role, active: $active, retries: $retries)'; } - class Api { final BlocksClient _client; Api(this._client); @@ -64,7 +70,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -82,4 +87,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/13-constraints-string/dart/client.dart b/native/codegen-fixtures/13-constraints-string/dart/client.dart index 0e039833c0..38163fcefc 100644 --- a/native/codegen-fixtures/13-constraints-string/dart/client.dart +++ b/native/codegen-fixtures/13-constraints-string/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -16,17 +26,18 @@ class ApiCreateUserInput { final String code; final String? nickname; - ApiCreateUserInput({ - required this.email, - required this.code, - this.nickname, - }) { - if (!(email.length >= 5)) throw ArgumentError('email must be at least 5 characters'); - if (!(email.length <= 254)) throw ArgumentError('email must be at most 254 characters'); - if (!(RegExp(r'^[A-Z]{3}$').hasMatch(code))) throw ArgumentError('code must match pattern'); + ApiCreateUserInput({required this.email, required this.code, this.nickname}) { + if (!(email.length >= 5)) + throw ArgumentError('email must be at least 5 characters'); + if (!(email.length <= 254)) + throw ArgumentError('email must be at most 254 characters'); + if (!(RegExp(r'^[A-Z]{3}$').hasMatch(code))) + throw ArgumentError('code must match pattern'); if (nickname case final nickname?) { - if (!(nickname.length >= 2)) throw ArgumentError('nickname must be at least 2 characters'); - if (!(nickname.length <= 30)) throw ArgumentError('nickname must be at most 30 characters'); + if (!(nickname.length >= 2)) + throw ArgumentError('nickname must be at least 2 characters'); + if (!(nickname.length <= 30)) + throw ArgumentError('nickname must be at most 30 characters'); } } @@ -58,34 +69,26 @@ class ApiCreateUserInput { int get hashCode => Object.hash(email, code, nickname); @override - String toString() => 'ApiCreateUserInput(email: $email, code: $code, nickname: $nickname)'; + String toString() => + 'ApiCreateUserInput(email: $email, code: $code, nickname: $nickname)'; } - class CreateUserResult { final bool ok; - const CreateUserResult({ - required this.ok, - }); + const CreateUserResult({required this.ok}); factory CreateUserResult.fromJson(Map json) { - return CreateUserResult( - ok: json['ok'] as bool, - ); + return CreateUserResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is CreateUserResult && - ok == other.ok; + identical(this, other) || other is CreateUserResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -94,21 +97,19 @@ class CreateUserResult { String toString() => 'CreateUserResult(ok: $ok)'; } - class Api { final BlocksClient _client; Api(this._client); - Future createUser({required ApiCreateUserInput input}) async { - final params = [ - input.toJson(), - ]; + Future createUser({ + required ApiCreateUserInput input, + }) async { + final params = [input.toJson()]; final result = await _client.call('api.createUser', params); return CreateUserResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -126,4 +127,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/14-constraints-numeric/dart/client.dart b/native/codegen-fixtures/14-constraints-numeric/dart/client.dart index 38e344c0bb..28de0af626 100644 --- a/native/codegen-fixtures/14-constraints-numeric/dart/client.dart +++ b/native/codegen-fixtures/14-constraints-numeric/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -24,7 +34,8 @@ class ApiSetScoreInput { if (!(score >= 0)) throw ArgumentError('score must be >= 0'); if (!(score <= 100)) throw ArgumentError('score must be <= 100'); if (!(level > 0)) throw ArgumentError('level must be > 0'); - if (!(step % 0.5 == 0)) throw ArgumentError('step must be a multiple of 0.5'); + if (!(step % 0.5 == 0)) + throw ArgumentError('step must be a multiple of 0.5'); } factory ApiSetScoreInput.fromJson(Map json) { @@ -36,11 +47,7 @@ class ApiSetScoreInput { } Map toJson() { - return { - 'score': score, - 'level': level, - 'step': step, - }; + return {'score': score, 'level': level, 'step': step}; } @override @@ -55,34 +62,26 @@ class ApiSetScoreInput { int get hashCode => Object.hash(score, level, step); @override - String toString() => 'ApiSetScoreInput(score: $score, level: $level, step: $step)'; + String toString() => + 'ApiSetScoreInput(score: $score, level: $level, step: $step)'; } - class SetScoreResult { final bool ok; - const SetScoreResult({ - required this.ok, - }); + const SetScoreResult({required this.ok}); factory SetScoreResult.fromJson(Map json) { - return SetScoreResult( - ok: json['ok'] as bool, - ); + return SetScoreResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is SetScoreResult && - ok == other.ok; + identical(this, other) || other is SetScoreResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -91,21 +90,17 @@ class SetScoreResult { String toString() => 'SetScoreResult(ok: $ok)'; } - class Api { final BlocksClient _client; Api(this._client); Future setScore({required ApiSetScoreInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('api.setScore', params); return SetScoreResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -123,4 +118,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/15-constraints-array/dart/client.dart b/native/codegen-fixtures/15-constraints-array/dart/client.dart index 382fa06902..cc5a8773dc 100644 --- a/native/codegen-fixtures/15-constraints-array/dart/client.dart +++ b/native/codegen-fixtures/15-constraints-array/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -14,11 +24,11 @@ export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksCli class ApiSetTagsInput { final List tags; - ApiSetTagsInput({ - required this.tags, - }) { - if (!(tags.length >= 1)) throw ArgumentError('tags must have at least 1 items'); - if (!(tags.length <= 10)) throw ArgumentError('tags must have at most 10 items'); + ApiSetTagsInput({required this.tags}) { + if (!(tags.length >= 1)) + throw ArgumentError('tags must have at least 1 items'); + if (!(tags.length <= 10)) + throw ArgumentError('tags must have at most 10 items'); } factory ApiSetTagsInput.fromJson(Map json) { @@ -28,16 +38,13 @@ class ApiSetTagsInput { } Map toJson() { - return { - 'tags': tags, - }; + return {'tags': tags}; } @override bool operator ==(Object other) => identical(this, other) || - other is ApiSetTagsInput && - blocksDeepEquals(tags, other.tags); + other is ApiSetTagsInput && blocksDeepEquals(tags, other.tags); @override int get hashCode => blocksDeepHash(tags); @@ -46,31 +53,22 @@ class ApiSetTagsInput { String toString() => 'ApiSetTagsInput(tags: $tags)'; } - class SetTagsResult { final bool ok; - const SetTagsResult({ - required this.ok, - }); + const SetTagsResult({required this.ok}); factory SetTagsResult.fromJson(Map json) { - return SetTagsResult( - ok: json['ok'] as bool, - ); + return SetTagsResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is SetTagsResult && - ok == other.ok; + identical(this, other) || other is SetTagsResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -79,21 +77,17 @@ class SetTagsResult { String toString() => 'SetTagsResult(ok: $ok)'; } - class Api { final BlocksClient _client; Api(this._client); Future setTags({required ApiSetTagsInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('api.setTags', params); return SetTagsResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -111,4 +105,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/16-ref-in-union-arm/dart/client.dart b/native/codegen-fixtures/16-ref-in-union-arm/dart/client.dart index f4eb186f9a..56c421daf7 100644 --- a/native/codegen-fixtures/16-ref-in-union-arm/dart/client.dart +++ b/native/codegen-fixtures/16-ref-in-union-arm/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,19 +6,26 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- enum MfaChallengeAction { - mfa -; + mfa; String toJson() => name; static MfaChallengeAction fromJson(String json) => values.byName(json); } - class MfaChallenge { final MfaChallengeAction action; final String code; @@ -38,11 +46,7 @@ class MfaChallenge { } Map toJson() { - return { - 'action': action.toJson(), - 'code': code, - 'session': session, - }; + return {'action': action.toJson(), 'code': code, 'session': session}; } @override @@ -57,36 +61,28 @@ class MfaChallenge { int get hashCode => Object.hash(action, code, session); @override - String toString() => 'MfaChallenge(action: $action, code: $code, session: $session)'; + String toString() => + 'MfaChallenge(action: $action, code: $code, session: $session)'; } - // --- API Namespaces --- class DoActionResult { final bool ok; - const DoActionResult({ - required this.ok, - }); + const DoActionResult({required this.ok}); factory DoActionResult.fromJson(Map json) { - return DoActionResult( - ok: json['ok'] as bool, - ); + return DoActionResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is DoActionResult && - ok == other.ok; + identical(this, other) || other is DoActionResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -95,21 +91,17 @@ class DoActionResult { String toString() => 'DoActionResult(ok: $ok)'; } - class Api { final BlocksClient _client; Api(this._client); Future doAction({required dynamic input}) async { - final params = [ - input, - ]; + final params = [input]; final result = await _client.call('api.doAction', params); return DoActionResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -127,4 +119,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/17-transferables/dart/client.dart b/native/codegen-fixtures/17-transferables/dart/client.dart index 74b8641634..9bc086c54b 100644 --- a/native/codegen-fixtures/17-transferables/dart/client.dart +++ b/native/codegen-fixtures/17-transferables/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,8 +6,28 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; -export 'package:blocks_runtime/blocks_runtime.dart' show RealtimeChannel, FileDownloadHandle, FileUploadHandle, FileTransferException, RealtimeException, RealtimeChannelClosedException, RealtimeConnectionException, RealtimeSubscriptionEndedException, TransferableException, InvalidDescriptorException; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + RealtimeChannel, + FileDownloadHandle, + FileUploadHandle, + FileTransferException, + RealtimeException, + RealtimeChannelClosedException, + RealtimeConnectionException, + RealtimeSubscriptionEndedException, + TransferableException, + InvalidDescriptorException; // --- Models --- @@ -27,10 +48,7 @@ class GetChannelResultMessage { } Map toJson() { - return { - 'message': message, - 'timestamp': timestamp, - }; + return {'message': message, 'timestamp': timestamp}; } @override @@ -44,10 +62,10 @@ class GetChannelResultMessage { int get hashCode => Object.hash(message, timestamp); @override - String toString() => 'GetChannelResultMessage(message: $message, timestamp: $timestamp)'; + String toString() => + 'GetChannelResultMessage(message: $message, timestamp: $timestamp)'; } - // --- API Namespaces --- class Api { @@ -56,27 +74,25 @@ class Api { Future> getChannel() async { final result = await _client.call('api.getChannel', const []); - return RealtimeChannel.fromJson(result as Map, (json) => GetChannelResultMessage.fromJson(json)); + return RealtimeChannel.fromJson( + result as Map, + (json) => GetChannelResultMessage.fromJson(json), + ); } Future getFile({required String path}) async { - final params = [ - path, - ]; + final params = [path]; final result = await _client.call('api.getFile', params); return FileDownloadHandle.fromJson(result as Map); } Future getUpload({required String path}) async { - final params = [ - path, - ]; + final params = [path]; final result = await _client.call('api.getUpload', params); return FileUploadHandle.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -94,4 +110,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/18-hybrid-arm/dart/client.dart b/native/codegen-fixtures/18-hybrid-arm/dart/client.dart index 52c456dd8e..a215cab81a 100644 --- a/native/codegen-fixtures/18-hybrid-arm/dart/client.dart +++ b/native/codegen-fixtures/18-hybrid-arm/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -60,25 +70,30 @@ class Todo { createdAt == other.createdAt; @override - int get hashCode => Object.hash(userId, todoId, title, completed, priority, createdAt); + int get hashCode => + Object.hash(userId, todoId, title, completed, priority, createdAt); @override - String toString() => 'Todo(userId: $userId, todoId: $todoId, title: $title, completed: $completed, priority: $priority, createdAt: $createdAt)'; + String toString() => + 'Todo(userId: $userId, todoId: $todoId, title: $title, completed: $completed, priority: $priority, createdAt: $createdAt)'; } - sealed class AuthStateState { static const signedOut = AuthStateStateKnown.signedOut; static const signedIn = AuthStateStateKnown.signedIn; static const confirmingSignUp = AuthStateStateKnown.confirmingSignUp; static const confirmingSignIn = AuthStateStateKnown.confirmingSignIn; static const confirmingMfa = AuthStateStateKnown.confirmingMfa; - static const confirmingPasswordReset = AuthStateStateKnown.confirmingPasswordReset; + static const confirmingPasswordReset = + AuthStateStateKnown.confirmingPasswordReset; static const values = AuthStateStateKnown.values; - static final Map _byJson = AuthStateStateKnown.values.asNameMap(); + static final Map _byJson = AuthStateStateKnown + .values + .asNameMap(); String toJson(); - static AuthStateState fromJson(String json) => _byJson[json] ?? AuthStateStateUnknown(json); + static AuthStateState fromJson(String json) => + _byJson[json] ?? AuthStateStateUnknown(json); } enum AuthStateStateKnown implements AuthStateState { @@ -87,8 +102,7 @@ enum AuthStateStateKnown implements AuthStateState { confirmingSignUp, confirmingSignIn, confirmingMfa, - confirmingPasswordReset -; + confirmingPasswordReset; @override String toJson() => name; @@ -110,10 +124,11 @@ final class AuthStateStateUnknown implements AuthStateState { int get hashCode => value.hashCode; @override - String toString() => 'AuthStateStateUnknown' '($value)'; + String toString() => + 'AuthStateStateUnknown' + '($value)'; } - class AuthUser { final String userId; final String username; @@ -153,24 +168,25 @@ class AuthUser { int get hashCode => Object.hash(userId, username, displayName); @override - String toString() => 'AuthUser(userId: $userId, username: $username, displayName: $displayName)'; + String toString() => + 'AuthUser(userId: $userId, username: $username, displayName: $displayName)'; } - sealed class AuthActionMethod { static const GET = AuthActionMethodKnown.GET; static const POST = AuthActionMethodKnown.POST; static const values = AuthActionMethodKnown.values; - static final Map _byJson = AuthActionMethodKnown.values.asNameMap(); + static final Map _byJson = + AuthActionMethodKnown.values.asNameMap(); String toJson(); - static AuthActionMethod fromJson(String json) => _byJson[json] ?? AuthActionMethodUnknown(json); + static AuthActionMethod fromJson(String json) => + _byJson[json] ?? AuthActionMethodUnknown(json); } enum AuthActionMethodKnown implements AuthActionMethod { GET, - POST -; + POST; @override String toJson() => name; @@ -192,23 +208,25 @@ final class AuthActionMethodUnknown implements AuthActionMethod { int get hashCode => value.hashCode; @override - String toString() => 'AuthActionMethodUnknown' '($value)'; + String toString() => + 'AuthActionMethodUnknown' + '($value)'; } - sealed class AuthActionCapability { static const webauthnGet = AuthActionCapabilityKnown.webauthnGet; static const webauthnCreate = AuthActionCapabilityKnown.webauthnCreate; static const values = AuthActionCapabilityKnown.values; String toJson(); - static AuthActionCapability fromJson(String json) => AuthActionCapabilityKnown._jsonMap[json] ?? AuthActionCapabilityUnknown(json); + static AuthActionCapability fromJson(String json) => + AuthActionCapabilityKnown._jsonMap[json] ?? + AuthActionCapabilityUnknown(json); } enum AuthActionCapabilityKnown implements AuthActionCapability { webauthnGet, - webauthnCreate -; + webauthnCreate; static const _jsonMap = { 'webauthn-get': webauthnGet, @@ -238,10 +256,11 @@ final class AuthActionCapabilityUnknown implements AuthActionCapability { int get hashCode => value.hashCode; @override - String toString() => 'AuthActionCapabilityUnknown' '($value)'; + String toString() => + 'AuthActionCapabilityUnknown' + '($value)'; } - class AuthAction { final String name; final String label; @@ -265,10 +284,16 @@ class AuthAction { return AuthAction( name: json['name'] as String, label: json['label'] as String, - fields: (json['fields'] as List).map((e) => AuthField.fromJson(e as Map)).toList(), + fields: (json['fields'] as List) + .map((e) => AuthField.fromJson(e as Map)) + .toList(), url: json['url'] as String?, - method: json['method'] != null ? AuthActionMethod.fromJson(json['method'] as String) : null, - capability: json['capability'] != null ? AuthActionCapability.fromJson(json['capability'] as String) : null, + method: json['method'] != null + ? AuthActionMethod.fromJson(json['method'] as String) + : null, + capability: json['capability'] != null + ? AuthActionCapability.fromJson(json['capability'] as String) + : null, unavailable: json['unavailable'] as String?, ); } @@ -298,13 +323,21 @@ class AuthAction { unavailable == other.unavailable; @override - int get hashCode => Object.hash(name, label, blocksDeepHash(fields), url, method, capability, unavailable); + int get hashCode => Object.hash( + name, + label, + blocksDeepHash(fields), + url, + method, + capability, + unavailable, + ); @override - String toString() => 'AuthAction(name: $name, label: $label, fields: $fields, url: $url, method: $method, capability: $capability, unavailable: $unavailable)'; + String toString() => + 'AuthAction(name: $name, label: $label, fields: $fields, url: $url, method: $method, capability: $capability, unavailable: $unavailable)'; } - sealed class AuthFieldType { static const number = AuthFieldTypeKnown.number; static const password = AuthFieldTypeKnown.password; @@ -313,10 +346,13 @@ sealed class AuthFieldType { static const tel = AuthFieldTypeKnown.tel; static const hidden = AuthFieldTypeKnown.hidden; static const values = AuthFieldTypeKnown.values; - static final Map _byJson = AuthFieldTypeKnown.values.asNameMap(); + static final Map _byJson = AuthFieldTypeKnown + .values + .asNameMap(); String toJson(); - static AuthFieldType fromJson(String json) => _byJson[json] ?? AuthFieldTypeUnknown(json); + static AuthFieldType fromJson(String json) => + _byJson[json] ?? AuthFieldTypeUnknown(json); } enum AuthFieldTypeKnown implements AuthFieldType { @@ -325,8 +361,7 @@ enum AuthFieldTypeKnown implements AuthFieldType { email, text, tel, - hidden -; + hidden; @override String toJson() => name; @@ -348,10 +383,11 @@ final class AuthFieldTypeUnknown implements AuthFieldType { int get hashCode => value.hashCode; @override - String toString() => 'AuthFieldTypeUnknown' '($value)'; + String toString() => + 'AuthFieldTypeUnknown' + '($value)'; } - class AuthField { final String name; final String label; @@ -401,24 +437,33 @@ class AuthField { int get hashCode => Object.hash(name, label, type, required$, defaultValue); @override - String toString() => 'AuthField(name: $name, label: $label, type: $type, required\$: ${required$}, defaultValue: $defaultValue)'; + String toString() => + 'AuthField(name: $name, label: $label, type: $type, required\$: ${required$}, defaultValue: $defaultValue)'; } - sealed class ConfirmSignInInputChallenge { const ConfirmSignInInputChallenge(); Map toJson(); static ConfirmSignInInputChallenge fromJson(Map json) { switch (json['challenge'] as String) { - case 'code': return CodeConfirmSignInInputChallenge.fromJson(json); - case 'mfaType': return MfaTypeConfirmSignInInputChallenge.fromJson(json); - case 'newPassword': return NewPasswordConfirmSignInInputChallenge.fromJson(json); - case 'totpSetup': return TotpSetupConfirmSignInInputChallenge.fromJson(json); - case 'email': return EmailConfirmSignInInputChallenge.fromJson(json); - case 'password': return PasswordConfirmSignInInputChallenge.fromJson(json); - case 'firstFactor': return FirstFactorConfirmSignInInputChallenge.fromJson(json); - case 'webauthn': return WebauthnConfirmSignInInputChallenge.fromJson(json); - default: throw ArgumentError('Unknown challenge: ${json['challenge']}'); + case 'code': + return CodeConfirmSignInInputChallenge.fromJson(json); + case 'mfaType': + return MfaTypeConfirmSignInInputChallenge.fromJson(json); + case 'newPassword': + return NewPasswordConfirmSignInInputChallenge.fromJson(json); + case 'totpSetup': + return TotpSetupConfirmSignInInputChallenge.fromJson(json); + case 'email': + return EmailConfirmSignInInputChallenge.fromJson(json); + case 'password': + return PasswordConfirmSignInInputChallenge.fromJson(json); + case 'firstFactor': + return FirstFactorConfirmSignInInputChallenge.fromJson(json); + case 'webauthn': + return WebauthnConfirmSignInInputChallenge.fromJson(json); + default: + throw ArgumentError('Unknown challenge: ${json['challenge']}'); } } } @@ -426,29 +471,21 @@ sealed class ConfirmSignInInputChallenge { class CodeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { final String code; - const CodeConfirmSignInInputChallenge({ - required this.code, - }); + const CodeConfirmSignInInputChallenge({required this.code}); factory CodeConfirmSignInInputChallenge.fromJson(Map json) { - return CodeConfirmSignInInputChallenge( - code: json['code'] as String, - ); + return CodeConfirmSignInInputChallenge(code: json['code'] as String); } @override Map toJson() { - return { - 'challenge': 'code', - 'code': code, - }; + return {'challenge': 'code', 'code': code}; } @override bool operator ==(Object other) => identical(this, other) || - other is CodeConfirmSignInInputChallenge && - code == other.code; + other is CodeConfirmSignInInputChallenge && code == other.code; @override int get hashCode => code.hashCode; @@ -460,11 +497,11 @@ class CodeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { class MfaTypeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { final String mfaType; - const MfaTypeConfirmSignInInputChallenge({ - required this.mfaType, - }); + const MfaTypeConfirmSignInInputChallenge({required this.mfaType}); - factory MfaTypeConfirmSignInInputChallenge.fromJson(Map json) { + factory MfaTypeConfirmSignInInputChallenge.fromJson( + Map json, + ) { return MfaTypeConfirmSignInInputChallenge( mfaType: json['mfaType'] as String, ); @@ -472,17 +509,13 @@ class MfaTypeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { @override Map toJson() { - return { - 'challenge': 'mfaType', - 'mfaType': mfaType, - }; + return {'challenge': 'mfaType', 'mfaType': mfaType}; } @override bool operator ==(Object other) => identical(this, other) || - other is MfaTypeConfirmSignInInputChallenge && - mfaType == other.mfaType; + other is MfaTypeConfirmSignInInputChallenge && mfaType == other.mfaType; @override int get hashCode => mfaType.hashCode; @@ -491,14 +524,15 @@ class MfaTypeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { String toString() => 'MfaTypeConfirmSignInInputChallenge(mfaType: $mfaType)'; } -class NewPasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { +class NewPasswordConfirmSignInInputChallenge + extends ConfirmSignInInputChallenge { final String newPassword; - const NewPasswordConfirmSignInInputChallenge({ - required this.newPassword, - }); + const NewPasswordConfirmSignInInputChallenge({required this.newPassword}); - factory NewPasswordConfirmSignInInputChallenge.fromJson(Map json) { + factory NewPasswordConfirmSignInInputChallenge.fromJson( + Map json, + ) { return NewPasswordConfirmSignInInputChallenge( newPassword: json['newPassword'] as String, ); @@ -506,10 +540,7 @@ class NewPasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge @override Map toJson() { - return { - 'challenge': 'newPassword', - 'newPassword': newPassword, - }; + return {'challenge': 'newPassword', 'newPassword': newPassword}; } @override @@ -522,7 +553,8 @@ class NewPasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge int get hashCode => newPassword.hashCode; @override - String toString() => 'NewPasswordConfirmSignInInputChallenge(newPassword: $newPassword)'; + String toString() => + 'NewPasswordConfirmSignInInputChallenge(newPassword: $newPassword)'; } class TotpSetupConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { @@ -534,7 +566,9 @@ class TotpSetupConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { required this.code, }); - factory TotpSetupConfirmSignInInputChallenge.fromJson(Map json) { + factory TotpSetupConfirmSignInInputChallenge.fromJson( + Map json, + ) { return TotpSetupConfirmSignInInputChallenge( sharedSecret: json['sharedSecret'] as String, code: json['code'] as String, @@ -561,35 +595,28 @@ class TotpSetupConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { int get hashCode => Object.hash(sharedSecret, code); @override - String toString() => 'TotpSetupConfirmSignInInputChallenge(sharedSecret: $sharedSecret, code: $code)'; + String toString() => + 'TotpSetupConfirmSignInInputChallenge(sharedSecret: $sharedSecret, code: $code)'; } class EmailConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { final String email; - const EmailConfirmSignInInputChallenge({ - required this.email, - }); + const EmailConfirmSignInInputChallenge({required this.email}); factory EmailConfirmSignInInputChallenge.fromJson(Map json) { - return EmailConfirmSignInInputChallenge( - email: json['email'] as String, - ); + return EmailConfirmSignInInputChallenge(email: json['email'] as String); } @override Map toJson() { - return { - 'challenge': 'email', - 'email': email, - }; + return {'challenge': 'email', 'email': email}; } @override bool operator ==(Object other) => identical(this, other) || - other is EmailConfirmSignInInputChallenge && - email == other.email; + other is EmailConfirmSignInInputChallenge && email == other.email; @override int get hashCode => email.hashCode; @@ -601,11 +628,11 @@ class EmailConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { class PasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { final String password; - const PasswordConfirmSignInInputChallenge({ - required this.password, - }); + const PasswordConfirmSignInInputChallenge({required this.password}); - factory PasswordConfirmSignInInputChallenge.fromJson(Map json) { + factory PasswordConfirmSignInInputChallenge.fromJson( + Map json, + ) { return PasswordConfirmSignInInputChallenge( password: json['password'] as String, ); @@ -613,10 +640,7 @@ class PasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { @override Map toJson() { - return { - 'challenge': 'password', - 'password': password, - }; + return {'challenge': 'password', 'password': password}; } @override @@ -629,17 +653,19 @@ class PasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { int get hashCode => password.hashCode; @override - String toString() => 'PasswordConfirmSignInInputChallenge(password: $password)'; + String toString() => + 'PasswordConfirmSignInInputChallenge(password: $password)'; } -class FirstFactorConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { +class FirstFactorConfirmSignInInputChallenge + extends ConfirmSignInInputChallenge { final String firstFactor; - const FirstFactorConfirmSignInInputChallenge({ - required this.firstFactor, - }); + const FirstFactorConfirmSignInInputChallenge({required this.firstFactor}); - factory FirstFactorConfirmSignInInputChallenge.fromJson(Map json) { + factory FirstFactorConfirmSignInInputChallenge.fromJson( + Map json, + ) { return FirstFactorConfirmSignInInputChallenge( firstFactor: json['firstFactor'] as String, ); @@ -647,10 +673,7 @@ class FirstFactorConfirmSignInInputChallenge extends ConfirmSignInInputChallenge @override Map toJson() { - return { - 'challenge': 'firstFactor', - 'firstFactor': firstFactor, - }; + return {'challenge': 'firstFactor', 'firstFactor': firstFactor}; } @override @@ -663,17 +686,18 @@ class FirstFactorConfirmSignInInputChallenge extends ConfirmSignInInputChallenge int get hashCode => firstFactor.hashCode; @override - String toString() => 'FirstFactorConfirmSignInInputChallenge(firstFactor: $firstFactor)'; + String toString() => + 'FirstFactorConfirmSignInInputChallenge(firstFactor: $firstFactor)'; } class WebauthnConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { final String credential; - const WebauthnConfirmSignInInputChallenge({ - required this.credential, - }); + const WebauthnConfirmSignInInputChallenge({required this.credential}); - factory WebauthnConfirmSignInInputChallenge.fromJson(Map json) { + factory WebauthnConfirmSignInInputChallenge.fromJson( + Map json, + ) { return WebauthnConfirmSignInInputChallenge( credential: json['credential'] as String, ); @@ -681,10 +705,7 @@ class WebauthnConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { @override Map toJson() { - return { - 'challenge': 'webauthn', - 'credential': credential, - }; + return {'challenge': 'webauthn', 'credential': credential}; } @override @@ -697,47 +718,43 @@ class WebauthnConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { int get hashCode => credential.hashCode; @override - String toString() => 'WebauthnConfirmSignInInputChallenge(credential: $credential)'; + String toString() => + 'WebauthnConfirmSignInInputChallenge(credential: $credential)'; } - - enum UpdateMfaPreferenceInputSms { ENABLED, DISABLED, PREFERRED, - NOT_PREFERRED -; + NOT_PREFERRED; String toJson() => name; - static UpdateMfaPreferenceInputSms fromJson(String json) => values.byName(json); + static UpdateMfaPreferenceInputSms fromJson(String json) => + values.byName(json); } - enum UpdateMfaPreferenceInputTotp { ENABLED, DISABLED, PREFERRED, - NOT_PREFERRED -; + NOT_PREFERRED; String toJson() => name; - static UpdateMfaPreferenceInputTotp fromJson(String json) => values.byName(json); + static UpdateMfaPreferenceInputTotp fromJson(String json) => + values.byName(json); } - enum UpdateMfaPreferenceInputEmail { ENABLED, DISABLED, PREFERRED, - NOT_PREFERRED -; + NOT_PREFERRED; String toJson() => name; - static UpdateMfaPreferenceInputEmail fromJson(String json) => values.byName(json); + static UpdateMfaPreferenceInputEmail fromJson(String json) => + values.byName(json); } - @Deprecated('Use AuthActionInput') typedef AuthApiSetAuthStateInput = AuthActionInput; @@ -763,8 +780,12 @@ class AuthState { factory AuthState.fromJson(Map json) { return AuthState( state: AuthStateState.fromJson(json['state'] as String), - user: json['user'] != null ? AuthUser.fromJson(json['user'] as Map) : null, - actions: (json['actions'] as List).map((e) => AuthAction.fromJson(e as Map)).toList(), + user: json['user'] != null + ? AuthUser.fromJson(json['user'] as Map) + : null, + actions: (json['actions'] as List) + .map((e) => AuthAction.fromJson(e as Map)) + .toList(), error: json['error'] as String?, errorName: json['errorName'] as String?, retriable: json['retriable'] as bool?, @@ -794,37 +815,63 @@ class AuthState { retriable == other.retriable; @override - int get hashCode => Object.hash(state, user, blocksDeepHash(actions), error, errorName, retriable); + int get hashCode => Object.hash( + state, + user, + blocksDeepHash(actions), + error, + errorName, + retriable, + ); @override - String toString() => 'AuthState(state: $state, user: $user, actions: $actions, error: $error, errorName: $errorName, retriable: $retriable)'; + String toString() => + 'AuthState(state: $state, user: $user, actions: $actions, error: $error, errorName: $errorName, retriable: $retriable)'; } - sealed class AuthActionInput { const AuthActionInput(); Map toJson(); static AuthActionInput fromJson(Map json) { switch (json['action'] as String) { - case 'signUp': return SignUpInput.fromJson(json); - case 'resetPassword': return ResetPasswordInput.fromJson(json); - case 'signIn': return SignInInput.fromJson(json); - case 'signInWithPasskey': return SignInWithPasskeyInput.fromJson(json); - case 'confirmSignUp': return ConfirmSignUpInput.fromJson(json); - case 'resendSignUpCode': return ResendSignUpCodeInput.fromJson(json); - case 'signOut': return SignOutInput.fromJson(json); - case 'confirmResetPassword': return ConfirmResetPasswordInput.fromJson(json); - case 'autoSignIn': return AutoSignInInput.fromJson(json); - case 'confirmSignIn': return ConfirmSignInInput.fromJson(json); - case 'startPasskeyRegistration': return StartPasskeyRegistrationInput.fromJson(json); - case 'completePasskeyRegistration': return CompletePasskeyRegistrationInput.fromJson(json); - case 'listPasskeys': return ListPasskeysInput.fromJson(json); - case 'deletePasskey': return DeletePasskeyInput.fromJson(json); - case 'setUpTotp': return SetUpTotpInput.fromJson(json); - case 'verifyTotpSetup': return VerifyTotpSetupInput.fromJson(json); - case 'getMfaPreference': return GetMfaPreferenceInput.fromJson(json); - case 'updateMfaPreference': return UpdateMfaPreferenceInput.fromJson(json); - default: throw ArgumentError('Unknown action: ${json['action']}'); + case 'signUp': + return SignUpInput.fromJson(json); + case 'resetPassword': + return ResetPasswordInput.fromJson(json); + case 'signIn': + return SignInInput.fromJson(json); + case 'signInWithPasskey': + return SignInWithPasskeyInput.fromJson(json); + case 'confirmSignUp': + return ConfirmSignUpInput.fromJson(json); + case 'resendSignUpCode': + return ResendSignUpCodeInput.fromJson(json); + case 'signOut': + return SignOutInput.fromJson(json); + case 'confirmResetPassword': + return ConfirmResetPasswordInput.fromJson(json); + case 'autoSignIn': + return AutoSignInInput.fromJson(json); + case 'confirmSignIn': + return ConfirmSignInInput.fromJson(json); + case 'startPasskeyRegistration': + return StartPasskeyRegistrationInput.fromJson(json); + case 'completePasskeyRegistration': + return CompletePasskeyRegistrationInput.fromJson(json); + case 'listPasskeys': + return ListPasskeysInput.fromJson(json); + case 'deletePasskey': + return DeletePasskeyInput.fromJson(json); + case 'setUpTotp': + return SetUpTotpInput.fromJson(json); + case 'verifyTotpSetup': + return VerifyTotpSetupInput.fromJson(json); + case 'getMfaPreference': + return GetMfaPreferenceInput.fromJson(json); + case 'updateMfaPreference': + return UpdateMfaPreferenceInput.fromJson(json); + default: + throw ArgumentError('Unknown action: ${json['action']}'); } } } @@ -846,7 +893,8 @@ class SignUpInput extends AuthActionInput { username: json['username'] as String, password: json['password'] as String, additionalProperties: Map.fromEntries( - json.entries.where((e) => !knownKeys.contains(e.key)) + json.entries + .where((e) => !knownKeys.contains(e.key)) .map((e) => MapEntry(e.key, e.value as String)), ), ); @@ -859,7 +907,8 @@ class SignUpInput extends AuthActionInput { 'username': username, 'password': password, for (final e in additionalProperties.entries) - if (!const {'action', 'username', 'password'}.contains(e.key)) e.key: e.value, + if (!const {'action', 'username', 'password'}.contains(e.key)) + e.key: e.value, }; } @@ -872,38 +921,32 @@ class SignUpInput extends AuthActionInput { blocksDeepEquals(additionalProperties, other.additionalProperties); @override - int get hashCode => Object.hash(username, password, blocksDeepHash(additionalProperties)); + int get hashCode => + Object.hash(username, password, blocksDeepHash(additionalProperties)); @override - String toString() => 'SignUpInput(username: $username, password: $password, additionalProperties: $additionalProperties)'; + String toString() => + 'SignUpInput(username: $username, password: $password, additionalProperties: $additionalProperties)'; } class ResetPasswordInput extends AuthActionInput { final String username; - const ResetPasswordInput({ - required this.username, - }); + const ResetPasswordInput({required this.username}); factory ResetPasswordInput.fromJson(Map json) { - return ResetPasswordInput( - username: json['username'] as String, - ); + return ResetPasswordInput(username: json['username'] as String); } @override Map toJson() { - return { - 'action': 'resetPassword', - 'username': username, - }; + return {'action': 'resetPassword', 'username': username}; } @override bool operator ==(Object other) => identical(this, other) || - other is ResetPasswordInput && - username == other.username; + other is ResetPasswordInput && username == other.username; @override int get hashCode => username.hashCode; @@ -916,10 +959,7 @@ class SignInInput extends AuthActionInput { final String username; final String password; - const SignInInput({ - required this.username, - required this.password, - }); + const SignInInput({required this.username, required this.password}); factory SignInInput.fromJson(Map json) { return SignInInput( @@ -930,11 +970,7 @@ class SignInInput extends AuthActionInput { @override Map toJson() { - return { - 'action': 'signIn', - 'username': username, - 'password': password, - }; + return {'action': 'signIn', 'username': username, 'password': password}; } @override @@ -954,29 +990,21 @@ class SignInInput extends AuthActionInput { class SignInWithPasskeyInput extends AuthActionInput { final String username; - const SignInWithPasskeyInput({ - required this.username, - }); + const SignInWithPasskeyInput({required this.username}); factory SignInWithPasskeyInput.fromJson(Map json) { - return SignInWithPasskeyInput( - username: json['username'] as String, - ); + return SignInWithPasskeyInput(username: json['username'] as String); } @override Map toJson() { - return { - 'action': 'signInWithPasskey', - 'username': username, - }; + return {'action': 'signInWithPasskey', 'username': username}; } @override bool operator ==(Object other) => identical(this, other) || - other is SignInWithPasskeyInput && - username == other.username; + other is SignInWithPasskeyInput && username == other.username; @override int get hashCode => username.hashCode; @@ -1026,35 +1054,28 @@ class ConfirmSignUpInput extends AuthActionInput { int get hashCode => Object.hash(username, code, password); @override - String toString() => 'ConfirmSignUpInput(username: $username, code: $code, password: $password)'; + String toString() => + 'ConfirmSignUpInput(username: $username, code: $code, password: $password)'; } class ResendSignUpCodeInput extends AuthActionInput { final String username; - const ResendSignUpCodeInput({ - required this.username, - }); + const ResendSignUpCodeInput({required this.username}); factory ResendSignUpCodeInput.fromJson(Map json) { - return ResendSignUpCodeInput( - username: json['username'] as String, - ); + return ResendSignUpCodeInput(username: json['username'] as String); } @override Map toJson() { - return { - 'action': 'resendSignUpCode', - 'username': username, - }; + return {'action': 'resendSignUpCode', 'username': username}; } @override bool operator ==(Object other) => identical(this, other) || - other is ResendSignUpCodeInput && - username == other.username; + other is ResendSignUpCodeInput && username == other.username; @override int get hashCode => username.hashCode; @@ -1064,25 +1085,20 @@ class ResendSignUpCodeInput extends AuthActionInput { } class SignOutInput extends AuthActionInput { - const SignOutInput(); factory SignOutInput.fromJson(Map json) { - return SignOutInput( - ); + return SignOutInput(); } @override Map toJson() { - return { - 'action': 'signOut', - }; + return {'action': 'signOut'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is SignOutInput; + identical(this, other) || other is SignOutInput; @override int get hashCode => runtimeType.hashCode; @@ -1132,35 +1148,28 @@ class ConfirmResetPasswordInput extends AuthActionInput { int get hashCode => Object.hash(username, code, newPassword); @override - String toString() => 'ConfirmResetPasswordInput(username: $username, code: $code, newPassword: $newPassword)'; + String toString() => + 'ConfirmResetPasswordInput(username: $username, code: $code, newPassword: $newPassword)'; } class AutoSignInInput extends AuthActionInput { final String username; - const AutoSignInInput({ - required this.username, - }); + const AutoSignInInput({required this.username}); factory AutoSignInInput.fromJson(Map json) { - return AutoSignInInput( - username: json['username'] as String, - ); + return AutoSignInInput(username: json['username'] as String); } @override Map toJson() { - return { - 'action': 'autoSignIn', - 'username': username, - }; + return {'action': 'autoSignIn', 'username': username}; } @override bool operator ==(Object other) => identical(this, other) || - other is AutoSignInInput && - username == other.username; + other is AutoSignInInput && username == other.username; @override int get hashCode => username.hashCode; @@ -1169,16 +1178,11 @@ class AutoSignInInput extends AuthActionInput { String toString() => 'AutoSignInInput(username: $username)'; } - - class ConfirmSignInInput extends AuthActionInput { final String session; final ConfirmSignInInputChallenge challenge; - const ConfirmSignInInput({ - required this.session, - required this.challenge, - }); + const ConfirmSignInInput({required this.session, required this.challenge}); factory ConfirmSignInInput.fromJson(Map json) { return ConfirmSignInInput( @@ -1207,29 +1211,25 @@ class ConfirmSignInInput extends AuthActionInput { int get hashCode => Object.hash(session, challenge); @override - String toString() => 'ConfirmSignInInput(session: $session, challenge: $challenge)'; + String toString() => + 'ConfirmSignInInput(session: $session, challenge: $challenge)'; } class StartPasskeyRegistrationInput extends AuthActionInput { - const StartPasskeyRegistrationInput(); factory StartPasskeyRegistrationInput.fromJson(Map json) { - return StartPasskeyRegistrationInput( - ); + return StartPasskeyRegistrationInput(); } @override Map toJson() { - return { - 'action': 'startPasskeyRegistration', - }; + return {'action': 'startPasskeyRegistration'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is StartPasskeyRegistrationInput; + identical(this, other) || other is StartPasskeyRegistrationInput; @override int get hashCode => runtimeType.hashCode; @@ -1241,9 +1241,7 @@ class StartPasskeyRegistrationInput extends AuthActionInput { class CompletePasskeyRegistrationInput extends AuthActionInput { final String credential; - const CompletePasskeyRegistrationInput({ - required this.credential, - }); + const CompletePasskeyRegistrationInput({required this.credential}); factory CompletePasskeyRegistrationInput.fromJson(Map json) { return CompletePasskeyRegistrationInput( @@ -1253,10 +1251,7 @@ class CompletePasskeyRegistrationInput extends AuthActionInput { @override Map toJson() { - return { - 'action': 'completePasskeyRegistration', - 'credential': credential, - }; + return {'action': 'completePasskeyRegistration', 'credential': credential}; } @override @@ -1269,29 +1264,25 @@ class CompletePasskeyRegistrationInput extends AuthActionInput { int get hashCode => credential.hashCode; @override - String toString() => 'CompletePasskeyRegistrationInput(credential: $credential)'; + String toString() => + 'CompletePasskeyRegistrationInput(credential: $credential)'; } class ListPasskeysInput extends AuthActionInput { - const ListPasskeysInput(); factory ListPasskeysInput.fromJson(Map json) { - return ListPasskeysInput( - ); + return ListPasskeysInput(); } @override Map toJson() { - return { - 'action': 'listPasskeys', - }; + return {'action': 'listPasskeys'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is ListPasskeysInput; + identical(this, other) || other is ListPasskeysInput; @override int get hashCode => runtimeType.hashCode; @@ -1303,29 +1294,21 @@ class ListPasskeysInput extends AuthActionInput { class DeletePasskeyInput extends AuthActionInput { final String credentialId; - const DeletePasskeyInput({ - required this.credentialId, - }); + const DeletePasskeyInput({required this.credentialId}); factory DeletePasskeyInput.fromJson(Map json) { - return DeletePasskeyInput( - credentialId: json['credentialId'] as String, - ); + return DeletePasskeyInput(credentialId: json['credentialId'] as String); } @override Map toJson() { - return { - 'action': 'deletePasskey', - 'credentialId': credentialId, - }; + return {'action': 'deletePasskey', 'credentialId': credentialId}; } @override bool operator ==(Object other) => identical(this, other) || - other is DeletePasskeyInput && - credentialId == other.credentialId; + other is DeletePasskeyInput && credentialId == other.credentialId; @override int get hashCode => credentialId.hashCode; @@ -1335,25 +1318,20 @@ class DeletePasskeyInput extends AuthActionInput { } class SetUpTotpInput extends AuthActionInput { - const SetUpTotpInput(); factory SetUpTotpInput.fromJson(Map json) { - return SetUpTotpInput( - ); + return SetUpTotpInput(); } @override Map toJson() { - return { - 'action': 'setUpTotp', - }; + return {'action': 'setUpTotp'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is SetUpTotpInput; + identical(this, other) || other is SetUpTotpInput; @override int get hashCode => runtimeType.hashCode; @@ -1365,29 +1343,21 @@ class SetUpTotpInput extends AuthActionInput { class VerifyTotpSetupInput extends AuthActionInput { final String code; - const VerifyTotpSetupInput({ - required this.code, - }); + const VerifyTotpSetupInput({required this.code}); factory VerifyTotpSetupInput.fromJson(Map json) { - return VerifyTotpSetupInput( - code: json['code'] as String, - ); + return VerifyTotpSetupInput(code: json['code'] as String); } @override Map toJson() { - return { - 'action': 'verifyTotpSetup', - 'code': code, - }; + return {'action': 'verifyTotpSetup', 'code': code}; } @override bool operator ==(Object other) => identical(this, other) || - other is VerifyTotpSetupInput && - code == other.code; + other is VerifyTotpSetupInput && code == other.code; @override int get hashCode => code.hashCode; @@ -1397,25 +1367,20 @@ class VerifyTotpSetupInput extends AuthActionInput { } class GetMfaPreferenceInput extends AuthActionInput { - const GetMfaPreferenceInput(); factory GetMfaPreferenceInput.fromJson(Map json) { - return GetMfaPreferenceInput( - ); + return GetMfaPreferenceInput(); } @override Map toJson() { - return { - 'action': 'getMfaPreference', - }; + return {'action': 'getMfaPreference'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is GetMfaPreferenceInput; + identical(this, other) || other is GetMfaPreferenceInput; @override int get hashCode => runtimeType.hashCode; @@ -1429,17 +1394,19 @@ class UpdateMfaPreferenceInput extends AuthActionInput { final UpdateMfaPreferenceInputTotp? totp; final UpdateMfaPreferenceInputEmail? email; - const UpdateMfaPreferenceInput({ - this.sms, - this.totp, - this.email, - }); + const UpdateMfaPreferenceInput({this.sms, this.totp, this.email}); factory UpdateMfaPreferenceInput.fromJson(Map json) { return UpdateMfaPreferenceInput( - sms: json['sms'] != null ? UpdateMfaPreferenceInputSms.fromJson(json['sms'] as String) : null, - totp: json['totp'] != null ? UpdateMfaPreferenceInputTotp.fromJson(json['totp'] as String) : null, - email: json['email'] != null ? UpdateMfaPreferenceInputEmail.fromJson(json['email'] as String) : null, + sms: json['sms'] != null + ? UpdateMfaPreferenceInputSms.fromJson(json['sms'] as String) + : null, + totp: json['totp'] != null + ? UpdateMfaPreferenceInputTotp.fromJson(json['totp'] as String) + : null, + email: json['email'] != null + ? UpdateMfaPreferenceInputEmail.fromJson(json['email'] as String) + : null, ); } @@ -1465,25 +1432,21 @@ class UpdateMfaPreferenceInput extends AuthActionInput { int get hashCode => Object.hash(sms, totp, email); @override - String toString() => 'UpdateMfaPreferenceInput(sms: $sms, totp: $totp, email: $email)'; + String toString() => + 'UpdateMfaPreferenceInput(sms: $sms, totp: $totp, email: $email)'; } - - class AuthApi { final BlocksClient _client; AuthApi(this._client); Future setAuthState({required AuthActionInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('authApi.setAuthState', params); return AuthState.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -1501,4 +1464,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/19-optional-collections/dart/client.dart b/native/codegen-fixtures/19-optional-collections/dart/client.dart index 053d4288f9..2a9823e47e 100644 --- a/native/codegen-fixtures/19-optional-collections/dart/client.dart +++ b/native/codegen-fixtures/19-optional-collections/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -30,8 +40,12 @@ class GetUserResult { return GetUserResult( name: json['name'] as String, tags: (json['tags'] as List).cast(), - scores: (json['scores'] as List?)?.map((e) => (e as num).toInt()).toList(), - metadata: (json['metadata'] as Map?)?.map((k, v) => MapEntry(k, v as String)), + scores: (json['scores'] as List?) + ?.map((e) => (e as num).toInt()) + .toList(), + metadata: (json['metadata'] as Map?)?.map( + (k, v) => MapEntry(k, v as String), + ), nicknames: (json['nicknames'] as List?)?.cast(), ); } @@ -57,29 +71,33 @@ class GetUserResult { blocksDeepEquals(nicknames, other.nicknames); @override - int get hashCode => Object.hash(name, blocksDeepHash(tags), blocksDeepHash(scores), blocksDeepHash(metadata), blocksDeepHash(nicknames)); + int get hashCode => Object.hash( + name, + blocksDeepHash(tags), + blocksDeepHash(scores), + blocksDeepHash(metadata), + blocksDeepHash(nicknames), + ); @override - String toString() => 'GetUserResult(name: $name, tags: $tags, scores: $scores, metadata: $metadata, nicknames: $nicknames)'; + String toString() => + 'GetUserResult(name: $name, tags: $tags, scores: $scores, metadata: $metadata, nicknames: $nicknames)'; } - class ApiUpdateUserInput { final String id; final List? tags; final Map? metadata; - const ApiUpdateUserInput({ - required this.id, - this.tags, - this.metadata, - }); + const ApiUpdateUserInput({required this.id, this.tags, this.metadata}); factory ApiUpdateUserInput.fromJson(Map json) { return ApiUpdateUserInput( id: json['id'] as String, tags: (json['tags'] as List?)?.cast(), - metadata: (json['metadata'] as Map?)?.map((k, v) => MapEntry(k, v as String)), + metadata: (json['metadata'] as Map?)?.map( + (k, v) => MapEntry(k, v as String), + ), ); } @@ -100,37 +118,30 @@ class ApiUpdateUserInput { blocksDeepEquals(metadata, other.metadata); @override - int get hashCode => Object.hash(id, blocksDeepHash(tags), blocksDeepHash(metadata)); + int get hashCode => + Object.hash(id, blocksDeepHash(tags), blocksDeepHash(metadata)); @override - String toString() => 'ApiUpdateUserInput(id: $id, tags: $tags, metadata: $metadata)'; + String toString() => + 'ApiUpdateUserInput(id: $id, tags: $tags, metadata: $metadata)'; } - class UpdateUserResult { final bool ok; - const UpdateUserResult({ - required this.ok, - }); + const UpdateUserResult({required this.ok}); factory UpdateUserResult.fromJson(Map json) { - return UpdateUserResult( - ok: json['ok'] as bool, - ); + return UpdateUserResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is UpdateUserResult && - ok == other.ok; + identical(this, other) || other is UpdateUserResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -139,29 +150,25 @@ class UpdateUserResult { String toString() => 'UpdateUserResult(ok: $ok)'; } - class Api { final BlocksClient _client; Api(this._client); Future getUser({required String id}) async { - final params = [ - id, - ]; + final params = [id]; final result = await _client.call('api.getUser', params); return GetUserResult.fromJson(result as Map); } - Future updateUser({required ApiUpdateUserInput input}) async { - final params = [ - input.toJson(), - ]; + Future updateUser({ + required ApiUpdateUserInput input, + }) async { + final params = [input.toJson()]; final result = await _client.call('api.updateUser', params); return UpdateUserResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -179,4 +186,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/20-multiple-namespaces/dart/client.dart b/native/codegen-fixtures/20-multiple-namespaces/dart/client.dart index 8799a2407c..b13d71a884 100644 --- a/native/codegen-fixtures/20-multiple-namespaces/dart/client.dart +++ b/native/codegen-fixtures/20-multiple-namespaces/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -16,11 +26,7 @@ class User { final String name; final String email; - const User({ - required this.id, - required this.name, - required this.email, - }); + const User({required this.id, required this.name, required this.email}); factory User.fromJson(Map json) { return User( @@ -31,11 +37,7 @@ class User { } Map toJson() { - return { - 'id': id, - 'name': name, - 'email': email, - }; + return {'id': id, 'name': name, 'email': email}; } @override @@ -53,15 +55,11 @@ class User { String toString() => 'User(id: $id, name: $name, email: $email)'; } - class UsersCreateInput { final String name; final String email; - const UsersCreateInput({ - required this.name, - required this.email, - }); + const UsersCreateInput({required this.name, required this.email}); factory UsersCreateInput.fromJson(Map json) { return UsersCreateInput( @@ -71,18 +69,13 @@ class UsersCreateInput { } Map toJson() { - return { - 'name': name, - 'email': email, - }; + return {'name': name, 'email': email}; } @override bool operator ==(Object other) => identical(this, other) || - other is UsersCreateInput && - name == other.name && - email == other.email; + other is UsersCreateInput && name == other.name && email == other.email; @override int get hashCode => Object.hash(name, email); @@ -91,34 +84,30 @@ class UsersCreateInput { String toString() => 'UsersCreateInput(name: $name, email: $email)'; } - class UsersApi { final BlocksClient _client; UsersApi(this._client); Future get$({required String id}) async { - final params = [ - id, - ]; + final params = [id]; final result = await _client.call('users.get', params); return User.fromJson(result as Map); } Future> list() async { final result = await _client.call('users.list', const []); - return (result as List).map((e) => User.fromJson(e as Map)).toList(); + return (result as List) + .map((e) => User.fromJson(e as Map)) + .toList(); } Future create({required UsersCreateInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('users.create', params); return User.fromJson(result as Map); } } - class PostsListResult { final String id; final String title; @@ -139,11 +128,7 @@ class PostsListResult { } Map toJson() { - return { - 'id': id, - 'title': title, - 'authorId': authorId, - }; + return {'id': id, 'title': title, 'authorId': authorId}; } @override @@ -158,10 +143,10 @@ class PostsListResult { int get hashCode => Object.hash(id, title, authorId); @override - String toString() => 'PostsListResult(id: $id, title: $title, authorId: $authorId)'; + String toString() => + 'PostsListResult(id: $id, title: $title, authorId: $authorId)'; } - class PostsCreateInput { final String title; final String body; @@ -182,11 +167,7 @@ class PostsCreateInput { } Map toJson() { - return { - 'title': title, - 'body': body, - 'authorId': authorId, - }; + return {'title': title, 'body': body, 'authorId': authorId}; } @override @@ -201,34 +182,26 @@ class PostsCreateInput { int get hashCode => Object.hash(title, body, authorId); @override - String toString() => 'PostsCreateInput(title: $title, body: $body, authorId: $authorId)'; + String toString() => + 'PostsCreateInput(title: $title, body: $body, authorId: $authorId)'; } - class PostsDeleteResult { final bool ok; - const PostsDeleteResult({ - required this.ok, - }); + const PostsDeleteResult({required this.ok}); factory PostsDeleteResult.fromJson(Map json) { - return PostsDeleteResult( - ok: json['ok'] as bool, - ); + return PostsDeleteResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is PostsDeleteResult && - ok == other.ok; + identical(this, other) || other is PostsDeleteResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -237,37 +210,31 @@ class PostsDeleteResult { String toString() => 'PostsDeleteResult(ok: $ok)'; } - class PostsApi { final BlocksClient _client; PostsApi(this._client); Future> list({required String authorId}) async { - final params = [ - authorId, - ]; + final params = [authorId]; final result = await _client.call('posts.list', params); - return (result as List).map((e) => PostsListResult.fromJson(e as Map)).toList(); + return (result as List) + .map((e) => PostsListResult.fromJson(e as Map)) + .toList(); } Future create({required PostsCreateInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('posts.create', params); return PostsListResult.fromJson(result as Map); } Future delete({required String id}) async { - final params = [ - id, - ]; + final params = [id]; final result = await _client.call('posts.delete', params); return PostsDeleteResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -287,4 +254,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/21-deeply-nested-objects/dart/client.dart b/native/codegen-fixtures/21-deeply-nested-objects/dart/client.dart index 14797cc3cb..cf4d6cc248 100644 --- a/native/codegen-fixtures/21-deeply-nested-objects/dart/client.dart +++ b/native/codegen-fixtures/21-deeply-nested-objects/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,34 +6,38 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- class GetOrganizationResultAddressContact { final String email; - const GetOrganizationResultAddressContact({ - required this.email, - }); + const GetOrganizationResultAddressContact({required this.email}); - factory GetOrganizationResultAddressContact.fromJson(Map json) { - return GetOrganizationResultAddressContact( - email: json['email'] as String, - ); + factory GetOrganizationResultAddressContact.fromJson( + Map json, + ) { + return GetOrganizationResultAddressContact(email: json['email'] as String); } Map toJson() { - return { - 'email': email, - }; + return {'email': email}; } @override bool operator ==(Object other) => identical(this, other) || - other is GetOrganizationResultAddressContact && - email == other.email; + other is GetOrganizationResultAddressContact && email == other.email; @override int get hashCode => email.hashCode; @@ -41,7 +46,6 @@ class GetOrganizationResultAddressContact { String toString() => 'GetOrganizationResultAddressContact(email: $email)'; } - class GetOrganizationResultAddress { final String street; final String city; @@ -57,16 +61,14 @@ class GetOrganizationResultAddress { return GetOrganizationResultAddress( street: json['street'] as String, city: json['city'] as String, - contact: GetOrganizationResultAddressContact.fromJson(json['contact'] as Map), + contact: GetOrganizationResultAddressContact.fromJson( + json['contact'] as Map, + ), ); } Map toJson() { - return { - 'street': street, - 'city': city, - 'contact': contact.toJson(), - }; + return {'street': street, 'city': city, 'contact': contact.toJson()}; } @override @@ -81,10 +83,10 @@ class GetOrganizationResultAddress { int get hashCode => Object.hash(street, city, contact); @override - String toString() => 'GetOrganizationResultAddress(street: $street, city: $city, contact: $contact)'; + String toString() => + 'GetOrganizationResultAddress(street: $street, city: $city, contact: $contact)'; } - class GetOrganizationResultOwnerContact { final String email; final String phone; @@ -94,7 +96,9 @@ class GetOrganizationResultOwnerContact { required this.phone, }); - factory GetOrganizationResultOwnerContact.fromJson(Map json) { + factory GetOrganizationResultOwnerContact.fromJson( + Map json, + ) { return GetOrganizationResultOwnerContact( email: json['email'] as String, phone: json['phone'] as String, @@ -102,10 +106,7 @@ class GetOrganizationResultOwnerContact { } Map toJson() { - return { - 'email': email, - 'phone': phone, - }; + return {'email': email, 'phone': phone}; } @override @@ -119,31 +120,27 @@ class GetOrganizationResultOwnerContact { int get hashCode => Object.hash(email, phone); @override - String toString() => 'GetOrganizationResultOwnerContact(email: $email, phone: $phone)'; + String toString() => + 'GetOrganizationResultOwnerContact(email: $email, phone: $phone)'; } - class GetOrganizationResultOwner { final String name; final GetOrganizationResultOwnerContact contact; - const GetOrganizationResultOwner({ - required this.name, - required this.contact, - }); + const GetOrganizationResultOwner({required this.name, required this.contact}); factory GetOrganizationResultOwner.fromJson(Map json) { return GetOrganizationResultOwner( name: json['name'] as String, - contact: GetOrganizationResultOwnerContact.fromJson(json['contact'] as Map), + contact: GetOrganizationResultOwnerContact.fromJson( + json['contact'] as Map, + ), ); } Map toJson() { - return { - 'name': name, - 'contact': contact.toJson(), - }; + return {'name': name, 'contact': contact.toJson()}; } @override @@ -157,10 +154,10 @@ class GetOrganizationResultOwner { int get hashCode => Object.hash(name, contact); @override - String toString() => 'GetOrganizationResultOwner(name: $name, contact: $contact)'; + String toString() => + 'GetOrganizationResultOwner(name: $name, contact: $contact)'; } - class ApiCreateOrganizationInputAddress { final String street; final String city; @@ -172,7 +169,9 @@ class ApiCreateOrganizationInputAddress { required this.countryCode, }); - factory ApiCreateOrganizationInputAddress.fromJson(Map json) { + factory ApiCreateOrganizationInputAddress.fromJson( + Map json, + ) { return ApiCreateOrganizationInputAddress( street: json['street'] as String, city: json['city'] as String, @@ -181,11 +180,7 @@ class ApiCreateOrganizationInputAddress { } Map toJson() { - return { - 'street': street, - 'city': city, - 'countryCode': countryCode, - }; + return {'street': street, 'city': city, 'countryCode': countryCode}; } @override @@ -200,10 +195,10 @@ class ApiCreateOrganizationInputAddress { int get hashCode => Object.hash(street, city, countryCode); @override - String toString() => 'ApiCreateOrganizationInputAddress(street: $street, city: $city, countryCode: $countryCode)'; + String toString() => + 'ApiCreateOrganizationInputAddress(street: $street, city: $city, countryCode: $countryCode)'; } - class ApiCreateOrganizationInputOwner { final String name; final String email; @@ -221,10 +216,7 @@ class ApiCreateOrganizationInputOwner { } Map toJson() { - return { - 'name': name, - 'email': email, - }; + return {'name': name, 'email': email}; } @override @@ -238,10 +230,10 @@ class ApiCreateOrganizationInputOwner { int get hashCode => Object.hash(name, email); @override - String toString() => 'ApiCreateOrganizationInputOwner(name: $name, email: $email)'; + String toString() => + 'ApiCreateOrganizationInputOwner(name: $name, email: $email)'; } - class ApiUpdateOrganizationInputAddress { final String street; final String city; @@ -253,7 +245,9 @@ class ApiUpdateOrganizationInputAddress { required this.zip, }); - factory ApiUpdateOrganizationInputAddress.fromJson(Map json) { + factory ApiUpdateOrganizationInputAddress.fromJson( + Map json, + ) { return ApiUpdateOrganizationInputAddress( street: json['street'] as String, city: json['city'] as String, @@ -262,11 +256,7 @@ class ApiUpdateOrganizationInputAddress { } Map toJson() { - return { - 'street': street, - 'city': city, - 'zip': zip, - }; + return {'street': street, 'city': city, 'zip': zip}; } @override @@ -281,10 +271,10 @@ class ApiUpdateOrganizationInputAddress { int get hashCode => Object.hash(street, city, zip); @override - String toString() => 'ApiUpdateOrganizationInputAddress(street: $street, city: $city, zip: $zip)'; + String toString() => + 'ApiUpdateOrganizationInputAddress(street: $street, city: $city, zip: $zip)'; } - class ApiUpdateOrganizationInputOwner { final String name; final GetOrganizationResultOwnerContact contact; @@ -297,15 +287,14 @@ class ApiUpdateOrganizationInputOwner { factory ApiUpdateOrganizationInputOwner.fromJson(Map json) { return ApiUpdateOrganizationInputOwner( name: json['name'] as String, - contact: GetOrganizationResultOwnerContact.fromJson(json['contact'] as Map), + contact: GetOrganizationResultOwnerContact.fromJson( + json['contact'] as Map, + ), ); } Map toJson() { - return { - 'name': name, - 'contact': contact.toJson(), - }; + return {'name': name, 'contact': contact.toJson()}; } @override @@ -319,10 +308,10 @@ class ApiUpdateOrganizationInputOwner { int get hashCode => Object.hash(name, contact); @override - String toString() => 'ApiUpdateOrganizationInputOwner(name: $name, contact: $contact)'; + String toString() => + 'ApiUpdateOrganizationInputOwner(name: $name, contact: $contact)'; } - // --- API Namespaces --- class GetOrganizationResult { @@ -342,8 +331,12 @@ class GetOrganizationResult { return GetOrganizationResult( id: json['id'] as String, name: json['name'] as String, - address: GetOrganizationResultAddress.fromJson(json['address'] as Map), - owner: GetOrganizationResultOwner.fromJson(json['owner'] as Map), + address: GetOrganizationResultAddress.fromJson( + json['address'] as Map, + ), + owner: GetOrganizationResultOwner.fromJson( + json['owner'] as Map, + ), ); } @@ -369,10 +362,10 @@ class GetOrganizationResult { int get hashCode => Object.hash(id, name, address, owner); @override - String toString() => 'GetOrganizationResult(id: $id, name: $name, address: $address, owner: $owner)'; + String toString() => + 'GetOrganizationResult(id: $id, name: $name, address: $address, owner: $owner)'; } - class ApiCreateOrganizationInput { final String name; final ApiCreateOrganizationInputAddress address; @@ -387,17 +380,17 @@ class ApiCreateOrganizationInput { factory ApiCreateOrganizationInput.fromJson(Map json) { return ApiCreateOrganizationInput( name: json['name'] as String, - address: ApiCreateOrganizationInputAddress.fromJson(json['address'] as Map), - owner: ApiCreateOrganizationInputOwner.fromJson(json['owner'] as Map), + address: ApiCreateOrganizationInputAddress.fromJson( + json['address'] as Map, + ), + owner: ApiCreateOrganizationInputOwner.fromJson( + json['owner'] as Map, + ), ); } Map toJson() { - return { - 'name': name, - 'address': address.toJson(), - 'owner': owner.toJson(), - }; + return {'name': name, 'address': address.toJson(), 'owner': owner.toJson()}; } @override @@ -412,34 +405,27 @@ class ApiCreateOrganizationInput { int get hashCode => Object.hash(name, address, owner); @override - String toString() => 'ApiCreateOrganizationInput(name: $name, address: $address, owner: $owner)'; + String toString() => + 'ApiCreateOrganizationInput(name: $name, address: $address, owner: $owner)'; } - class CreateOrganizationResult { final String id; - const CreateOrganizationResult({ - required this.id, - }); + const CreateOrganizationResult({required this.id}); factory CreateOrganizationResult.fromJson(Map json) { - return CreateOrganizationResult( - id: json['id'] as String, - ); + return CreateOrganizationResult(id: json['id'] as String); } Map toJson() { - return { - 'id': id, - }; + return {'id': id}; } @override bool operator ==(Object other) => identical(this, other) || - other is CreateOrganizationResult && - id == other.id; + other is CreateOrganizationResult && id == other.id; @override int get hashCode => id.hashCode; @@ -448,7 +434,6 @@ class CreateOrganizationResult { String toString() => 'CreateOrganizationResult(id: $id)'; } - class ApiUpdateOrganizationInput { final String id; final String? name; @@ -466,8 +451,16 @@ class ApiUpdateOrganizationInput { return ApiUpdateOrganizationInput( id: json['id'] as String, name: json['name'] as String?, - address: json['address'] != null ? ApiUpdateOrganizationInputAddress.fromJson(json['address'] as Map) : null, - owner: json['owner'] != null ? ApiUpdateOrganizationInputOwner.fromJson(json['owner'] as Map) : null, + address: json['address'] != null + ? ApiUpdateOrganizationInputAddress.fromJson( + json['address'] as Map, + ) + : null, + owner: json['owner'] != null + ? ApiUpdateOrganizationInputOwner.fromJson( + json['owner'] as Map, + ) + : null, ); } @@ -493,34 +486,27 @@ class ApiUpdateOrganizationInput { int get hashCode => Object.hash(id, name, address, owner); @override - String toString() => 'ApiUpdateOrganizationInput(id: $id, name: $name, address: $address, owner: $owner)'; + String toString() => + 'ApiUpdateOrganizationInput(id: $id, name: $name, address: $address, owner: $owner)'; } - class UpdateOrganizationResult { final bool ok; - const UpdateOrganizationResult({ - required this.ok, - }); + const UpdateOrganizationResult({required this.ok}); factory UpdateOrganizationResult.fromJson(Map json) { - return UpdateOrganizationResult( - ok: json['ok'] as bool, - ); + return UpdateOrganizationResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => identical(this, other) || - other is UpdateOrganizationResult && - ok == other.ok; + other is UpdateOrganizationResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -529,37 +515,33 @@ class UpdateOrganizationResult { String toString() => 'UpdateOrganizationResult(ok: $ok)'; } - class Api { final BlocksClient _client; Api(this._client); Future getOrganization({required String id}) async { - final params = [ - id, - ]; + final params = [id]; final result = await _client.call('api.getOrganization', params); return GetOrganizationResult.fromJson(result as Map); } - Future createOrganization({required ApiCreateOrganizationInput input}) async { - final params = [ - input.toJson(), - ]; + Future createOrganization({ + required ApiCreateOrganizationInput input, + }) async { + final params = [input.toJson()]; final result = await _client.call('api.createOrganization', params); return CreateOrganizationResult.fromJson(result as Map); } - Future updateOrganization({required ApiUpdateOrganizationInput input}) async { - final params = [ - input.toJson(), - ]; + Future updateOrganization({ + required ApiUpdateOrganizationInput input, + }) async { + final params = [input.toJson()]; final result = await _client.call('api.updateOrganization', params); return UpdateOrganizationResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -577,4 +559,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/22-reserved-keywords/dart/client.dart b/native/codegen-fixtures/22-reserved-keywords/dart/client.dart index 3395e5c06c..6b771cd990 100644 --- a/native/codegen-fixtures/22-reserved-keywords/dart/client.dart +++ b/native/codegen-fixtures/22-reserved-keywords/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -92,13 +102,26 @@ class GetClassResult { super$ == other.super$; @override - int get hashCode => Object.hash(type, class$, default$, in$, is$, return$, var$, val, when, switch$, self, super$); + int get hashCode => Object.hash( + type, + class$, + default$, + in$, + is$, + return$, + var$, + val, + when, + switch$, + self, + super$, + ); @override - String toString() => 'GetClassResult(type: $type, class\$: ${class$}, default\$: ${default$}, in\$: ${in$}, is\$: ${is$}, return\$: ${return$}, var\$: ${var$}, val: $val, when: $when, switch\$: ${switch$}, self: $self, super\$: ${super$})'; + String toString() => + 'GetClassResult(type: $type, class\$: ${class$}, default\$: ${default$}, in\$: ${in$}, is\$: ${is$}, return\$: ${return$}, var\$: ${var$}, val: $val, when: $when, switch\$: ${switch$}, self: $self, super\$: ${super$})'; } - class ApiImportInput { final String for$; final int while$; @@ -160,37 +183,30 @@ class ApiImportInput { abstract$ == other.abstract$; @override - int get hashCode => Object.hash(for$, while$, do$, else$, enum$, extends$, final$, abstract$); + int get hashCode => + Object.hash(for$, while$, do$, else$, enum$, extends$, final$, abstract$); @override - String toString() => 'ApiImportInput(for\$: ${for$}, while\$: ${while$}, do\$: ${do$}, else\$: ${else$}, enum\$: ${enum$}, extends\$: ${extends$}, final\$: ${final$}, abstract\$: ${abstract$})'; + String toString() => + 'ApiImportInput(for\$: ${for$}, while\$: ${while$}, do\$: ${do$}, else\$: ${else$}, enum\$: ${enum$}, extends\$: ${extends$}, final\$: ${final$}, abstract\$: ${abstract$})'; } - class ImportResult { final bool ok; - const ImportResult({ - required this.ok, - }); + const ImportResult({required this.ok}); factory ImportResult.fromJson(Map json) { - return ImportResult( - ok: json['ok'] as bool, - ); + return ImportResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is ImportResult && - ok == other.ok; + identical(this, other) || other is ImportResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -199,7 +215,6 @@ class ImportResult { String toString() => 'ImportResult(ok: $ok)'; } - class ExportResult { final String object; final String package; @@ -266,29 +281,35 @@ class ExportResult { null$ == other.null$; @override - int get hashCode => Object.hash(object, package, internal, operator$, this$, throw$, true$, false$, null$); + int get hashCode => Object.hash( + object, + package, + internal, + operator$, + this$, + throw$, + true$, + false$, + null$, + ); @override - String toString() => 'ExportResult(object: $object, package: $package, internal: $internal, operator\$: ${operator$}, this\$: ${this$}, throw\$: ${throw$}, true\$: ${true$}, false\$: ${false$}, null\$: ${null$})'; + String toString() => + 'ExportResult(object: $object, package: $package, internal: $internal, operator\$: ${operator$}, this\$: ${this$}, throw\$: ${throw$}, true\$: ${true$}, false\$: ${false$}, null\$: ${null$})'; } - class Api { final BlocksClient _client; Api(this._client); Future getClass({required String id}) async { - final params = [ - id, - ]; + final params = [id]; final result = await _client.call('api.getClass', params); return GetClassResult.fromJson(result as Map); } Future import$({required ApiImportInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('api.import', params); return ImportResult.fromJson(result as Map); } @@ -299,7 +320,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -317,4 +337,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/23-cognito-nested-unions/dart/client.dart b/native/codegen-fixtures/23-cognito-nested-unions/dart/client.dart index ae38bf00d0..bf6e00d304 100644 --- a/native/codegen-fixtures/23-cognito-nested-unions/dart/client.dart +++ b/native/codegen-fixtures/23-cognito-nested-unions/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,32 +6,45 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- sealed class CodeDeliveryDetailsDeliveryMedium { static const SMS = CodeDeliveryDetailsDeliveryMediumKnown.SMS; static const EMAIL = CodeDeliveryDetailsDeliveryMediumKnown.EMAIL; - static const PHONE_NUMBER = CodeDeliveryDetailsDeliveryMediumKnown.PHONE_NUMBER; + static const PHONE_NUMBER = + CodeDeliveryDetailsDeliveryMediumKnown.PHONE_NUMBER; static const values = CodeDeliveryDetailsDeliveryMediumKnown.values; - static final Map _byJson = CodeDeliveryDetailsDeliveryMediumKnown.values.asNameMap(); + static final Map _byJson = + CodeDeliveryDetailsDeliveryMediumKnown.values.asNameMap(); String toJson(); - static CodeDeliveryDetailsDeliveryMedium fromJson(String json) => _byJson[json] ?? CodeDeliveryDetailsDeliveryMediumUnknown(json); + static CodeDeliveryDetailsDeliveryMedium fromJson(String json) => + _byJson[json] ?? CodeDeliveryDetailsDeliveryMediumUnknown(json); } -enum CodeDeliveryDetailsDeliveryMediumKnown implements CodeDeliveryDetailsDeliveryMedium { +enum CodeDeliveryDetailsDeliveryMediumKnown + implements CodeDeliveryDetailsDeliveryMedium { SMS, EMAIL, - PHONE_NUMBER -; + PHONE_NUMBER; @override String toJson() => name; } -final class CodeDeliveryDetailsDeliveryMediumUnknown implements CodeDeliveryDetailsDeliveryMedium { +final class CodeDeliveryDetailsDeliveryMediumUnknown + implements CodeDeliveryDetailsDeliveryMedium { final String value; const CodeDeliveryDetailsDeliveryMediumUnknown(this.value); @@ -46,10 +60,11 @@ final class CodeDeliveryDetailsDeliveryMediumUnknown implements CodeDeliveryDeta int get hashCode => value.hashCode; @override - String toString() => 'CodeDeliveryDetailsDeliveryMediumUnknown' '($value)'; + String toString() => + 'CodeDeliveryDetailsDeliveryMediumUnknown' + '($value)'; } - class CodeDeliveryDetails { final String destination; final CodeDeliveryDetailsDeliveryMedium deliveryMedium; @@ -64,7 +79,9 @@ class CodeDeliveryDetails { factory CodeDeliveryDetails.fromJson(Map json) { return CodeDeliveryDetails( destination: json['destination'] as String, - deliveryMedium: CodeDeliveryDetailsDeliveryMedium.fromJson(json['deliveryMedium'] as String), + deliveryMedium: CodeDeliveryDetailsDeliveryMedium.fromJson( + json['deliveryMedium'] as String, + ), attributeName: json['attributeName'] as String, ); } @@ -89,24 +106,25 @@ class CodeDeliveryDetails { int get hashCode => Object.hash(destination, deliveryMedium, attributeName); @override - String toString() => 'CodeDeliveryDetails(destination: $destination, deliveryMedium: $deliveryMedium, attributeName: $attributeName)'; + String toString() => + 'CodeDeliveryDetails(destination: $destination, deliveryMedium: $deliveryMedium, attributeName: $attributeName)'; } - sealed class AuthenticatedUserGroups { static const users = AuthenticatedUserGroupsKnown.users; static const admins = AuthenticatedUserGroupsKnown.admins; static const values = AuthenticatedUserGroupsKnown.values; - static final Map _byJson = AuthenticatedUserGroupsKnown.values.asNameMap(); + static final Map _byJson = + AuthenticatedUserGroupsKnown.values.asNameMap(); String toJson(); - static AuthenticatedUserGroups fromJson(String json) => _byJson[json] ?? AuthenticatedUserGroupsUnknown(json); + static AuthenticatedUserGroups fromJson(String json) => + _byJson[json] ?? AuthenticatedUserGroupsUnknown(json); } enum AuthenticatedUserGroupsKnown implements AuthenticatedUserGroups { users, - admins -; + admins; @override String toJson() => name; @@ -128,28 +146,32 @@ final class AuthenticatedUserGroupsUnknown implements AuthenticatedUserGroups { int get hashCode => value.hashCode; @override - String toString() => 'AuthenticatedUserGroupsUnknown' '($value)'; + String toString() => + 'AuthenticatedUserGroupsUnknown' + '($value)'; } - sealed class AuthenticatedUserSignInProvider { static const password = AuthenticatedUserSignInProviderKnown.password; static const values = AuthenticatedUserSignInProviderKnown.values; - static final Map _byJson = AuthenticatedUserSignInProviderKnown.values.asNameMap(); + static final Map _byJson = + AuthenticatedUserSignInProviderKnown.values.asNameMap(); String toJson(); - static AuthenticatedUserSignInProvider fromJson(String json) => _byJson[json] ?? AuthenticatedUserSignInProviderUnknown(json); + static AuthenticatedUserSignInProvider fromJson(String json) => + _byJson[json] ?? AuthenticatedUserSignInProviderUnknown(json); } -enum AuthenticatedUserSignInProviderKnown implements AuthenticatedUserSignInProvider { - password -; +enum AuthenticatedUserSignInProviderKnown + implements AuthenticatedUserSignInProvider { + password; @override String toJson() => name; } -final class AuthenticatedUserSignInProviderUnknown implements AuthenticatedUserSignInProvider { +final class AuthenticatedUserSignInProviderUnknown + implements AuthenticatedUserSignInProvider { final String value; const AuthenticatedUserSignInProviderUnknown(this.value); @@ -165,10 +187,11 @@ final class AuthenticatedUserSignInProviderUnknown implements AuthenticatedUserS int get hashCode => value.hashCode; @override - String toString() => 'AuthenticatedUserSignInProviderUnknown' '($value)'; + String toString() => + 'AuthenticatedUserSignInProviderUnknown' + '($value)'; } - class AuthenticatedUser { final String userSub; final List groups; @@ -193,11 +216,23 @@ class AuthenticatedUser { factory AuthenticatedUser.fromJson(Map json) { return AuthenticatedUser( userSub: json['userSub'] as String, - groups: (json['groups'] as List).map((e) => AuthenticatedUserGroups.fromJson(e as String)).toList(), - attributes: (json['attributes'] as Map).map((k, v) => MapEntry(k, v as String?)), - signInProvider: AuthenticatedUserSignInProvider.fromJson(json['signInProvider'] as String), - claims: (json['claims'] as Map?)?.map((k, v) => MapEntry(k, v as dynamic)), - federatedIdentity: json['federatedIdentity'] != null ? FederatedIdentity.fromJson(json['federatedIdentity'] as Map) : null, + groups: (json['groups'] as List) + .map((e) => AuthenticatedUserGroups.fromJson(e as String)) + .toList(), + attributes: (json['attributes'] as Map).map( + (k, v) => MapEntry(k, v as String?), + ), + signInProvider: AuthenticatedUserSignInProvider.fromJson( + json['signInProvider'] as String, + ), + claims: (json['claims'] as Map?)?.map( + (k, v) => MapEntry(k, v as dynamic), + ), + federatedIdentity: json['federatedIdentity'] != null + ? FederatedIdentity.fromJson( + json['federatedIdentity'] as Map, + ) + : null, userId: json['userId'] as String, username: json['username'] as String, ); @@ -210,7 +245,8 @@ class AuthenticatedUser { 'attributes': attributes, 'signInProvider': signInProvider.toJson(), if (claims != null) 'claims': claims, - if (federatedIdentity != null) 'federatedIdentity': federatedIdentity?.toJson(), + if (federatedIdentity != null) + 'federatedIdentity': federatedIdentity?.toJson(), 'userId': userId, 'username': username, }; @@ -230,21 +266,27 @@ class AuthenticatedUser { username == other.username; @override - int get hashCode => Object.hash(userSub, blocksDeepHash(groups), blocksDeepHash(attributes), signInProvider, blocksDeepHash(claims), federatedIdentity, userId, username); + int get hashCode => Object.hash( + userSub, + blocksDeepHash(groups), + blocksDeepHash(attributes), + signInProvider, + blocksDeepHash(claims), + federatedIdentity, + userId, + username, + ); @override - String toString() => 'AuthenticatedUser(userSub: $userSub, groups: $groups, attributes: $attributes, signInProvider: $signInProvider, claims: $claims, federatedIdentity: $federatedIdentity, userId: $userId, username: $username)'; + String toString() => + 'AuthenticatedUser(userSub: $userSub, groups: $groups, attributes: $attributes, signInProvider: $signInProvider, claims: $claims, federatedIdentity: $federatedIdentity, userId: $userId, username: $username)'; } - class FederatedIdentity { final String providerId; final String sub; - const FederatedIdentity({ - required this.providerId, - required this.sub, - }); + const FederatedIdentity({required this.providerId, required this.sub}); factory FederatedIdentity.fromJson(Map json) { return FederatedIdentity( @@ -254,10 +296,7 @@ class FederatedIdentity { } Map toJson() { - return { - 'providerId': providerId, - 'sub': sub, - }; + return {'providerId': providerId, 'sub': sub}; } @override @@ -274,156 +313,290 @@ class FederatedIdentity { String toString() => 'FederatedIdentity(providerId: $providerId, sub: $sub)'; } - sealed class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes { - static const SMS = CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown.SMS; - static const TOTP = CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown.TOTP; - static const EMAIL = CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown.EMAIL; - static const values = CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown.values; - static final Map _byJson = CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown.values.asNameMap(); + static const SMS = + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + .SMS; + static const TOTP = + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + .TOTP; + static const EMAIL = + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + .EMAIL; + static const values = + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + .values; + static final Map< + String, + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + > + _byJson = + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + .values + .asNameMap(); String toJson(); - static CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes fromJson(String json) => _byJson[json] ?? CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown(json); + static CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes + fromJson(String json) => + _byJson[json] ?? + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown( + json, + ); } -enum CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown implements CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes { +enum CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + implements + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes { SMS, TOTP, - EMAIL -; + EMAIL; @override String toJson() => name; } -final class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown implements CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes { +final class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown + implements + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes { final String value; - const CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown(this.value); + const CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown( + this.value, + ); @override String toJson() => value; @override bool operator ==(Object other) => - other is CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown && value == other.value; + other + is CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown && + value == other.value; @override int get hashCode => value.hashCode; @override - String toString() => 'CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown' '($value)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown' + '($value)'; } - sealed class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes { - static const TOTP = CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown.TOTP; - static const EMAIL = CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown.EMAIL; - static const values = CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown.values; - static final Map _byJson = CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown.values.asNameMap(); + static const TOTP = + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + .TOTP; + static const EMAIL = + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + .EMAIL; + static const values = + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + .values; + static final Map< + String, + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + > + _byJson = + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + .values + .asNameMap(); String toJson(); - static CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes fromJson(String json) => _byJson[json] ?? CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown(json); + static CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes + fromJson(String json) => + _byJson[json] ?? + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown( + json, + ); } -enum CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown implements CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes { +enum CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesKnown + implements + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes { TOTP, - EMAIL -; + EMAIL; @override String toJson() => name; } -final class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown implements CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes { +final class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown + implements + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes { final String value; - const CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown(this.value); + const CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown( + this.value, + ); @override String toJson() => value; @override bool operator ==(Object other) => - other is CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown && value == other.value; + other + is CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown && + value == other.value; @override int get hashCode => value.hashCode; @override - String toString() => 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown' '($value)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypesUnknown' + '($value)'; } - sealed class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallenges { - static const PASSWORD = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown.PASSWORD; - static const EMAIL_OTP = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown.EMAIL_OTP; - static const SMS_OTP = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown.SMS_OTP; - static const WEB_AUTHN = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown.WEB_AUTHN; - static const values = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown.values; - static final Map _byJson = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown.values.asNameMap(); + static const PASSWORD = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown + .PASSWORD; + static const EMAIL_OTP = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown + .EMAIL_OTP; + static const SMS_OTP = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown + .SMS_OTP; + static const WEB_AUTHN = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown + .WEB_AUTHN; + static const values = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown + .values; + static final Map< + String, + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown + > + _byJson = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown + .values + .asNameMap(); String toJson(); - static CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallenges fromJson(String json) => _byJson[json] ?? CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesUnknown(json); + static CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallenges + fromJson(String json) => + _byJson[json] ?? + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesUnknown( + json, + ); } -enum CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown implements CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallenges { +enum CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesKnown + implements + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallenges { PASSWORD, EMAIL_OTP, SMS_OTP, - WEB_AUTHN -; + WEB_AUTHN; @override String toJson() => name; } -final class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesUnknown implements CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallenges { +final class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesUnknown + implements + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallenges { final String value; - const CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesUnknown(this.value); + const CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesUnknown( + this.value, + ); @override String toJson() => value; @override bool operator ==(Object other) => - other is CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesUnknown && value == other.value; + other + is CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesUnknown && + value == other.value; @override int get hashCode => value.hashCode; @override - String toString() => 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesUnknown' '($value)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallengesUnknown' + '($value)'; } - sealed class ContinueSignInCognitoConfirmSignInResultNextStep { const ContinueSignInCognitoConfirmSignInResultNextStep(); Map toJson(); - static ContinueSignInCognitoConfirmSignInResultNextStep fromJson(Map json) { + static ContinueSignInCognitoConfirmSignInResultNextStep fromJson( + Map json, + ) { switch (json['name'] as String) { - case 'CONFIRM_SIGN_IN_WITH_SMS_CODE': return CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_TOTP_CODE': return CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_EMAIL_CODE': return CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONTINUE_SIGN_IN_WITH_MFA_SELECTION': return CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION': return CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONTINUE_SIGN_IN_WITH_TOTP_SETUP': return CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP': return CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED': return CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION': return CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_PASSWORD': return CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTP': return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTP': return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_WEB_AUTHN': return CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'RESET_PASSWORD': return RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_UP': return CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json); - default: return ContinueSignInCognitoConfirmSignInResultNextStepUnknown(_blocksFrozenObject(json)); + case 'CONFIRM_SIGN_IN_WITH_SMS_CODE': + return CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_TOTP_CODE': + return CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_EMAIL_CODE': + return CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONTINUE_SIGN_IN_WITH_MFA_SELECTION': + return CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION': + return CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONTINUE_SIGN_IN_WITH_TOTP_SETUP': + return CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP': + return CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED': + return CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION': + return CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_PASSWORD': + return CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTP': + return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTP': + return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_WEB_AUTHN': + return CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'RESET_PASSWORD': + return RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_UP': + return CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json, + ); + default: + return ContinueSignInCognitoConfirmSignInResultNextStepUnknown( + _blocksFrozenObject(json), + ); } } } -class CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; final CodeDeliveryDetails codeDeliveryDetails; @@ -432,10 +605,14 @@ class CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextS required this.codeDeliveryDetails, }); - factory CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, - codeDeliveryDetails: CodeDeliveryDetails.fromJson(json['codeDeliveryDetails'] as Map), + codeDeliveryDetails: CodeDeliveryDetails.fromJson( + json['codeDeliveryDetails'] as Map, + ), ); } @@ -451,7 +628,8 @@ class CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextS @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextStep && session == other.session && codeDeliveryDetails == other.codeDeliveryDetails; @@ -459,17 +637,21 @@ class CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextS int get hashCode => Object.hash(session, codeDeliveryDetails); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoConfirmSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; } -class CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; const CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep({ required this.session, }); - factory CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, ); @@ -477,26 +659,26 @@ class CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNext @override Map toJson() { - return { - 'name': 'CONFIRM_SIGN_IN_WITH_TOTP_CODE', - 'session': session, - }; + return {'name': 'CONFIRM_SIGN_IN_WITH_TOTP_CODE', 'session': session}; } @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep && session == other.session; @override int get hashCode => session.hashCode; @override - String toString() => 'CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep(session: $session)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoConfirmSignInResultNextStep(session: $session)'; } -class CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; final CodeDeliveryDetails codeDeliveryDetails; @@ -505,10 +687,14 @@ class CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNex required this.codeDeliveryDetails, }); - factory CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, - codeDeliveryDetails: CodeDeliveryDetails.fromJson(json['codeDeliveryDetails'] as Map), + codeDeliveryDetails: CodeDeliveryDetails.fromJson( + json['codeDeliveryDetails'] as Map, + ), ); } @@ -524,7 +710,8 @@ class CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNex @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNextStep && session == other.session && codeDeliveryDetails == other.codeDeliveryDetails; @@ -532,22 +719,36 @@ class CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNex int get hashCode => Object.hash(session, codeDeliveryDetails); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoConfirmSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; } -class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; - final List allowedMFATypes; + final List< + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes + > + allowedMFATypes; const CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep({ required this.session, required this.allowedMFATypes, }); - factory CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, - allowedMFATypes: (json['allowedMFATypes'] as List).map((e) => CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes.fromJson(e as String)).toList(), + allowedMFATypes: (json['allowedMFATypes'] as List) + .map( + (e) => + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes.fromJson( + e as String, + ), + ) + .toList(), ); } @@ -563,7 +764,8 @@ class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResul @override bool operator ==(Object other) => identical(this, other) || - other is CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep && session == other.session && blocksDeepEquals(allowedMFATypes, other.allowedMFATypes); @@ -571,22 +773,36 @@ class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResul int get hashCode => Object.hash(session, blocksDeepHash(allowedMFATypes)); @override - String toString() => 'CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep(session: $session, allowedMFATypes: $allowedMFATypes)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep(session: $session, allowedMFATypes: $allowedMFATypes)'; } -class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; - final List allowedMFATypes; + final List< + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes + > + allowedMFATypes; const CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep({ required this.session, required this.allowedMFATypes, }); - factory CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, - allowedMFATypes: (json['allowedMFATypes'] as List).map((e) => CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes.fromJson(e as String)).toList(), + allowedMFATypes: (json['allowedMFATypes'] as List) + .map( + (e) => + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAllowedMFATypes.fromJson( + e as String, + ), + ) + .toList(), ); } @@ -602,7 +818,8 @@ class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignI @override bool operator ==(Object other) => identical(this, other) || - other is CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep && session == other.session && blocksDeepEquals(allowedMFATypes, other.allowedMFATypes); @@ -610,10 +827,12 @@ class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignI int get hashCode => Object.hash(session, blocksDeepHash(allowedMFATypes)); @override - String toString() => 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep(session: $session, allowedMFATypes: $allowedMFATypes)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep(session: $session, allowedMFATypes: $allowedMFATypes)'; } -class CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; final String sharedSecret; @@ -622,7 +841,9 @@ class CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNe required this.sharedSecret, }); - factory CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, sharedSecret: json['sharedSecret'] as String, @@ -641,7 +862,8 @@ class CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNe @override bool operator ==(Object other) => identical(this, other) || - other is CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNextStep && session == other.session && sharedSecret == other.sharedSecret; @@ -649,17 +871,21 @@ class CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNe int get hashCode => Object.hash(session, sharedSecret); @override - String toString() => 'CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNextStep(session: $session, sharedSecret: $sharedSecret)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoConfirmSignInResultNextStep(session: $session, sharedSecret: $sharedSecret)'; } -class CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; const CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep({ required this.session, }); - factory CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, ); @@ -667,26 +893,26 @@ class CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultN @override Map toJson() { - return { - 'name': 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP', - 'session': session, - }; + return {'name': 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP', 'session': session}; } @override bool operator ==(Object other) => identical(this, other) || - other is CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep && session == other.session; @override int get hashCode => session.hashCode; @override - String toString() => 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep(session: $session)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoConfirmSignInResultNextStep(session: $session)'; } -class CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; final List? requiredAttributes; @@ -695,10 +921,13 @@ class CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSign this.requiredAttributes, }); - factory CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, - requiredAttributes: (json['requiredAttributes'] as List?)?.cast(), + requiredAttributes: (json['requiredAttributes'] as List?) + ?.cast(), ); } @@ -714,7 +943,8 @@ class CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSign @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSignInResultNextStep && session == other.session && blocksDeepEquals(requiredAttributes, other.requiredAttributes); @@ -722,22 +952,36 @@ class CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSign int get hashCode => Object.hash(session, blocksDeepHash(requiredAttributes)); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSignInResultNextStep(session: $session, requiredAttributes: $requiredAttributes)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoConfirmSignInResultNextStep(session: $session, requiredAttributes: $requiredAttributes)'; } -class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; - final List availableChallenges; + final List< + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallenges + > + availableChallenges; const CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep({ required this.session, required this.availableChallenges, }); - factory CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, - availableChallenges: (json['availableChallenges'] as List).map((e) => CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallenges.fromJson(e as String)).toList(), + availableChallenges: (json['availableChallenges'] as List) + .map( + (e) => + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStepAvailableChallenges.fromJson( + e as String, + ), + ) + .toList(), ); } @@ -746,14 +990,17 @@ class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSi return { 'name': 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION', 'session': session, - 'availableChallenges': availableChallenges.map((e) => e.toJson()).toList(), + 'availableChallenges': availableChallenges + .map((e) => e.toJson()) + .toList(), }; } @override bool operator ==(Object other) => identical(this, other) || - other is CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep && session == other.session && blocksDeepEquals(availableChallenges, other.availableChallenges); @@ -761,17 +1008,21 @@ class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSi int get hashCode => Object.hash(session, blocksDeepHash(availableChallenges)); @override - String toString() => 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep(session: $session, availableChallenges: $availableChallenges)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoConfirmSignInResultNextStep(session: $session, availableChallenges: $availableChallenges)'; } -class CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; const CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep({ required this.session, }); - factory CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, ); @@ -779,26 +1030,26 @@ class CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextS @override Map toJson() { - return { - 'name': 'CONFIRM_SIGN_IN_WITH_PASSWORD', - 'session': session, - }; + return {'name': 'CONFIRM_SIGN_IN_WITH_PASSWORD', 'session': session}; } @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep && session == other.session; @override int get hashCode => session.hashCode; @override - String toString() => 'CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep(session: $session)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep(session: $session)'; } -class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; final CodeDeliveryDetails codeDeliveryDetails; @@ -807,10 +1058,14 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSig required this.codeDeliveryDetails, }); - factory CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, - codeDeliveryDetails: CodeDeliveryDetails.fromJson(json['codeDeliveryDetails'] as Map), + codeDeliveryDetails: CodeDeliveryDetails.fromJson( + json['codeDeliveryDetails'] as Map, + ), ); } @@ -826,7 +1081,8 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSig @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSignInResultNextStep && session == other.session && codeDeliveryDetails == other.codeDeliveryDetails; @@ -834,10 +1090,12 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSig int get hashCode => Object.hash(session, codeDeliveryDetails); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoConfirmSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; } -class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; final CodeDeliveryDetails codeDeliveryDetails; @@ -846,10 +1104,14 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignI required this.codeDeliveryDetails, }); - factory CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, - codeDeliveryDetails: CodeDeliveryDetails.fromJson(json['codeDeliveryDetails'] as Map), + codeDeliveryDetails: CodeDeliveryDetails.fromJson( + json['codeDeliveryDetails'] as Map, + ), ); } @@ -865,7 +1127,8 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignI @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignInResultNextStep && session == other.session && codeDeliveryDetails == other.codeDeliveryDetails; @@ -873,10 +1136,12 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignI int get hashCode => Object.hash(session, codeDeliveryDetails); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoConfirmSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; } -class CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final String session; final String credentialRequestOptions; @@ -885,7 +1150,9 @@ class CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNext required this.credentialRequestOptions, }); - factory CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNextStep( session: json['session'] as String, credentialRequestOptions: json['credentialRequestOptions'] as String, @@ -904,7 +1171,8 @@ class CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNext @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNextStep && session == other.session && credentialRequestOptions == other.credentialRequestOptions; @@ -912,23 +1180,23 @@ class CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNext int get hashCode => Object.hash(session, credentialRequestOptions); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNextStep(session: $session, credentialRequestOptions: $credentialRequestOptions)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoConfirmSignInResultNextStep(session: $session, credentialRequestOptions: $credentialRequestOptions)'; } -class RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { - +class RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { const RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep(); - factory RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { - return RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep( - ); + factory RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { + return RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep(); } @override Map toJson() { - return { - 'name': 'RESET_PASSWORD', - }; + return {'name': 'RESET_PASSWORD'}; } @override @@ -940,19 +1208,27 @@ class RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep extends Con int get hashCode => runtimeType.hashCode; @override - String toString() => 'RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep()'; + String toString() => + 'RESET_PASSWORDContinueSignInCognitoConfirmSignInResultNextStep()'; } -class CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep extends ContinueSignInCognitoConfirmSignInResultNextStep { +class CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep + extends ContinueSignInCognitoConfirmSignInResultNextStep { final CodeDeliveryDetails? codeDeliveryDetails; const CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep({ this.codeDeliveryDetails, }); - factory CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep( - codeDeliveryDetails: json['codeDeliveryDetails'] != null ? CodeDeliveryDetails.fromJson(json['codeDeliveryDetails'] as Map) : null, + codeDeliveryDetails: json['codeDeliveryDetails'] != null + ? CodeDeliveryDetails.fromJson( + json['codeDeliveryDetails'] as Map, + ) + : null, ); } @@ -960,7 +1236,8 @@ class CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep extends Co Map toJson() { return { 'name': 'CONFIRM_SIGN_UP', - if (codeDeliveryDetails != null) 'codeDeliveryDetails': codeDeliveryDetails?.toJson(), + if (codeDeliveryDetails != null) + 'codeDeliveryDetails': codeDeliveryDetails?.toJson(), }; } @@ -974,10 +1251,12 @@ class CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep extends Co int get hashCode => codeDeliveryDetails.hashCode; @override - String toString() => 'CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep(codeDeliveryDetails: $codeDeliveryDetails)'; + String toString() => + 'CONFIRM_SIGN_UPContinueSignInCognitoConfirmSignInResultNextStep(codeDeliveryDetails: $codeDeliveryDetails)'; } -final class ContinueSignInCognitoConfirmSignInResultNextStepUnknown extends ContinueSignInCognitoConfirmSignInResultNextStep { +final class ContinueSignInCognitoConfirmSignInResultNextStepUnknown + extends ContinueSignInCognitoConfirmSignInResultNextStep { final Map json; const ContinueSignInCognitoConfirmSignInResultNextStepUnknown(this.json); @@ -989,166 +1268,302 @@ final class ContinueSignInCognitoConfirmSignInResultNextStepUnknown extends Cont @override bool operator ==(Object other) => - other is ContinueSignInCognitoConfirmSignInResultNextStepUnknown && blocksDeepEquals(json, other.json); + other is ContinueSignInCognitoConfirmSignInResultNextStepUnknown && + blocksDeepEquals(json, other.json); @override int get hashCode => blocksDeepHash(json); @override - String toString() => 'ContinueSignInCognitoConfirmSignInResultNextStepUnknown' '($json)'; + String toString() => + 'ContinueSignInCognitoConfirmSignInResultNextStepUnknown' + '($json)'; } - - sealed class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes { - static const SMS = CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown.SMS; - static const TOTP = CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown.TOTP; - static const EMAIL = CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown.EMAIL; - static const values = CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown.values; - static final Map _byJson = CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown.values.asNameMap(); + static const SMS = + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + .SMS; + static const TOTP = + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + .TOTP; + static const EMAIL = + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + .EMAIL; + static const values = + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + .values; + static final Map< + String, + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + > + _byJson = + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + .values + .asNameMap(); String toJson(); - static CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes fromJson(String json) => _byJson[json] ?? CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown(json); + static CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes + fromJson(String json) => + _byJson[json] ?? + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown( + json, + ); } -enum CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown implements CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes { +enum CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + implements + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes { SMS, TOTP, - EMAIL -; + EMAIL; @override String toJson() => name; } -final class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown implements CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes { +final class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown + implements + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes { final String value; - const CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown(this.value); + const CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown( + this.value, + ); @override String toJson() => value; @override bool operator ==(Object other) => - other is CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown && value == other.value; + other + is CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown && + value == other.value; @override int get hashCode => value.hashCode; @override - String toString() => 'CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown' '($value)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown' + '($value)'; } - sealed class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes { - static const TOTP = CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown.TOTP; - static const EMAIL = CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown.EMAIL; - static const values = CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown.values; - static final Map _byJson = CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown.values.asNameMap(); + static const TOTP = + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + .TOTP; + static const EMAIL = + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + .EMAIL; + static const values = + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + .values; + static final Map< + String, + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + > + _byJson = + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + .values + .asNameMap(); String toJson(); - static CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes fromJson(String json) => _byJson[json] ?? CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown(json); + static CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes + fromJson(String json) => + _byJson[json] ?? + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown( + json, + ); } -enum CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown implements CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes { +enum CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesKnown + implements + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes { TOTP, - EMAIL -; + EMAIL; @override String toJson() => name; } -final class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown implements CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes { +final class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown + implements + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes { final String value; - const CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown(this.value); + const CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown( + this.value, + ); @override String toJson() => value; @override bool operator ==(Object other) => - other is CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown && value == other.value; + other + is CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown && + value == other.value; @override int get hashCode => value.hashCode; @override - String toString() => 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown' '($value)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypesUnknown' + '($value)'; } - sealed class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallenges { - static const PASSWORD = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown.PASSWORD; - static const EMAIL_OTP = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown.EMAIL_OTP; - static const SMS_OTP = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown.SMS_OTP; - static const WEB_AUTHN = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown.WEB_AUTHN; - static const values = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown.values; - static final Map _byJson = CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown.values.asNameMap(); + static const PASSWORD = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown + .PASSWORD; + static const EMAIL_OTP = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown + .EMAIL_OTP; + static const SMS_OTP = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown + .SMS_OTP; + static const WEB_AUTHN = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown + .WEB_AUTHN; + static const values = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown + .values; + static final Map< + String, + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown + > + _byJson = + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown + .values + .asNameMap(); String toJson(); - static CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallenges fromJson(String json) => _byJson[json] ?? CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesUnknown(json); + static CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallenges + fromJson(String json) => + _byJson[json] ?? + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesUnknown( + json, + ); } -enum CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown implements CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallenges { +enum CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesKnown + implements + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallenges { PASSWORD, EMAIL_OTP, SMS_OTP, - WEB_AUTHN -; + WEB_AUTHN; @override String toJson() => name; } -final class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesUnknown implements CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallenges { +final class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesUnknown + implements + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallenges { final String value; - const CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesUnknown(this.value); + const CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesUnknown( + this.value, + ); @override String toJson() => value; @override bool operator ==(Object other) => - other is CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesUnknown && value == other.value; + other + is CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesUnknown && + value == other.value; @override int get hashCode => value.hashCode; @override - String toString() => 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesUnknown' '($value)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallengesUnknown' + '($value)'; } - sealed class ContinueSignInCognitoSignInResultNextStep { const ContinueSignInCognitoSignInResultNextStep(); Map toJson(); - static ContinueSignInCognitoSignInResultNextStep fromJson(Map json) { + static ContinueSignInCognitoSignInResultNextStep fromJson( + Map json, + ) { switch (json['name'] as String) { - case 'CONFIRM_SIGN_IN_WITH_SMS_CODE': return CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_TOTP_CODE': return CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_EMAIL_CODE': return CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONTINUE_SIGN_IN_WITH_MFA_SELECTION': return CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION': return CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONTINUE_SIGN_IN_WITH_TOTP_SETUP': return CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP': return CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED': return CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION': return CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_PASSWORD': return CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTP': return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTP': return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_IN_WITH_WEB_AUTHN': return CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'RESET_PASSWORD': return RESET_PASSWORDContinueSignInCognitoSignInResultNextStep.fromJson(json); - case 'CONFIRM_SIGN_UP': return CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep.fromJson(json); - default: return ContinueSignInCognitoSignInResultNextStepUnknown(_blocksFrozenObject(json)); + case 'CONFIRM_SIGN_IN_WITH_SMS_CODE': + return CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_TOTP_CODE': + return CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_EMAIL_CODE': + return CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONTINUE_SIGN_IN_WITH_MFA_SELECTION': + return CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION': + return CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONTINUE_SIGN_IN_WITH_TOTP_SETUP': + return CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP': + return CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED': + return CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION': + return CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_PASSWORD': + return CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTP': + return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTP': + return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_IN_WITH_WEB_AUTHN': + return CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'RESET_PASSWORD': + return RESET_PASSWORDContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + case 'CONFIRM_SIGN_UP': + return CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep.fromJson( + json, + ); + default: + return ContinueSignInCognitoSignInResultNextStepUnknown( + _blocksFrozenObject(json), + ); } } } -class CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; final CodeDeliveryDetails codeDeliveryDetails; @@ -1157,10 +1572,14 @@ class CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoSignInResultNextStep ext required this.codeDeliveryDetails, }); - factory CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, - codeDeliveryDetails: CodeDeliveryDetails.fromJson(json['codeDeliveryDetails'] as Map), + codeDeliveryDetails: CodeDeliveryDetails.fromJson( + json['codeDeliveryDetails'] as Map, + ), ); } @@ -1184,17 +1603,21 @@ class CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoSignInResultNextStep ext int get hashCode => Object.hash(session, codeDeliveryDetails); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_SMS_CODEContinueSignInCognitoSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; } -class CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; const CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep({ required this.session, }); - factory CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, ); @@ -1202,26 +1625,26 @@ class CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep ex @override Map toJson() { - return { - 'name': 'CONFIRM_SIGN_IN_WITH_TOTP_CODE', - 'session': session, - }; + return {'name': 'CONFIRM_SIGN_IN_WITH_TOTP_CODE', 'session': session}; } @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep && session == other.session; @override int get hashCode => session.hashCode; @override - String toString() => 'CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep(session: $session)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_TOTP_CODEContinueSignInCognitoSignInResultNextStep(session: $session)'; } -class CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; final CodeDeliveryDetails codeDeliveryDetails; @@ -1230,10 +1653,14 @@ class CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep e required this.codeDeliveryDetails, }); - factory CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, - codeDeliveryDetails: CodeDeliveryDetails.fromJson(json['codeDeliveryDetails'] as Map), + codeDeliveryDetails: CodeDeliveryDetails.fromJson( + json['codeDeliveryDetails'] as Map, + ), ); } @@ -1249,7 +1676,8 @@ class CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep e @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep && session == other.session && codeDeliveryDetails == other.codeDeliveryDetails; @@ -1257,22 +1685,36 @@ class CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep e int get hashCode => Object.hash(session, codeDeliveryDetails); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_EMAIL_CODEContinueSignInCognitoSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; } -class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; - final List allowedMFATypes; + final List< + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes + > + allowedMFATypes; const CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep({ required this.session, required this.allowedMFATypes, }); - factory CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, - allowedMFATypes: (json['allowedMFATypes'] as List).map((e) => CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes.fromJson(e as String)).toList(), + allowedMFATypes: (json['allowedMFATypes'] as List) + .map( + (e) => + CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes.fromJson( + e as String, + ), + ) + .toList(), ); } @@ -1288,7 +1730,8 @@ class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextSt @override bool operator ==(Object other) => identical(this, other) || - other is CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep && + other + is CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep && session == other.session && blocksDeepEquals(allowedMFATypes, other.allowedMFATypes); @@ -1296,22 +1739,36 @@ class CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextSt int get hashCode => Object.hash(session, blocksDeepHash(allowedMFATypes)); @override - String toString() => 'CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep(session: $session, allowedMFATypes: $allowedMFATypes)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_MFA_SELECTIONContinueSignInCognitoSignInResultNextStep(session: $session, allowedMFATypes: $allowedMFATypes)'; } -class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; - final List allowedMFATypes; + final List< + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes + > + allowedMFATypes; const CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep({ required this.session, required this.allowedMFATypes, }); - factory CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, - allowedMFATypes: (json['allowedMFATypes'] as List).map((e) => CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes.fromJson(e as String)).toList(), + allowedMFATypes: (json['allowedMFATypes'] as List) + .map( + (e) => + CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStepAllowedMFATypes.fromJson( + e as String, + ), + ) + .toList(), ); } @@ -1327,7 +1784,8 @@ class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResult @override bool operator ==(Object other) => identical(this, other) || - other is CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep && + other + is CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep && session == other.session && blocksDeepEquals(allowedMFATypes, other.allowedMFATypes); @@ -1335,10 +1793,12 @@ class CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResult int get hashCode => Object.hash(session, blocksDeepHash(allowedMFATypes)); @override - String toString() => 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep(session: $session, allowedMFATypes: $allowedMFATypes)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTIONContinueSignInCognitoSignInResultNextStep(session: $session, allowedMFATypes: $allowedMFATypes)'; } -class CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; final String sharedSecret; @@ -1347,7 +1807,9 @@ class CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep required this.sharedSecret, }); - factory CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, sharedSecret: json['sharedSecret'] as String, @@ -1366,7 +1828,8 @@ class CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep @override bool operator ==(Object other) => identical(this, other) || - other is CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep && + other + is CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep && session == other.session && sharedSecret == other.sharedSecret; @@ -1374,17 +1837,21 @@ class CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep int get hashCode => Object.hash(session, sharedSecret); @override - String toString() => 'CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep(session: $session, sharedSecret: $sharedSecret)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_TOTP_SETUPContinueSignInCognitoSignInResultNextStep(session: $session, sharedSecret: $sharedSecret)'; } -class CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; const CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep({ required this.session, }); - factory CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, ); @@ -1392,26 +1859,26 @@ class CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep @override Map toJson() { - return { - 'name': 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP', - 'session': session, - }; + return {'name': 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP', 'session': session}; } @override bool operator ==(Object other) => identical(this, other) || - other is CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep && + other + is CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep && session == other.session; @override int get hashCode => session.hashCode; @override - String toString() => 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep(session: $session)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUPContinueSignInCognitoSignInResultNextStep(session: $session)'; } -class CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; final List? requiredAttributes; @@ -1420,10 +1887,13 @@ class CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResul this.requiredAttributes, }); - factory CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, - requiredAttributes: (json['requiredAttributes'] as List?)?.cast(), + requiredAttributes: (json['requiredAttributes'] as List?) + ?.cast(), ); } @@ -1439,7 +1909,8 @@ class CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResul @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResultNextStep && session == other.session && blocksDeepEquals(requiredAttributes, other.requiredAttributes); @@ -1447,22 +1918,36 @@ class CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResul int get hashCode => Object.hash(session, blocksDeepHash(requiredAttributes)); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResultNextStep(session: $session, requiredAttributes: $requiredAttributes)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIREDContinueSignInCognitoSignInResultNextStep(session: $session, requiredAttributes: $requiredAttributes)'; } -class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; - final List availableChallenges; + final List< + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallenges + > + availableChallenges; const CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep({ required this.session, required this.availableChallenges, }); - factory CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, - availableChallenges: (json['availableChallenges'] as List).map((e) => CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallenges.fromJson(e as String)).toList(), + availableChallenges: (json['availableChallenges'] as List) + .map( + (e) => + CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStepAvailableChallenges.fromJson( + e as String, + ), + ) + .toList(), ); } @@ -1471,14 +1956,17 @@ class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInRes return { 'name': 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION', 'session': session, - 'availableChallenges': availableChallenges.map((e) => e.toJson()).toList(), + 'availableChallenges': availableChallenges + .map((e) => e.toJson()) + .toList(), }; } @override bool operator ==(Object other) => identical(this, other) || - other is CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep && + other + is CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep && session == other.session && blocksDeepEquals(availableChallenges, other.availableChallenges); @@ -1486,17 +1974,21 @@ class CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInRes int get hashCode => Object.hash(session, blocksDeepHash(availableChallenges)); @override - String toString() => 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep(session: $session, availableChallenges: $availableChallenges)'; + String toString() => + 'CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTIONContinueSignInCognitoSignInResultNextStep(session: $session, availableChallenges: $availableChallenges)'; } -class CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; const CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep({ required this.session, }); - factory CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, ); @@ -1504,10 +1996,7 @@ class CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep ext @override Map toJson() { - return { - 'name': 'CONFIRM_SIGN_IN_WITH_PASSWORD', - 'session': session, - }; + return {'name': 'CONFIRM_SIGN_IN_WITH_PASSWORD', 'session': session}; } @override @@ -1520,10 +2009,12 @@ class CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep ext int get hashCode => session.hashCode; @override - String toString() => 'CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep(session: $session)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_PASSWORDContinueSignInCognitoSignInResultNextStep(session: $session)'; } -class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; final CodeDeliveryDetails codeDeliveryDetails; @@ -1532,10 +2023,14 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResu required this.codeDeliveryDetails, }); - factory CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, - codeDeliveryDetails: CodeDeliveryDetails.fromJson(json['codeDeliveryDetails'] as Map), + codeDeliveryDetails: CodeDeliveryDetails.fromJson( + json['codeDeliveryDetails'] as Map, + ), ); } @@ -1551,7 +2046,8 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResu @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResultNextStep && session == other.session && codeDeliveryDetails == other.codeDeliveryDetails; @@ -1559,10 +2055,12 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResu int get hashCode => Object.hash(session, codeDeliveryDetails); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_EMAIL_OTPContinueSignInCognitoSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; } -class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; final CodeDeliveryDetails codeDeliveryDetails; @@ -1571,10 +2069,14 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResult required this.codeDeliveryDetails, }); - factory CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, - codeDeliveryDetails: CodeDeliveryDetails.fromJson(json['codeDeliveryDetails'] as Map), + codeDeliveryDetails: CodeDeliveryDetails.fromJson( + json['codeDeliveryDetails'] as Map, + ), ); } @@ -1590,7 +2092,8 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResult @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResultNextStep && session == other.session && codeDeliveryDetails == other.codeDeliveryDetails; @@ -1598,10 +2101,12 @@ class CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResult int get hashCode => Object.hash(session, codeDeliveryDetails); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_FIRST_FACTOR_SMS_OTPContinueSignInCognitoSignInResultNextStep(session: $session, codeDeliveryDetails: $codeDeliveryDetails)'; } -class CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final String session; final String credentialRequestOptions; @@ -1610,7 +2115,9 @@ class CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep ex required this.credentialRequestOptions, }); - factory CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep( session: json['session'] as String, credentialRequestOptions: json['credentialRequestOptions'] as String, @@ -1629,7 +2136,8 @@ class CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep ex @override bool operator ==(Object other) => identical(this, other) || - other is CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep && + other + is CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep && session == other.session && credentialRequestOptions == other.credentialRequestOptions; @@ -1637,23 +2145,23 @@ class CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep ex int get hashCode => Object.hash(session, credentialRequestOptions); @override - String toString() => 'CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep(session: $session, credentialRequestOptions: $credentialRequestOptions)'; + String toString() => + 'CONFIRM_SIGN_IN_WITH_WEB_AUTHNContinueSignInCognitoSignInResultNextStep(session: $session, credentialRequestOptions: $credentialRequestOptions)'; } -class RESET_PASSWORDContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { - +class RESET_PASSWORDContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { const RESET_PASSWORDContinueSignInCognitoSignInResultNextStep(); - factory RESET_PASSWORDContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { - return RESET_PASSWORDContinueSignInCognitoSignInResultNextStep( - ); + factory RESET_PASSWORDContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { + return RESET_PASSWORDContinueSignInCognitoSignInResultNextStep(); } @override Map toJson() { - return { - 'name': 'RESET_PASSWORD', - }; + return {'name': 'RESET_PASSWORD'}; } @override @@ -1665,19 +2173,27 @@ class RESET_PASSWORDContinueSignInCognitoSignInResultNextStep extends ContinueSi int get hashCode => runtimeType.hashCode; @override - String toString() => 'RESET_PASSWORDContinueSignInCognitoSignInResultNextStep()'; + String toString() => + 'RESET_PASSWORDContinueSignInCognitoSignInResultNextStep()'; } -class CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep extends ContinueSignInCognitoSignInResultNextStep { +class CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep + extends ContinueSignInCognitoSignInResultNextStep { final CodeDeliveryDetails? codeDeliveryDetails; const CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep({ this.codeDeliveryDetails, }); - factory CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep.fromJson(Map json) { + factory CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep.fromJson( + Map json, + ) { return CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep( - codeDeliveryDetails: json['codeDeliveryDetails'] != null ? CodeDeliveryDetails.fromJson(json['codeDeliveryDetails'] as Map) : null, + codeDeliveryDetails: json['codeDeliveryDetails'] != null + ? CodeDeliveryDetails.fromJson( + json['codeDeliveryDetails'] as Map, + ) + : null, ); } @@ -1685,7 +2201,8 @@ class CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep extends ContinueS Map toJson() { return { 'name': 'CONFIRM_SIGN_UP', - if (codeDeliveryDetails != null) 'codeDeliveryDetails': codeDeliveryDetails?.toJson(), + if (codeDeliveryDetails != null) + 'codeDeliveryDetails': codeDeliveryDetails?.toJson(), }; } @@ -1699,10 +2216,12 @@ class CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep extends ContinueS int get hashCode => codeDeliveryDetails.hashCode; @override - String toString() => 'CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep(codeDeliveryDetails: $codeDeliveryDetails)'; + String toString() => + 'CONFIRM_SIGN_UPContinueSignInCognitoSignInResultNextStep(codeDeliveryDetails: $codeDeliveryDetails)'; } -final class ContinueSignInCognitoSignInResultNextStepUnknown extends ContinueSignInCognitoSignInResultNextStep { +final class ContinueSignInCognitoSignInResultNextStepUnknown + extends ContinueSignInCognitoSignInResultNextStep { final Map json; const ContinueSignInCognitoSignInResultNextStepUnknown(this.json); @@ -1714,17 +2233,18 @@ final class ContinueSignInCognitoSignInResultNextStepUnknown extends ContinueSig @override bool operator ==(Object other) => - other is ContinueSignInCognitoSignInResultNextStepUnknown && blocksDeepEquals(json, other.json); + other is ContinueSignInCognitoSignInResultNextStepUnknown && + blocksDeepEquals(json, other.json); @override int get hashCode => blocksDeepHash(json); @override - String toString() => 'ContinueSignInCognitoSignInResultNextStepUnknown' '($json)'; + String toString() => + 'ContinueSignInCognitoSignInResultNextStepUnknown' + '($json)'; } - - Map _blocksFrozenObject(Map json) => Map.unmodifiable({ for (final e in json.entries) e.key: _blocksFrozen(e.value), @@ -1745,9 +2265,12 @@ sealed class CognitoConfirmSignInResult { Map toJson(); static CognitoConfirmSignInResult fromJson(Map json) { switch (json['status'] as String) { - case 'signedIn': return SignedInCognitoConfirmSignInResult.fromJson(json); - case 'continueSignIn': return ContinueSignInCognitoConfirmSignInResult.fromJson(json); - default: return CognitoConfirmSignInResultUnknown(_blocksFrozenObject(json)); + case 'signedIn': + return SignedInCognitoConfirmSignInResult.fromJson(json); + case 'continueSignIn': + return ContinueSignInCognitoConfirmSignInResult.fromJson(json); + default: + return CognitoConfirmSignInResultUnknown(_blocksFrozenObject(json)); } } } @@ -1755,11 +2278,11 @@ sealed class CognitoConfirmSignInResult { class SignedInCognitoConfirmSignInResult extends CognitoConfirmSignInResult { final AuthenticatedUser user; - const SignedInCognitoConfirmSignInResult({ - required this.user, - }); + const SignedInCognitoConfirmSignInResult({required this.user}); - factory SignedInCognitoConfirmSignInResult.fromJson(Map json) { + factory SignedInCognitoConfirmSignInResult.fromJson( + Map json, + ) { return SignedInCognitoConfirmSignInResult( user: AuthenticatedUser.fromJson(json['user'] as Map), ); @@ -1767,17 +2290,13 @@ class SignedInCognitoConfirmSignInResult extends CognitoConfirmSignInResult { @override Map toJson() { - return { - 'status': 'signedIn', - 'user': user.toJson(), - }; + return {'status': 'signedIn', 'user': user.toJson()}; } @override bool operator ==(Object other) => identical(this, other) || - other is SignedInCognitoConfirmSignInResult && - user == other.user; + other is SignedInCognitoConfirmSignInResult && user == other.user; @override int get hashCode => user.hashCode; @@ -1786,25 +2305,25 @@ class SignedInCognitoConfirmSignInResult extends CognitoConfirmSignInResult { String toString() => 'SignedInCognitoConfirmSignInResult(user: $user)'; } -class ContinueSignInCognitoConfirmSignInResult extends CognitoConfirmSignInResult { +class ContinueSignInCognitoConfirmSignInResult + extends CognitoConfirmSignInResult { final ContinueSignInCognitoConfirmSignInResultNextStep nextStep; - const ContinueSignInCognitoConfirmSignInResult({ - required this.nextStep, - }); + const ContinueSignInCognitoConfirmSignInResult({required this.nextStep}); - factory ContinueSignInCognitoConfirmSignInResult.fromJson(Map json) { + factory ContinueSignInCognitoConfirmSignInResult.fromJson( + Map json, + ) { return ContinueSignInCognitoConfirmSignInResult( - nextStep: ContinueSignInCognitoConfirmSignInResultNextStep.fromJson(json['nextStep'] as Map), + nextStep: ContinueSignInCognitoConfirmSignInResultNextStep.fromJson( + json['nextStep'] as Map, + ), ); } @override Map toJson() { - return { - 'status': 'continueSignIn', - 'nextStep': nextStep.toJson(), - }; + return {'status': 'continueSignIn', 'nextStep': nextStep.toJson()}; } @override @@ -1817,10 +2336,12 @@ class ContinueSignInCognitoConfirmSignInResult extends CognitoConfirmSignInResul int get hashCode => nextStep.hashCode; @override - String toString() => 'ContinueSignInCognitoConfirmSignInResult(nextStep: $nextStep)'; + String toString() => + 'ContinueSignInCognitoConfirmSignInResult(nextStep: $nextStep)'; } -final class CognitoConfirmSignInResultUnknown extends CognitoConfirmSignInResult { +final class CognitoConfirmSignInResultUnknown + extends CognitoConfirmSignInResult { final Map json; const CognitoConfirmSignInResultUnknown(this.json); @@ -1832,25 +2353,29 @@ final class CognitoConfirmSignInResultUnknown extends CognitoConfirmSignInResult @override bool operator ==(Object other) => - other is CognitoConfirmSignInResultUnknown && blocksDeepEquals(json, other.json); + other is CognitoConfirmSignInResultUnknown && + blocksDeepEquals(json, other.json); @override int get hashCode => blocksDeepHash(json); @override - String toString() => 'CognitoConfirmSignInResultUnknown' '($json)'; + String toString() => + 'CognitoConfirmSignInResultUnknown' + '($json)'; } - - sealed class CognitoSignInResult { const CognitoSignInResult(); Map toJson(); static CognitoSignInResult fromJson(Map json) { switch (json['status'] as String) { - case 'signedIn': return SignedInCognitoSignInResult.fromJson(json); - case 'continueSignIn': return ContinueSignInCognitoSignInResult.fromJson(json); - default: return CognitoSignInResultUnknown(_blocksFrozenObject(json)); + case 'signedIn': + return SignedInCognitoSignInResult.fromJson(json); + case 'continueSignIn': + return ContinueSignInCognitoSignInResult.fromJson(json); + default: + return CognitoSignInResultUnknown(_blocksFrozenObject(json)); } } } @@ -1858,9 +2383,7 @@ sealed class CognitoSignInResult { class SignedInCognitoSignInResult extends CognitoSignInResult { final AuthenticatedUser user; - const SignedInCognitoSignInResult({ - required this.user, - }); + const SignedInCognitoSignInResult({required this.user}); factory SignedInCognitoSignInResult.fromJson(Map json) { return SignedInCognitoSignInResult( @@ -1870,17 +2393,13 @@ class SignedInCognitoSignInResult extends CognitoSignInResult { @override Map toJson() { - return { - 'status': 'signedIn', - 'user': user.toJson(), - }; + return {'status': 'signedIn', 'user': user.toJson()}; } @override bool operator ==(Object other) => identical(this, other) || - other is SignedInCognitoSignInResult && - user == other.user; + other is SignedInCognitoSignInResult && user == other.user; @override int get hashCode => user.hashCode; @@ -1892,29 +2411,27 @@ class SignedInCognitoSignInResult extends CognitoSignInResult { class ContinueSignInCognitoSignInResult extends CognitoSignInResult { final ContinueSignInCognitoSignInResultNextStep nextStep; - const ContinueSignInCognitoSignInResult({ - required this.nextStep, - }); + const ContinueSignInCognitoSignInResult({required this.nextStep}); - factory ContinueSignInCognitoSignInResult.fromJson(Map json) { + factory ContinueSignInCognitoSignInResult.fromJson( + Map json, + ) { return ContinueSignInCognitoSignInResult( - nextStep: ContinueSignInCognitoSignInResultNextStep.fromJson(json['nextStep'] as Map), + nextStep: ContinueSignInCognitoSignInResultNextStep.fromJson( + json['nextStep'] as Map, + ), ); } @override Map toJson() { - return { - 'status': 'continueSignIn', - 'nextStep': nextStep.toJson(), - }; + return {'status': 'continueSignIn', 'nextStep': nextStep.toJson()}; } @override bool operator ==(Object other) => identical(this, other) || - other is ContinueSignInCognitoSignInResult && - nextStep == other.nextStep; + other is ContinueSignInCognitoSignInResult && nextStep == other.nextStep; @override int get hashCode => nextStep.hashCode; @@ -1941,35 +2458,34 @@ final class CognitoSignInResultUnknown extends CognitoSignInResult { int get hashCode => blocksDeepHash(json); @override - String toString() => 'CognitoSignInResultUnknown' '($json)'; + String toString() => + 'CognitoSignInResultUnknown' + '($json)'; } - - class Api { final BlocksClient _client; Api(this._client); - Future cognitoConfirmSignIn({required String session, required String challengeResponse}) async { - final params = [ - session, - challengeResponse, - ]; + Future cognitoConfirmSignIn({ + required String session, + required String challengeResponse, + }) async { + final params = [session, challengeResponse]; final result = await _client.call('api.cognitoConfirmSignIn', params); return CognitoConfirmSignInResult.fromJson(result as Map); } - Future cognitoSignIn({required String username, required String password}) async { - final params = [ - username, - password, - ]; + Future cognitoSignIn({ + required String username, + required String password, + }) async { + final params = [username, password]; final result = await _client.call('api.cognitoSignIn', params); return CognitoSignInResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -1987,4 +2503,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/24-nullable-discriminated-union/dart/client.dart b/native/codegen-fixtures/24-nullable-discriminated-union/dart/client.dart index 11ead69d4f..3a52387acb 100644 --- a/native/codegen-fixtures/24-nullable-discriminated-union/dart/client.dart +++ b/native/codegen-fixtures/24-nullable-discriminated-union/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -13,10 +23,7 @@ class IsUpdatedFalseNextStep { final String name; final String destination; - const IsUpdatedFalseNextStep({ - required this.name, - required this.destination, - }); + const IsUpdatedFalseNextStep({required this.name, required this.destination}); factory IsUpdatedFalseNextStep.fromJson(Map json) { return IsUpdatedFalseNextStep( @@ -26,10 +33,7 @@ class IsUpdatedFalseNextStep { } Map toJson() { - return { - 'name': name, - 'destination': destination, - }; + return {'name': name, 'destination': destination}; } @override @@ -43,10 +47,10 @@ class IsUpdatedFalseNextStep { int get hashCode => Object.hash(name, destination); @override - String toString() => 'IsUpdatedFalseNextStep(name: $name, destination: $destination)'; + String toString() => + 'IsUpdatedFalseNextStep(name: $name, destination: $destination)'; } - Map _blocksFrozenObject(Map json) => Map.unmodifiable({ for (final e in json.entries) e.key: _blocksFrozen(e.value), @@ -67,32 +71,29 @@ sealed class UpdateAttributesResult { Map toJson(); static UpdateAttributesResult fromJson(Map json) { switch (json['isUpdated'] as bool) { - case true: return IsUpdatedTrue.fromJson(json); - case false: return IsUpdatedFalse.fromJson(json); + case true: + return IsUpdatedTrue.fromJson(json); + case false: + return IsUpdatedFalse.fromJson(json); } } } class IsUpdatedTrue extends UpdateAttributesResult { - const IsUpdatedTrue(); factory IsUpdatedTrue.fromJson(Map json) { - return IsUpdatedTrue( - ); + return IsUpdatedTrue(); } @override Map toJson() { - return { - 'isUpdated': true, - }; + return {'isUpdated': true}; } @override bool operator ==(Object other) => - identical(this, other) || - other is IsUpdatedTrue; + identical(this, other) || other is IsUpdatedTrue; @override int get hashCode => runtimeType.hashCode; @@ -104,29 +105,25 @@ class IsUpdatedTrue extends UpdateAttributesResult { class IsUpdatedFalse extends UpdateAttributesResult { final IsUpdatedFalseNextStep nextStep; - const IsUpdatedFalse({ - required this.nextStep, - }); + const IsUpdatedFalse({required this.nextStep}); factory IsUpdatedFalse.fromJson(Map json) { return IsUpdatedFalse( - nextStep: IsUpdatedFalseNextStep.fromJson(json['nextStep'] as Map), + nextStep: IsUpdatedFalseNextStep.fromJson( + json['nextStep'] as Map, + ), ); } @override Map toJson() { - return { - 'isUpdated': false, - 'nextStep': nextStep.toJson(), - }; + return {'isUpdated': false, 'nextStep': nextStep.toJson()}; } @override bool operator ==(Object other) => identical(this, other) || - other is IsUpdatedFalse && - nextStep == other.nextStep; + other is IsUpdatedFalse && nextStep == other.nextStep; @override int get hashCode => nextStep.hashCode; @@ -135,16 +132,17 @@ class IsUpdatedFalse extends UpdateAttributesResult { String toString() => 'IsUpdatedFalse(nextStep: $nextStep)'; } - - sealed class GetNotificationResult { const GetNotificationResult(); Map toJson(); static GetNotificationResult fromJson(Map json) { switch (json['type'] as String) { - case 'email': return EmailGetNotificationResult.fromJson(json); - case 'sms': return SmsGetNotificationResult.fromJson(json); - default: return GetNotificationResultUnknown(_blocksFrozenObject(json)); + case 'email': + return EmailGetNotificationResult.fromJson(json); + case 'sms': + return SmsGetNotificationResult.fromJson(json); + default: + return GetNotificationResultUnknown(_blocksFrozenObject(json)); } } } @@ -153,10 +151,7 @@ class EmailGetNotificationResult extends GetNotificationResult { final String subject; final String body; - const EmailGetNotificationResult({ - required this.subject, - required this.body, - }); + const EmailGetNotificationResult({required this.subject, required this.body}); factory EmailGetNotificationResult.fromJson(Map json) { return EmailGetNotificationResult( @@ -167,11 +162,7 @@ class EmailGetNotificationResult extends GetNotificationResult { @override Map toJson() { - return { - 'type': 'email', - 'subject': subject, - 'body': body, - }; + return {'type': 'email', 'subject': subject, 'body': body}; } @override @@ -185,35 +176,28 @@ class EmailGetNotificationResult extends GetNotificationResult { int get hashCode => Object.hash(subject, body); @override - String toString() => 'EmailGetNotificationResult(subject: $subject, body: $body)'; + String toString() => + 'EmailGetNotificationResult(subject: $subject, body: $body)'; } class SmsGetNotificationResult extends GetNotificationResult { final String message; - const SmsGetNotificationResult({ - required this.message, - }); + const SmsGetNotificationResult({required this.message}); factory SmsGetNotificationResult.fromJson(Map json) { - return SmsGetNotificationResult( - message: json['message'] as String, - ); + return SmsGetNotificationResult(message: json['message'] as String); } @override Map toJson() { - return { - 'type': 'sms', - 'message': message, - }; + return {'type': 'sms', 'message': message}; } @override bool operator ==(Object other) => identical(this, other) || - other is SmsGetNotificationResult && - message == other.message; + other is SmsGetNotificationResult && message == other.message; @override int get hashCode => message.hashCode; @@ -234,39 +218,46 @@ final class GetNotificationResultUnknown extends GetNotificationResult { @override bool operator ==(Object other) => - other is GetNotificationResultUnknown && blocksDeepEquals(json, other.json); + other is GetNotificationResultUnknown && + blocksDeepEquals(json, other.json); @override int get hashCode => blocksDeepHash(json); @override - String toString() => 'GetNotificationResultUnknown' '($json)'; + String toString() => + 'GetNotificationResultUnknown' + '($json)'; } - - class Api { final BlocksClient _client; Api(this._client); - Future> updateAttributes({required Map attributes}) async { - final params = [ - attributes, - ]; + Future> updateAttributes({ + required Map attributes, + }) async { + final params = [attributes]; final result = await _client.call('api.updateAttributes', params); - return (result as Map).map((k, v) => MapEntry(k, v == null ? null : UpdateAttributesResult.fromJson(v as Map))); + return (result as Map).map( + (k, v) => MapEntry( + k, + v == null + ? null + : UpdateAttributesResult.fromJson(v as Map), + ), + ); } Future getNotification({required String id}) async { - final params = [ - id, - ]; + final params = [id]; final result = await _client.call('api.getNotification', params); - return result == null ? null : GetNotificationResult.fromJson(result as Map); + return result == null + ? null + : GetNotificationResult.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -284,4 +275,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/25-nested-transferable-operation-result/dart/client.dart b/native/codegen-fixtures/25-nested-transferable-operation-result/dart/client.dart index ff438508b8..a9659a1fdd 100644 --- a/native/codegen-fixtures/25-nested-transferable-operation-result/dart/client.dart +++ b/native/codegen-fixtures/25-nested-transferable-operation-result/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,35 +6,48 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; -export 'package:blocks_runtime/blocks_runtime.dart' show RealtimeChannel, FileDownloadHandle, FileUploadHandle, FileTransferException, RealtimeException, RealtimeChannelClosedException, RealtimeConnectionException, RealtimeSubscriptionEndedException, TransferableException, InvalidDescriptorException; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + RealtimeChannel, + FileDownloadHandle, + FileUploadHandle, + FileTransferException, + RealtimeException, + RealtimeChannelClosedException, + RealtimeConnectionException, + RealtimeSubscriptionEndedException, + TransferableException, + InvalidDescriptorException; // --- Models --- class GetSessionResultChannelMessage { final String text; - const GetSessionResultChannelMessage({ - required this.text, - }); + const GetSessionResultChannelMessage({required this.text}); factory GetSessionResultChannelMessage.fromJson(Map json) { - return GetSessionResultChannelMessage( - text: json['text'] as String, - ); + return GetSessionResultChannelMessage(text: json['text'] as String); } Map toJson() { - return { - 'text': text, - }; + return {'text': text}; } @override bool operator ==(Object other) => identical(this, other) || - other is GetSessionResultChannelMessage && - text == other.text; + other is GetSessionResultChannelMessage && text == other.text; @override int get hashCode => text.hashCode; @@ -42,31 +56,22 @@ class GetSessionResultChannelMessage { String toString() => 'GetSessionResultChannelMessage(text: $text)'; } - class CountResult { final int count; - const CountResult({ - required this.count, - }); + const CountResult({required this.count}); factory CountResult.fromJson(Map json) { - return CountResult( - count: (json['count'] as num).toInt(), - ); + return CountResult(count: (json['count'] as num).toInt()); } Map toJson() { - return { - 'count': count, - }; + return {'count': count}; } @override bool operator ==(Object other) => - identical(this, other) || - other is CountResult && - count == other.count; + identical(this, other) || other is CountResult && count == other.count; @override int get hashCode => count.hashCode; @@ -75,57 +80,51 @@ class CountResult { String toString() => 'CountResult(count: $count)'; } - class MessageGetSessionResultEventChannelMessage { final String body; - const MessageGetSessionResultEventChannelMessage({ - required this.body, - }); + const MessageGetSessionResultEventChannelMessage({required this.body}); - factory MessageGetSessionResultEventChannelMessage.fromJson(Map json) { + factory MessageGetSessionResultEventChannelMessage.fromJson( + Map json, + ) { return MessageGetSessionResultEventChannelMessage( body: json['body'] as String, ); } Map toJson() { - return { - 'body': body, - }; + return {'body': body}; } @override bool operator ==(Object other) => identical(this, other) || - other is MessageGetSessionResultEventChannelMessage && - body == other.body; + other is MessageGetSessionResultEventChannelMessage && body == other.body; @override int get hashCode => body.hashCode; @override - String toString() => 'MessageGetSessionResultEventChannelMessage(body: $body)'; + String toString() => + 'MessageGetSessionResultEventChannelMessage(body: $body)'; } - class PresenceGetSessionResultEventChannelMessage { final bool online; - const PresenceGetSessionResultEventChannelMessage({ - required this.online, - }); + const PresenceGetSessionResultEventChannelMessage({required this.online}); - factory PresenceGetSessionResultEventChannelMessage.fromJson(Map json) { + factory PresenceGetSessionResultEventChannelMessage.fromJson( + Map json, + ) { return PresenceGetSessionResultEventChannelMessage( online: json['online'] as bool, ); } Map toJson() { - return { - 'online': online, - }; + return {'online': online}; } @override @@ -138,18 +137,21 @@ class PresenceGetSessionResultEventChannelMessage { int get hashCode => online.hashCode; @override - String toString() => 'PresenceGetSessionResultEventChannelMessage(online: $online)'; + String toString() => + 'PresenceGetSessionResultEventChannelMessage(online: $online)'; } - sealed class GetSessionResultEvent { const GetSessionResultEvent(); Map toJson(); static GetSessionResultEvent fromJson(Map json) { switch (json['kind'] as String) { - case 'message': return MessageGetSessionResultEvent.fromJson(json); - case 'presence': return PresenceGetSessionResultEvent.fromJson(json); - default: return GetSessionResultEventUnknown(_blocksFrozenObject(json)); + case 'message': + return MessageGetSessionResultEvent.fromJson(json); + case 'presence': + return PresenceGetSessionResultEvent.fromJson(json); + default: + return GetSessionResultEventUnknown(_blocksFrozenObject(json)); } } } @@ -157,29 +159,26 @@ sealed class GetSessionResultEvent { class MessageGetSessionResultEvent extends GetSessionResultEvent { final RealtimeChannel channel; - const MessageGetSessionResultEvent({ - required this.channel, - }); + const MessageGetSessionResultEvent({required this.channel}); factory MessageGetSessionResultEvent.fromJson(Map json) { return MessageGetSessionResultEvent( - channel: RealtimeChannel.fromJson(json['channel'] as Map, (json) => MessageGetSessionResultEventChannelMessage.fromJson(json)), + channel: RealtimeChannel.fromJson( + json['channel'] as Map, + (json) => MessageGetSessionResultEventChannelMessage.fromJson(json), + ), ); } @override Map toJson() { - return { - 'kind': 'message', - 'channel': channel, - }; + return {'kind': 'message', 'channel': channel}; } @override bool operator ==(Object other) => identical(this, other) || - other is MessageGetSessionResultEvent && - channel == other.channel; + other is MessageGetSessionResultEvent && channel == other.channel; @override int get hashCode => channel.hashCode; @@ -191,29 +190,26 @@ class MessageGetSessionResultEvent extends GetSessionResultEvent { class PresenceGetSessionResultEvent extends GetSessionResultEvent { final RealtimeChannel channel; - const PresenceGetSessionResultEvent({ - required this.channel, - }); + const PresenceGetSessionResultEvent({required this.channel}); factory PresenceGetSessionResultEvent.fromJson(Map json) { return PresenceGetSessionResultEvent( - channel: RealtimeChannel.fromJson(json['channel'] as Map, (json) => PresenceGetSessionResultEventChannelMessage.fromJson(json)), + channel: RealtimeChannel.fromJson( + json['channel'] as Map, + (json) => PresenceGetSessionResultEventChannelMessage.fromJson(json), + ), ); } @override Map toJson() { - return { - 'kind': 'presence', - 'channel': channel, - }; + return {'kind': 'presence', 'channel': channel}; } @override bool operator ==(Object other) => identical(this, other) || - other is PresenceGetSessionResultEvent && - channel == other.channel; + other is PresenceGetSessionResultEvent && channel == other.channel; @override int get hashCode => channel.hashCode; @@ -234,17 +230,18 @@ final class GetSessionResultEventUnknown extends GetSessionResultEvent { @override bool operator ==(Object other) => - other is GetSessionResultEventUnknown && blocksDeepEquals(json, other.json); + other is GetSessionResultEventUnknown && + blocksDeepEquals(json, other.json); @override int get hashCode => blocksDeepHash(json); @override - String toString() => 'GetSessionResultEventUnknown' '($json)'; + String toString() => + 'GetSessionResultEventUnknown' + '($json)'; } - - Map _blocksFrozenObject(Map json) => Map.unmodifiable({ for (final e in json.entries) e.key: _blocksFrozen(e.value), @@ -263,27 +260,25 @@ Object? _blocksFrozen(Object? value) => switch (value) { class GetSessionResultInner { final RealtimeChannel channel; - const GetSessionResultInner({ - required this.channel, - }); + const GetSessionResultInner({required this.channel}); factory GetSessionResultInner.fromJson(Map json) { return GetSessionResultInner( - channel: RealtimeChannel.fromJson(json['channel'] as Map, (json) => CountResult.fromJson(json)), + channel: RealtimeChannel.fromJson( + json['channel'] as Map, + (json) => CountResult.fromJson(json), + ), ); } Map toJson() { - return { - 'channel': channel, - }; + return {'channel': channel}; } @override bool operator ==(Object other) => identical(this, other) || - other is GetSessionResultInner && - channel == other.channel; + other is GetSessionResultInner && channel == other.channel; @override int get hashCode => channel.hashCode; @@ -292,7 +287,6 @@ class GetSessionResultInner { String toString() => 'GetSessionResultInner(channel: $channel)'; } - class GetSessionResult { final String sessionId; final RealtimeChannel channel; @@ -313,11 +307,24 @@ class GetSessionResult { factory GetSessionResult.fromJson(Map json) { return GetSessionResult( sessionId: json['sessionId'] as String, - channel: RealtimeChannel.fromJson(json['channel'] as Map, (json) => GetSessionResultChannelMessage.fromJson(json)), - inner: GetSessionResultInner.fromJson(json['inner'] as Map), - event: GetSessionResultEvent.fromJson(json['event'] as Map), - stringValues: RealtimeChannel.fromJsonValue(json['stringValues'] as Map, (payload) => (payload as List).cast()), - integerValues: RealtimeChannel.fromJsonValue(json['integerValues'] as Map, (payload) => (payload as List).cast()), + channel: RealtimeChannel.fromJson( + json['channel'] as Map, + (json) => GetSessionResultChannelMessage.fromJson(json), + ), + inner: GetSessionResultInner.fromJson( + json['inner'] as Map, + ), + event: GetSessionResultEvent.fromJson( + json['event'] as Map, + ), + stringValues: RealtimeChannel.fromJsonValue( + json['stringValues'] as Map, + (payload) => (payload as List).cast(), + ), + integerValues: RealtimeChannel.fromJsonValue( + json['integerValues'] as Map, + (payload) => (payload as List).cast(), + ), ); } @@ -344,13 +351,20 @@ class GetSessionResult { integerValues == other.integerValues; @override - int get hashCode => Object.hash(sessionId, channel, inner, event, stringValues, integerValues); + int get hashCode => Object.hash( + sessionId, + channel, + inner, + event, + stringValues, + integerValues, + ); @override - String toString() => 'GetSessionResult(sessionId: $sessionId, channel: $channel, inner: $inner, event: $event, stringValues: $stringValues, integerValues: $integerValues)'; + String toString() => + 'GetSessionResult(sessionId: $sessionId, channel: $channel, inner: $inner, event: $event, stringValues: $stringValues, integerValues: $integerValues)'; } - class Api { final BlocksClient _client; Api(this._client); @@ -366,7 +380,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -384,4 +397,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/26-unknown-transferable/dart/client.dart b/native/codegen-fixtures/26-unknown-transferable/dart/client.dart index 6da8a6580d..bdbaee99d8 100644 --- a/native/codegen-fixtures/26-unknown-transferable/dart/client.dart +++ b/native/codegen-fixtures/26-unknown-transferable/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,8 +6,28 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; -export 'package:blocks_runtime/blocks_runtime.dart' show RealtimeChannel, FileDownloadHandle, FileUploadHandle, FileTransferException, RealtimeException, RealtimeChannelClosedException, RealtimeConnectionException, RealtimeSubscriptionEndedException, TransferableException, InvalidDescriptorException; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + RealtimeChannel, + FileDownloadHandle, + FileUploadHandle, + FileTransferException, + RealtimeException, + RealtimeChannelClosedException, + RealtimeConnectionException, + RealtimeSubscriptionEndedException, + TransferableException, + InvalidDescriptorException; export 'package:blocks_runtime/blocks_runtime.dart' show UnknownTransferable; // --- Models --- @@ -28,10 +49,7 @@ class ConnectDeviceResultMessage { } Map toJson() { - return { - 'temperature': temperature, - 'humidity': humidity, - }; + return {'temperature': temperature, 'humidity': humidity}; } @override @@ -45,34 +63,37 @@ class ConnectDeviceResultMessage { int get hashCode => Object.hash(temperature, humidity); @override - String toString() => 'ConnectDeviceResultMessage(temperature: $temperature, humidity: $humidity)'; + String toString() => + 'ConnectDeviceResultMessage(temperature: $temperature, humidity: $humidity)'; } - // --- API Namespaces --- class Api { final BlocksClient _client; Api(this._client); - Future getDeviceHandle({required String deviceId}) async { - final params = [ - deviceId, - ]; + Future getDeviceHandle({ + required String deviceId, + }) async { + final params = [deviceId]; final result = await _client.call('api.getDeviceHandle', params); - return UnknownTransferable.fromJson(result, expectedTag: 'example-iot/device-handle'); + return UnknownTransferable.fromJson( + result, + expectedTag: 'example-iot/device-handle', + ); } Future connectDevice({required String deviceId}) async { - final params = [ - deviceId, - ]; + final params = [deviceId]; final result = await _client.call('api.connectDevice', params); - return UnknownTransferable.fromJson(result, expectedTag: 'example-iot/device-link'); + return UnknownTransferable.fromJson( + result, + expectedTag: 'example-iot/device-link', + ); } } - // --- Blocks Client --- class Blocks { @@ -90,4 +111,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/27-declared-transferable-bindings/dart/client.dart b/native/codegen-fixtures/27-declared-transferable-bindings/dart/client.dart index c46f7681ee..2fc00f7f7d 100644 --- a/native/codegen-fixtures/27-declared-transferable-bindings/dart/client.dart +++ b/native/codegen-fixtures/27-declared-transferable-bindings/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,10 +6,32 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -import 'package:example_iot_native/example_iot_native.dart' show APILink, DeviceHandle; -import 'package:example_sensor_native/example_sensor_native.dart' show SensorStream; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; -export 'package:blocks_runtime/blocks_runtime.dart' show RealtimeChannel, FileDownloadHandle, FileUploadHandle, FileTransferException, RealtimeException, RealtimeChannelClosedException, RealtimeConnectionException, RealtimeSubscriptionEndedException, TransferableException, InvalidDescriptorException; +import 'package:example_iot_native/example_iot_native.dart' + show APILink, DeviceHandle; +import 'package:example_sensor_native/example_sensor_native.dart' + show SensorStream; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + RealtimeChannel, + FileDownloadHandle, + FileUploadHandle, + FileTransferException, + RealtimeException, + RealtimeChannelClosedException, + RealtimeConnectionException, + RealtimeSubscriptionEndedException, + TransferableException, + InvalidDescriptorException; export 'package:blocks_runtime/blocks_runtime.dart' show UnknownTransferable; // --- Models --- @@ -16,29 +39,22 @@ export 'package:blocks_runtime/blocks_runtime.dart' show UnknownTransferable; class DeviceLabel { final String name; - DeviceLabel({ - required this.name, - }) { - if (!(name.length >= 1)) throw ArgumentError('name must be at least 1 characters'); + DeviceLabel({required this.name}) { + if (!(name.length >= 1)) + throw ArgumentError('name must be at least 1 characters'); } factory DeviceLabel.fromJson(Map json) { - return DeviceLabel( - name: json['name'] as String, - ); + return DeviceLabel(name: json['name'] as String); } Map toJson() { - return { - 'name': name, - }; + return {'name': name}; } @override bool operator ==(Object other) => - identical(this, other) || - other is DeviceLabel && - name == other.name; + identical(this, other) || other is DeviceLabel && name == other.name; @override int get hashCode => name.hashCode; @@ -47,7 +63,6 @@ class DeviceLabel { String toString() => 'DeviceLabel(name: $name)'; } - class ConnectDeviceResultMessage { final num temperature; final num humidity; @@ -65,10 +80,7 @@ class ConnectDeviceResultMessage { } Map toJson() { - return { - 'temperature': temperature, - 'humidity': humidity, - }; + return {'temperature': temperature, 'humidity': humidity}; } @override @@ -82,10 +94,10 @@ class ConnectDeviceResultMessage { int get hashCode => Object.hash(temperature, humidity); @override - String toString() => 'ConnectDeviceResultMessage(temperature: $temperature, humidity: $humidity)'; + String toString() => + 'ConnectDeviceResultMessage(temperature: $temperature, humidity: $humidity)'; } - // --- API Namespaces --- class Api { @@ -93,55 +105,75 @@ class Api { Api(this._client); Future getDeviceHandle({required String deviceId}) async { - final params = [ - deviceId, - ]; + final params = [deviceId]; final result = await _client.call('api.getDeviceHandle', params); - return DeviceHandle.fromBlocksDescriptor(validateTransferableDescriptor(result, expectedTag: 'example-iot/device-handle')); + return DeviceHandle.fromBlocksDescriptor( + validateTransferableDescriptor( + result, + expectedTag: 'example-iot/device-handle', + ), + ); } - Future> connectDevice({required String deviceId}) async { - final params = [ - deviceId, - ]; + Future> connectDevice({ + required String deviceId, + }) async { + final params = [deviceId]; final result = await _client.call('api.connectDevice', params); - return APILink.fromBlocksDescriptor(validateTransferableDescriptor(result, expectedTag: 'example-iot/device-link'), (json) => ConnectDeviceResultMessage.fromJson(json)); + return APILink.fromBlocksDescriptor( + validateTransferableDescriptor( + result, + expectedTag: 'example-iot/device-link', + ), + (json) => ConnectDeviceResultMessage.fromJson(json), + ); } Future findDeviceHandle({required String serialNumber}) async { - final params = [ - serialNumber, - ]; + final params = [serialNumber]; final result = await _client.call('api.findDeviceHandle', params); - return DeviceHandle.fromBlocksDescriptor(validateTransferableDescriptor(result, expectedTag: 'example-iot/device-handle')); + return DeviceHandle.fromBlocksDescriptor( + validateTransferableDescriptor( + result, + expectedTag: 'example-iot/device-handle', + ), + ); } Future openSensorStream({required String sensorId}) async { - final params = [ - sensorId, - ]; + final params = [sensorId]; final result = await _client.call('api.openSensorStream', params); - return SensorStream.fromBlocksDescriptor(validateTransferableDescriptor(result, expectedTag: 'example-sensor/stream')); + return SensorStream.fromBlocksDescriptor( + validateTransferableDescriptor( + result, + expectedTag: 'example-sensor/stream', + ), + ); } - Future openGatewayLink({required String gatewayId}) async { - final params = [ - gatewayId, - ]; + Future openGatewayLink({ + required String gatewayId, + }) async { + final params = [gatewayId]; final result = await _client.call('api.openGatewayLink', params); - return UnknownTransferable.fromJson(result, expectedTag: 'example-gateway/link'); + return UnknownTransferable.fromJson( + result, + expectedTag: 'example-gateway/link', + ); } - Future getFirmwareSession({required String deviceId}) async { - final params = [ - deviceId, - ]; + Future getFirmwareSession({ + required String deviceId, + }) async { + final params = [deviceId]; final result = await _client.call('api.getFirmwareSession', params); - return UnknownTransferable.fromJson(result, expectedTag: 'example-iot/firmware-session'); + return UnknownTransferable.fromJson( + result, + expectedTag: 'example-iot/firmware-session', + ); } } - // --- Blocks Client --- class Blocks { @@ -159,4 +191,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/28-escaping/dart/client.dart b/native/codegen-fixtures/28-escaping/dart/client.dart index b79df1eeed..42114d4845 100644 --- a/native/codegen-fixtures/28-escaping/dart/client.dart +++ b/native/codegen-fixtures/28-escaping/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -18,7 +28,8 @@ sealed class WidgetKind { static const values = WidgetKindKnown.values; String toJson(); - static WidgetKind fromJson(String json) => WidgetKindKnown._jsonMap[json] ?? WidgetKindUnknown(json); + static WidgetKind fromJson(String json) => + WidgetKindKnown._jsonMap[json] ?? WidgetKindUnknown(json); } enum WidgetKindKnown implements WidgetKind { @@ -26,8 +37,7 @@ enum WidgetKindKnown implements WidgetKind { a$b, x$$y, b$c, - d_$e -; + d_$e; static const _jsonMap = { 'cost\$': cost$, @@ -63,10 +73,11 @@ final class WidgetKindUnknown implements WidgetKind { int get hashCode => value.hashCode; @override - String toString() => 'WidgetKindUnknown' '($value)'; + String toString() => + 'WidgetKindUnknown' + '($value)'; } - // --- API Namespaces --- class Widget { @@ -91,7 +102,8 @@ class Widget { this.scale, this.flag, }) { - if (!(RegExp('^a\'b"c\\\$d[\${x}]+\$').hasMatch(code))) throw ArgumentError('code must match pattern'); + if (!(RegExp('^a\'b"c\\\$d[\${x}]+\$').hasMatch(code))) + throw ArgumentError('code must match pattern'); } factory Widget.fromJson(Map json) { @@ -137,21 +149,25 @@ class Widget { flag == other.flag; @override - int get hashCode => Object.hash(id, code, kind, note$, count, limit, ratio, scale, flag); + int get hashCode => + Object.hash(id, code, kind, note$, count, limit, ratio, scale, flag); @override - String toString() => 'Widget(id: $id, code: $code, kind: $kind, note\$: ${note$}, count: $count, limit: $limit, ratio: $ratio, scale: $scale, flag: $flag)'; + String toString() => + 'Widget(id: $id, code: $code, kind: $kind, note\$: ${note$}, count: $count, limit: $limit, ratio: $ratio, scale: $scale, flag: $flag)'; } - sealed class ApiDoActionInput { const ApiDoActionInput(); Map toJson(); static ApiDoActionInput fromJson(Map json) { switch (json['action'] as String) { - case 'create\$': return Create$Input.fromJson(json); - case 're\$move': return Re$moveInput.fromJson(json); - default: throw ArgumentError('Unknown action: ${json['action']}'); + case 'create\$': + return Create$Input.fromJson(json); + case 're\$move': + return Re$moveInput.fromJson(json); + default: + throw ArgumentError('Unknown action: ${json['action']}'); } } } @@ -159,29 +175,20 @@ sealed class ApiDoActionInput { class Create$Input extends ApiDoActionInput { final String title; - const Create$Input({ - required this.title, - }); + const Create$Input({required this.title}); factory Create$Input.fromJson(Map json) { - return Create$Input( - title: json['title'] as String, - ); + return Create$Input(title: json['title'] as String); } @override Map toJson() { - return { - 'action': 'create\$', - 'title': title, - }; + return {'action': 'create\$', 'title': title}; } @override bool operator ==(Object other) => - identical(this, other) || - other is Create$Input && - title == other.title; + identical(this, other) || other is Create$Input && title == other.title; @override int get hashCode => title.hashCode; @@ -193,29 +200,20 @@ class Create$Input extends ApiDoActionInput { class Re$moveInput extends ApiDoActionInput { final String id; - const Re$moveInput({ - required this.id, - }); + const Re$moveInput({required this.id}); factory Re$moveInput.fromJson(Map json) { - return Re$moveInput( - id: json['id'] as String, - ); + return Re$moveInput(id: json['id'] as String); } @override Map toJson() { - return { - 'action': 're\$move', - 'id': id, - }; + return {'action': 're\$move', 'id': id}; } @override bool operator ==(Object other) => - identical(this, other) || - other is Re$moveInput && - id == other.id; + identical(this, other) || other is Re$moveInput && id == other.id; @override int get hashCode => id.hashCode; @@ -224,32 +222,22 @@ class Re$moveInput extends ApiDoActionInput { String toString() => 'Re\$moveInput(id: $id)'; } - - class DoActionResult { final bool ok; - const DoActionResult({ - required this.ok, - }); + const DoActionResult({required this.ok}); factory DoActionResult.fromJson(Map json) { - return DoActionResult( - ok: json['ok'] as bool, - ); + return DoActionResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is DoActionResult && - ok == other.ok; + identical(this, other) || other is DoActionResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -258,36 +246,29 @@ class DoActionResult { String toString() => 'DoActionResult(ok: $ok)'; } - class Api { final BlocksClient _client; Api(this._client); Future get$x({required String id}) async { - final params = [ - id, - ]; + final params = [id]; final result = await _client.call('api.get\$x', params); return Widget.fromJson(result as Map); } Future doAction({required ApiDoActionInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('api.doAction', params); return DoActionResult.fromJson(result as Map); } } - // --- Servers --- class Servers { static const String primary = 'https://example.com/a\'b\$c\${x}"d\\e'; } - // --- Blocks Client --- class Blocks { @@ -295,7 +276,10 @@ class Blocks { late final BlocksClient _client; Blocks({String? baseUrl, SessionStore? sessionStore}) { - final client = BlocksClient(baseUrl: baseUrl ?? Servers.primary, sessionStore: sessionStore); + final client = BlocksClient( + baseUrl: baseUrl ?? Servers.primary, + sessionStore: sessionStore, + ); _client = client; api = Api(client); } @@ -305,4 +289,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/29-unknown-values/dart/client.dart b/native/codegen-fixtures/29-unknown-values/dart/client.dart index 49a2004bdb..a75777fbe7 100644 --- a/native/codegen-fixtures/29-unknown-values/dart/client.dart +++ b/native/codegen-fixtures/29-unknown-values/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -35,10 +45,16 @@ class Entry { payload: json['payload'] as dynamic, optionalPayload: json['optionalPayload'] as dynamic, nullablePayload: json['nullablePayload'] as dynamic, - metadata: (json['metadata'] as Map).map((k, v) => MapEntry(k, v as dynamic)), + metadata: (json['metadata'] as Map).map( + (k, v) => MapEntry(k, v as dynamic), + ), tags: (json['tags'] as List).cast(), - sparse: (json['sparse'] as Map).map((k, v) => MapEntry(k, v as dynamic)), - claims: (json['claims'] as Map?)?.map((k, v) => MapEntry(k, v as dynamic)), + sparse: (json['sparse'] as Map).map( + (k, v) => MapEntry(k, v as dynamic), + ), + claims: (json['claims'] as Map?)?.map( + (k, v) => MapEntry(k, v as dynamic), + ), ); } @@ -67,34 +83,45 @@ class Entry { blocksDeepEquals(claims, other.claims); @override - int get hashCode => Object.hash(blocksDeepHash(payload), blocksDeepHash(optionalPayload), blocksDeepHash(nullablePayload), blocksDeepHash(metadata), blocksDeepHash(tags), blocksDeepHash(sparse), blocksDeepHash(claims)); + int get hashCode => Object.hash( + blocksDeepHash(payload), + blocksDeepHash(optionalPayload), + blocksDeepHash(nullablePayload), + blocksDeepHash(metadata), + blocksDeepHash(tags), + blocksDeepHash(sparse), + blocksDeepHash(claims), + ); @override - String toString() => 'Entry(payload: $payload, optionalPayload: $optionalPayload, nullablePayload: $nullablePayload, metadata: $metadata, tags: $tags, sparse: $sparse, claims: $claims)'; + String toString() => + 'Entry(payload: $payload, optionalPayload: $optionalPayload, nullablePayload: $nullablePayload, metadata: $metadata, tags: $tags, sparse: $sparse, claims: $claims)'; } - class Api { final BlocksClient _client; Api(this._client); Future echo({required dynamic payload}) async { - final params = [ - payload, - ]; + final params = [payload]; final result = await _client.call('api.echo', params); return result as dynamic; } Future store({required Entry entry}) async { - final params = [ - entry.toJson(), - ]; + final params = [entry.toJson()]; final result = await _client.call('api.store', params); return Entry.fromJson(result as Map); } - Future> collect({required List items, required Map metadata, required dynamic maybe, required List holes, required Map sparse, dynamic extra}) async { + Future> collect({ + required List items, + required Map metadata, + required dynamic maybe, + required List holes, + required Map sparse, + dynamic extra, + }) async { final params = [ items, metadata, @@ -108,7 +135,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -126,4 +152,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/30-inline-object-properties/dart/client.dart b/native/codegen-fixtures/30-inline-object-properties/dart/client.dart index 0ce36f46b0..2aaa321331 100644 --- a/native/codegen-fixtures/30-inline-object-properties/dart/client.dart +++ b/native/codegen-fixtures/30-inline-object-properties/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -13,22 +23,25 @@ sealed class ShipmentDestinationGeoAccuracySource { static const gps = ShipmentDestinationGeoAccuracySourceKnown.gps; static const cell = ShipmentDestinationGeoAccuracySourceKnown.cell; static const values = ShipmentDestinationGeoAccuracySourceKnown.values; - static final Map _byJson = ShipmentDestinationGeoAccuracySourceKnown.values.asNameMap(); + static final Map _byJson = + ShipmentDestinationGeoAccuracySourceKnown.values.asNameMap(); String toJson(); - static ShipmentDestinationGeoAccuracySource fromJson(String json) => _byJson[json] ?? ShipmentDestinationGeoAccuracySourceUnknown(json); + static ShipmentDestinationGeoAccuracySource fromJson(String json) => + _byJson[json] ?? ShipmentDestinationGeoAccuracySourceUnknown(json); } -enum ShipmentDestinationGeoAccuracySourceKnown implements ShipmentDestinationGeoAccuracySource { +enum ShipmentDestinationGeoAccuracySourceKnown + implements ShipmentDestinationGeoAccuracySource { gps, - cell -; + cell; @override String toJson() => name; } -final class ShipmentDestinationGeoAccuracySourceUnknown implements ShipmentDestinationGeoAccuracySource { +final class ShipmentDestinationGeoAccuracySourceUnknown + implements ShipmentDestinationGeoAccuracySource { final String value; const ShipmentDestinationGeoAccuracySourceUnknown(this.value); @@ -38,16 +51,18 @@ final class ShipmentDestinationGeoAccuracySourceUnknown implements ShipmentDesti @override bool operator ==(Object other) => - other is ShipmentDestinationGeoAccuracySourceUnknown && value == other.value; + other is ShipmentDestinationGeoAccuracySourceUnknown && + value == other.value; @override int get hashCode => value.hashCode; @override - String toString() => 'ShipmentDestinationGeoAccuracySourceUnknown' '($value)'; + String toString() => + 'ShipmentDestinationGeoAccuracySourceUnknown' + '($value)'; } - class ShipmentDestinationGeoAccuracy { final num meters; final ShipmentDestinationGeoAccuracySource source; @@ -60,15 +75,14 @@ class ShipmentDestinationGeoAccuracy { factory ShipmentDestinationGeoAccuracy.fromJson(Map json) { return ShipmentDestinationGeoAccuracy( meters: json['meters'] as num, - source: ShipmentDestinationGeoAccuracySource.fromJson(json['source'] as String), + source: ShipmentDestinationGeoAccuracySource.fromJson( + json['source'] as String, + ), ); } Map toJson() { - return { - 'meters': meters, - 'source': source.toJson(), - }; + return {'meters': meters, 'source': source.toJson()}; } @override @@ -82,10 +96,10 @@ class ShipmentDestinationGeoAccuracy { int get hashCode => Object.hash(meters, source); @override - String toString() => 'ShipmentDestinationGeoAccuracy(meters: $meters, source: $source)'; + String toString() => + 'ShipmentDestinationGeoAccuracy(meters: $meters, source: $source)'; } - class ShipmentDestinationGeo { final num lat; final num lng; @@ -101,7 +115,11 @@ class ShipmentDestinationGeo { return ShipmentDestinationGeo( lat: json['lat'] as num, lng: json['lng'] as num, - accuracy: json['accuracy'] != null ? ShipmentDestinationGeoAccuracy.fromJson(json['accuracy'] as Map) : null, + accuracy: json['accuracy'] != null + ? ShipmentDestinationGeoAccuracy.fromJson( + json['accuracy'] as Map, + ) + : null, ); } @@ -125,18 +143,15 @@ class ShipmentDestinationGeo { int get hashCode => Object.hash(lat, lng, accuracy); @override - String toString() => 'ShipmentDestinationGeo(lat: $lat, lng: $lng, accuracy: $accuracy)'; + String toString() => + 'ShipmentDestinationGeo(lat: $lat, lng: $lng, accuracy: $accuracy)'; } - class ShipmentDestination { final String city; final ShipmentDestinationGeo geo; - const ShipmentDestination({ - required this.city, - required this.geo, - }); + const ShipmentDestination({required this.city, required this.geo}); factory ShipmentDestination.fromJson(Map json) { return ShipmentDestination( @@ -146,18 +161,13 @@ class ShipmentDestination { } Map toJson() { - return { - 'city': city, - 'geo': geo.toJson(), - }; + return {'city': city, 'geo': geo.toJson()}; } @override bool operator ==(Object other) => identical(this, other) || - other is ShipmentDestination && - city == other.city && - geo == other.geo; + other is ShipmentDestination && city == other.city && geo == other.geo; @override int get hashCode => Object.hash(city, geo); @@ -166,15 +176,11 @@ class ShipmentDestination { String toString() => 'ShipmentDestination(city: $city, geo: $geo)'; } - class ShipmentInsurance { final String provider; final num? amount; - const ShipmentInsurance({ - required this.provider, - this.amount, - }); + const ShipmentInsurance({required this.provider, this.amount}); factory ShipmentInsurance.fromJson(Map json) { return ShipmentInsurance( @@ -184,10 +190,7 @@ class ShipmentInsurance { } Map toJson() { - return { - 'provider': provider, - if (amount != null) 'amount': amount, - }; + return {'provider': provider, if (amount != null) 'amount': amount}; } @override @@ -201,18 +204,15 @@ class ShipmentInsurance { int get hashCode => Object.hash(provider, amount); @override - String toString() => 'ShipmentInsurance(provider: $provider, amount: $amount)'; + String toString() => + 'ShipmentInsurance(provider: $provider, amount: $amount)'; } - class ShipmentSignature { final String signedBy; final String signedAt; - const ShipmentSignature({ - required this.signedBy, - required this.signedAt, - }); + const ShipmentSignature({required this.signedBy, required this.signedAt}); factory ShipmentSignature.fromJson(Map json) { return ShipmentSignature( @@ -222,10 +222,7 @@ class ShipmentSignature { } Map toJson() { - return { - 'signedBy': signedBy, - 'signedAt': signedAt, - }; + return {'signedBy': signedBy, 'signedAt': signedAt}; } @override @@ -239,18 +236,15 @@ class ShipmentSignature { int get hashCode => Object.hash(signedBy, signedAt); @override - String toString() => 'ShipmentSignature(signedBy: $signedBy, signedAt: $signedAt)'; + String toString() => + 'ShipmentSignature(signedBy: $signedBy, signedAt: $signedAt)'; } - class ShipmentParcels { final String sku; final num weightKg; - const ShipmentParcels({ - required this.sku, - required this.weightKg, - }); + const ShipmentParcels({required this.sku, required this.weightKg}); factory ShipmentParcels.fromJson(Map json) { return ShipmentParcels( @@ -260,10 +254,7 @@ class ShipmentParcels { } Map toJson() { - return { - 'sku': sku, - 'weightKg': weightKg, - }; + return {'sku': sku, 'weightKg': weightKg}; } @override @@ -280,15 +271,11 @@ class ShipmentParcels { String toString() => 'ShipmentParcels(sku: $sku, weightKg: $weightKg)'; } - class ShipmentCustoms { final String code; final num value; - const ShipmentCustoms({ - required this.code, - required this.value, - }); + const ShipmentCustoms({required this.code, required this.value}); factory ShipmentCustoms.fromJson(Map json) { return ShipmentCustoms( @@ -298,18 +285,13 @@ class ShipmentCustoms { } Map toJson() { - return { - 'code': code, - 'value': value, - }; + return {'code': code, 'value': value}; } @override bool operator ==(Object other) => identical(this, other) || - other is ShipmentCustoms && - code == other.code && - value == other.value; + other is ShipmentCustoms && code == other.code && value == other.value; @override int get hashCode => Object.hash(code, value); @@ -318,31 +300,22 @@ class ShipmentCustoms { String toString() => 'ShipmentCustoms(code: $code, value: $value)'; } - class ValueResult { final int value; - const ValueResult({ - required this.value, - }); + const ValueResult({required this.value}); factory ValueResult.fromJson(Map json) { - return ValueResult( - value: (json['value'] as num).toInt(), - ); + return ValueResult(value: (json['value'] as num).toInt()); } Map toJson() { - return { - 'value': value, - }; + return {'value': value}; } @override bool operator ==(Object other) => - identical(this, other) || - other is ValueResult && - value == other.value; + identical(this, other) || other is ValueResult && value == other.value; @override int get hashCode => value.hashCode; @@ -351,31 +324,22 @@ class ValueResult { String toString() => 'ValueResult(value: $value)'; } - class ReceiptMeta { final String value; - const ReceiptMeta({ - required this.value, - }); + const ReceiptMeta({required this.value}); factory ReceiptMeta.fromJson(Map json) { - return ReceiptMeta( - value: json['value'] as String, - ); + return ReceiptMeta(value: json['value'] as String); } Map toJson() { - return { - 'value': value, - }; + return {'value': value}; } @override bool operator ==(Object other) => - identical(this, other) || - other is ReceiptMeta && - value == other.value; + identical(this, other) || other is ReceiptMeta && value == other.value; @override int get hashCode => value.hashCode; @@ -384,7 +348,6 @@ class ReceiptMeta { String toString() => 'ReceiptMeta(value: $value)'; } - // --- API Namespaces --- class Shipment { @@ -407,11 +370,26 @@ class Shipment { factory Shipment.fromJson(Map json) { return Shipment( id: json['id'] as String, - destination: ShipmentDestination.fromJson(json['destination'] as Map), - insurance: json['insurance'] != null ? ShipmentInsurance.fromJson(json['insurance'] as Map) : null, - signature: json['signature'] != null ? ShipmentSignature.fromJson(json['signature'] as Map) : null, - parcels: (json['parcels'] as List).map((e) => ShipmentParcels.fromJson(e as Map)).toList(), - customs: (json['customs'] as Map?)?.map((k, v) => MapEntry(k, ShipmentCustoms.fromJson(v as Map))), + destination: ShipmentDestination.fromJson( + json['destination'] as Map, + ), + insurance: json['insurance'] != null + ? ShipmentInsurance.fromJson( + json['insurance'] as Map, + ) + : null, + signature: json['signature'] != null + ? ShipmentSignature.fromJson( + json['signature'] as Map, + ) + : null, + parcels: (json['parcels'] as List) + .map((e) => ShipmentParcels.fromJson(e as Map)) + .toList(), + customs: (json['customs'] as Map?)?.map( + (k, v) => + MapEntry(k, ShipmentCustoms.fromJson(v as Map)), + ), ); } @@ -422,7 +400,8 @@ class Shipment { if (insurance != null) 'insurance': insurance?.toJson(), 'signature': signature?.toJson(), 'parcels': parcels.map((e) => e.toJson()).toList(), - if (customs != null) 'customs': customs?.map((k, v) => MapEntry(k, v.toJson())), + if (customs != null) + 'customs': customs?.map((k, v) => MapEntry(k, v.toJson())), }; } @@ -438,21 +417,25 @@ class Shipment { blocksDeepEquals(customs, other.customs); @override - int get hashCode => Object.hash(id, destination, insurance, signature, blocksDeepHash(parcels), blocksDeepHash(customs)); + int get hashCode => Object.hash( + id, + destination, + insurance, + signature, + blocksDeepHash(parcels), + blocksDeepHash(customs), + ); @override - String toString() => 'Shipment(id: $id, destination: $destination, insurance: $insurance, signature: $signature, parcels: $parcels, customs: $customs)'; + String toString() => + 'Shipment(id: $id, destination: $destination, insurance: $insurance, signature: $signature, parcels: $parcels, customs: $customs)'; } - class Invoice { final String id; final ValueResult meta; - const Invoice({ - required this.id, - required this.meta, - }); + const Invoice({required this.id, required this.meta}); factory Invoice.fromJson(Map json) { return Invoice( @@ -462,18 +445,13 @@ class Invoice { } Map toJson() { - return { - 'id': id, - 'meta': meta.toJson(), - }; + return {'id': id, 'meta': meta.toJson()}; } @override bool operator ==(Object other) => identical(this, other) || - other is Invoice && - id == other.id && - meta == other.meta; + other is Invoice && id == other.id && meta == other.meta; @override int get hashCode => Object.hash(id, meta); @@ -482,15 +460,11 @@ class Invoice { String toString() => 'Invoice(id: $id, meta: $meta)'; } - class Receipt { final String id; final ReceiptMeta meta; - const Receipt({ - required this.id, - required this.meta, - }); + const Receipt({required this.id, required this.meta}); factory Receipt.fromJson(Map json) { return Receipt( @@ -500,18 +474,13 @@ class Receipt { } Map toJson() { - return { - 'id': id, - 'meta': meta.toJson(), - }; + return {'id': id, 'meta': meta.toJson()}; } @override bool operator ==(Object other) => identical(this, other) || - other is Receipt && - id == other.id && - meta == other.meta; + other is Receipt && id == other.id && meta == other.meta; @override int get hashCode => Object.hash(id, meta); @@ -520,23 +489,18 @@ class Receipt { String toString() => 'Receipt(id: $id, meta: $meta)'; } - class Api { final BlocksClient _client; Api(this._client); Future getShipment({required String id}) async { - final params = [ - id, - ]; + final params = [id]; final result = await _client.call('api.getShipment', params); return Shipment.fromJson(result as Map); } Future saveShipment({required Shipment shipment}) async { - final params = [ - shipment.toJson(), - ]; + final params = [shipment.toJson()]; final result = await _client.call('api.saveShipment', params); return Shipment.fromJson(result as Map); } @@ -552,7 +516,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -570,4 +533,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/31-nested-container-decoding/dart/client.dart b/native/codegen-fixtures/31-nested-container-decoding/dart/client.dart index 8b644bec31..478f2fc4ec 100644 --- a/native/codegen-fixtures/31-nested-container-decoding/dart/client.dart +++ b/native/codegen-fixtures/31-nested-container-decoding/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,9 +6,41 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; -export 'package:blocks_runtime/blocks_runtime.dart' show RealtimeChannel, FileDownloadHandle, FileUploadHandle, FileTransferException, RealtimeException, RealtimeChannelClosedException, RealtimeConnectionException, RealtimeSubscriptionEndedException, TransferableException, InvalidDescriptorException; -export 'package:blocks_runtime/blocks_runtime.dart' show OidcClient, OidcAuthState, OidcSignedIn, OidcSignedOut, OidcLoading, OidcUser, TokenStore, InMemoryTokenStore, AuthProvider, BrowserLauncher, ProviderConfig; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + RealtimeChannel, + FileDownloadHandle, + FileUploadHandle, + FileTransferException, + RealtimeException, + RealtimeChannelClosedException, + RealtimeConnectionException, + RealtimeSubscriptionEndedException, + TransferableException, + InvalidDescriptorException; +export 'package:blocks_runtime/blocks_runtime.dart' + show + OidcClient, + OidcAuthState, + OidcSignedIn, + OidcSignedOut, + OidcLoading, + OidcUser, + TokenStore, + InMemoryTokenStore, + AuthProvider, + BrowserLauncher, + ProviderConfig; // --- Models --- @@ -15,31 +48,31 @@ class SignInOption { final String label; final OidcClient client; - const SignInOption({ - required this.label, - required this.client, - }); + const SignInOption({required this.label, required this.client}); - factory SignInOption.fromJson(Map json, BlocksClient client) { + factory SignInOption.fromJson( + Map json, + BlocksClient client, + ) { return SignInOption( label: json['label'] as String, - client: OidcClient.fromJson(json['client'] as Map, baseUrl: client.baseUrl, tokenStore: client.tokenStore, sessionStore: client.sessionStore), + client: OidcClient.fromJson( + json['client'] as Map, + baseUrl: client.baseUrl, + tokenStore: client.tokenStore, + sessionStore: client.sessionStore, + ), ); } Map toJson() { - return { - 'label': label, - 'client': client, - }; + return {'label': label, 'client': client}; } @override bool operator ==(Object other) => identical(this, other) || - other is SignInOption && - label == other.label && - client == other.client; + other is SignInOption && label == other.label && client == other.client; @override int get hashCode => Object.hash(label, client); @@ -48,7 +81,6 @@ class SignInOption { String toString() => 'SignInOption(label: $label, client: $client)'; } - // --- API Namespaces --- sealed class Level { @@ -63,8 +95,7 @@ sealed class Level { enum LevelKnown implements Level { low, - high -; + high; @override String toJson() => name; @@ -86,39 +117,29 @@ final class LevelUnknown implements Level { int get hashCode => value.hashCode; @override - String toString() => 'LevelUnknown' '($value)'; + String toString() => + 'LevelUnknown' + '($value)'; } - class Note { final String id; final String body; - const Note({ - required this.id, - required this.body, - }); + const Note({required this.id, required this.body}); factory Note.fromJson(Map json) { - return Note( - id: json['id'] as String, - body: json['body'] as String, - ); + return Note(id: json['id'] as String, body: json['body'] as String); } Map toJson() { - return { - 'id': id, - 'body': body, - }; + return {'id': id, 'body': body}; } @override bool operator ==(Object other) => identical(this, other) || - other is Note && - id == other.id && - body == other.body; + other is Note && id == other.id && body == other.body; @override int get hashCode => Object.hash(id, body); @@ -127,7 +148,6 @@ class Note { String toString() => 'Note(id: $id, body: $body)'; } - class Layout { final Map> tagsByUser; final Map>? scoresByUser; @@ -155,16 +175,62 @@ class Layout { factory Layout.fromJson(Map json) { return Layout( - tagsByUser: (json['tagsByUser'] as Map).map((k, v) => MapEntry(k, (v as List).cast())), - scoresByUser: (json['scoresByUser'] as Map?)?.map((k, v) => MapEntry(k, (v as List).cast())), - notesByTag: (json['notesByTag'] as Map).map((k, v) => MapEntry(k, (v as List).map((e1) => Note.fromJson(e1 as Map)).toList())), - pages: (json['pages'] as List).map((e) => (e as Map).map((k1, v1) => MapEntry(k1, Note.fromJson(v1 as Map)))).toList(), - grid: (json['grid'] as List).map((e) => (e as List).map((e1) => Note.fromJson(e1 as Map)).toList()).toList(), - matrix: (json['matrix'] as List).map((e) => (e as List).cast()).toList(), - levels: (json['levels'] as List).map((e) => Level.fromJson(e as String)).toList(), - levelsByUser: (json['levelsByUser'] as Map?)?.map((k, v) => MapEntry(k, (v as List).map((e1) => Level.fromJson(e1 as String)).toList())), - nestedLevels: (json['nestedLevels'] as Map).map((k, v) => MapEntry(k, (v as Map).map((k1, v1) => MapEntry(k1, Level.fromJson(v1 as String))))), - maybeNotes: (json['maybeNotes'] as List).map((e) => e == null ? null : Note.fromJson(e as Map)).toList(), + tagsByUser: (json['tagsByUser'] as Map).map( + (k, v) => MapEntry(k, (v as List).cast()), + ), + scoresByUser: (json['scoresByUser'] as Map?)?.map( + (k, v) => MapEntry(k, (v as List).cast()), + ), + notesByTag: (json['notesByTag'] as Map).map( + (k, v) => MapEntry( + k, + (v as List) + .map((e1) => Note.fromJson(e1 as Map)) + .toList(), + ), + ), + pages: (json['pages'] as List) + .map( + (e) => (e as Map).map( + (k1, v1) => + MapEntry(k1, Note.fromJson(v1 as Map)), + ), + ) + .toList(), + grid: (json['grid'] as List) + .map( + (e) => (e as List) + .map((e1) => Note.fromJson(e1 as Map)) + .toList(), + ) + .toList(), + matrix: (json['matrix'] as List) + .map((e) => (e as List).cast()) + .toList(), + levels: (json['levels'] as List) + .map((e) => Level.fromJson(e as String)) + .toList(), + levelsByUser: (json['levelsByUser'] as Map?)?.map( + (k, v) => MapEntry( + k, + (v as List) + .map((e1) => Level.fromJson(e1 as String)) + .toList(), + ), + ), + nestedLevels: (json['nestedLevels'] as Map).map( + (k, v) => MapEntry( + k, + (v as Map).map( + (k1, v1) => MapEntry(k1, Level.fromJson(v1 as String)), + ), + ), + ), + maybeNotes: (json['maybeNotes'] as List) + .map( + (e) => e == null ? null : Note.fromJson(e as Map), + ) + .toList(), ); } @@ -172,13 +238,22 @@ class Layout { return { 'tagsByUser': tagsByUser, if (scoresByUser != null) 'scoresByUser': scoresByUser, - 'notesByTag': notesByTag.map((k, v) => MapEntry(k, v.map((e1) => e1.toJson()).toList())), - 'pages': pages.map((e) => e.map((k1, v1) => MapEntry(k1, v1.toJson()))).toList(), + 'notesByTag': notesByTag.map( + (k, v) => MapEntry(k, v.map((e1) => e1.toJson()).toList()), + ), + 'pages': pages + .map((e) => e.map((k1, v1) => MapEntry(k1, v1.toJson()))) + .toList(), 'grid': grid.map((e) => e.map((e1) => e1.toJson()).toList()).toList(), 'matrix': matrix, 'levels': levels.map((e) => e.toJson()).toList(), - if (levelsByUser != null) 'levelsByUser': levelsByUser?.map((k, v) => MapEntry(k, v.map((e1) => e1.toJson()).toList())), - 'nestedLevels': nestedLevels.map((k, v) => MapEntry(k, v.map((k1, v1) => MapEntry(k1, v1.toJson())))), + if (levelsByUser != null) + 'levelsByUser': levelsByUser?.map( + (k, v) => MapEntry(k, v.map((e1) => e1.toJson()).toList()), + ), + 'nestedLevels': nestedLevels.map( + (k, v) => MapEntry(k, v.map((k1, v1) => MapEntry(k1, v1.toJson()))), + ), 'maybeNotes': maybeNotes.map((e) => e?.toJson()).toList(), }; } @@ -199,13 +274,24 @@ class Layout { blocksDeepEquals(maybeNotes, other.maybeNotes); @override - int get hashCode => Object.hash(blocksDeepHash(tagsByUser), blocksDeepHash(scoresByUser), blocksDeepHash(notesByTag), blocksDeepHash(pages), blocksDeepHash(grid), blocksDeepHash(matrix), blocksDeepHash(levels), blocksDeepHash(levelsByUser), blocksDeepHash(nestedLevels), blocksDeepHash(maybeNotes)); + int get hashCode => Object.hash( + blocksDeepHash(tagsByUser), + blocksDeepHash(scoresByUser), + blocksDeepHash(notesByTag), + blocksDeepHash(pages), + blocksDeepHash(grid), + blocksDeepHash(matrix), + blocksDeepHash(levels), + blocksDeepHash(levelsByUser), + blocksDeepHash(nestedLevels), + blocksDeepHash(maybeNotes), + ); @override - String toString() => 'Layout(tagsByUser: $tagsByUser, scoresByUser: $scoresByUser, notesByTag: $notesByTag, pages: $pages, grid: $grid, matrix: $matrix, levels: $levels, levelsByUser: $levelsByUser, nestedLevels: $nestedLevels, maybeNotes: $maybeNotes)'; + String toString() => + 'Layout(tagsByUser: $tagsByUser, scoresByUser: $scoresByUser, notesByTag: $notesByTag, pages: $pages, grid: $grid, matrix: $matrix, levels: $levels, levelsByUser: $levelsByUser, nestedLevels: $nestedLevels, maybeNotes: $maybeNotes)'; } - class Board { final String title; final List> channels; @@ -226,10 +312,34 @@ class Board { factory Board.fromJson(Map json) { return Board( title: json['title'] as String, - channels: (json['channels'] as List).map((e) => RealtimeChannel.fromJson(e as Map, (json) => Note.fromJson(json))).toList(), - tagFeeds: (json['tagFeeds'] as List?)?.map((e) => RealtimeChannel.fromJsonValue(e as Map, (payload) => (payload as List).cast())).toList(), - feedsByRoom: (json['feedsByRoom'] as Map).map((k, v) => MapEntry(k, RealtimeChannel.fromJson(v as Map, (json) => Note.fromJson(json)))), - downloads: (json['downloads'] as List).map((e) => FileDownloadHandle.fromJson(e as Map)).toList(), + channels: (json['channels'] as List) + .map( + (e) => RealtimeChannel.fromJson( + e as Map, + (json) => Note.fromJson(json), + ), + ) + .toList(), + tagFeeds: (json['tagFeeds'] as List?) + ?.map( + (e) => RealtimeChannel.fromJsonValue( + e as Map, + (payload) => (payload as List).cast(), + ), + ) + .toList(), + feedsByRoom: (json['feedsByRoom'] as Map).map( + (k, v) => MapEntry( + k, + RealtimeChannel.fromJson( + v as Map, + (json) => Note.fromJson(json), + ), + ), + ), + downloads: (json['downloads'] as List) + .map((e) => FileDownloadHandle.fromJson(e as Map)) + .toList(), layout: Layout.fromJson(json['layout'] as Map), ); } @@ -257,13 +367,20 @@ class Board { layout == other.layout; @override - int get hashCode => Object.hash(title, blocksDeepHash(channels), blocksDeepHash(tagFeeds), blocksDeepHash(feedsByRoom), blocksDeepHash(downloads), layout); + int get hashCode => Object.hash( + title, + blocksDeepHash(channels), + blocksDeepHash(tagFeeds), + blocksDeepHash(feedsByRoom), + blocksDeepHash(downloads), + layout, + ); @override - String toString() => 'Board(title: $title, channels: $channels, tagFeeds: $tagFeeds, feedsByRoom: $feedsByRoom, downloads: $downloads, layout: $layout)'; + String toString() => + 'Board(title: $title, channels: $channels, tagFeeds: $tagFeeds, feedsByRoom: $feedsByRoom, downloads: $downloads, layout: $layout)'; } - class LoginMenu { final SignInOption primary; final List options; @@ -277,9 +394,21 @@ class LoginMenu { factory LoginMenu.fromJson(Map json, BlocksClient client) { return LoginMenu( - primary: SignInOption.fromJson(json['primary'] as Map, client), - options: (json['options'] as List).map((e) => SignInOption.fromJson(e as Map, client)).toList(), - fallback: json['fallback'] != null ? OidcClient.fromJson(json['fallback'] as Map, baseUrl: client.baseUrl, tokenStore: client.tokenStore, sessionStore: client.sessionStore) : null, + primary: SignInOption.fromJson( + json['primary'] as Map, + client, + ), + options: (json['options'] as List) + .map((e) => SignInOption.fromJson(e as Map, client)) + .toList(), + fallback: json['fallback'] != null + ? OidcClient.fromJson( + json['fallback'] as Map, + baseUrl: client.baseUrl, + tokenStore: client.tokenStore, + sessionStore: client.sessionStore, + ) + : null, ); } @@ -303,10 +432,10 @@ class LoginMenu { int get hashCode => Object.hash(primary, blocksDeepHash(options), fallback); @override - String toString() => 'LoginMenu(primary: $primary, options: $options, fallback: $fallback)'; + String toString() => + 'LoginMenu(primary: $primary, options: $options, fallback: $fallback)'; } - class Api { final BlocksClient _client; Api(this._client); @@ -317,25 +446,40 @@ class Api { } Future saveLayout({required Layout layout}) async { - final params = [ - layout.toJson(), - ]; + final params = [layout.toJson()]; final result = await _client.call('api.saveLayout', params); return Layout.fromJson(result as Map); } - Future>> groupNotes({required Map> groups, List? levels}) async { + Future>> groupNotes({ + required Map> groups, + List? levels, + }) async { final params = [ groups.map((k, v) => MapEntry(k, v.map((e1) => e1.toJson()).toList())), if (levels != null) levels.map((e) => e.toJson()).toList(), ]; final result = await _client.call('api.groupNotes', params); - return (result as Map).map((k, v) => MapEntry(k, (v as List).map((e1) => Note.fromJson(e1 as Map)).toList())); + return (result as Map).map( + (k, v) => MapEntry( + k, + (v as List) + .map((e1) => Note.fromJson(e1 as Map)) + .toList(), + ), + ); } Future>> listFeeds() async { final result = await _client.call('api.listFeeds', const []); - return (result as List).map((e) => RealtimeChannel.fromJson(e as Map, (json) => Note.fromJson(json))).toList(); + return (result as List) + .map( + (e) => RealtimeChannel.fromJson( + e as Map, + (json) => Note.fromJson(json), + ), + ) + .toList(); } Future getLoginMenu() async { @@ -344,7 +488,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -362,4 +505,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/32-name-collisions/dart/client.dart b/native/codegen-fixtures/32-name-collisions/dart/client.dart index 02dd13d224..3fe1bf7490 100644 --- a/native/codegen-fixtures/32-name-collisions/dart/client.dart +++ b/native/codegen-fixtures/32-name-collisions/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,35 +6,47 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; -export 'package:blocks_runtime/blocks_runtime.dart' show RealtimeChannel, FileDownloadHandle, FileUploadHandle, FileTransferException, RealtimeException, RealtimeChannelClosedException, RealtimeConnectionException, RealtimeSubscriptionEndedException, TransferableException, InvalidDescriptorException; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + RealtimeChannel, + FileDownloadHandle, + FileUploadHandle, + FileTransferException, + RealtimeException, + RealtimeChannelClosedException, + RealtimeConnectionException, + RealtimeSubscriptionEndedException, + TransferableException, + InvalidDescriptorException; // --- Models --- class CartTags { final String label; - const CartTags({ - required this.label, - }); + const CartTags({required this.label}); factory CartTags.fromJson(Map json) { - return CartTags( - label: json['label'] as String, - ); + return CartTags(label: json['label'] as String); } Map toJson() { - return { - 'label': label, - }; + return {'label': label}; } @override bool operator ==(Object other) => - identical(this, other) || - other is CartTags && - label == other.label; + identical(this, other) || other is CartTags && label == other.label; @override int get hashCode => label.hashCode; @@ -42,31 +55,23 @@ class CartTags { String toString() => 'CartTags(label: $label)'; } - class CartTagsValue { final num weight; - const CartTagsValue({ - required this.weight, - }); + const CartTagsValue({required this.weight}); factory CartTagsValue.fromJson(Map json) { - return CartTagsValue( - weight: json['weight'] as num, - ); + return CartTagsValue(weight: json['weight'] as num); } Map toJson() { - return { - 'weight': weight, - }; + return {'weight': weight}; } @override bool operator ==(Object other) => identical(this, other) || - other is CartTagsValue && - weight == other.weight; + other is CartTagsValue && weight == other.weight; @override int get hashCode => weight.hashCode; @@ -75,21 +80,21 @@ class CartTagsValue { String toString() => 'CartTagsValue(weight: $weight)'; } - sealed class OrderStatus { static const pending = OrderStatusKnown.pending; static const shipped = OrderStatusKnown.shipped; static const values = OrderStatusKnown.values; - static final Map _byJson = OrderStatusKnown.values.asNameMap(); + static final Map _byJson = OrderStatusKnown.values + .asNameMap(); String toJson(); - static OrderStatus fromJson(String json) => _byJson[json] ?? OrderStatusUnknown(json); + static OrderStatus fromJson(String json) => + _byJson[json] ?? OrderStatusUnknown(json); } enum OrderStatusKnown implements OrderStatus { pending, - shipped -; + shipped; @override String toJson() => name; @@ -111,24 +116,26 @@ final class OrderStatusUnknown implements OrderStatus { int get hashCode => value.hashCode; @override - String toString() => 'OrderStatusUnknown' '($value)'; + String toString() => + 'OrderStatusUnknown' + '($value)'; } - sealed class TicketStatus { static const open = TicketStatusKnown.open; static const closed = TicketStatusKnown.closed; static const values = TicketStatusKnown.values; - static final Map _byJson = TicketStatusKnown.values.asNameMap(); + static final Map _byJson = TicketStatusKnown.values + .asNameMap(); String toJson(); - static TicketStatus fromJson(String json) => _byJson[json] ?? TicketStatusUnknown(json); + static TicketStatus fromJson(String json) => + _byJson[json] ?? TicketStatusUnknown(json); } enum TicketStatusKnown implements TicketStatus { open, - closed -; + closed; @override String toJson() => name; @@ -150,24 +157,26 @@ final class TicketStatusUnknown implements TicketStatus { int get hashCode => value.hashCode; @override - String toString() => 'TicketStatusUnknown' '($value)'; + String toString() => + 'TicketStatusUnknown' + '($value)'; } - sealed class TicketKind { static const bug = TicketKindKnown.bug; static const task = TicketKindKnown.task; static const values = TicketKindKnown.values; - static final Map _byJson = TicketKindKnown.values.asNameMap(); + static final Map _byJson = TicketKindKnown.values + .asNameMap(); String toJson(); - static TicketKind fromJson(String json) => _byJson[json] ?? TicketKindUnknown(json); + static TicketKind fromJson(String json) => + _byJson[json] ?? TicketKindUnknown(json); } enum TicketKindKnown implements TicketKind { bug, - task -; + task; @override String toJson() => name; @@ -189,24 +198,26 @@ final class TicketKindUnknown implements TicketKind { int get hashCode => value.hashCode; @override - String toString() => 'TicketKindUnknown' '($value)'; + String toString() => + 'TicketKindUnknown' + '($value)'; } - sealed class TicketKinds { static const urgent = TicketKindsKnown.urgent; static const later = TicketKindsKnown.later; static const values = TicketKindsKnown.values; - static final Map _byJson = TicketKindsKnown.values.asNameMap(); + static final Map _byJson = TicketKindsKnown.values + .asNameMap(); String toJson(); - static TicketKinds fromJson(String json) => _byJson[json] ?? TicketKindsUnknown(json); + static TicketKinds fromJson(String json) => + _byJson[json] ?? TicketKindsUnknown(json); } enum TicketKindsKnown implements TicketKinds { urgent, - later -; + later; @override String toJson() => name; @@ -228,18 +239,22 @@ final class TicketKindsUnknown implements TicketKinds { int get hashCode => value.hashCode; @override - String toString() => 'TicketKindsUnknown' '($value)'; + String toString() => + 'TicketKindsUnknown' + '($value)'; } - sealed class TicketPayload { const TicketPayload(); Map toJson(); static TicketPayload fromJson(Map json) { switch (json['type'] as String) { - case 'text': return TextTicketPayload.fromJson(json); - case 'count': return CountTicketPayload.fromJson(json); - default: return TicketPayloadUnknown(_blocksFrozenObject(json)); + case 'text': + return TextTicketPayload.fromJson(json); + case 'count': + return CountTicketPayload.fromJson(json); + default: + return TicketPayloadUnknown(_blocksFrozenObject(json)); } } } @@ -247,29 +262,21 @@ sealed class TicketPayload { class TextTicketPayload extends TicketPayload { final String body; - const TextTicketPayload({ - required this.body, - }); + const TextTicketPayload({required this.body}); factory TextTicketPayload.fromJson(Map json) { - return TextTicketPayload( - body: json['body'] as String, - ); + return TextTicketPayload(body: json['body'] as String); } @override Map toJson() { - return { - 'type': 'text', - 'body': body, - }; + return {'type': 'text', 'body': body}; } @override bool operator ==(Object other) => identical(this, other) || - other is TextTicketPayload && - body == other.body; + other is TextTicketPayload && body == other.body; @override int get hashCode => body.hashCode; @@ -281,29 +288,21 @@ class TextTicketPayload extends TicketPayload { class CountTicketPayload extends TicketPayload { final num total; - const CountTicketPayload({ - required this.total, - }); + const CountTicketPayload({required this.total}); factory CountTicketPayload.fromJson(Map json) { - return CountTicketPayload( - total: json['total'] as num, - ); + return CountTicketPayload(total: json['total'] as num); } @override Map toJson() { - return { - 'type': 'count', - 'total': total, - }; + return {'type': 'count', 'total': total}; } @override bool operator ==(Object other) => identical(this, other) || - other is CountTicketPayload && - total == other.total; + other is CountTicketPayload && total == other.total; @override int get hashCode => total.hashCode; @@ -330,19 +329,22 @@ final class TicketPayloadUnknown extends TicketPayload { int get hashCode => blocksDeepHash(json); @override - String toString() => 'TicketPayloadUnknown' '($json)'; + String toString() => + 'TicketPayloadUnknown' + '($json)'; } - - sealed class TicketPayloads { const TicketPayloads(); Map toJson(); static TicketPayloads fromJson(Map json) { switch (json['format'] as String) { - case 'plain': return PlainTicketPayloads.fromJson(json); - case 'rich': return RichTicketPayloads.fromJson(json); - default: return TicketPayloadsUnknown(_blocksFrozenObject(json)); + case 'plain': + return PlainTicketPayloads.fromJson(json); + case 'rich': + return RichTicketPayloads.fromJson(json); + default: + return TicketPayloadsUnknown(_blocksFrozenObject(json)); } } } @@ -350,29 +352,21 @@ sealed class TicketPayloads { class PlainTicketPayloads extends TicketPayloads { final String raw; - const PlainTicketPayloads({ - required this.raw, - }); + const PlainTicketPayloads({required this.raw}); factory PlainTicketPayloads.fromJson(Map json) { - return PlainTicketPayloads( - raw: json['raw'] as String, - ); + return PlainTicketPayloads(raw: json['raw'] as String); } @override Map toJson() { - return { - 'format': 'plain', - 'raw': raw, - }; + return {'format': 'plain', 'raw': raw}; } @override bool operator ==(Object other) => identical(this, other) || - other is PlainTicketPayloads && - raw == other.raw; + other is PlainTicketPayloads && raw == other.raw; @override int get hashCode => raw.hashCode; @@ -384,29 +378,21 @@ class PlainTicketPayloads extends TicketPayloads { class RichTicketPayloads extends TicketPayloads { final String html; - const RichTicketPayloads({ - required this.html, - }); + const RichTicketPayloads({required this.html}); factory RichTicketPayloads.fromJson(Map json) { - return RichTicketPayloads( - html: json['html'] as String, - ); + return RichTicketPayloads(html: json['html'] as String); } @override Map toJson() { - return { - 'format': 'rich', - 'html': html, - }; + return {'format': 'rich', 'html': html}; } @override bool operator ==(Object other) => identical(this, other) || - other is RichTicketPayloads && - html == other.html; + other is RichTicketPayloads && html == other.html; @override int get hashCode => html.hashCode; @@ -433,35 +419,28 @@ final class TicketPayloadsUnknown extends TicketPayloads { int get hashCode => blocksDeepHash(json); @override - String toString() => 'TicketPayloadsUnknown' '($json)'; + String toString() => + 'TicketPayloadsUnknown' + '($json)'; } - - class PutItemsResultItem { final num count; - const PutItemsResultItem({ - required this.count, - }); + const PutItemsResultItem({required this.count}); factory PutItemsResultItem.fromJson(Map json) { - return PutItemsResultItem( - count: json['count'] as num, - ); + return PutItemsResultItem(count: json['count'] as num); } Map toJson() { - return { - 'count': count, - }; + return {'count': count}; } @override bool operator ==(Object other) => identical(this, other) || - other is PutItemsResultItem && - count == other.count; + other is PutItemsResultItem && count == other.count; @override int get hashCode => count.hashCode; @@ -470,31 +449,23 @@ class PutItemsResultItem { String toString() => 'PutItemsResultItem(count: $count)'; } - class GetFeedsResultFeedMessage { final String text; - const GetFeedsResultFeedMessage({ - required this.text, - }); + const GetFeedsResultFeedMessage({required this.text}); factory GetFeedsResultFeedMessage.fromJson(Map json) { - return GetFeedsResultFeedMessage( - text: json['text'] as String, - ); + return GetFeedsResultFeedMessage(text: json['text'] as String); } Map toJson() { - return { - 'text': text, - }; + return {'text': text}; } @override bool operator ==(Object other) => identical(this, other) || - other is GetFeedsResultFeedMessage && - text == other.text; + other is GetFeedsResultFeedMessage && text == other.text; @override int get hashCode => text.hashCode; @@ -503,31 +474,22 @@ class GetFeedsResultFeedMessage { String toString() => 'GetFeedsResultFeedMessage(text: $text)'; } - class PickActResultItems { final num qty; - const PickActResultItems({ - required this.qty, - }); + const PickActResultItems({required this.qty}); factory PickActResultItems.fromJson(Map json) { - return PickActResultItems( - qty: json['qty'] as num, - ); + return PickActResultItems(qty: json['qty'] as num); } Map toJson() { - return { - 'qty': qty, - }; + return {'qty': qty}; } @override bool operator ==(Object other) => - identical(this, other) || - other is PickActResultItems && - qty == other.qty; + identical(this, other) || other is PickActResultItems && qty == other.qty; @override int get hashCode => qty.hashCode; @@ -536,7 +498,6 @@ class PickActResultItems { String toString() => 'PickActResultItems(qty: $qty)'; } - Map _blocksFrozenObject(Map json) => Map.unmodifiable({ for (final e in json.entries) e.key: _blocksFrozen(e.value), @@ -555,27 +516,19 @@ Object? _blocksFrozen(Object? value) => switch (value) { class CartItem { final String sku; - const CartItem({ - required this.sku, - }); + const CartItem({required this.sku}); factory CartItem.fromJson(Map json) { - return CartItem( - sku: json['sku'] as String, - ); + return CartItem(sku: json['sku'] as String); } Map toJson() { - return { - 'sku': sku, - }; + return {'sku': sku}; } @override bool operator ==(Object other) => - identical(this, other) || - other is CartItem && - sku == other.sku; + identical(this, other) || other is CartItem && sku == other.sku; @override int get hashCode => sku.hashCode; @@ -584,36 +537,24 @@ class CartItem { String toString() => 'CartItem(sku: $sku)'; } - class CartItems { final String sku; final num qty; - const CartItems({ - required this.sku, - required this.qty, - }); + const CartItems({required this.sku, required this.qty}); factory CartItems.fromJson(Map json) { - return CartItems( - sku: json['sku'] as String, - qty: json['qty'] as num, - ); + return CartItems(sku: json['sku'] as String, qty: json['qty'] as num); } Map toJson() { - return { - 'sku': sku, - 'qty': qty, - }; + return {'sku': sku, 'qty': qty}; } @override bool operator ==(Object other) => identical(this, other) || - other is CartItems && - sku == other.sku && - qty == other.qty; + other is CartItems && sku == other.sku && qty == other.qty; @override int get hashCode => Object.hash(sku, qty); @@ -622,7 +563,6 @@ class CartItems { String toString() => 'CartItems(sku: $sku, qty: $qty)'; } - class Cart { final String id; final CartItem item; @@ -642,9 +582,15 @@ class Cart { return Cart( id: json['id'] as String, item: CartItem.fromJson(json['item'] as Map), - items: (json['items'] as List).map((e) => CartItems.fromJson(e as Map)).toList(), - tags: (json['tags'] as Map).map((k, v) => MapEntry(k, CartTags.fromJson(v as Map))), - tagsValue: CartTagsValue.fromJson(json['tagsValue'] as Map), + items: (json['items'] as List) + .map((e) => CartItems.fromJson(e as Map)) + .toList(), + tags: (json['tags'] as Map).map( + (k, v) => MapEntry(k, CartTags.fromJson(v as Map)), + ), + tagsValue: CartTagsValue.fromJson( + json['tagsValue'] as Map, + ), ); } @@ -669,13 +615,19 @@ class Cart { tagsValue == other.tagsValue; @override - int get hashCode => Object.hash(id, item, blocksDeepHash(items), blocksDeepHash(tags), tagsValue); + int get hashCode => Object.hash( + id, + item, + blocksDeepHash(items), + blocksDeepHash(tags), + tagsValue, + ); @override - String toString() => 'Cart(id: $id, item: $item, items: $items, tags: $tags, tagsValue: $tagsValue)'; + String toString() => + 'Cart(id: $id, item: $item, items: $items, tags: $tags, tagsValue: $tagsValue)'; } - sealed class Kind { static const x = KindKnown.x; static const y = KindKnown.y; @@ -688,8 +640,7 @@ sealed class Kind { enum KindKnown implements Kind { x, - y -; + y; @override String toJson() => name; @@ -711,34 +662,27 @@ final class KindUnknown implements Kind { int get hashCode => value.hashCode; @override - String toString() => 'KindUnknown' '($value)'; + String toString() => + 'KindUnknown' + '($value)'; } - class Order { final OrderStatus status; - const Order({ - required this.status, - }); + const Order({required this.status}); factory Order.fromJson(Map json) { - return Order( - status: OrderStatus.fromJson(json['status'] as String), - ); + return Order(status: OrderStatus.fromJson(json['status'] as String)); } Map toJson() { - return { - 'status': status.toJson(), - }; + return {'status': status.toJson()}; } @override bool operator ==(Object other) => - identical(this, other) || - other is Order && - status == other.status; + identical(this, other) || other is Order && status == other.status; @override int get hashCode => status.hashCode; @@ -747,7 +691,6 @@ class Order { String toString() => 'Order(status: $status)'; } - class Ticket { final TicketStatus status; final TicketKind kind; @@ -767,9 +710,13 @@ class Ticket { return Ticket( status: TicketStatus.fromJson(json['status'] as String), kind: TicketKind.fromJson(json['kind'] as String), - kinds: (json['kinds'] as List).map((e) => TicketKinds.fromJson(e as String)).toList(), + kinds: (json['kinds'] as List) + .map((e) => TicketKinds.fromJson(e as String)) + .toList(), payload: TicketPayload.fromJson(json['payload'] as Map), - payloads: (json['payloads'] as List).map((e) => TicketPayloads.fromJson(e as Map)).toList(), + payloads: (json['payloads'] as List) + .map((e) => TicketPayloads.fromJson(e as Map)) + .toList(), ); } @@ -794,26 +741,31 @@ class Ticket { blocksDeepEquals(payloads, other.payloads); @override - int get hashCode => Object.hash(status, kind, blocksDeepHash(kinds), payload, blocksDeepHash(payloads)); + int get hashCode => Object.hash( + status, + kind, + blocksDeepHash(kinds), + payload, + blocksDeepHash(payloads), + ); @override - String toString() => 'Ticket(status: $status, kind: $kind, kinds: $kinds, payload: $payload, payloads: $payloads)'; + String toString() => + 'Ticket(status: $status, kind: $kind, kinds: $kinds, payload: $payload, payloads: $payloads)'; } - class PutItemsResult { final PutItemsResultItem item; final List items; - const PutItemsResult({ - required this.item, - required this.items, - }); + const PutItemsResult({required this.item, required this.items}); factory PutItemsResult.fromJson(Map json) { return PutItemsResult( item: PutItemsResultItem.fromJson(json['item'] as Map), - items: (json['items'] as List).map((e) => CartItem.fromJson(e as Map)).toList(), + items: (json['items'] as List) + .map((e) => CartItem.fromJson(e as Map)) + .toList(), ); } @@ -838,28 +790,31 @@ class PutItemsResult { String toString() => 'PutItemsResult(item: $item, items: $items)'; } - class GetFeedsResult { final RealtimeChannel feed; final List> feeds; - const GetFeedsResult({ - required this.feed, - required this.feeds, - }); + const GetFeedsResult({required this.feed, required this.feeds}); factory GetFeedsResult.fromJson(Map json) { return GetFeedsResult( - feed: RealtimeChannel.fromJson(json['feed'] as Map, (json) => GetFeedsResultFeedMessage.fromJson(json)), - feeds: (json['feeds'] as List).map((e) => RealtimeChannel.fromJson(e as Map, (json) => PutItemsResultItem.fromJson(json))).toList(), + feed: RealtimeChannel.fromJson( + json['feed'] as Map, + (json) => GetFeedsResultFeedMessage.fromJson(json), + ), + feeds: (json['feeds'] as List) + .map( + (e) => RealtimeChannel.fromJson( + e as Map, + (json) => PutItemsResultItem.fromJson(json), + ), + ) + .toList(), ); } Map toJson() { - return { - 'feed': feed, - 'feeds': feeds, - }; + return {'feed': feed, 'feeds': feeds}; } @override @@ -876,15 +831,17 @@ class GetFeedsResult { String toString() => 'GetFeedsResult(feed: $feed, feeds: $feeds)'; } - sealed class ActResult { const ActResult(); Map toJson(); static ActResult fromJson(Map json) { switch (json['action'] as String) { - case 'pick': return PickActResult.fromJson(json); - case 'skip': return SkipActResult.fromJson(json); - default: return ActResultUnknown(_blocksFrozenObject(json)); + case 'pick': + return PickActResult.fromJson(json); + case 'skip': + return SkipActResult.fromJson(json); + default: + return ActResultUnknown(_blocksFrozenObject(json)); } } } @@ -893,15 +850,14 @@ class PickActResult extends ActResult { final CartItem item; final List items; - const PickActResult({ - required this.item, - required this.items, - }); + const PickActResult({required this.item, required this.items}); factory PickActResult.fromJson(Map json) { return PickActResult( item: CartItem.fromJson(json['item'] as Map), - items: (json['items'] as List).map((e) => PickActResultItems.fromJson(e as Map)).toList(), + items: (json['items'] as List) + .map((e) => PickActResultItems.fromJson(e as Map)) + .toList(), ); } @@ -931,29 +887,21 @@ class PickActResult extends ActResult { class SkipActResult extends ActResult { final String reason; - const SkipActResult({ - required this.reason, - }); + const SkipActResult({required this.reason}); factory SkipActResult.fromJson(Map json) { - return SkipActResult( - reason: json['reason'] as String, - ); + return SkipActResult(reason: json['reason'] as String); } @override Map toJson() { - return { - 'action': 'skip', - 'reason': reason, - }; + return {'action': 'skip', 'reason': reason}; } @override bool operator ==(Object other) => identical(this, other) || - other is SkipActResult && - reason == other.reason; + other is SkipActResult && reason == other.reason; @override int get hashCode => reason.hashCode; @@ -980,35 +928,27 @@ final class ActResultUnknown extends ActResult { int get hashCode => blocksDeepHash(json); @override - String toString() => 'ActResultUnknown' '($json)'; + String toString() => + 'ActResultUnknown' + '($json)'; } - - class ApiCheckResult { final String input; - const ApiCheckResult({ - required this.input, - }); + const ApiCheckResult({required this.input}); factory ApiCheckResult.fromJson(Map json) { - return ApiCheckResult( - input: json['input'] as String, - ); + return ApiCheckResult(input: json['input'] as String); } Map toJson() { - return { - 'input': input, - }; + return {'input': input}; } @override bool operator ==(Object other) => - identical(this, other) || - other is ApiCheckResult && - input == other.input; + identical(this, other) || other is ApiCheckResult && input == other.input; @override int get hashCode => input.hashCode; @@ -1017,31 +957,22 @@ class ApiCheckResult { String toString() => 'ApiCheckResult(input: $input)'; } - class CheckResult { final bool passed; - const CheckResult({ - required this.passed, - }); + const CheckResult({required this.passed}); factory CheckResult.fromJson(Map json) { - return CheckResult( - passed: json['passed'] as bool, - ); + return CheckResult(passed: json['passed'] as bool); } Map toJson() { - return { - 'passed': passed, - }; + return {'passed': passed}; } @override bool operator ==(Object other) => - identical(this, other) || - other is CheckResult && - passed == other.passed; + identical(this, other) || other is CheckResult && passed == other.passed; @override int get hashCode => passed.hashCode; @@ -1050,7 +981,6 @@ class CheckResult { String toString() => 'CheckResult(passed: $passed)'; } - class Api { final BlocksClient _client; Api(this._client); @@ -1075,7 +1005,10 @@ class Api { return Kind.fromJson(result as String); } - Future putItems({required CartItem item, required List items}) async { + Future putItems({ + required CartItem item, + required List items, + }) async { final params = [ item.toJson(), items.map((e) => e.toJson()).toList(), @@ -1095,15 +1028,12 @@ class Api { } Future check({required ApiCheckResult result}) async { - final params = [ - result.toJson(), - ]; + final params = [result.toJson()]; final $result = await _client.call('api.check', params); return CheckResult.fromJson($result as Map); } } - // --- Blocks Client --- class Blocks { @@ -1121,4 +1051,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/33-channel-payload-transferables/dart/client.dart b/native/codegen-fixtures/33-channel-payload-transferables/dart/client.dart index b5c0afb349..84df52e4cc 100644 --- a/native/codegen-fixtures/33-channel-payload-transferables/dart/client.dart +++ b/native/codegen-fixtures/33-channel-payload-transferables/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,9 +6,41 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; -export 'package:blocks_runtime/blocks_runtime.dart' show RealtimeChannel, FileDownloadHandle, FileUploadHandle, FileTransferException, RealtimeException, RealtimeChannelClosedException, RealtimeConnectionException, RealtimeSubscriptionEndedException, TransferableException, InvalidDescriptorException; -export 'package:blocks_runtime/blocks_runtime.dart' show OidcClient, OidcAuthState, OidcSignedIn, OidcSignedOut, OidcLoading, OidcUser, TokenStore, InMemoryTokenStore, AuthProvider, BrowserLauncher, ProviderConfig; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + RealtimeChannel, + FileDownloadHandle, + FileUploadHandle, + FileTransferException, + RealtimeException, + RealtimeChannelClosedException, + RealtimeConnectionException, + RealtimeSubscriptionEndedException, + TransferableException, + InvalidDescriptorException; +export 'package:blocks_runtime/blocks_runtime.dart' + show + OidcClient, + OidcAuthState, + OidcSignedIn, + OidcSignedOut, + OidcLoading, + OidcUser, + TokenStore, + InMemoryTokenStore, + AuthProvider, + BrowserLauncher, + ProviderConfig; // --- Models --- @@ -15,31 +48,20 @@ class Note { final String id; final String text; - const Note({ - required this.id, - required this.text, - }); + const Note({required this.id, required this.text}); factory Note.fromJson(Map json) { - return Note( - id: json['id'] as String, - text: json['text'] as String, - ); + return Note(id: json['id'] as String, text: json['text'] as String); } Map toJson() { - return { - 'id': id, - 'text': text, - }; + return {'id': id, 'text': text}; } @override bool operator ==(Object other) => identical(this, other) || - other is Note && - id == other.id && - text == other.text; + other is Note && id == other.id && text == other.text; @override int get hashCode => Object.hash(id, text); @@ -48,7 +70,6 @@ class Note { String toString() => 'Note(id: $id, text: $text)'; } - class Attachment { final String name; final FileDownloadHandle file; @@ -64,16 +85,14 @@ class Attachment { return Attachment( name: json['name'] as String, file: FileDownloadHandle.fromJson(json['file'] as Map), - previews: (json['previews'] as List).map((e) => FileDownloadHandle.fromJson(e as Map)).toList(), + previews: (json['previews'] as List) + .map((e) => FileDownloadHandle.fromJson(e as Map)) + .toList(), ); } Map toJson() { - return { - 'name': name, - 'file': file, - 'previews': previews, - }; + return {'name': name, 'file': file, 'previews': previews}; } @override @@ -88,39 +107,39 @@ class Attachment { int get hashCode => Object.hash(name, file, blocksDeepHash(previews)); @override - String toString() => 'Attachment(name: $name, file: $file, previews: $previews)'; + String toString() => + 'Attachment(name: $name, file: $file, previews: $previews)'; } - class SignInOption { final String label; final OidcClient client; - const SignInOption({ - required this.label, - required this.client, - }); + const SignInOption({required this.label, required this.client}); - factory SignInOption.fromJson(Map json, BlocksClient client) { + factory SignInOption.fromJson( + Map json, + BlocksClient client, + ) { return SignInOption( label: json['label'] as String, - client: OidcClient.fromJson(json['client'] as Map, baseUrl: client.baseUrl, tokenStore: client.tokenStore, sessionStore: client.sessionStore), + client: OidcClient.fromJson( + json['client'] as Map, + baseUrl: client.baseUrl, + tokenStore: client.tokenStore, + sessionStore: client.sessionStore, + ), ); } Map toJson() { - return { - 'label': label, - 'client': client, - }; + return {'label': label, 'client': client}; } @override bool operator ==(Object other) => identical(this, other) || - other is SignInOption && - label == other.label && - client == other.client; + other is SignInOption && label == other.label && client == other.client; @override int get hashCode => Object.hash(label, client); @@ -129,31 +148,23 @@ class SignInOption { String toString() => 'SignInOption(label: $label, client: $client)'; } - class GetChatFeedResultChannelMessage { final String text; - const GetChatFeedResultChannelMessage({ - required this.text, - }); + const GetChatFeedResultChannelMessage({required this.text}); factory GetChatFeedResultChannelMessage.fromJson(Map json) { - return GetChatFeedResultChannelMessage( - text: json['text'] as String, - ); + return GetChatFeedResultChannelMessage(text: json['text'] as String); } Map toJson() { - return { - 'text': text, - }; + return {'text': text}; } @override bool operator ==(Object other) => identical(this, other) || - other is GetChatFeedResultChannelMessage && - text == other.text; + other is GetChatFeedResultChannelMessage && text == other.text; @override int get hashCode => text.hashCode; @@ -162,31 +173,25 @@ class GetChatFeedResultChannelMessage { String toString() => 'GetChatFeedResultChannelMessage(text: $text)'; } - class GetCounterFeedResultChannelMessage { final num count; - const GetCounterFeedResultChannelMessage({ - required this.count, - }); + const GetCounterFeedResultChannelMessage({required this.count}); - factory GetCounterFeedResultChannelMessage.fromJson(Map json) { - return GetCounterFeedResultChannelMessage( - count: json['count'] as num, - ); + factory GetCounterFeedResultChannelMessage.fromJson( + Map json, + ) { + return GetCounterFeedResultChannelMessage(count: json['count'] as num); } Map toJson() { - return { - 'count': count, - }; + return {'count': count}; } @override bool operator ==(Object other) => identical(this, other) || - other is GetCounterFeedResultChannelMessage && - count == other.count; + other is GetCounterFeedResultChannelMessage && count == other.count; @override int get hashCode => count.hashCode; @@ -195,7 +200,6 @@ class GetCounterFeedResultChannelMessage { String toString() => 'GetCounterFeedResultChannelMessage(count: $count)'; } - // --- API Namespaces --- class Lobby { @@ -211,9 +215,42 @@ class Lobby { factory Lobby.fromJson(Map json) { return Lobby( - rooms: RealtimeChannel.fromJsonValue(json['rooms'] as Map, (payload) => (payload as List).map((e1) => RealtimeChannel.fromJson(e1 as Map, (json) => Note.fromJson(json))).toList()), - roomGroups: (json['roomGroups'] as List).map((e) => RealtimeChannel.fromJsonValue(e as Map, (payload) => (payload as List).map((e2) => RealtimeChannel.fromJson(e2 as Map, (json) => Note.fromJson(json))).toList())).toList(), - uploadsByRoom: (json['uploadsByRoom'] as Map).map((k, v) => MapEntry(k, RealtimeChannel.fromJsonValue(v as Map, (payload) => FileUploadHandle.fromJson(payload as Map)))), + rooms: RealtimeChannel.fromJsonValue( + json['rooms'] as Map, + (payload) => (payload as List) + .map( + (e1) => RealtimeChannel.fromJson( + e1 as Map, + (json) => Note.fromJson(json), + ), + ) + .toList(), + ), + roomGroups: (json['roomGroups'] as List) + .map( + (e) => RealtimeChannel.fromJsonValue( + e as Map, + (payload) => (payload as List) + .map( + (e2) => RealtimeChannel.fromJson( + e2 as Map, + (json) => Note.fromJson(json), + ), + ) + .toList(), + ), + ) + .toList(), + uploadsByRoom: (json['uploadsByRoom'] as Map).map( + (k, v) => MapEntry( + k, + RealtimeChannel.fromJsonValue( + v as Map, + (payload) => + FileUploadHandle.fromJson(payload as Map), + ), + ), + ), ); } @@ -234,34 +271,56 @@ class Lobby { blocksDeepEquals(uploadsByRoom, other.uploadsByRoom); @override - int get hashCode => Object.hash(rooms, blocksDeepHash(roomGroups), blocksDeepHash(uploadsByRoom)); + int get hashCode => Object.hash( + rooms, + blocksDeepHash(roomGroups), + blocksDeepHash(uploadsByRoom), + ); @override - String toString() => 'Lobby(rooms: $rooms, roomGroups: $roomGroups, uploadsByRoom: $uploadsByRoom)'; + String toString() => + 'Lobby(rooms: $rooms, roomGroups: $roomGroups, uploadsByRoom: $uploadsByRoom)'; } - class SignInBoard { final List> feeds; final Map>> clientsByTenant; - const SignInBoard({ - required this.feeds, - required this.clientsByTenant, - }); + const SignInBoard({required this.feeds, required this.clientsByTenant}); factory SignInBoard.fromJson(Map json, BlocksClient client) { return SignInBoard( - feeds: (json['feeds'] as List).map((e) => RealtimeChannel.fromJson(e as Map, (json) => SignInOption.fromJson(json, client))).toList(), - clientsByTenant: (json['clientsByTenant'] as Map).map((k, v) => MapEntry(k, RealtimeChannel.fromJsonValue(v as Map, (payload) => (payload as List).map((e2) => OidcClient.fromJson(e2 as Map, baseUrl: client.baseUrl, tokenStore: client.tokenStore, sessionStore: client.sessionStore)).toList()))), + feeds: (json['feeds'] as List) + .map( + (e) => RealtimeChannel.fromJson( + e as Map, + (json) => SignInOption.fromJson(json, client), + ), + ) + .toList(), + clientsByTenant: (json['clientsByTenant'] as Map).map( + (k, v) => MapEntry( + k, + RealtimeChannel.fromJsonValue( + v as Map, + (payload) => (payload as List) + .map( + (e2) => OidcClient.fromJson( + e2 as Map, + baseUrl: client.baseUrl, + tokenStore: client.tokenStore, + sessionStore: client.sessionStore, + ), + ) + .toList(), + ), + ), + ), ); } Map toJson() { - return { - 'feeds': feeds, - 'clientsByTenant': clientsByTenant, - }; + return {'feeds': feeds, 'clientsByTenant': clientsByTenant}; } @override @@ -272,13 +331,14 @@ class SignInBoard { blocksDeepEquals(clientsByTenant, other.clientsByTenant); @override - int get hashCode => Object.hash(blocksDeepHash(feeds), blocksDeepHash(clientsByTenant)); + int get hashCode => + Object.hash(blocksDeepHash(feeds), blocksDeepHash(clientsByTenant)); @override - String toString() => 'SignInBoard(feeds: $feeds, clientsByTenant: $clientsByTenant)'; + String toString() => + 'SignInBoard(feeds: $feeds, clientsByTenant: $clientsByTenant)'; } - class ProviderDirectory { final String title; final Map additionalProperties; @@ -288,13 +348,27 @@ class ProviderDirectory { this.additionalProperties = const {}, }); - factory ProviderDirectory.fromJson(Map json, BlocksClient client) { + factory ProviderDirectory.fromJson( + Map json, + BlocksClient client, + ) { const knownKeys = {'title'}; return ProviderDirectory( title: json['title'] as String, additionalProperties: Map.fromEntries( - json.entries.where((e) => !knownKeys.contains(e.key)) - .map((e) => MapEntry(e.key, OidcClient.fromJson(e.value as Map, baseUrl: client.baseUrl, tokenStore: client.tokenStore, sessionStore: client.sessionStore))), + json.entries + .where((e) => !knownKeys.contains(e.key)) + .map( + (e) => MapEntry( + e.key, + OidcClient.fromJson( + e.value as Map, + baseUrl: client.baseUrl, + tokenStore: client.tokenStore, + sessionStore: client.sessionStore, + ), + ), + ), ), ); } @@ -318,34 +392,32 @@ class ProviderDirectory { int get hashCode => Object.hash(title, blocksDeepHash(additionalProperties)); @override - String toString() => 'ProviderDirectory(title: $title, additionalProperties: $additionalProperties)'; + String toString() => + 'ProviderDirectory(title: $title, additionalProperties: $additionalProperties)'; } - class GetChatFeedResult { final RealtimeChannel channel; - const GetChatFeedResult({ - required this.channel, - }); + const GetChatFeedResult({required this.channel}); factory GetChatFeedResult.fromJson(Map json) { return GetChatFeedResult( - channel: RealtimeChannel.fromJson(json['channel'] as Map, (json) => GetChatFeedResultChannelMessage.fromJson(json)), + channel: RealtimeChannel.fromJson( + json['channel'] as Map, + (json) => GetChatFeedResultChannelMessage.fromJson(json), + ), ); } Map toJson() { - return { - 'channel': channel, - }; + return {'channel': channel}; } @override bool operator ==(Object other) => identical(this, other) || - other is GetChatFeedResult && - channel == other.channel; + other is GetChatFeedResult && channel == other.channel; @override int get hashCode => channel.hashCode; @@ -354,31 +426,28 @@ class GetChatFeedResult { String toString() => 'GetChatFeedResult(channel: $channel)'; } - class GetCounterFeedResult { final RealtimeChannel channel; - const GetCounterFeedResult({ - required this.channel, - }); + const GetCounterFeedResult({required this.channel}); factory GetCounterFeedResult.fromJson(Map json) { return GetCounterFeedResult( - channel: RealtimeChannel.fromJson(json['channel'] as Map, (json) => GetCounterFeedResultChannelMessage.fromJson(json)), + channel: RealtimeChannel.fromJson( + json['channel'] as Map, + (json) => GetCounterFeedResultChannelMessage.fromJson(json), + ), ); } Map toJson() { - return { - 'channel': channel, - }; + return {'channel': channel}; } @override bool operator ==(Object other) => identical(this, other) || - other is GetCounterFeedResult && - channel == other.channel; + other is GetCounterFeedResult && channel == other.channel; @override int get hashCode => channel.hashCode; @@ -387,19 +456,29 @@ class GetCounterFeedResult { String toString() => 'GetCounterFeedResult(channel: $channel)'; } - class Api { final BlocksClient _client; Api(this._client); Future> getAttachmentFeed() async { - final result = await _client.call('api.getAttachmentFeed', const []); - return RealtimeChannel.fromJson(result as Map, (json) => Attachment.fromJson(json)); + final result = await _client.call( + 'api.getAttachmentFeed', + const [], + ); + return RealtimeChannel.fromJson( + result as Map, + (json) => Attachment.fromJson(json), + ); } Future>> getDownloadFeed() async { final result = await _client.call('api.getDownloadFeed', const []); - return RealtimeChannel.fromJsonValue(result as Map, (payload) => (payload as List).map((e1) => FileDownloadHandle.fromJson(e1 as Map)).toList()); + return RealtimeChannel.fromJsonValue( + result as Map, + (payload) => (payload as List) + .map((e1) => FileDownloadHandle.fromJson(e1 as Map)) + .toList(), + ); } Future getChatFeed() async { @@ -419,7 +498,10 @@ class Api { Future> getSignInFeed() async { final result = await _client.call('api.getSignInFeed', const []); - return RealtimeChannel.fromJson(result as Map, (json) => SignInOption.fromJson(json, _client)); + return RealtimeChannel.fromJson( + result as Map, + (json) => SignInOption.fromJson(json, _client), + ); } Future getSignInBoard() async { @@ -428,12 +510,14 @@ class Api { } Future getProviderDirectory() async { - final result = await _client.call('api.getProviderDirectory', const []); + final result = await _client.call( + 'api.getProviderDirectory', + const [], + ); return ProviderDirectory.fromJson(result as Map, _client); } } - // --- Blocks Client --- class Blocks { @@ -451,4 +535,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/34-reserved-member-names/dart/client.dart b/native/codegen-fixtures/34-reserved-member-names/dart/client.dart index 86cb9bf51d..316be6e94f 100644 --- a/native/codegen-fixtures/34-reserved-member-names/dart/client.dart +++ b/native/codegen-fixtures/34-reserved-member-names/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -77,13 +87,23 @@ class Doc { level == other.level; @override - int get hashCode => Object.hash($id, $$v, toJson$, fromJson$, hashCode$, toString$, int$, String$, level); + int get hashCode => Object.hash( + $id, + $$v, + toJson$, + fromJson$, + hashCode$, + toString$, + int$, + String$, + level, + ); @override - String toString() => 'Doc(\$id: ${$id}, \$\$v: ${$$v}, toJson\$: ${toJson$}, fromJson\$: ${fromJson$}, hashCode\$: ${hashCode$}, toString\$: ${toString$}, int\$: ${int$}, String\$: ${String$}, level: $level)'; + String toString() => + 'Doc(\$id: ${$id}, \$\$v: ${$$v}, toJson\$: ${toJson$}, fromJson\$: ${fromJson$}, hashCode\$: ${hashCode$}, toString\$: ${toString$}, int\$: ${int$}, String\$: ${String$}, level: $level)'; } - class Extras { final String additionalProperties$; final String id; @@ -101,7 +121,8 @@ class Extras { additionalProperties$: json['additionalProperties'] as String, id: json['id'] as String, additionalProperties: Map.fromEntries( - json.entries.where((e) => !knownKeys.contains(e.key)) + json.entries + .where((e) => !knownKeys.contains(e.key)) .map((e) => MapEntry(e.key, e.value as int)), ), ); @@ -112,7 +133,8 @@ class Extras { 'additionalProperties': additionalProperties$, 'id': id, for (final e in additionalProperties.entries) - if (!const {'additionalProperties', 'id'}.contains(e.key)) e.key: e.value, + if (!const {'additionalProperties', 'id'}.contains(e.key)) + e.key: e.value, }; } @@ -125,13 +147,17 @@ class Extras { blocksDeepEquals(additionalProperties, other.additionalProperties); @override - int get hashCode => Object.hash(additionalProperties$, id, blocksDeepHash(additionalProperties)); + int get hashCode => Object.hash( + additionalProperties$, + id, + blocksDeepHash(additionalProperties), + ); @override - String toString() => 'Extras(additionalProperties\$: ${additionalProperties$}, id: $id, additionalProperties: $additionalProperties)'; + String toString() => + 'Extras(additionalProperties\$: ${additionalProperties$}, id: $id, additionalProperties: $additionalProperties)'; } - sealed class Level { static const values$ = LevelKnown.values$; static const index$ = LevelKnown.index$; @@ -141,7 +167,8 @@ sealed class Level { static const values = LevelKnown.values; String toJson(); - static Level fromJson(String json) => LevelKnown._jsonMap[json] ?? LevelUnknown(json); + static Level fromJson(String json) => + LevelKnown._jsonMap[json] ?? LevelUnknown(json); } enum LevelKnown implements Level { @@ -149,8 +176,7 @@ enum LevelKnown implements Level { index$, name$, $hidden, - ok -; + ok; static const _jsonMap = { 'values': values$, @@ -186,27 +212,23 @@ final class LevelUnknown implements Level { int get hashCode => value.hashCode; @override - String toString() => 'LevelUnknown' '($value)'; + String toString() => + 'LevelUnknown' + '($value)'; } - class Api { final BlocksClient _client; Api(this._client); Future getDoc({required String $id, int? int$}) async { - final params = [ - $id, - if (int$ != null) int$, - ]; + final params = [$id, if (int$ != null) int$]; final result = await _client.call('api.getDoc', params); return Doc.fromJson(result as Map); } Future putExtras({required Extras extras}) async { - final params = [ - extras.toJson(), - ]; + final params = [extras.toJson()]; final result = await _client.call('api.putExtras', params); return Extras.fromJson(result as Map); } @@ -217,7 +239,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -235,4 +256,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/36-union-value-arms/dart/client.dart b/native/codegen-fixtures/36-union-value-arms/dart/client.dart index 68b81fc756..a0a939162d 100644 --- a/native/codegen-fixtures/36-union-value-arms/dart/client.dart +++ b/native/codegen-fixtures/36-union-value-arms/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -13,31 +23,19 @@ class Point { final num x; final num y; - const Point({ - required this.x, - required this.y, - }); + const Point({required this.x, required this.y}); factory Point.fromJson(Map json) { - return Point( - x: json['x'] as num, - y: json['y'] as num, - ); + return Point(x: json['x'] as num, y: json['y'] as num); } Map toJson() { - return { - 'x': x, - 'y': y, - }; + return {'x': x, 'y': y}; } @override bool operator ==(Object other) => - identical(this, other) || - other is Point && - x == other.x && - y == other.y; + identical(this, other) || other is Point && x == other.x && y == other.y; @override int get hashCode => Object.hash(x, y); @@ -46,7 +44,6 @@ class Point { String toString() => 'Point(x: $x, y: $y)'; } - // --- API Namespaces --- class Api { @@ -54,49 +51,37 @@ class Api { Api(this._client); Future echoPrimitive({required dynamic value}) async { - final params = [ - value, - ]; + final params = [value]; final result = await _client.call('api.echoPrimitive', params); return result as dynamic; } Future echoCollection({required dynamic value}) async { - final params = [ - value, - ]; + final params = [value]; final result = await _client.call('api.echoCollection', params); return result as dynamic; } Future echoShape({required dynamic value}) async { - final params = [ - value, - ]; + final params = [value]; final result = await _client.call('api.echoShape', params); return result as dynamic; } Future echoLiteral({required dynamic value}) async { - final params = [ - value, - ]; + final params = [value]; final result = await _client.call('api.echoLiteral', params); return result as dynamic; } Future echoTagged({required dynamic value}) async { - final params = [ - value, - ]; + final params = [value]; final result = await _client.call('api.echoTagged', params); return result as dynamic; } Future echoMoment({required dynamic value}) async { - final params = [ - value, - ]; + final params = [value]; final result = await _client.call('api.echoMoment', params); return result as dynamic; } @@ -107,7 +92,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -125,4 +109,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/37-oidc-provider-enum/dart/client.dart b/native/codegen-fixtures/37-oidc-provider-enum/dart/client.dart index 87ad35cfd3..6c2ff2f09c 100644 --- a/native/codegen-fixtures/37-oidc-provider-enum/dart/client.dart +++ b/native/codegen-fixtures/37-oidc-provider-enum/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,10 +6,43 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; -export 'package:blocks_runtime/blocks_runtime.dart' show RealtimeChannel, FileDownloadHandle, FileUploadHandle, FileTransferException, RealtimeException, RealtimeChannelClosedException, RealtimeConnectionException, RealtimeSubscriptionEndedException, TransferableException, InvalidDescriptorException; -export 'package:blocks_runtime/blocks_runtime.dart' show OidcClient, OidcAuthState, OidcSignedIn, OidcSignedOut, OidcLoading, OidcUser, TokenStore, InMemoryTokenStore, AuthProvider, BrowserLauncher, ProviderConfig; -export 'package:blocks_runtime/blocks_runtime.dart' show TypedOidcClient, OidcProvider; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + RealtimeChannel, + FileDownloadHandle, + FileUploadHandle, + FileTransferException, + RealtimeException, + RealtimeChannelClosedException, + RealtimeConnectionException, + RealtimeSubscriptionEndedException, + TransferableException, + InvalidDescriptorException; +export 'package:blocks_runtime/blocks_runtime.dart' + show + OidcClient, + OidcAuthState, + OidcSignedIn, + OidcSignedOut, + OidcLoading, + OidcUser, + TokenStore, + InMemoryTokenStore, + AuthProvider, + BrowserLauncher, + ProviderConfig; +export 'package:blocks_runtime/blocks_runtime.dart' + show TypedOidcClient, OidcProvider; // --- Models --- @@ -19,8 +53,7 @@ enum AuthApiGetClientProvider implements OidcProvider { google('google'), github('github'), mySso('my-sso'), - loginGov('login.gov') -; + loginGov('login.gov'); const AuthApiGetClientProvider(this.providerName); @@ -36,29 +69,41 @@ enum AuthApiGetClientProvider implements OidcProvider { } } - class AuthApi { final BlocksClient _client; AuthApi(this._client); Future> getClient() async { final result = await _client.call('auth.getClient', const []); - return TypedOidcClient(OidcClient.fromJson(result as Map, baseUrl: _client.baseUrl, tokenStore: _client.tokenStore, sessionStore: _client.sessionStore)); + return TypedOidcClient( + OidcClient.fromJson( + result as Map, + baseUrl: _client.baseUrl, + tokenStore: _client.tokenStore, + sessionStore: _client.sessionStore, + ), + ); } } - class LegacyAuthApi { final BlocksClient _client; LegacyAuthApi(this._client); Future getClient() async { - final result = await _client.call('legacyAuth.getClient', const []); - return OidcClient.fromJson(result as Map, baseUrl: _client.baseUrl, tokenStore: _client.tokenStore, sessionStore: _client.sessionStore); + final result = await _client.call( + 'legacyAuth.getClient', + const [], + ); + return OidcClient.fromJson( + result as Map, + baseUrl: _client.baseUrl, + tokenStore: _client.tokenStore, + sessionStore: _client.sessionStore, + ); } } - // --- Blocks Client --- class Blocks { @@ -78,4 +123,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/38-generated-name-collisions/dart/client.dart b/native/codegen-fixtures/38-generated-name-collisions/dart/client.dart index 54366bad95..e09ebb1335 100644 --- a/native/codegen-fixtures/38-generated-name-collisions/dart/client.dart +++ b/native/codegen-fixtures/38-generated-name-collisions/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,34 +6,36 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- class ProfileUser_name { final String first; - const ProfileUser_name({ - required this.first, - }); + const ProfileUser_name({required this.first}); factory ProfileUser_name.fromJson(Map json) { - return ProfileUser_name( - first: json['first'] as String, - ); + return ProfileUser_name(first: json['first'] as String); } Map toJson() { - return { - 'first': first, - }; + return {'first': first}; } @override bool operator ==(Object other) => identical(this, other) || - other is ProfileUser_name && - first == other.first; + other is ProfileUser_name && first == other.first; @override int get hashCode => first.hashCode; @@ -41,31 +44,22 @@ class ProfileUser_name { String toString() => 'ProfileUser_name(first: $first)'; } - class ProfileUserName { final String last; - const ProfileUserName({ - required this.last, - }); + const ProfileUserName({required this.last}); factory ProfileUserName.fromJson(Map json) { - return ProfileUserName( - last: json['last'] as String, - ); + return ProfileUserName(last: json['last'] as String); } Map toJson() { - return { - 'last': last, - }; + return {'last': last}; } @override bool operator ==(Object other) => - identical(this, other) || - other is ProfileUserName && - last == other.last; + identical(this, other) || other is ProfileUserName && last == other.last; @override int get hashCode => last.hashCode; @@ -74,31 +68,22 @@ class ProfileUserName { String toString() => 'ProfileUserName(last: $last)'; } - class ProfileMeta { final String x; - const ProfileMeta({ - required this.x, - }); + const ProfileMeta({required this.x}); factory ProfileMeta.fromJson(Map json) { - return ProfileMeta( - x: json['x'] as String, - ); + return ProfileMeta(x: json['x'] as String); } Map toJson() { - return { - 'x': x, - }; + return {'x': x}; } @override bool operator ==(Object other) => - identical(this, other) || - other is ProfileMeta && - x == other.x; + identical(this, other) || other is ProfileMeta && x == other.x; @override int get hashCode => x.hashCode; @@ -107,20 +92,19 @@ class ProfileMeta { String toString() => 'ProfileMeta(x: $x)'; } - sealed class ProfileState { static const inProgress = ProfileStateKnown.inProgress; static const in_progress = ProfileStateKnown.in_progress; static const values = ProfileStateKnown.values; String toJson(); - static ProfileState fromJson(String json) => ProfileStateKnown._jsonMap[json] ?? ProfileStateUnknown(json); + static ProfileState fromJson(String json) => + ProfileStateKnown._jsonMap[json] ?? ProfileStateUnknown(json); } enum ProfileStateKnown implements ProfileState { inProgress, - in_progress -; + in_progress; static const _jsonMap = { 'in-progress': inProgress, @@ -150,10 +134,11 @@ final class ProfileStateUnknown implements ProfileState { int get hashCode => value.hashCode; @override - String toString() => 'ProfileStateUnknown' '($value)'; + String toString() => + 'ProfileStateUnknown' + '($value)'; } - // --- API Namespaces --- class Profile { @@ -171,8 +156,12 @@ class Profile { factory Profile.fromJson(Map json) { return Profile( - user_name: ProfileUser_name.fromJson(json['user_name'] as Map), - userName: ProfileUserName.fromJson(json['userName'] as Map), + user_name: ProfileUser_name.fromJson( + json['user_name'] as Map, + ), + userName: ProfileUserName.fromJson( + json['userName'] as Map, + ), Meta: ProfileMeta.fromJson(json['Meta'] as Map), state: ProfileState.fromJson(json['state'] as String), ); @@ -200,25 +189,23 @@ class Profile { int get hashCode => Object.hash(user_name, userName, Meta, state); @override - String toString() => 'Profile(user_name: $user_name, userName: $userName, Meta: $Meta, state: $state)'; + String toString() => + 'Profile(user_name: $user_name, userName: $userName, Meta: $Meta, state: $state)'; } - class Bag { final String attributes; final Map additionalProperties; - const Bag({ - required this.attributes, - this.additionalProperties = const {}, - }); + const Bag({required this.attributes, this.additionalProperties = const {}}); factory Bag.fromJson(Map json) { const knownKeys = {'attributes'}; return Bag( attributes: json['attributes'] as String, additionalProperties: Map.fromEntries( - json.entries.where((e) => !knownKeys.contains(e.key)) + json.entries + .where((e) => !knownKeys.contains(e.key)) .map((e) => MapEntry(e.key, e.value as String)), ), ); @@ -240,37 +227,30 @@ class Bag { blocksDeepEquals(additionalProperties, other.additionalProperties); @override - int get hashCode => Object.hash(attributes, blocksDeepHash(additionalProperties)); + int get hashCode => + Object.hash(attributes, blocksDeepHash(additionalProperties)); @override - String toString() => 'Bag(attributes: $attributes, additionalProperties: $additionalProperties)'; + String toString() => + 'Bag(attributes: $attributes, additionalProperties: $additionalProperties)'; } - class Weird { final String backSlash; - const Weird({ - required this.backSlash, - }); + const Weird({required this.backSlash}); factory Weird.fromJson(Map json) { - return Weird( - backSlash: json['back\\slash'] as String, - ); + return Weird(backSlash: json['back\\slash'] as String); } Map toJson() { - return { - 'back\\slash': backSlash, - }; + return {'back\\slash': backSlash}; } @override bool operator ==(Object other) => - identical(this, other) || - other is Weird && - backSlash == other.backSlash; + identical(this, other) || other is Weird && backSlash == other.backSlash; @override int get hashCode => backSlash.hashCode; @@ -279,31 +259,22 @@ class Weird { String toString() => 'Weird(backSlash: $backSlash)'; } - class ApiSendResult { final String sent; - const ApiSendResult({ - required this.sent, - }); + const ApiSendResult({required this.sent}); factory ApiSendResult.fromJson(Map json) { - return ApiSendResult( - sent: json['sent'] as String, - ); + return ApiSendResult(sent: json['sent'] as String); } Map toJson() { - return { - 'sent': sent, - }; + return {'sent': sent}; } @override bool operator ==(Object other) => - identical(this, other) || - other is ApiSendResult && - sent == other.sent; + identical(this, other) || other is ApiSendResult && sent == other.sent; @override int get hashCode => sent.hashCode; @@ -312,31 +283,22 @@ class ApiSendResult { String toString() => 'ApiSendResult(sent: $sent)'; } - class Same { final String a; - const Same({ - required this.a, - }); + const Same({required this.a}); factory Same.fromJson(Map json) { - return Same( - a: json['a'] as String, - ); + return Same(a: json['a'] as String); } Map toJson() { - return { - 'a': a, - }; + return {'a': a}; } @override bool operator ==(Object other) => - identical(this, other) || - other is Same && - a == other.a; + identical(this, other) || other is Same && a == other.a; @override int get hashCode => a.hashCode; @@ -345,31 +307,22 @@ class Same { String toString() => 'Same(a: $a)'; } - class Same2 { final num b; - const Same2({ - required this.b, - }); + const Same2({required this.b}); factory Same2.fromJson(Map json) { - return Same2( - b: json['b'] as num, - ); + return Same2(b: json['b'] as num); } Map toJson() { - return { - 'b': b, - }; + return {'b': b}; } @override bool operator ==(Object other) => - identical(this, other) || - other is Same2 && - b == other.b; + identical(this, other) || other is Same2 && b == other.b; @override int get hashCode => b.hashCode; @@ -378,12 +331,16 @@ class Same2 { String toString() => 'Same2(b: $b)'; } - class Api { final BlocksClient _client; Api(this._client); - Future send({required String request, required String class$, String? args, String? json}) async { + Future send({ + required String request, + required String class$, + String? args, + String? json, + }) async { final params = [ request, class$, @@ -395,9 +352,7 @@ class Api { } Future getProfile({required Profile profile}) async { - final params = [ - profile.toJson(), - ]; + final params = [profile.toJson()]; final result = await _client.call('api.getProfile', params); return Profile.fromJson(result as Map); } @@ -413,31 +368,24 @@ class Api { } Future relay({required String client}) async { - final params = [ - client, - ]; + final params = [client]; final result = await _client.call('api.relay', params); return result as String; } Future putBag({required Bag bag}) async { - final params = [ - bag.toJson(), - ]; + final params = [bag.toJson()]; final result = await _client.call('api.putBag', params); return Bag.fromJson(result as Map); } Future getWeird({required Weird weird}) async { - final params = [ - weird.toJson(), - ]; + final params = [weird.toJson()]; final result = await _client.call('api.getWeird', params); return Weird.fromJson(result as Map); } } - class ABApi { final BlocksClient _client; ABApi(this._client); @@ -448,7 +396,6 @@ class ABApi { } } - // --- Blocks Client --- class Blocks { @@ -468,4 +415,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/39-self-referencing-types/dart/client.dart b/native/codegen-fixtures/39-self-referencing-types/dart/client.dart index 9d73545742..6dae798503 100644 --- a/native/codegen-fixtures/39-self-referencing-types/dart/client.dart +++ b/native/codegen-fixtures/39-self-referencing-types/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -13,15 +23,14 @@ class Product { final String sku; final List categories; - const Product({ - required this.sku, - required this.categories, - }); + const Product({required this.sku, required this.categories}); factory Product.fromJson(Map json) { return Product( sku: json['sku'] as String, - categories: (json['categories'] as List).map((e) => Category.fromJson(e as Map)).toList(), + categories: (json['categories'] as List) + .map((e) => Category.fromJson(e as Map)) + .toList(), ); } @@ -46,7 +55,6 @@ class Product { String toString() => 'Product(sku: $sku, categories: $categories)'; } - // --- API Namespaces --- class TreeNode { @@ -54,17 +62,17 @@ class TreeNode { final List children; final Map? byName; - const TreeNode({ - required this.label, - required this.children, - this.byName, - }); + const TreeNode({required this.label, required this.children, this.byName}); factory TreeNode.fromJson(Map json) { return TreeNode( label: json['label'] as String, - children: (json['children'] as List).map((e) => TreeNode.fromJson(e as Map)).toList(), - byName: (json['byName'] as Map?)?.map((k, v) => MapEntry(k, TreeNode.fromJson(v as Map))), + children: (json['children'] as List) + .map((e) => TreeNode.fromJson(e as Map)) + .toList(), + byName: (json['byName'] as Map?)?.map( + (k, v) => MapEntry(k, TreeNode.fromJson(v as Map)), + ), ); } @@ -72,7 +80,8 @@ class TreeNode { return { 'label': label, 'children': children.map((e) => e.toJson()).toList(), - if (byName != null) 'byName': byName?.map((k, v) => MapEntry(k, v.toJson())), + if (byName != null) + 'byName': byName?.map((k, v) => MapEntry(k, v.toJson())), }; } @@ -85,34 +94,31 @@ class TreeNode { blocksDeepEquals(byName, other.byName); @override - int get hashCode => Object.hash(label, blocksDeepHash(children), blocksDeepHash(byName)); + int get hashCode => + Object.hash(label, blocksDeepHash(children), blocksDeepHash(byName)); @override - String toString() => 'TreeNode(label: $label, children: $children, byName: $byName)'; + String toString() => + 'TreeNode(label: $label, children: $children, byName: $byName)'; } - class Comment { final String text; final List? replies; - const Comment({ - required this.text, - required this.replies, - }); + const Comment({required this.text, required this.replies}); factory Comment.fromJson(Map json) { return Comment( text: json['text'] as String, - replies: (json['replies'] as List?)?.map((e) => Comment.fromJson(e as Map)).toList(), + replies: (json['replies'] as List?) + ?.map((e) => Comment.fromJson(e as Map)) + .toList(), ); } Map toJson() { - return { - 'text': text, - 'replies': replies?.map((e) => e.toJson()).toList(), - }; + return {'text': text, 'replies': replies?.map((e) => e.toJson()).toList()}; } @override @@ -129,28 +135,23 @@ class Comment { String toString() => 'Comment(text: $text, replies: $replies)'; } - class Category { final String name; final List products; - const Category({ - required this.name, - required this.products, - }); + const Category({required this.name, required this.products}); factory Category.fromJson(Map json) { return Category( name: json['name'] as String, - products: (json['products'] as List).map((e) => Product.fromJson(e as Map)).toList(), + products: (json['products'] as List) + .map((e) => Product.fromJson(e as Map)) + .toList(), ); } Map toJson() { - return { - 'name': name, - 'products': products.map((e) => e.toJson()).toList(), - }; + return {'name': name, 'products': products.map((e) => e.toJson()).toList()}; } @override @@ -167,15 +168,12 @@ class Category { String toString() => 'Category(name: $name, products: $products)'; } - class Api { final BlocksClient _client; Api(this._client); Future getTree({required TreeNode root}) async { - final params = [ - root.toJson(), - ]; + final params = [root.toJson()]; final result = await _client.call('api.getTree', params); return TreeNode.fromJson(result as Map); } @@ -187,11 +185,12 @@ class Api { Future getCategory() async { final result = await _client.call('api.getCategory', const []); - return result == null ? null : Category.fromJson(result as Map); + return result == null + ? null + : Category.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -209,4 +208,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/40-empty-object-schemas/dart/client.dart b/native/codegen-fixtures/40-empty-object-schemas/dart/client.dart index 4e7f953a8f..9539536796 100644 --- a/native/codegen-fixtures/40-empty-object-schemas/dart/client.dart +++ b/native/codegen-fixtures/40-empty-object-schemas/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -52,30 +62,30 @@ class GetEnvelopeResult { blocksDeepEquals(settings, other.settings); @override - int get hashCode => Object.hash(id, blocksDeepHash(meta), blocksDeepHash(attachments), blocksDeepHash(settings)); + int get hashCode => Object.hash( + id, + blocksDeepHash(meta), + blocksDeepHash(attachments), + blocksDeepHash(settings), + ); @override - String toString() => 'GetEnvelopeResult(id: $id, meta: $meta, attachments: $attachments, settings: $settings)'; + String toString() => + 'GetEnvelopeResult(id: $id, meta: $meta, attachments: $attachments, settings: $settings)'; } - class Api { final BlocksClient _client; Api(this._client); Future getOptions({required dynamic options, dynamic extra}) async { - final params = [ - options, - if (extra != null) extra, - ]; + final params = [options, if (extra != null) extra]; final result = await _client.call('api.getOptions', params); return result as dynamic; } Future getSettings({required dynamic settings}) async { - final params = [ - settings, - ]; + final params = [settings]; final result = await _client.call('api.getSettings', params); return result as dynamic; } @@ -86,7 +96,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -104,4 +113,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/41-void-methods/dart/client.dart b/native/codegen-fixtures/41-void-methods/dart/client.dart index 306229d4ca..9fef7d1c04 100644 --- a/native/codegen-fixtures/41-void-methods/dart/client.dart +++ b/native/codegen-fixtures/41-void-methods/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -20,10 +30,7 @@ class Api { } Future remember({required String note, String? tag}) async { - final params = [ - note, - if (tag != null) tag, - ]; + final params = [note, if (tag != null) tag]; await _client.call('api.remember', params); } @@ -33,7 +40,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -51,4 +57,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/42-deduplicated-embedded-union/dart/client.dart b/native/codegen-fixtures/42-deduplicated-embedded-union/dart/client.dart index f86edcfc83..09ed81e374 100644 --- a/native/codegen-fixtures/42-deduplicated-embedded-union/dart/client.dart +++ b/native/codegen-fixtures/42-deduplicated-embedded-union/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -14,9 +24,12 @@ sealed class ConfirmSignInInputChallenge { Map toJson(); static ConfirmSignInInputChallenge fromJson(Map json) { switch (json['challenge'] as String) { - case 'code': return CodeConfirmSignInInputChallenge.fromJson(json); - case 'newPassword': return NewPasswordConfirmSignInInputChallenge.fromJson(json); - default: throw ArgumentError('Unknown challenge: ${json['challenge']}'); + case 'code': + return CodeConfirmSignInInputChallenge.fromJson(json); + case 'newPassword': + return NewPasswordConfirmSignInInputChallenge.fromJson(json); + default: + throw ArgumentError('Unknown challenge: ${json['challenge']}'); } } } @@ -24,29 +37,21 @@ sealed class ConfirmSignInInputChallenge { class CodeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { final String code; - const CodeConfirmSignInInputChallenge({ - required this.code, - }); + const CodeConfirmSignInInputChallenge({required this.code}); factory CodeConfirmSignInInputChallenge.fromJson(Map json) { - return CodeConfirmSignInInputChallenge( - code: json['code'] as String, - ); + return CodeConfirmSignInInputChallenge(code: json['code'] as String); } @override Map toJson() { - return { - 'challenge': 'code', - 'code': code, - }; + return {'challenge': 'code', 'code': code}; } @override bool operator ==(Object other) => identical(this, other) || - other is CodeConfirmSignInInputChallenge && - code == other.code; + other is CodeConfirmSignInInputChallenge && code == other.code; @override int get hashCode => code.hashCode; @@ -55,14 +60,15 @@ class CodeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { String toString() => 'CodeConfirmSignInInputChallenge(code: $code)'; } -class NewPasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { +class NewPasswordConfirmSignInInputChallenge + extends ConfirmSignInInputChallenge { final String newPassword; - const NewPasswordConfirmSignInInputChallenge({ - required this.newPassword, - }); + const NewPasswordConfirmSignInInputChallenge({required this.newPassword}); - factory NewPasswordConfirmSignInInputChallenge.fromJson(Map json) { + factory NewPasswordConfirmSignInInputChallenge.fromJson( + Map json, + ) { return NewPasswordConfirmSignInInputChallenge( newPassword: json['newPassword'] as String, ); @@ -70,10 +76,7 @@ class NewPasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge @override Map toJson() { - return { - 'challenge': 'newPassword', - 'newPassword': newPassword, - }; + return {'challenge': 'newPassword', 'newPassword': newPassword}; } @override @@ -86,19 +89,21 @@ class NewPasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge int get hashCode => newPassword.hashCode; @override - String toString() => 'NewPasswordConfirmSignInInputChallenge(newPassword: $newPassword)'; + String toString() => + 'NewPasswordConfirmSignInInputChallenge(newPassword: $newPassword)'; } - - sealed class AlphaApiSetStateInput { const AlphaApiSetStateInput(); Map toJson(); static AlphaApiSetStateInput fromJson(Map json) { switch (json['action'] as String) { - case 'signIn': return SignInInput.fromJson(json); - case 'confirmSignIn': return ConfirmSignInInput.fromJson(json); - default: throw ArgumentError('Unknown action: ${json['action']}'); + case 'signIn': + return SignInInput.fromJson(json); + case 'confirmSignIn': + return ConfirmSignInInput.fromJson(json); + default: + throw ArgumentError('Unknown action: ${json['action']}'); } } } @@ -106,29 +111,21 @@ sealed class AlphaApiSetStateInput { class SignInInput extends AlphaApiSetStateInput { final String username; - const SignInInput({ - required this.username, - }); + const SignInInput({required this.username}); factory SignInInput.fromJson(Map json) { - return SignInInput( - username: json['username'] as String, - ); + return SignInInput(username: json['username'] as String); } @override Map toJson() { - return { - 'action': 'signIn', - 'username': username, - }; + return {'action': 'signIn', 'username': username}; } @override bool operator ==(Object other) => identical(this, other) || - other is SignInInput && - username == other.username; + other is SignInInput && username == other.username; @override int get hashCode => username.hashCode; @@ -137,16 +134,11 @@ class SignInInput extends AlphaApiSetStateInput { String toString() => 'SignInInput(username: $username)'; } - - class ConfirmSignInInput extends AlphaApiSetStateInput { final String session; final ConfirmSignInInputChallenge challenge; - const ConfirmSignInInput({ - required this.session, - required this.challenge, - }); + const ConfirmSignInInput({required this.session, required this.challenge}); factory ConfirmSignInInput.fromJson(Map json) { return ConfirmSignInInput( @@ -175,11 +167,10 @@ class ConfirmSignInInput extends AlphaApiSetStateInput { int get hashCode => Object.hash(session, challenge); @override - String toString() => 'ConfirmSignInInput(session: $session, challenge: $challenge)'; + String toString() => + 'ConfirmSignInInput(session: $session, challenge: $challenge)'; } - - // --- API Namespaces --- class AlphaApi { @@ -187,29 +178,23 @@ class AlphaApi { AlphaApi(this._client); Future setState({required AlphaApiSetStateInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('alphaApi.setState', params); return result as bool; } } - class BetaApi { final BlocksClient _client; BetaApi(this._client); Future setState({required AlphaApiSetStateInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('betaApi.setState', params); return result as bool; } } - // --- Blocks Client --- class Blocks { @@ -229,4 +214,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/43-non-identifier-names/dart/client.dart b/native/codegen-fixtures/43-non-identifier-names/dart/client.dart index e8071375fd..5eecc32594 100644 --- a/native/codegen-fixtures/43-non-identifier-names/dart/client.dart +++ b/native/codegen-fixtures/43-non-identifier-names/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -22,7 +32,8 @@ sealed class SampleType$XKind { static const values = SampleType$XKindKnown.values; String toJson(); - static SampleType$XKind fromJson(String json) => SampleType$XKindKnown._jsonMap[json] ?? SampleType$XKindUnknown(json); + static SampleType$XKind fromJson(String json) => + SampleType$XKindKnown._jsonMap[json] ?? SampleType$XKindUnknown(json); } enum SampleType$XKindKnown implements SampleType$XKind { @@ -34,8 +45,7 @@ enum SampleType$XKindKnown implements SampleType$XKind { Z, $, $1st, - SpAce -; + SpAce; static const _jsonMap = { 'a"b': aB, @@ -79,10 +89,11 @@ final class SampleType$XKindUnknown implements SampleType$XKind { int get hashCode => value.hashCode; @override - String toString() => 'SampleType\$XKindUnknown' '($value)'; + String toString() => + 'SampleType\$XKindUnknown' + '($value)'; } - // --- API Namespaces --- class SampleType$X { @@ -115,8 +126,10 @@ class SampleType$X { this.$9lives, this.kind, }) { - if (!(runErrorXId.length >= 2)) throw ArgumentError('runErrorXId must be at least 2 characters'); - if (!(semiColon.length <= 10)) throw ArgumentError('semiColon must be at most 10 characters'); + if (!(runErrorXId.length >= 2)) + throw ArgumentError('runErrorXId must be at least 2 characters'); + if (!(semiColon.length <= 10)) + throw ArgumentError('semiColon must be at most 10 characters'); if (!(withSpace >= 1)) throw ArgumentError('withSpace must be >= 1'); } @@ -134,7 +147,9 @@ class SampleType$X { newLine: json['new\nline'] as String?, withSpace: (json['with space'] as num).toInt(), $9lives: json['9lives'] as bool?, - kind: json['kind'] != null ? SampleType$XKind.fromJson(json['kind'] as String) : null, + kind: json['kind'] != null + ? SampleType$XKind.fromJson(json['kind'] as String) + : null, ); } @@ -175,18 +190,36 @@ class SampleType$X { kind == other.kind; @override - int get hashCode => Object.hash(runErrorXId, $, $X, Y, $$, qUote, sIngle, semiColon, backTick, newLine, withSpace, $9lives, kind); + int get hashCode => Object.hash( + runErrorXId, + $, + $X, + Y, + $$, + qUote, + sIngle, + semiColon, + backTick, + newLine, + withSpace, + $9lives, + kind, + ); @override - String toString() => 'SampleType\$X(runErrorXId: $runErrorXId, \$: ${$}, \$X: ${$X}, Y: $Y, \$\$: ${$$}, qUote: $qUote, sIngle: $sIngle, semiColon: $semiColon, backTick: $backTick, newLine: $newLine, withSpace: $withSpace, \$9lives: ${$9lives}, kind: $kind)'; + String toString() => + 'SampleType\$X(runErrorXId: $runErrorXId, \$: ${$}, \$X: ${$X}, Y: $Y, \$\$: ${$$}, qUote: $qUote, sIngle: $sIngle, semiColon: $semiColon, backTick: $backTick, newLine: $newLine, withSpace: $withSpace, \$9lives: ${$9lives}, kind: $kind)'; } - class Api { final BlocksClient _client; Api(this._client); - Future getSampleX({required String runErrorXParamP, required SampleType$X item, int? optIonal}) async { + Future getSampleX({ + required String runErrorXParamP, + required SampleType$X item, + int? optIonal, + }) async { final params = [ runErrorXParamP, item.toJson(), @@ -197,15 +230,17 @@ class Api { } } - sealed class NsDoActionInput { const NsDoActionInput(); Map toJson(); static NsDoActionInput fromJson(Map json) { switch (json['ty pe'] as String) { - case 'cre"ate': return CreAteInput.fromJson(json); - case 're`move': return ReMoveInput.fromJson(json); - default: throw ArgumentError('Unknown ty pe: ${json['ty pe']}'); + case 'cre"ate': + return CreAteInput.fromJson(json); + case 're`move': + return ReMoveInput.fromJson(json); + default: + throw ArgumentError('Unknown ty pe: ${json['ty pe']}'); } } } @@ -213,29 +248,20 @@ sealed class NsDoActionInput { class CreAteInput extends NsDoActionInput { final String tiTle; - const CreAteInput({ - required this.tiTle, - }); + const CreAteInput({required this.tiTle}); factory CreAteInput.fromJson(Map json) { - return CreAteInput( - tiTle: json['ti;tle'] as String, - ); + return CreAteInput(tiTle: json['ti;tle'] as String); } @override Map toJson() { - return { - 'ty pe': 'cre"ate', - 'ti;tle': tiTle, - }; + return {'ty pe': 'cre"ate', 'ti;tle': tiTle}; } @override bool operator ==(Object other) => - identical(this, other) || - other is CreAteInput && - tiTle == other.tiTle; + identical(this, other) || other is CreAteInput && tiTle == other.tiTle; @override int get hashCode => tiTle.hashCode; @@ -247,29 +273,20 @@ class CreAteInput extends NsDoActionInput { class ReMoveInput extends NsDoActionInput { final String $Id; - const ReMoveInput({ - required this.$Id, - }); + const ReMoveInput({required this.$Id}); factory ReMoveInput.fromJson(Map json) { - return ReMoveInput( - $Id: json['\${id}'] as String, - ); + return ReMoveInput($Id: json['\${id}'] as String); } @override Map toJson() { - return { - 'ty pe': 're`move', - '\${id}': $Id, - }; + return {'ty pe': 're`move', '\${id}': $Id}; } @override bool operator ==(Object other) => - identical(this, other) || - other is ReMoveInput && - $Id == other.$Id; + identical(this, other) || other is ReMoveInput && $Id == other.$Id; @override int get hashCode => $Id.hashCode; @@ -278,32 +295,22 @@ class ReMoveInput extends NsDoActionInput { String toString() => 'ReMoveInput(\$Id: ${$Id})'; } - - class DoActionResult { final bool ok; - const DoActionResult({ - required this.ok, - }); + const DoActionResult({required this.ok}); factory DoActionResult.fromJson(Map json) { - return DoActionResult( - ok: json['ok`'] as bool, - ); + return DoActionResult(ok: json['ok`'] as bool); } Map toJson() { - return { - 'ok`': ok, - }; + return {'ok`': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is DoActionResult && - ok == other.ok; + identical(this, other) || other is DoActionResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -312,28 +319,23 @@ class DoActionResult { String toString() => 'DoActionResult(ok: $ok)'; } - class NsApi { final BlocksClient _client; NsApi(this._client); Future doAction({required NsDoActionInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('ns.do`Action', params); return DoActionResult.fromJson(result as Map); } } - // --- Servers --- class Servers { static const String mainValX1 = 'https://example.com'; } - // --- Blocks Client --- class Blocks { @@ -342,7 +344,10 @@ class Blocks { late final BlocksClient _client; Blocks({String? baseUrl, SessionStore? sessionStore}) { - final client = BlocksClient(baseUrl: baseUrl ?? Servers.mainValX1, sessionStore: sessionStore); + final client = BlocksClient( + baseUrl: baseUrl ?? Servers.mainValX1, + sessionStore: sessionStore, + ); _client = client; api = Api(client); ns = NsApi(client); @@ -353,4 +358,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/44-shared-union-type-name/dart/client.dart b/native/codegen-fixtures/44-shared-union-type-name/dart/client.dart index 736ca76d29..c71385a6b6 100644 --- a/native/codegen-fixtures/44-shared-union-type-name/dart/client.dart +++ b/native/codegen-fixtures/44-shared-union-type-name/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,7 +6,16 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; // --- Models --- @@ -15,12 +25,16 @@ sealed class AuthStateState { static const confirmingSignUp = AuthStateStateKnown.confirmingSignUp; static const confirmingSignIn = AuthStateStateKnown.confirmingSignIn; static const confirmingMfa = AuthStateStateKnown.confirmingMfa; - static const confirmingPasswordReset = AuthStateStateKnown.confirmingPasswordReset; + static const confirmingPasswordReset = + AuthStateStateKnown.confirmingPasswordReset; static const values = AuthStateStateKnown.values; - static final Map _byJson = AuthStateStateKnown.values.asNameMap(); + static final Map _byJson = AuthStateStateKnown + .values + .asNameMap(); String toJson(); - static AuthStateState fromJson(String json) => _byJson[json] ?? AuthStateStateUnknown(json); + static AuthStateState fromJson(String json) => + _byJson[json] ?? AuthStateStateUnknown(json); } enum AuthStateStateKnown implements AuthStateState { @@ -29,8 +43,7 @@ enum AuthStateStateKnown implements AuthStateState { confirmingSignUp, confirmingSignIn, confirmingMfa, - confirmingPasswordReset -; + confirmingPasswordReset; @override String toJson() => name; @@ -52,10 +65,11 @@ final class AuthStateStateUnknown implements AuthStateState { int get hashCode => value.hashCode; @override - String toString() => 'AuthStateStateUnknown' '($value)'; + String toString() => + 'AuthStateStateUnknown' + '($value)'; } - class AuthState { final AuthStateState state; final AuthUser? user; @@ -76,8 +90,12 @@ class AuthState { factory AuthState.fromJson(Map json) { return AuthState( state: AuthStateState.fromJson(json['state'] as String), - user: json['user'] != null ? AuthUser.fromJson(json['user'] as Map) : null, - actions: (json['actions'] as List).map((e) => AuthAction.fromJson(e as Map)).toList(), + user: json['user'] != null + ? AuthUser.fromJson(json['user'] as Map) + : null, + actions: (json['actions'] as List) + .map((e) => AuthAction.fromJson(e as Map)) + .toList(), error: json['error'] as String?, errorName: json['errorName'] as String?, retriable: json['retriable'] as bool?, @@ -107,13 +125,20 @@ class AuthState { retriable == other.retriable; @override - int get hashCode => Object.hash(state, user, blocksDeepHash(actions), error, errorName, retriable); + int get hashCode => Object.hash( + state, + user, + blocksDeepHash(actions), + error, + errorName, + retriable, + ); @override - String toString() => 'AuthState(state: $state, user: $user, actions: $actions, error: $error, errorName: $errorName, retriable: $retriable)'; + String toString() => + 'AuthState(state: $state, user: $user, actions: $actions, error: $error, errorName: $errorName, retriable: $retriable)'; } - class AuthUser { final String userId; final String username; @@ -153,24 +178,25 @@ class AuthUser { int get hashCode => Object.hash(userId, username, displayName); @override - String toString() => 'AuthUser(userId: $userId, username: $username, displayName: $displayName)'; + String toString() => + 'AuthUser(userId: $userId, username: $username, displayName: $displayName)'; } - sealed class AuthActionMethod { static const GET = AuthActionMethodKnown.GET; static const POST = AuthActionMethodKnown.POST; static const values = AuthActionMethodKnown.values; - static final Map _byJson = AuthActionMethodKnown.values.asNameMap(); + static final Map _byJson = + AuthActionMethodKnown.values.asNameMap(); String toJson(); - static AuthActionMethod fromJson(String json) => _byJson[json] ?? AuthActionMethodUnknown(json); + static AuthActionMethod fromJson(String json) => + _byJson[json] ?? AuthActionMethodUnknown(json); } enum AuthActionMethodKnown implements AuthActionMethod { GET, - POST -; + POST; @override String toJson() => name; @@ -192,23 +218,25 @@ final class AuthActionMethodUnknown implements AuthActionMethod { int get hashCode => value.hashCode; @override - String toString() => 'AuthActionMethodUnknown' '($value)'; + String toString() => + 'AuthActionMethodUnknown' + '($value)'; } - sealed class AuthActionCapability { static const webauthnGet = AuthActionCapabilityKnown.webauthnGet; static const webauthnCreate = AuthActionCapabilityKnown.webauthnCreate; static const values = AuthActionCapabilityKnown.values; String toJson(); - static AuthActionCapability fromJson(String json) => AuthActionCapabilityKnown._jsonMap[json] ?? AuthActionCapabilityUnknown(json); + static AuthActionCapability fromJson(String json) => + AuthActionCapabilityKnown._jsonMap[json] ?? + AuthActionCapabilityUnknown(json); } enum AuthActionCapabilityKnown implements AuthActionCapability { webauthnGet, - webauthnCreate -; + webauthnCreate; static const _jsonMap = { 'webauthn-get': webauthnGet, @@ -238,10 +266,11 @@ final class AuthActionCapabilityUnknown implements AuthActionCapability { int get hashCode => value.hashCode; @override - String toString() => 'AuthActionCapabilityUnknown' '($value)'; + String toString() => + 'AuthActionCapabilityUnknown' + '($value)'; } - class AuthAction { final String name; final String label; @@ -265,10 +294,16 @@ class AuthAction { return AuthAction( name: json['name'] as String, label: json['label'] as String, - fields: (json['fields'] as List).map((e) => AuthField.fromJson(e as Map)).toList(), + fields: (json['fields'] as List) + .map((e) => AuthField.fromJson(e as Map)) + .toList(), url: json['url'] as String?, - method: json['method'] != null ? AuthActionMethod.fromJson(json['method'] as String) : null, - capability: json['capability'] != null ? AuthActionCapability.fromJson(json['capability'] as String) : null, + method: json['method'] != null + ? AuthActionMethod.fromJson(json['method'] as String) + : null, + capability: json['capability'] != null + ? AuthActionCapability.fromJson(json['capability'] as String) + : null, unavailable: json['unavailable'] as String?, ); } @@ -298,13 +333,21 @@ class AuthAction { unavailable == other.unavailable; @override - int get hashCode => Object.hash(name, label, blocksDeepHash(fields), url, method, capability, unavailable); + int get hashCode => Object.hash( + name, + label, + blocksDeepHash(fields), + url, + method, + capability, + unavailable, + ); @override - String toString() => 'AuthAction(name: $name, label: $label, fields: $fields, url: $url, method: $method, capability: $capability, unavailable: $unavailable)'; + String toString() => + 'AuthAction(name: $name, label: $label, fields: $fields, url: $url, method: $method, capability: $capability, unavailable: $unavailable)'; } - sealed class AuthFieldType { static const number = AuthFieldTypeKnown.number; static const email = AuthFieldTypeKnown.email; @@ -313,10 +356,13 @@ sealed class AuthFieldType { static const tel = AuthFieldTypeKnown.tel; static const hidden = AuthFieldTypeKnown.hidden; static const values = AuthFieldTypeKnown.values; - static final Map _byJson = AuthFieldTypeKnown.values.asNameMap(); + static final Map _byJson = AuthFieldTypeKnown + .values + .asNameMap(); String toJson(); - static AuthFieldType fromJson(String json) => _byJson[json] ?? AuthFieldTypeUnknown(json); + static AuthFieldType fromJson(String json) => + _byJson[json] ?? AuthFieldTypeUnknown(json); } enum AuthFieldTypeKnown implements AuthFieldType { @@ -325,8 +371,7 @@ enum AuthFieldTypeKnown implements AuthFieldType { password, text, tel, - hidden -; + hidden; @override String toJson() => name; @@ -348,10 +393,11 @@ final class AuthFieldTypeUnknown implements AuthFieldType { int get hashCode => value.hashCode; @override - String toString() => 'AuthFieldTypeUnknown' '($value)'; + String toString() => + 'AuthFieldTypeUnknown' + '($value)'; } - class AuthField { final String name; final String label; @@ -401,24 +447,33 @@ class AuthField { int get hashCode => Object.hash(name, label, type, required$, defaultValue); @override - String toString() => 'AuthField(name: $name, label: $label, type: $type, required\$: ${required$}, defaultValue: $defaultValue)'; + String toString() => + 'AuthField(name: $name, label: $label, type: $type, required\$: ${required$}, defaultValue: $defaultValue)'; } - sealed class ConfirmSignInInputChallenge { const ConfirmSignInInputChallenge(); Map toJson(); static ConfirmSignInInputChallenge fromJson(Map json) { switch (json['challenge'] as String) { - case 'code': return CodeConfirmSignInInputChallenge.fromJson(json); - case 'mfaType': return MfaTypeConfirmSignInInputChallenge.fromJson(json); - case 'newPassword': return NewPasswordConfirmSignInInputChallenge.fromJson(json); - case 'totpSetup': return TotpSetupConfirmSignInInputChallenge.fromJson(json); - case 'email': return EmailConfirmSignInInputChallenge.fromJson(json); - case 'password': return PasswordConfirmSignInInputChallenge.fromJson(json); - case 'firstFactor': return FirstFactorConfirmSignInInputChallenge.fromJson(json); - case 'webauthn': return WebauthnConfirmSignInInputChallenge.fromJson(json); - default: throw ArgumentError('Unknown challenge: ${json['challenge']}'); + case 'code': + return CodeConfirmSignInInputChallenge.fromJson(json); + case 'mfaType': + return MfaTypeConfirmSignInInputChallenge.fromJson(json); + case 'newPassword': + return NewPasswordConfirmSignInInputChallenge.fromJson(json); + case 'totpSetup': + return TotpSetupConfirmSignInInputChallenge.fromJson(json); + case 'email': + return EmailConfirmSignInInputChallenge.fromJson(json); + case 'password': + return PasswordConfirmSignInInputChallenge.fromJson(json); + case 'firstFactor': + return FirstFactorConfirmSignInInputChallenge.fromJson(json); + case 'webauthn': + return WebauthnConfirmSignInInputChallenge.fromJson(json); + default: + throw ArgumentError('Unknown challenge: ${json['challenge']}'); } } } @@ -426,29 +481,21 @@ sealed class ConfirmSignInInputChallenge { class CodeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { final String code; - const CodeConfirmSignInInputChallenge({ - required this.code, - }); + const CodeConfirmSignInInputChallenge({required this.code}); factory CodeConfirmSignInInputChallenge.fromJson(Map json) { - return CodeConfirmSignInInputChallenge( - code: json['code'] as String, - ); + return CodeConfirmSignInInputChallenge(code: json['code'] as String); } @override Map toJson() { - return { - 'challenge': 'code', - 'code': code, - }; + return {'challenge': 'code', 'code': code}; } @override bool operator ==(Object other) => identical(this, other) || - other is CodeConfirmSignInInputChallenge && - code == other.code; + other is CodeConfirmSignInInputChallenge && code == other.code; @override int get hashCode => code.hashCode; @@ -460,11 +507,11 @@ class CodeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { class MfaTypeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { final String mfaType; - const MfaTypeConfirmSignInInputChallenge({ - required this.mfaType, - }); + const MfaTypeConfirmSignInInputChallenge({required this.mfaType}); - factory MfaTypeConfirmSignInInputChallenge.fromJson(Map json) { + factory MfaTypeConfirmSignInInputChallenge.fromJson( + Map json, + ) { return MfaTypeConfirmSignInInputChallenge( mfaType: json['mfaType'] as String, ); @@ -472,17 +519,13 @@ class MfaTypeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { @override Map toJson() { - return { - 'challenge': 'mfaType', - 'mfaType': mfaType, - }; + return {'challenge': 'mfaType', 'mfaType': mfaType}; } @override bool operator ==(Object other) => identical(this, other) || - other is MfaTypeConfirmSignInInputChallenge && - mfaType == other.mfaType; + other is MfaTypeConfirmSignInInputChallenge && mfaType == other.mfaType; @override int get hashCode => mfaType.hashCode; @@ -491,14 +534,15 @@ class MfaTypeConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { String toString() => 'MfaTypeConfirmSignInInputChallenge(mfaType: $mfaType)'; } -class NewPasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { +class NewPasswordConfirmSignInInputChallenge + extends ConfirmSignInInputChallenge { final String newPassword; - const NewPasswordConfirmSignInInputChallenge({ - required this.newPassword, - }); + const NewPasswordConfirmSignInInputChallenge({required this.newPassword}); - factory NewPasswordConfirmSignInInputChallenge.fromJson(Map json) { + factory NewPasswordConfirmSignInInputChallenge.fromJson( + Map json, + ) { return NewPasswordConfirmSignInInputChallenge( newPassword: json['newPassword'] as String, ); @@ -506,10 +550,7 @@ class NewPasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge @override Map toJson() { - return { - 'challenge': 'newPassword', - 'newPassword': newPassword, - }; + return {'challenge': 'newPassword', 'newPassword': newPassword}; } @override @@ -522,7 +563,8 @@ class NewPasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge int get hashCode => newPassword.hashCode; @override - String toString() => 'NewPasswordConfirmSignInInputChallenge(newPassword: $newPassword)'; + String toString() => + 'NewPasswordConfirmSignInInputChallenge(newPassword: $newPassword)'; } class TotpSetupConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { @@ -534,7 +576,9 @@ class TotpSetupConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { required this.code, }); - factory TotpSetupConfirmSignInInputChallenge.fromJson(Map json) { + factory TotpSetupConfirmSignInInputChallenge.fromJson( + Map json, + ) { return TotpSetupConfirmSignInInputChallenge( sharedSecret: json['sharedSecret'] as String, code: json['code'] as String, @@ -561,35 +605,28 @@ class TotpSetupConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { int get hashCode => Object.hash(sharedSecret, code); @override - String toString() => 'TotpSetupConfirmSignInInputChallenge(sharedSecret: $sharedSecret, code: $code)'; + String toString() => + 'TotpSetupConfirmSignInInputChallenge(sharedSecret: $sharedSecret, code: $code)'; } class EmailConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { final String email; - const EmailConfirmSignInInputChallenge({ - required this.email, - }); + const EmailConfirmSignInInputChallenge({required this.email}); factory EmailConfirmSignInInputChallenge.fromJson(Map json) { - return EmailConfirmSignInInputChallenge( - email: json['email'] as String, - ); + return EmailConfirmSignInInputChallenge(email: json['email'] as String); } @override Map toJson() { - return { - 'challenge': 'email', - 'email': email, - }; + return {'challenge': 'email', 'email': email}; } @override bool operator ==(Object other) => identical(this, other) || - other is EmailConfirmSignInInputChallenge && - email == other.email; + other is EmailConfirmSignInInputChallenge && email == other.email; @override int get hashCode => email.hashCode; @@ -601,11 +638,11 @@ class EmailConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { class PasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { final String password; - const PasswordConfirmSignInInputChallenge({ - required this.password, - }); + const PasswordConfirmSignInInputChallenge({required this.password}); - factory PasswordConfirmSignInInputChallenge.fromJson(Map json) { + factory PasswordConfirmSignInInputChallenge.fromJson( + Map json, + ) { return PasswordConfirmSignInInputChallenge( password: json['password'] as String, ); @@ -613,10 +650,7 @@ class PasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { @override Map toJson() { - return { - 'challenge': 'password', - 'password': password, - }; + return {'challenge': 'password', 'password': password}; } @override @@ -629,17 +663,19 @@ class PasswordConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { int get hashCode => password.hashCode; @override - String toString() => 'PasswordConfirmSignInInputChallenge(password: $password)'; + String toString() => + 'PasswordConfirmSignInInputChallenge(password: $password)'; } -class FirstFactorConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { +class FirstFactorConfirmSignInInputChallenge + extends ConfirmSignInInputChallenge { final String firstFactor; - const FirstFactorConfirmSignInInputChallenge({ - required this.firstFactor, - }); + const FirstFactorConfirmSignInInputChallenge({required this.firstFactor}); - factory FirstFactorConfirmSignInInputChallenge.fromJson(Map json) { + factory FirstFactorConfirmSignInInputChallenge.fromJson( + Map json, + ) { return FirstFactorConfirmSignInInputChallenge( firstFactor: json['firstFactor'] as String, ); @@ -647,10 +683,7 @@ class FirstFactorConfirmSignInInputChallenge extends ConfirmSignInInputChallenge @override Map toJson() { - return { - 'challenge': 'firstFactor', - 'firstFactor': firstFactor, - }; + return {'challenge': 'firstFactor', 'firstFactor': firstFactor}; } @override @@ -663,17 +696,18 @@ class FirstFactorConfirmSignInInputChallenge extends ConfirmSignInInputChallenge int get hashCode => firstFactor.hashCode; @override - String toString() => 'FirstFactorConfirmSignInInputChallenge(firstFactor: $firstFactor)'; + String toString() => + 'FirstFactorConfirmSignInInputChallenge(firstFactor: $firstFactor)'; } class WebauthnConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { final String credential; - const WebauthnConfirmSignInInputChallenge({ - required this.credential, - }); + const WebauthnConfirmSignInInputChallenge({required this.credential}); - factory WebauthnConfirmSignInInputChallenge.fromJson(Map json) { + factory WebauthnConfirmSignInInputChallenge.fromJson( + Map json, + ) { return WebauthnConfirmSignInInputChallenge( credential: json['credential'] as String, ); @@ -681,10 +715,7 @@ class WebauthnConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { @override Map toJson() { - return { - 'challenge': 'webauthn', - 'credential': credential, - }; + return {'challenge': 'webauthn', 'credential': credential}; } @override @@ -697,71 +728,86 @@ class WebauthnConfirmSignInInputChallenge extends ConfirmSignInInputChallenge { int get hashCode => credential.hashCode; @override - String toString() => 'WebauthnConfirmSignInInputChallenge(credential: $credential)'; + String toString() => + 'WebauthnConfirmSignInInputChallenge(credential: $credential)'; } - - enum UpdateMfaPreferenceInputSms { ENABLED, DISABLED, PREFERRED, - NOT_PREFERRED -; + NOT_PREFERRED; String toJson() => name; - static UpdateMfaPreferenceInputSms fromJson(String json) => values.byName(json); + static UpdateMfaPreferenceInputSms fromJson(String json) => + values.byName(json); } - enum UpdateMfaPreferenceInputTotp { ENABLED, DISABLED, PREFERRED, - NOT_PREFERRED -; + NOT_PREFERRED; String toJson() => name; - static UpdateMfaPreferenceInputTotp fromJson(String json) => values.byName(json); + static UpdateMfaPreferenceInputTotp fromJson(String json) => + values.byName(json); } - enum UpdateMfaPreferenceInputEmail { ENABLED, DISABLED, PREFERRED, - NOT_PREFERRED -; + NOT_PREFERRED; String toJson() => name; - static UpdateMfaPreferenceInputEmail fromJson(String json) => values.byName(json); + static UpdateMfaPreferenceInputEmail fromJson(String json) => + values.byName(json); } - sealed class AuthActionInput { const AuthActionInput(); Map toJson(); static AuthActionInput fromJson(Map json) { switch (json['action'] as String) { - case 'signUp': return SignUpInput.fromJson(json); - case 'resetPassword': return ResetPasswordInput.fromJson(json); - case 'signIn': return SignInInput.fromJson(json); - case 'signInWithPasskey': return SignInWithPasskeyInput.fromJson(json); - case 'confirmSignUp': return ConfirmSignUpInput.fromJson(json); - case 'resendSignUpCode': return ResendSignUpCodeInput.fromJson(json); - case 'signOut': return SignOutInput.fromJson(json); - case 'confirmResetPassword': return ConfirmResetPasswordInput.fromJson(json); - case 'autoSignIn': return AutoSignInInput.fromJson(json); - case 'confirmSignIn': return ConfirmSignInInput.fromJson(json); - case 'startPasskeyRegistration': return StartPasskeyRegistrationInput.fromJson(json); - case 'completePasskeyRegistration': return CompletePasskeyRegistrationInput.fromJson(json); - case 'listPasskeys': return ListPasskeysInput.fromJson(json); - case 'deletePasskey': return DeletePasskeyInput.fromJson(json); - case 'setUpTotp': return SetUpTotpInput.fromJson(json); - case 'verifyTotpSetup': return VerifyTotpSetupInput.fromJson(json); - case 'getMfaPreference': return GetMfaPreferenceInput.fromJson(json); - case 'updateMfaPreference': return UpdateMfaPreferenceInput.fromJson(json); - default: throw ArgumentError('Unknown action: ${json['action']}'); + case 'signUp': + return SignUpInput.fromJson(json); + case 'resetPassword': + return ResetPasswordInput.fromJson(json); + case 'signIn': + return SignInInput.fromJson(json); + case 'signInWithPasskey': + return SignInWithPasskeyInput.fromJson(json); + case 'confirmSignUp': + return ConfirmSignUpInput.fromJson(json); + case 'resendSignUpCode': + return ResendSignUpCodeInput.fromJson(json); + case 'signOut': + return SignOutInput.fromJson(json); + case 'confirmResetPassword': + return ConfirmResetPasswordInput.fromJson(json); + case 'autoSignIn': + return AutoSignInInput.fromJson(json); + case 'confirmSignIn': + return ConfirmSignInInput.fromJson(json); + case 'startPasskeyRegistration': + return StartPasskeyRegistrationInput.fromJson(json); + case 'completePasskeyRegistration': + return CompletePasskeyRegistrationInput.fromJson(json); + case 'listPasskeys': + return ListPasskeysInput.fromJson(json); + case 'deletePasskey': + return DeletePasskeyInput.fromJson(json); + case 'setUpTotp': + return SetUpTotpInput.fromJson(json); + case 'verifyTotpSetup': + return VerifyTotpSetupInput.fromJson(json); + case 'getMfaPreference': + return GetMfaPreferenceInput.fromJson(json); + case 'updateMfaPreference': + return UpdateMfaPreferenceInput.fromJson(json); + default: + throw ArgumentError('Unknown action: ${json['action']}'); } } } @@ -783,7 +829,8 @@ class SignUpInput extends AuthActionInput { username: json['username'] as String, password: json['password'] as String, additionalProperties: Map.fromEntries( - json.entries.where((e) => !knownKeys.contains(e.key)) + json.entries + .where((e) => !knownKeys.contains(e.key)) .map((e) => MapEntry(e.key, e.value as String)), ), ); @@ -796,7 +843,8 @@ class SignUpInput extends AuthActionInput { 'username': username, 'password': password, for (final e in additionalProperties.entries) - if (!const {'action', 'username', 'password'}.contains(e.key)) e.key: e.value, + if (!const {'action', 'username', 'password'}.contains(e.key)) + e.key: e.value, }; } @@ -809,38 +857,32 @@ class SignUpInput extends AuthActionInput { blocksDeepEquals(additionalProperties, other.additionalProperties); @override - int get hashCode => Object.hash(username, password, blocksDeepHash(additionalProperties)); + int get hashCode => + Object.hash(username, password, blocksDeepHash(additionalProperties)); @override - String toString() => 'SignUpInput(username: $username, password: $password, additionalProperties: $additionalProperties)'; + String toString() => + 'SignUpInput(username: $username, password: $password, additionalProperties: $additionalProperties)'; } class ResetPasswordInput extends AuthActionInput { final String username; - const ResetPasswordInput({ - required this.username, - }); + const ResetPasswordInput({required this.username}); factory ResetPasswordInput.fromJson(Map json) { - return ResetPasswordInput( - username: json['username'] as String, - ); + return ResetPasswordInput(username: json['username'] as String); } @override Map toJson() { - return { - 'action': 'resetPassword', - 'username': username, - }; + return {'action': 'resetPassword', 'username': username}; } @override bool operator ==(Object other) => identical(this, other) || - other is ResetPasswordInput && - username == other.username; + other is ResetPasswordInput && username == other.username; @override int get hashCode => username.hashCode; @@ -853,10 +895,7 @@ class SignInInput extends AuthActionInput { final String username; final String password; - const SignInInput({ - required this.username, - required this.password, - }); + const SignInInput({required this.username, required this.password}); factory SignInInput.fromJson(Map json) { return SignInInput( @@ -867,11 +906,7 @@ class SignInInput extends AuthActionInput { @override Map toJson() { - return { - 'action': 'signIn', - 'username': username, - 'password': password, - }; + return {'action': 'signIn', 'username': username, 'password': password}; } @override @@ -891,29 +926,21 @@ class SignInInput extends AuthActionInput { class SignInWithPasskeyInput extends AuthActionInput { final String username; - const SignInWithPasskeyInput({ - required this.username, - }); + const SignInWithPasskeyInput({required this.username}); factory SignInWithPasskeyInput.fromJson(Map json) { - return SignInWithPasskeyInput( - username: json['username'] as String, - ); + return SignInWithPasskeyInput(username: json['username'] as String); } @override Map toJson() { - return { - 'action': 'signInWithPasskey', - 'username': username, - }; + return {'action': 'signInWithPasskey', 'username': username}; } @override bool operator ==(Object other) => identical(this, other) || - other is SignInWithPasskeyInput && - username == other.username; + other is SignInWithPasskeyInput && username == other.username; @override int get hashCode => username.hashCode; @@ -963,35 +990,28 @@ class ConfirmSignUpInput extends AuthActionInput { int get hashCode => Object.hash(username, code, password); @override - String toString() => 'ConfirmSignUpInput(username: $username, code: $code, password: $password)'; + String toString() => + 'ConfirmSignUpInput(username: $username, code: $code, password: $password)'; } class ResendSignUpCodeInput extends AuthActionInput { final String username; - const ResendSignUpCodeInput({ - required this.username, - }); + const ResendSignUpCodeInput({required this.username}); factory ResendSignUpCodeInput.fromJson(Map json) { - return ResendSignUpCodeInput( - username: json['username'] as String, - ); + return ResendSignUpCodeInput(username: json['username'] as String); } @override Map toJson() { - return { - 'action': 'resendSignUpCode', - 'username': username, - }; + return {'action': 'resendSignUpCode', 'username': username}; } @override bool operator ==(Object other) => identical(this, other) || - other is ResendSignUpCodeInput && - username == other.username; + other is ResendSignUpCodeInput && username == other.username; @override int get hashCode => username.hashCode; @@ -1001,25 +1021,20 @@ class ResendSignUpCodeInput extends AuthActionInput { } class SignOutInput extends AuthActionInput { - const SignOutInput(); factory SignOutInput.fromJson(Map json) { - return SignOutInput( - ); + return SignOutInput(); } @override Map toJson() { - return { - 'action': 'signOut', - }; + return {'action': 'signOut'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is SignOutInput; + identical(this, other) || other is SignOutInput; @override int get hashCode => runtimeType.hashCode; @@ -1069,35 +1084,28 @@ class ConfirmResetPasswordInput extends AuthActionInput { int get hashCode => Object.hash(username, code, newPassword); @override - String toString() => 'ConfirmResetPasswordInput(username: $username, code: $code, newPassword: $newPassword)'; + String toString() => + 'ConfirmResetPasswordInput(username: $username, code: $code, newPassword: $newPassword)'; } class AutoSignInInput extends AuthActionInput { final String username; - const AutoSignInInput({ - required this.username, - }); + const AutoSignInInput({required this.username}); factory AutoSignInInput.fromJson(Map json) { - return AutoSignInInput( - username: json['username'] as String, - ); + return AutoSignInInput(username: json['username'] as String); } @override Map toJson() { - return { - 'action': 'autoSignIn', - 'username': username, - }; + return {'action': 'autoSignIn', 'username': username}; } @override bool operator ==(Object other) => identical(this, other) || - other is AutoSignInInput && - username == other.username; + other is AutoSignInInput && username == other.username; @override int get hashCode => username.hashCode; @@ -1106,16 +1114,11 @@ class AutoSignInInput extends AuthActionInput { String toString() => 'AutoSignInInput(username: $username)'; } - - class ConfirmSignInInput extends AuthActionInput { final String session; final ConfirmSignInInputChallenge challenge; - const ConfirmSignInInput({ - required this.session, - required this.challenge, - }); + const ConfirmSignInInput({required this.session, required this.challenge}); factory ConfirmSignInInput.fromJson(Map json) { return ConfirmSignInInput( @@ -1144,29 +1147,25 @@ class ConfirmSignInInput extends AuthActionInput { int get hashCode => Object.hash(session, challenge); @override - String toString() => 'ConfirmSignInInput(session: $session, challenge: $challenge)'; + String toString() => + 'ConfirmSignInInput(session: $session, challenge: $challenge)'; } class StartPasskeyRegistrationInput extends AuthActionInput { - const StartPasskeyRegistrationInput(); factory StartPasskeyRegistrationInput.fromJson(Map json) { - return StartPasskeyRegistrationInput( - ); + return StartPasskeyRegistrationInput(); } @override Map toJson() { - return { - 'action': 'startPasskeyRegistration', - }; + return {'action': 'startPasskeyRegistration'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is StartPasskeyRegistrationInput; + identical(this, other) || other is StartPasskeyRegistrationInput; @override int get hashCode => runtimeType.hashCode; @@ -1178,9 +1177,7 @@ class StartPasskeyRegistrationInput extends AuthActionInput { class CompletePasskeyRegistrationInput extends AuthActionInput { final String credential; - const CompletePasskeyRegistrationInput({ - required this.credential, - }); + const CompletePasskeyRegistrationInput({required this.credential}); factory CompletePasskeyRegistrationInput.fromJson(Map json) { return CompletePasskeyRegistrationInput( @@ -1190,10 +1187,7 @@ class CompletePasskeyRegistrationInput extends AuthActionInput { @override Map toJson() { - return { - 'action': 'completePasskeyRegistration', - 'credential': credential, - }; + return {'action': 'completePasskeyRegistration', 'credential': credential}; } @override @@ -1206,29 +1200,25 @@ class CompletePasskeyRegistrationInput extends AuthActionInput { int get hashCode => credential.hashCode; @override - String toString() => 'CompletePasskeyRegistrationInput(credential: $credential)'; + String toString() => + 'CompletePasskeyRegistrationInput(credential: $credential)'; } class ListPasskeysInput extends AuthActionInput { - const ListPasskeysInput(); factory ListPasskeysInput.fromJson(Map json) { - return ListPasskeysInput( - ); + return ListPasskeysInput(); } @override Map toJson() { - return { - 'action': 'listPasskeys', - }; + return {'action': 'listPasskeys'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is ListPasskeysInput; + identical(this, other) || other is ListPasskeysInput; @override int get hashCode => runtimeType.hashCode; @@ -1240,29 +1230,21 @@ class ListPasskeysInput extends AuthActionInput { class DeletePasskeyInput extends AuthActionInput { final String credentialId; - const DeletePasskeyInput({ - required this.credentialId, - }); + const DeletePasskeyInput({required this.credentialId}); factory DeletePasskeyInput.fromJson(Map json) { - return DeletePasskeyInput( - credentialId: json['credentialId'] as String, - ); + return DeletePasskeyInput(credentialId: json['credentialId'] as String); } @override Map toJson() { - return { - 'action': 'deletePasskey', - 'credentialId': credentialId, - }; + return {'action': 'deletePasskey', 'credentialId': credentialId}; } @override bool operator ==(Object other) => identical(this, other) || - other is DeletePasskeyInput && - credentialId == other.credentialId; + other is DeletePasskeyInput && credentialId == other.credentialId; @override int get hashCode => credentialId.hashCode; @@ -1272,25 +1254,20 @@ class DeletePasskeyInput extends AuthActionInput { } class SetUpTotpInput extends AuthActionInput { - const SetUpTotpInput(); factory SetUpTotpInput.fromJson(Map json) { - return SetUpTotpInput( - ); + return SetUpTotpInput(); } @override Map toJson() { - return { - 'action': 'setUpTotp', - }; + return {'action': 'setUpTotp'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is SetUpTotpInput; + identical(this, other) || other is SetUpTotpInput; @override int get hashCode => runtimeType.hashCode; @@ -1302,29 +1279,21 @@ class SetUpTotpInput extends AuthActionInput { class VerifyTotpSetupInput extends AuthActionInput { final String code; - const VerifyTotpSetupInput({ - required this.code, - }); + const VerifyTotpSetupInput({required this.code}); factory VerifyTotpSetupInput.fromJson(Map json) { - return VerifyTotpSetupInput( - code: json['code'] as String, - ); + return VerifyTotpSetupInput(code: json['code'] as String); } @override Map toJson() { - return { - 'action': 'verifyTotpSetup', - 'code': code, - }; + return {'action': 'verifyTotpSetup', 'code': code}; } @override bool operator ==(Object other) => identical(this, other) || - other is VerifyTotpSetupInput && - code == other.code; + other is VerifyTotpSetupInput && code == other.code; @override int get hashCode => code.hashCode; @@ -1334,25 +1303,20 @@ class VerifyTotpSetupInput extends AuthActionInput { } class GetMfaPreferenceInput extends AuthActionInput { - const GetMfaPreferenceInput(); factory GetMfaPreferenceInput.fromJson(Map json) { - return GetMfaPreferenceInput( - ); + return GetMfaPreferenceInput(); } @override Map toJson() { - return { - 'action': 'getMfaPreference', - }; + return {'action': 'getMfaPreference'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is GetMfaPreferenceInput; + identical(this, other) || other is GetMfaPreferenceInput; @override int get hashCode => runtimeType.hashCode; @@ -1366,17 +1330,19 @@ class UpdateMfaPreferenceInput extends AuthActionInput { final UpdateMfaPreferenceInputTotp? totp; final UpdateMfaPreferenceInputEmail? email; - const UpdateMfaPreferenceInput({ - this.sms, - this.totp, - this.email, - }); + const UpdateMfaPreferenceInput({this.sms, this.totp, this.email}); factory UpdateMfaPreferenceInput.fromJson(Map json) { return UpdateMfaPreferenceInput( - sms: json['sms'] != null ? UpdateMfaPreferenceInputSms.fromJson(json['sms'] as String) : null, - totp: json['totp'] != null ? UpdateMfaPreferenceInputTotp.fromJson(json['totp'] as String) : null, - email: json['email'] != null ? UpdateMfaPreferenceInputEmail.fromJson(json['email'] as String) : null, + sms: json['sms'] != null + ? UpdateMfaPreferenceInputSms.fromJson(json['sms'] as String) + : null, + totp: json['totp'] != null + ? UpdateMfaPreferenceInputTotp.fromJson(json['totp'] as String) + : null, + email: json['email'] != null + ? UpdateMfaPreferenceInputEmail.fromJson(json['email'] as String) + : null, ); } @@ -1402,11 +1368,10 @@ class UpdateMfaPreferenceInput extends AuthActionInput { int get hashCode => Object.hash(sms, totp, email); @override - String toString() => 'UpdateMfaPreferenceInput(sms: $sms, totp: $totp, email: $email)'; + String toString() => + 'UpdateMfaPreferenceInput(sms: $sms, totp: $totp, email: $email)'; } - - @Deprecated('Use AuthActionInput') typedef AlphaAuthApiSetAuthStateInput = AuthActionInput; @@ -1417,39 +1382,39 @@ class AlphaAuthApi { AlphaAuthApi(this._client); Future getAuthState() async { - final result = await _client.call('alphaAuthApi.getAuthState', const []); + final result = await _client.call( + 'alphaAuthApi.getAuthState', + const [], + ); return AuthState.fromJson(result as Map); } Future setAuthState({required AuthActionInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('alphaAuthApi.setAuthState', params); return AuthState.fromJson(result as Map); } } - class ZetaAuthApi { final BlocksClient _client; ZetaAuthApi(this._client); Future getAuthState() async { - final result = await _client.call('zetaAuthApi.getAuthState', const []); + final result = await _client.call( + 'zetaAuthApi.getAuthState', + const [], + ); return AuthState.fromJson(result as Map); } Future setAuthState({required AuthActionInput input}) async { - final params = [ - input.toJson(), - ]; + final params = [input.toJson()]; final result = await _client.call('zetaAuthApi.setAuthState', params); return AuthState.fromJson(result as Map); } } - // --- Blocks Client --- class Blocks { @@ -1469,4 +1434,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/codegen-fixtures/45-open-enums/dart/client.dart b/native/codegen-fixtures/45-open-enums/dart/client.dart index be8f642f8d..e3be6d6e32 100644 --- a/native/codegen-fixtures/45-open-enums/dart/client.dart +++ b/native/codegen-fixtures/45-open-enums/dart/client.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE — DO NOT MODIFY BY HAND // Generator: blocks-codegen // Source: test v1.0.0 @@ -5,8 +6,28 @@ // ignore_for_file: constant_identifier_names import 'package:blocks_runtime/blocks_runtime.dart'; -export 'package:blocks_runtime/blocks_runtime.dart' show ApiException, BlocksClient, BlocksException, ClientClosedException, InMemorySessionStore, SessionStore, TransportException, isBlocksError; -export 'package:blocks_runtime/blocks_runtime.dart' show RealtimeChannel, FileDownloadHandle, FileUploadHandle, FileTransferException, RealtimeException, RealtimeChannelClosedException, RealtimeConnectionException, RealtimeSubscriptionEndedException, TransferableException, InvalidDescriptorException; +export 'package:blocks_runtime/blocks_runtime.dart' + show + ApiException, + BlocksClient, + BlocksException, + ClientClosedException, + InMemorySessionStore, + SessionStore, + TransportException, + isBlocksError; +export 'package:blocks_runtime/blocks_runtime.dart' + show + RealtimeChannel, + FileDownloadHandle, + FileUploadHandle, + FileTransferException, + RealtimeException, + RealtimeChannelClosedException, + RealtimeConnectionException, + RealtimeSubscriptionEndedException, + TransferableException, + InvalidDescriptorException; // --- Models --- @@ -14,16 +35,17 @@ sealed class TaskLabels { static const red = TaskLabelsKnown.red; static const green = TaskLabelsKnown.green; static const values = TaskLabelsKnown.values; - static final Map _byJson = TaskLabelsKnown.values.asNameMap(); + static final Map _byJson = TaskLabelsKnown.values + .asNameMap(); String toJson(); - static TaskLabels fromJson(String json) => _byJson[json] ?? TaskLabelsUnknown(json); + static TaskLabels fromJson(String json) => + _byJson[json] ?? TaskLabelsUnknown(json); } enum TaskLabelsKnown implements TaskLabels { red, - green -; + green; @override String toJson() => name; @@ -45,24 +67,26 @@ final class TaskLabelsUnknown implements TaskLabels { int get hashCode => value.hashCode; @override - String toString() => 'TaskLabelsUnknown' '($value)'; + String toString() => + 'TaskLabelsUnknown' + '($value)'; } - sealed class TaskPriority { static const low = TaskPriorityKnown.low; static const high = TaskPriorityKnown.high; static const values = TaskPriorityKnown.values; - static final Map _byJson = TaskPriorityKnown.values.asNameMap(); + static final Map _byJson = TaskPriorityKnown.values + .asNameMap(); String toJson(); - static TaskPriority fromJson(String json) => _byJson[json] ?? TaskPriorityUnknown(json); + static TaskPriority fromJson(String json) => + _byJson[json] ?? TaskPriorityUnknown(json); } enum TaskPriorityKnown implements TaskPriority { low, - high -; + high; @override String toJson() => name; @@ -84,24 +108,26 @@ final class TaskPriorityUnknown implements TaskPriority { int get hashCode => value.hashCode; @override - String toString() => 'TaskPriorityUnknown' '($value)'; + String toString() => + 'TaskPriorityUnknown' + '($value)'; } - sealed class TaskSource { static const web = TaskSourceKnown.web; static const unknown = TaskSourceKnown.unknown; static const values = TaskSourceKnown.values; - static final Map _byJson = TaskSourceKnown.values.asNameMap(); + static final Map _byJson = TaskSourceKnown.values + .asNameMap(); String toJson(); - static TaskSource fromJson(String json) => _byJson[json] ?? TaskSourceUnknown(json); + static TaskSource fromJson(String json) => + _byJson[json] ?? TaskSourceUnknown(json); } enum TaskSourceKnown implements TaskSource { web, - unknown -; + unknown; @override String toJson() => name; @@ -123,24 +149,26 @@ final class TaskSourceUnknown implements TaskSource { int get hashCode => value.hashCode; @override - String toString() => 'TaskSourceUnknown' '($value)'; + String toString() => + 'TaskSourceUnknown' + '($value)'; } - sealed class TaskPhase { static const companion = TaskPhaseKnown.companion; static const other = TaskPhaseKnown.other; static const values = TaskPhaseKnown.values; - static final Map _byJson = TaskPhaseKnown.values.asNameMap(); + static final Map _byJson = TaskPhaseKnown.values + .asNameMap(); String toJson(); - static TaskPhase fromJson(String json) => _byJson[json] ?? TaskPhaseUnknown(json); + static TaskPhase fromJson(String json) => + _byJson[json] ?? TaskPhaseUnknown(json); } enum TaskPhaseKnown implements TaskPhase { companion, - other -; + other; @override String toJson() => name; @@ -162,24 +190,26 @@ final class TaskPhaseUnknown implements TaskPhase { int get hashCode => value.hashCode; @override - String toString() => 'TaskPhaseUnknown' '($value)'; + String toString() => + 'TaskPhaseUnknown' + '($value)'; } - sealed class NodeKind { static const leaf = NodeKindKnown.leaf; static const branch = NodeKindKnown.branch; static const values = NodeKindKnown.values; - static final Map _byJson = NodeKindKnown.values.asNameMap(); + static final Map _byJson = NodeKindKnown.values + .asNameMap(); String toJson(); - static NodeKind fromJson(String json) => _byJson[json] ?? NodeKindUnknown(json); + static NodeKind fromJson(String json) => + _byJson[json] ?? NodeKindUnknown(json); } enum NodeKindKnown implements NodeKind { leaf, - branch -; + branch; @override String toJson() => name; @@ -201,10 +231,11 @@ final class NodeKindUnknown implements NodeKind { int get hashCode => value.hashCode; @override - String toString() => 'NodeKindUnknown' '($value)'; + String toString() => + 'NodeKindUnknown' + '($value)'; } - sealed class Kind { static const kind = KindKnown.kind; static const other = KindKnown.other; @@ -217,8 +248,7 @@ sealed class Kind { enum KindKnown implements Kind { kind, - other -; + other; @override String toJson() => name; @@ -240,23 +270,24 @@ final class KindUnknown implements Kind { int get hashCode => value.hashCode; @override - String toString() => 'KindUnknown' '($value)'; + String toString() => + 'KindUnknown' + '($value)'; } - sealed class LabelsSpelling { static const unknown = LabelsSpellingKnown.unknown; static const unKnown = LabelsSpellingKnown.unKnown; static const values = LabelsSpellingKnown.values; String toJson(); - static LabelsSpelling fromJson(String json) => LabelsSpellingKnown._jsonMap[json] ?? LabelsSpellingUnknown(json); + static LabelsSpelling fromJson(String json) => + LabelsSpellingKnown._jsonMap[json] ?? LabelsSpellingUnknown(json); } enum LabelsSpellingKnown implements LabelsSpelling { unknown, - unKnown -; + unKnown; static const _jsonMap = { 'unknown': unknown, @@ -286,10 +317,11 @@ final class LabelsSpellingUnknown implements LabelsSpelling { int get hashCode => value.hashCode; @override - String toString() => 'LabelsSpellingUnknown' '($value)'; + String toString() => + 'LabelsSpellingUnknown' + '($value)'; } - sealed class LabelsCase { static const fooBar$ = LabelsCaseKnown.fooBar$; static const foo_bar = LabelsCaseKnown.foo_bar; @@ -299,7 +331,8 @@ sealed class LabelsCase { static const values = LabelsCaseKnown.values; String toJson(); - static LabelsCase fromJson(String json) => LabelsCaseKnown._jsonMap[json] ?? LabelsCaseUnknown(json); + static LabelsCase fromJson(String json) => + LabelsCaseKnown._jsonMap[json] ?? LabelsCaseUnknown(json); } enum LabelsCaseKnown implements LabelsCase { @@ -307,8 +340,7 @@ enum LabelsCaseKnown implements LabelsCase { foo_bar, fooBar, FOO_BAR, - fooBar$$ -; + fooBar$$; static const _jsonMap = { 'foo-bar': fooBar$, @@ -344,26 +376,29 @@ final class LabelsCaseUnknown implements LabelsCase { int get hashCode => value.hashCode; @override - String toString() => 'LabelsCaseUnknown' '($value)'; + String toString() => + 'LabelsCaseUnknown' + '($value)'; } - sealed class LabelsFallback { static const unknown = LabelsFallbackKnown.unknown; static const unknownValue = LabelsFallbackKnown.unknownValue; static const UnknownValue = LabelsFallbackKnown.UnknownValue; static const values = LabelsFallbackKnown.values; - static final Map _byJson = LabelsFallbackKnown.values.asNameMap(); + static final Map _byJson = LabelsFallbackKnown + .values + .asNameMap(); String toJson(); - static LabelsFallback fromJson(String json) => _byJson[json] ?? LabelsFallbackUnknown(json); + static LabelsFallback fromJson(String json) => + _byJson[json] ?? LabelsFallbackUnknown(json); } enum LabelsFallbackKnown implements LabelsFallback { unknown, unknownValue, - UnknownValue -; + UnknownValue; @override String toJson() => name; @@ -385,24 +420,26 @@ final class LabelsFallbackUnknown implements LabelsFallback { int get hashCode => value.hashCode; @override - String toString() => 'LabelsFallbackUnknown' '($value)'; + String toString() => + 'LabelsFallbackUnknown' + '($value)'; } - sealed class LabelsMaybe { static const yes = LabelsMaybeKnown.yes; static const no = LabelsMaybeKnown.no; static const values = LabelsMaybeKnown.values; - static final Map _byJson = LabelsMaybeKnown.values.asNameMap(); + static final Map _byJson = LabelsMaybeKnown.values + .asNameMap(); String toJson(); - static LabelsMaybe fromJson(String json) => _byJson[json] ?? LabelsMaybeUnknown(json); + static LabelsMaybe fromJson(String json) => + _byJson[json] ?? LabelsMaybeUnknown(json); } enum LabelsMaybeKnown implements LabelsMaybe { yes, - no -; + no; @override String toJson() => name; @@ -424,43 +461,39 @@ final class LabelsMaybeUnknown implements LabelsMaybe { int get hashCode => value.hashCode; @override - String toString() => 'LabelsMaybeUnknown' '($value)'; + String toString() => + 'LabelsMaybeUnknown' + '($value)'; } - enum PendingState { idle, - loading -; + loading; String toJson() => name; static PendingState fromJson(String json) => values.byName(json); } - enum PendingSteps { fetch, - parse -; + parse; String toJson() => name; static PendingSteps fromJson(String json) => values.byName(json); } - class Pending { final PendingState state; final List? steps; - const Pending({ - required this.state, - this.steps, - }); + const Pending({required this.state, this.steps}); factory Pending.fromJson(Map json) { return Pending( state: PendingState.fromJson(json['state'] as String), - steps: (json['steps'] as List?)?.map((e) => PendingSteps.fromJson(e as String)).toList(), + steps: (json['steps'] as List?) + ?.map((e) => PendingSteps.fromJson(e as String)) + .toList(), ); } @@ -485,24 +518,18 @@ class Pending { String toString() => 'Pending(state: $state, steps: $steps)'; } - enum FailedState { - error -; + error; String toJson() => name; static FailedState fromJson(String json) => values.byName(json); } - class Failed { final FailedState state; final String message; - const Failed({ - required this.state, - required this.message, - }); + const Failed({required this.state, required this.message}); factory Failed.fromJson(Map json) { return Failed( @@ -512,18 +539,13 @@ class Failed { } Map toJson() { - return { - 'state': state.toJson(), - 'message': message, - }; + return {'state': state.toJson(), 'message': message}; } @override bool operator ==(Object other) => identical(this, other) || - other is Failed && - state == other.state && - message == other.message; + other is Failed && state == other.state && message == other.message; @override int get hashCode => Object.hash(state, message); @@ -532,15 +554,17 @@ class Failed { String toString() => 'Failed(state: $state, message: $message)'; } - sealed class ConfirmAuthStepChallenge { const ConfirmAuthStepChallenge(); Map toJson(); static ConfirmAuthStepChallenge fromJson(Map json) { switch (json['challenge'] as String) { - case 'sms': return SmsConfirmAuthStepChallenge.fromJson(json); - case 'totp': return TotpConfirmAuthStepChallenge.fromJson(json); - default: throw ArgumentError('Unknown challenge: ${json['challenge']}'); + case 'sms': + return SmsConfirmAuthStepChallenge.fromJson(json); + case 'totp': + return TotpConfirmAuthStepChallenge.fromJson(json); + default: + throw ArgumentError('Unknown challenge: ${json['challenge']}'); } } } @@ -548,29 +572,21 @@ sealed class ConfirmAuthStepChallenge { class SmsConfirmAuthStepChallenge extends ConfirmAuthStepChallenge { final String code; - const SmsConfirmAuthStepChallenge({ - required this.code, - }); + const SmsConfirmAuthStepChallenge({required this.code}); factory SmsConfirmAuthStepChallenge.fromJson(Map json) { - return SmsConfirmAuthStepChallenge( - code: json['code'] as String, - ); + return SmsConfirmAuthStepChallenge(code: json['code'] as String); } @override Map toJson() { - return { - 'challenge': 'sms', - 'code': code, - }; + return {'challenge': 'sms', 'code': code}; } @override bool operator ==(Object other) => identical(this, other) || - other is SmsConfirmAuthStepChallenge && - code == other.code; + other is SmsConfirmAuthStepChallenge && code == other.code; @override int get hashCode => code.hashCode; @@ -582,29 +598,21 @@ class SmsConfirmAuthStepChallenge extends ConfirmAuthStepChallenge { class TotpConfirmAuthStepChallenge extends ConfirmAuthStepChallenge { final String otp; - const TotpConfirmAuthStepChallenge({ - required this.otp, - }); + const TotpConfirmAuthStepChallenge({required this.otp}); factory TotpConfirmAuthStepChallenge.fromJson(Map json) { - return TotpConfirmAuthStepChallenge( - otp: json['otp'] as String, - ); + return TotpConfirmAuthStepChallenge(otp: json['otp'] as String); } @override Map toJson() { - return { - 'challenge': 'totp', - 'otp': otp, - }; + return {'challenge': 'totp', 'otp': otp}; } @override bool operator ==(Object other) => identical(this, other) || - other is TotpConfirmAuthStepChallenge && - otp == other.otp; + other is TotpConfirmAuthStepChallenge && otp == other.otp; @override int get hashCode => otp.hashCode; @@ -613,28 +621,29 @@ class TotpConfirmAuthStepChallenge extends ConfirmAuthStepChallenge { String toString() => 'TotpConfirmAuthStepChallenge(otp: $otp)'; } - - sealed class FlaggedGetEventResultSeverity { static const low = FlaggedGetEventResultSeverityKnown.low; static const high = FlaggedGetEventResultSeverityKnown.high; static const values = FlaggedGetEventResultSeverityKnown.values; - static final Map _byJson = FlaggedGetEventResultSeverityKnown.values.asNameMap(); + static final Map _byJson = + FlaggedGetEventResultSeverityKnown.values.asNameMap(); String toJson(); - static FlaggedGetEventResultSeverity fromJson(String json) => _byJson[json] ?? FlaggedGetEventResultSeverityUnknown(json); + static FlaggedGetEventResultSeverity fromJson(String json) => + _byJson[json] ?? FlaggedGetEventResultSeverityUnknown(json); } -enum FlaggedGetEventResultSeverityKnown implements FlaggedGetEventResultSeverity { +enum FlaggedGetEventResultSeverityKnown + implements FlaggedGetEventResultSeverity { low, - high -; + high; @override String toJson() => name; } -final class FlaggedGetEventResultSeverityUnknown implements FlaggedGetEventResultSeverity { +final class FlaggedGetEventResultSeverityUnknown + implements FlaggedGetEventResultSeverity { final String value; const FlaggedGetEventResultSeverityUnknown(this.value); @@ -650,30 +659,34 @@ final class FlaggedGetEventResultSeverityUnknown implements FlaggedGetEventResul int get hashCode => value.hashCode; @override - String toString() => 'FlaggedGetEventResultSeverityUnknown' '($value)'; + String toString() => + 'FlaggedGetEventResultSeverityUnknown' + '($value)'; } - sealed class WatchTasksResultMessageChange { static const created = WatchTasksResultMessageChangeKnown.created; static const deleted = WatchTasksResultMessageChangeKnown.deleted; static const values = WatchTasksResultMessageChangeKnown.values; - static final Map _byJson = WatchTasksResultMessageChangeKnown.values.asNameMap(); + static final Map _byJson = + WatchTasksResultMessageChangeKnown.values.asNameMap(); String toJson(); - static WatchTasksResultMessageChange fromJson(String json) => _byJson[json] ?? WatchTasksResultMessageChangeUnknown(json); + static WatchTasksResultMessageChange fromJson(String json) => + _byJson[json] ?? WatchTasksResultMessageChangeUnknown(json); } -enum WatchTasksResultMessageChangeKnown implements WatchTasksResultMessageChange { +enum WatchTasksResultMessageChangeKnown + implements WatchTasksResultMessageChange { created, - deleted -; + deleted; @override String toJson() => name; } -final class WatchTasksResultMessageChangeUnknown implements WatchTasksResultMessageChange { +final class WatchTasksResultMessageChangeUnknown + implements WatchTasksResultMessageChange { final String value; const WatchTasksResultMessageChangeUnknown(this.value); @@ -689,18 +702,16 @@ final class WatchTasksResultMessageChangeUnknown implements WatchTasksResultMess int get hashCode => value.hashCode; @override - String toString() => 'WatchTasksResultMessageChangeUnknown' '($value)'; + String toString() => + 'WatchTasksResultMessageChangeUnknown' + '($value)'; } - class WatchTasksResultMessage { final String taskId; final WatchTasksResultMessageChange change; - const WatchTasksResultMessage({ - required this.taskId, - required this.change, - }); + const WatchTasksResultMessage({required this.taskId, required this.change}); factory WatchTasksResultMessage.fromJson(Map json) { return WatchTasksResultMessage( @@ -710,10 +721,7 @@ class WatchTasksResultMessage { } Map toJson() { - return { - 'taskId': taskId, - 'change': change.toJson(), - }; + return {'taskId': taskId, 'change': change.toJson()}; } @override @@ -727,24 +735,25 @@ class WatchTasksResultMessage { int get hashCode => Object.hash(taskId, change); @override - String toString() => 'WatchTasksResultMessage(taskId: $taskId, change: $change)'; + String toString() => + 'WatchTasksResultMessage(taskId: $taskId, change: $change)'; } - sealed class GetSettingsResultMode { static const light = GetSettingsResultModeKnown.light; static const dark = GetSettingsResultModeKnown.dark; static const values = GetSettingsResultModeKnown.values; - static final Map _byJson = GetSettingsResultModeKnown.values.asNameMap(); + static final Map _byJson = + GetSettingsResultModeKnown.values.asNameMap(); String toJson(); - static GetSettingsResultMode fromJson(String json) => _byJson[json] ?? GetSettingsResultModeUnknown(json); + static GetSettingsResultMode fromJson(String json) => + _byJson[json] ?? GetSettingsResultModeUnknown(json); } enum GetSettingsResultModeKnown implements GetSettingsResultMode { light, - dark -; + dark; @override String toJson() => name; @@ -766,10 +775,11 @@ final class GetSettingsResultModeUnknown implements GetSettingsResultMode { int get hashCode => value.hashCode; @override - String toString() => 'GetSettingsResultModeUnknown' '($value)'; + String toString() => + 'GetSettingsResultModeUnknown' + '($value)'; } - Map _blocksFrozenObject(Map json) => Map.unmodifiable({ for (final e in json.entries) e.key: _blocksFrozen(e.value), @@ -792,14 +802,14 @@ sealed class Status { static const values = StatusKnown.values; String toJson(); - static Status fromJson(String json) => StatusKnown._jsonMap[json] ?? StatusUnknown(json); + static Status fromJson(String json) => + StatusKnown._jsonMap[json] ?? StatusUnknown(json); } enum StatusKnown implements Status { todo, inProgress, - done -; + done; static const _jsonMap = { 'todo': todo, @@ -831,10 +841,11 @@ final class StatusUnknown implements Status { int get hashCode => value.hashCode; @override - String toString() => 'StatusUnknown' '($value)'; + String toString() => + 'StatusUnknown' + '($value)'; } - class Task { final String id; final Status status; @@ -858,11 +869,21 @@ class Task { return Task( id: json['id'] as String, status: Status.fromJson(json['status'] as String), - history: (json['history'] as List).map((e) => Status.fromJson(e as String)).toList(), - labels: (json['labels'] as Map).map((k, v) => MapEntry(k, TaskLabels.fromJson(v as String))), - priority: json['priority'] != null ? TaskPriority.fromJson(json['priority'] as String) : null, - source: json['source'] != null ? TaskSource.fromJson(json['source'] as String) : null, - phase: json['phase'] != null ? TaskPhase.fromJson(json['phase'] as String) : null, + history: (json['history'] as List) + .map((e) => Status.fromJson(e as String)) + .toList(), + labels: (json['labels'] as Map).map( + (k, v) => MapEntry(k, TaskLabels.fromJson(v as String)), + ), + priority: json['priority'] != null + ? TaskPriority.fromJson(json['priority'] as String) + : null, + source: json['source'] != null + ? TaskSource.fromJson(json['source'] as String) + : null, + phase: json['phase'] != null + ? TaskPhase.fromJson(json['phase'] as String) + : null, ); } @@ -891,13 +912,21 @@ class Task { phase == other.phase; @override - int get hashCode => Object.hash(id, status, blocksDeepHash(history), blocksDeepHash(labels), priority, source, phase); + int get hashCode => Object.hash( + id, + status, + blocksDeepHash(history), + blocksDeepHash(labels), + priority, + source, + phase, + ); @override - String toString() => 'Task(id: $id, status: $status, history: $history, labels: $labels, priority: $priority, source: $source, phase: $phase)'; + String toString() => + 'Task(id: $id, status: $status, history: $history, labels: $labels, priority: $priority, source: $source, phase: $phase)'; } - sealed class Color { static const red = ColorKnown.red; static const blue = ColorKnown.blue; @@ -910,8 +939,7 @@ sealed class Color { enum ColorKnown implements Color { red, - blue -; + blue; @override String toJson() => name; @@ -933,10 +961,11 @@ final class ColorUnknown implements Color { int get hashCode => value.hashCode; @override - String toString() => 'ColorUnknown' '($value)'; + String toString() => + 'ColorUnknown' + '($value)'; } - sealed class Size { static const small = SizeKnown.small; static const large = SizeKnown.large; @@ -949,8 +978,7 @@ sealed class Size { enum SizeKnown implements Size { small, - large -; + large; @override String toJson() => name; @@ -972,33 +1000,31 @@ final class SizeUnknown implements Size { int get hashCode => value.hashCode; @override - String toString() => 'SizeUnknown' '($value)'; + String toString() => + 'SizeUnknown' + '($value)'; } - enum Mode { auto, - manual -; + manual; String toJson() => name; static Mode fromJson(String json) => values.byName(json); } - class Node { final NodeKind kind; final List children; - const Node({ - required this.kind, - required this.children, - }); + const Node({required this.kind, required this.children}); factory Node.fromJson(Map json) { return Node( kind: NodeKind.fromJson(json['kind'] as String), - children: (json['children'] as List).map((e) => Node.fromJson(e as Map)).toList(), + children: (json['children'] as List) + .map((e) => Node.fromJson(e as Map)) + .toList(), ); } @@ -1023,7 +1049,6 @@ class Node { String toString() => 'Node(kind: $kind, children: $children)'; } - class Labels { final Kind kind; final LabelsSpelling spelling; @@ -1045,7 +1070,9 @@ class Labels { spelling: LabelsSpelling.fromJson(json['spelling'] as String), case$: LabelsCase.fromJson(json['case'] as String), fallback: LabelsFallback.fromJson(json['fallback'] as String), - maybe: json['maybe'] != null ? LabelsMaybe.fromJson(json['maybe'] as String) : null, + maybe: json['maybe'] != null + ? LabelsMaybe.fromJson(json['maybe'] as String) + : null, ); } @@ -1073,42 +1100,40 @@ class Labels { int get hashCode => Object.hash(kind, spelling, case$, fallback, maybe); @override - String toString() => 'Labels(kind: $kind, spelling: $spelling, case\$: ${case$}, fallback: $fallback, maybe: $maybe)'; + String toString() => + 'Labels(kind: $kind, spelling: $spelling, case\$: ${case$}, fallback: $fallback, maybe: $maybe)'; } - sealed class AuthStep { const AuthStep(); Map toJson(); static AuthStep fromJson(Map json) { switch (json['step'] as String) { - case 'done': return DoneAuthStep.fromJson(json); - case 'confirm': return ConfirmAuthStep.fromJson(json); - default: return AuthStepUnknown(_blocksFrozenObject(json)); + case 'done': + return DoneAuthStep.fromJson(json); + case 'confirm': + return ConfirmAuthStep.fromJson(json); + default: + return AuthStepUnknown(_blocksFrozenObject(json)); } } } class DoneAuthStep extends AuthStep { - const DoneAuthStep(); factory DoneAuthStep.fromJson(Map json) { - return DoneAuthStep( - ); + return DoneAuthStep(); } @override Map toJson() { - return { - 'step': 'done', - }; + return {'step': 'done'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is DoneAuthStep; + identical(this, other) || other is DoneAuthStep; @override int get hashCode => runtimeType.hashCode; @@ -1117,16 +1142,11 @@ class DoneAuthStep extends AuthStep { String toString() => 'DoneAuthStep()'; } - - class ConfirmAuthStep extends AuthStep { final String session; final ConfirmAuthStepChallenge challenge; - const ConfirmAuthStep({ - required this.session, - required this.challenge, - }); + const ConfirmAuthStep({required this.session, required this.challenge}); factory ConfirmAuthStep.fromJson(Map json) { return ConfirmAuthStep( @@ -1137,11 +1157,7 @@ class ConfirmAuthStep extends AuthStep { @override Map toJson() { - return { - 'step': 'confirm', - 'session': session, - ...challenge.toJson(), - }; + return {'step': 'confirm', 'session': session, ...challenge.toJson()}; } @override @@ -1155,7 +1171,8 @@ class ConfirmAuthStep extends AuthStep { int get hashCode => Object.hash(session, challenge); @override - String toString() => 'ConfirmAuthStep(session: $session, challenge: $challenge)'; + String toString() => + 'ConfirmAuthStep(session: $session, challenge: $challenge)'; } final class AuthStepUnknown extends AuthStep { @@ -1176,45 +1193,35 @@ final class AuthStepUnknown extends AuthStep { int get hashCode => blocksDeepHash(json); @override - String toString() => 'AuthStepUnknown' '($json)'; + String toString() => + 'AuthStepUnknown' + '($json)'; } - - enum ApiUpdateTaskSort { newest, - oldest -; + oldest; String toJson() => name; static ApiUpdateTaskSort fromJson(String json) => values.byName(json); } - class UpdateTaskResult { final bool ok; - const UpdateTaskResult({ - required this.ok, - }); + const UpdateTaskResult({required this.ok}); factory UpdateTaskResult.fromJson(Map json) { - return UpdateTaskResult( - ok: json['ok'] as bool, - ); + return UpdateTaskResult(ok: json['ok'] as bool); } Map toJson() { - return { - 'ok': ok, - }; + return {'ok': ok}; } @override bool operator ==(Object other) => - identical(this, other) || - other is UpdateTaskResult && - ok == other.ok; + identical(this, other) || other is UpdateTaskResult && ok == other.ok; @override int get hashCode => ok.hashCode; @@ -1223,16 +1230,19 @@ class UpdateTaskResult { String toString() => 'UpdateTaskResult(ok: $ok)'; } - sealed class GetEventResult { const GetEventResult(); Map toJson(); static GetEventResult fromJson(Map json) { switch (json['kind'] as String) { - case 'moved': return MovedGetEventResult.fromJson(json); - case 'flagged': return FlaggedGetEventResult.fromJson(json); - case 'unknown': return UnknownGetEventResult.fromJson(json); - default: return GetEventResultUnknown(_blocksFrozenObject(json)); + case 'moved': + return MovedGetEventResult.fromJson(json); + case 'flagged': + return FlaggedGetEventResult.fromJson(json); + case 'unknown': + return UnknownGetEventResult.fromJson(json); + default: + return GetEventResultUnknown(_blocksFrozenObject(json)); } } } @@ -1240,29 +1250,20 @@ sealed class GetEventResult { class MovedGetEventResult extends GetEventResult { final Status to; - const MovedGetEventResult({ - required this.to, - }); + const MovedGetEventResult({required this.to}); factory MovedGetEventResult.fromJson(Map json) { - return MovedGetEventResult( - to: Status.fromJson(json['to'] as String), - ); + return MovedGetEventResult(to: Status.fromJson(json['to'] as String)); } @override Map toJson() { - return { - 'kind': 'moved', - 'to': to.toJson(), - }; + return {'kind': 'moved', 'to': to.toJson()}; } @override bool operator ==(Object other) => - identical(this, other) || - other is MovedGetEventResult && - to == other.to; + identical(this, other) || other is MovedGetEventResult && to == other.to; @override int get hashCode => to.hashCode; @@ -1274,29 +1275,25 @@ class MovedGetEventResult extends GetEventResult { class FlaggedGetEventResult extends GetEventResult { final FlaggedGetEventResultSeverity severity; - const FlaggedGetEventResult({ - required this.severity, - }); + const FlaggedGetEventResult({required this.severity}); factory FlaggedGetEventResult.fromJson(Map json) { return FlaggedGetEventResult( - severity: FlaggedGetEventResultSeverity.fromJson(json['severity'] as String), + severity: FlaggedGetEventResultSeverity.fromJson( + json['severity'] as String, + ), ); } @override Map toJson() { - return { - 'kind': 'flagged', - 'severity': severity.toJson(), - }; + return {'kind': 'flagged', 'severity': severity.toJson()}; } @override bool operator ==(Object other) => identical(this, other) || - other is FlaggedGetEventResult && - severity == other.severity; + other is FlaggedGetEventResult && severity == other.severity; @override int get hashCode => severity.hashCode; @@ -1308,29 +1305,21 @@ class FlaggedGetEventResult extends GetEventResult { class UnknownGetEventResult extends GetEventResult { final String note; - const UnknownGetEventResult({ - required this.note, - }); + const UnknownGetEventResult({required this.note}); factory UnknownGetEventResult.fromJson(Map json) { - return UnknownGetEventResult( - note: json['note'] as String, - ); + return UnknownGetEventResult(note: json['note'] as String); } @override Map toJson() { - return { - 'kind': 'unknown', - 'note': note, - }; + return {'kind': 'unknown', 'note': note}; } @override bool operator ==(Object other) => identical(this, other) || - other is UnknownGetEventResult && - note == other.note; + other is UnknownGetEventResult && note == other.note; @override int get hashCode => note.hashCode; @@ -1357,17 +1346,15 @@ final class GetEventResultUnknown extends GetEventResult { int get hashCode => blocksDeepHash(json); @override - String toString() => 'GetEventResultUnknown' '($json)'; + String toString() => + 'GetEventResultUnknown' + '($json)'; } - - class GetSettingsResult { final GetSettingsResultMode mode; - const GetSettingsResult({ - required this.mode, - }); + const GetSettingsResult({required this.mode}); factory GetSettingsResult.fromJson(Map json) { return GetSettingsResult( @@ -1376,16 +1363,13 @@ class GetSettingsResult { } Map toJson() { - return { - 'mode': mode.toJson(), - }; + return {'mode': mode.toJson()}; } @override bool operator ==(Object other) => identical(this, other) || - other is GetSettingsResult && - mode == other.mode; + other is GetSettingsResult && mode == other.mode; @override int get hashCode => mode.hashCode; @@ -1394,21 +1378,22 @@ class GetSettingsResult { String toString() => 'GetSettingsResult(mode: $mode)'; } - sealed class GetRangeResult { static const up = GetRangeResultKnown.up; static const down = GetRangeResultKnown.down; static const values = GetRangeResultKnown.values; - static final Map _byJson = GetRangeResultKnown.values.asNameMap(); + static final Map _byJson = GetRangeResultKnown + .values + .asNameMap(); String toJson(); - static GetRangeResult fromJson(String json) => _byJson[json] ?? GetRangeResultUnknown(json); + static GetRangeResult fromJson(String json) => + _byJson[json] ?? GetRangeResultUnknown(json); } enum GetRangeResultKnown implements GetRangeResult { up, - down -; + down; @override String toJson() => name; @@ -1430,18 +1415,22 @@ final class GetRangeResultUnknown implements GetRangeResult { int get hashCode => value.hashCode; @override - String toString() => 'GetRangeResultUnknown' '($value)'; + String toString() => + 'GetRangeResultUnknown' + '($value)'; } - sealed class GetSignalResult { const GetSignalResult(); Map toJson(); static GetSignalResult fromJson(Map json) { switch (json['kind'] as String) { - case 'un-known': return UnKnownGetSignalResult.fromJson(json); - case 'on': return OnGetSignalResult.fromJson(json); - default: return GetSignalResultUnknown(_blocksFrozenObject(json)); + case 'un-known': + return UnKnownGetSignalResult.fromJson(json); + case 'on': + return OnGetSignalResult.fromJson(json); + default: + return GetSignalResultUnknown(_blocksFrozenObject(json)); } } } @@ -1449,29 +1438,21 @@ sealed class GetSignalResult { class UnKnownGetSignalResult extends GetSignalResult { final String note; - const UnKnownGetSignalResult({ - required this.note, - }); + const UnKnownGetSignalResult({required this.note}); factory UnKnownGetSignalResult.fromJson(Map json) { - return UnKnownGetSignalResult( - note: json['note'] as String, - ); + return UnKnownGetSignalResult(note: json['note'] as String); } @override Map toJson() { - return { - 'kind': 'un-known', - 'note': note, - }; + return {'kind': 'un-known', 'note': note}; } @override bool operator ==(Object other) => identical(this, other) || - other is UnKnownGetSignalResult && - note == other.note; + other is UnKnownGetSignalResult && note == other.note; @override int get hashCode => note.hashCode; @@ -1481,25 +1462,20 @@ class UnKnownGetSignalResult extends GetSignalResult { } class OnGetSignalResult extends GetSignalResult { - const OnGetSignalResult(); factory OnGetSignalResult.fromJson(Map json) { - return OnGetSignalResult( - ); + return OnGetSignalResult(); } @override Map toJson() { - return { - 'kind': 'on', - }; + return {'kind': 'on'}; } @override bool operator ==(Object other) => - identical(this, other) || - other is OnGetSignalResult; + identical(this, other) || other is OnGetSignalResult; @override int get hashCode => runtimeType.hashCode; @@ -1526,24 +1502,26 @@ final class GetSignalResultUnknown extends GetSignalResult { int get hashCode => blocksDeepHash(json); @override - String toString() => 'GetSignalResultUnknown' '($json)'; + String toString() => + 'GetSignalResultUnknown' + '($json)'; } - - class Api { final BlocksClient _client; Api(this._client); Future getTask({required String id}) async { - final params = [ - id, - ]; + final params = [id]; final result = await _client.call('api.getTask', params); return Task.fromJson(result as Map); } - Future updateTask({required String id, required Status status, ApiUpdateTaskSort? sort}) async { + Future updateTask({ + required String id, + required Status status, + ApiUpdateTaskSort? sort, + }) async { final params = [ id, status.toJson(), @@ -1560,7 +1538,10 @@ class Api { Future> watchTasks() async { final result = await _client.call('api.watchTasks', const []); - return RealtimeChannel.fromJson(result as Map, (json) => WatchTasksResultMessage.fromJson(json)); + return RealtimeChannel.fromJson( + result as Map, + (json) => WatchTasksResultMessage.fromJson(json), + ); } Future getColor() async { @@ -1574,9 +1555,7 @@ class Api { } Future setMode({required Mode mode}) async { - final params = [ - mode.toJson(), - ]; + final params = [mode.toJson()]; final result = await _client.call('api.setMode', params); return result as bool; } @@ -1593,7 +1572,10 @@ class Api { Future<(Size, GetRangeResult)> getRange() async { final result = await _client.call('api.getRange', const []); - return (Size.fromJson((result as List)[0] as String), GetRangeResult.fromJson((result as List)[1] as String)); + return ( + Size.fromJson((result as List)[0] as String), + GetRangeResult.fromJson((result as List)[1] as String), + ); } Future getLabels() async { @@ -1617,7 +1599,6 @@ class Api { } } - // --- Blocks Client --- class Blocks { @@ -1635,4 +1616,3 @@ class Blocks { /// does nothing more. void close() => _client.close(); } - diff --git a/native/dart/packages/blocks_codegen/CHANGELOG.md b/native/dart/packages/blocks_codegen/CHANGELOG.md index 788885706e..189d1dae85 100644 --- a/native/dart/packages/blocks_codegen/CHANGELOG.md +++ b/native/dart/packages/blocks_codegen/CHANGELOG.md @@ -107,6 +107,9 @@ ### Other changes +- Format every generated Dart client at width 80, using the target package's + Dart language version when available, so output passes `dart format` without + a separate consumer-side formatting step. - The generated client re-exports `RealtimeSubscriptionEndedException` with the other realtime errors. - The generated `Blocks` class has a `close()` that closes its diff --git a/native/dart/packages/blocks_codegen/README.md b/native/dart/packages/blocks_codegen/README.md index 4ac354b615..e678c8edf7 100644 --- a/native/dart/packages/blocks_codegen/README.md +++ b/native/dart/packages/blocks_codegen/README.md @@ -18,6 +18,12 @@ Add to `build.yaml` and place your `.spec.json` in `lib/`. Run: dart run build_runner build ``` +Generated clients are formatted at width 80 and start with +`// dart format width=80`, so checked-in output passes `dart format` without a +separate formatting step. The CLI and build_runner use the target package's +Dart language version when available; direct generator calls default to Dart +3.11 unless they pass `languageVersion`. + ## Generated names Dart declares a union's arm classes at the top level, named `` diff --git a/native/dart/packages/blocks_codegen/bin/blocks_codegen.dart b/native/dart/packages/blocks_codegen/bin/blocks_codegen.dart index cf70347925..150595ca83 100644 --- a/native/dart/packages/blocks_codegen/bin/blocks_codegen.dart +++ b/native/dart/packages/blocks_codegen/bin/blocks_codegen.dart @@ -1,11 +1,15 @@ import 'dart:io'; import 'package:args/args.dart'; -import 'package:blocks_codegen/src/parser.dart'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; +import 'package:blocks_codegen/src/language_version.dart'; +import 'package:blocks_codegen/src/parser.dart'; +import 'package:dart_style/dart_style.dart'; +import 'package:package_config/package_config.dart'; +import 'package:pub_semver/pub_semver.dart'; -void main(List args) { +Future main(List args) async { final parser = ArgParser() ..addOption('spec', abbr: 's', help: 'Path to the OpenRPC spec file') ..addOption( @@ -84,6 +88,7 @@ void main(List args) { } final String output; try { + final languageVersion = await _resolveTargetLanguageVersion(outputPath); final rpcModel = const OpenRpcParser().parse(contents); final codegenModel = CodegenModelBuilder( failOnCollision: failOnCollision, @@ -92,7 +97,13 @@ void main(List args) { for (final w in codegenModel.warnings) { stderr.writeln('Warning: $w'); } - output = const DartCodeGenerator().generate(codegenModel); + output = const DartCodeGenerator().generate( + codegenModel, + languageVersion: languageVersion, + ); + } on FormatterException catch (e) { + stderr.writeln('Error: ${e.message(color: false)}'); + exit(1); } on FormatException catch (e) { stderr.writeln('Error: ${e.message}'); exit(1); @@ -110,3 +121,38 @@ void main(List args) { stdout.write(output); } } + +Future _resolveTargetLanguageVersion(String? outputPath) async { + if (outputPath == null) { + final packageConfig = await findPackageConfig(Directory.current); + if (packageConfig == null) return null; + return languageVersionForUri( + packageConfig, + Directory.current.absolute.uri, + ).version; + } + + final outputFile = File(outputPath).absolute; + final outputConfig = await findPackageConfig( + _nearestExistingDirectory(outputFile.parent), + ); + if (outputConfig != null) { + final target = languageVersionForUri(outputConfig, outputFile.uri); + if (target.found) return target.version; + } + + final cwdConfig = await findPackageConfig(Directory.current); + if (cwdConfig == null) return null; + final target = languageVersionForUri(cwdConfig, outputFile.uri); + return target.found ? target.version : null; +} + +Directory _nearestExistingDirectory(Directory directory) { + var current = directory.absolute; + while (!current.existsSync()) { + final parent = current.parent; + if (parent.path == current.path) return current; + current = parent; + } + return current; +} diff --git a/native/dart/packages/blocks_codegen/lib/builder.dart b/native/dart/packages/blocks_codegen/lib/builder.dart index 0baa7b9205..b49b63fbbc 100644 --- a/native/dart/packages/blocks_codegen/lib/builder.dart +++ b/native/dart/packages/blocks_codegen/lib/builder.dart @@ -1,9 +1,9 @@ +import 'package:blocks_codegen/src/builder.dart' as codegen_builder; +import 'package:blocks_codegen/src/generator.dart'; +import 'package:blocks_codegen/src/language_version.dart'; +import 'package:blocks_codegen/src/parser.dart'; import 'package:build/build.dart'; -import 'src/parser.dart'; -import 'src/builder.dart' as codegen_builder; -import 'src/generator.dart'; - /// Factory for the build_runner builder. Builder blocksCodegenBuilder(BuilderOptions options) => _BlocksCodegenBuilder( options.config['fail_on_collision'] as bool? ?? false, @@ -33,6 +33,11 @@ class _BlocksCodegenBuilder extends Builder { Future build(BuildStep buildStep) async { final inputId = buildStep.inputId; final contents = await buildStep.readAsString(inputId); + final packageConfig = await buildStep.packageConfig; + final languageVersion = languageVersionForPackage( + packageConfig, + inputId.package, + ); final rpcModel = const OpenRpcParser().parse(contents); final codegenModel = codegen_builder.CodegenModelBuilder( @@ -42,7 +47,10 @@ class _BlocksCodegenBuilder extends Builder { for (final w in codegenModel.warnings) { log.warning(w); } - final output = const DartCodeGenerator().generate(codegenModel); + final output = const DartCodeGenerator().generate( + codegenModel, + languageVersion: languageVersion, + ); // .spec.json → .blocks.dart (strip both extensions) final path = inputId.path; diff --git a/native/dart/packages/blocks_codegen/lib/src/generator.dart b/native/dart/packages/blocks_codegen/lib/src/generator.dart index e67e50cb68..7783aa77c7 100644 --- a/native/dart/packages/blocks_codegen/lib/src/generator.dart +++ b/native/dart/packages/blocks_codegen/lib/src/generator.dart @@ -1,8 +1,10 @@ -import 'builder.dart'; -import 'dart_source.dart'; -import 'diagnostics.dart'; -import 'identifiers.dart'; -import 'model.dart'; +import 'package:blocks_codegen/src/builder.dart'; +import 'package:blocks_codegen/src/dart_source.dart'; +import 'package:blocks_codegen/src/diagnostics.dart'; +import 'package:blocks_codegen/src/identifiers.dart'; +import 'package:blocks_codegen/src/model.dart'; +import 'package:dart_style/dart_style.dart'; +import 'package:pub_semver/pub_semver.dart'; /// The oldest `blocks_runtime` that has every API generated code calls /// (`blocksDeepEquals`, `RealtimeChannel.fromJsonValue`, a list-typed @@ -17,9 +19,12 @@ class DartCodeGenerator { /// Emits the complete contents of one generated `.blocks.dart` library. /// - /// Output is deterministic for a given [model], so it is safe to check in - /// and diff. - String generate(CodegenModel model) { + /// Output is formatted at 80 columns and deterministic for a given [model] + /// and [languageVersion], so it is safe to check in and diff. + /// + /// Pass the target package's [languageVersion] when known. When omitted, + /// Dart 3.11 is used, matching this package's minimum SDK version. + String generate(CodegenModel model, {Version? languageVersion}) { _checkNoTransferableParams(model); final buf = StringBuffer(); buf.writeln('// GENERATED CODE — DO NOT MODIFY BY HAND'); @@ -211,9 +216,11 @@ class DartCodeGenerator { _emitBlocksFacade(model.namespaces, apiClasses, model.servers, declared), ); - final output = buf.toString(); - _checkBoundTypesNotShadowed(model, output); - return output; + final rawOutput = buf.toString(); + _checkBoundTypesNotShadowed(model, rawOutput); + return DartFormatter( + languageVersion: languageVersion ?? Version(3, 11, 0), + ).format('// dart format width=80\n$rawOutput'); } String _emitType( diff --git a/native/dart/packages/blocks_codegen/lib/src/language_version.dart b/native/dart/packages/blocks_codegen/lib/src/language_version.dart new file mode 100644 index 0000000000..86c06ad351 --- /dev/null +++ b/native/dart/packages/blocks_codegen/lib/src/language_version.dart @@ -0,0 +1,22 @@ +import 'package:package_config/package_config.dart'; +import 'package:pub_semver/pub_semver.dart'; + +Version? languageVersionForPackage( + PackageConfig packageConfig, + String packageName, +) => _toVersion(packageConfig[packageName]?.languageVersion); + +({bool found, Version? version}) languageVersionForUri( + PackageConfig packageConfig, + Uri target, +) { + final package = packageConfig.packageOf(target); + return ( + found: package != null, + version: _toVersion(package?.languageVersion), + ); +} + +Version? _toVersion(LanguageVersion? languageVersion) => languageVersion == null + ? null + : Version(languageVersion.major, languageVersion.minor, 0); diff --git a/native/dart/packages/blocks_codegen/pubspec.yaml b/native/dart/packages/blocks_codegen/pubspec.yaml index a1981b4f34..9d795ed991 100644 --- a/native/dart/packages/blocks_codegen/pubspec.yaml +++ b/native/dart/packages/blocks_codegen/pubspec.yaml @@ -10,13 +10,16 @@ environment: dependencies: args: ^2.4.0 + # Generated clients need blocks_runtime 0.2.0 (`minimumRuntimeVersion` in + # lib/src/generator.dart); test/generator_test.dart checks the two agree. + blocks_runtime: ^0.2.0 # build_runner 2.17.1 requires build 5, while mockito and other builders # still pin build <5. build 5.0.0 only breaks BuildStep implementers; # this package extends Builder, which is unchanged. build: '>=4.0.0 <6.0.0' - # Generated clients need blocks_runtime 0.2.0 (`minimumRuntimeVersion` in - # lib/src/generator.dart); test/generator_test.dart checks the two agree. - blocks_runtime: ^0.2.0 + dart_style: ^3.1.11 + package_config: '>=2.1.0 <4.0.0' + pub_semver: ^2.1.4 dev_dependencies: # build_runner 2.16.2 is the first release that compiles against analyzer diff --git a/native/dart/packages/blocks_codegen/test/cli_test.dart b/native/dart/packages/blocks_codegen/test/cli_test.dart index 185ec3c3ff..04366e7696 100644 --- a/native/dart/packages/blocks_codegen/test/cli_test.dart +++ b/native/dart/packages/blocks_codegen/test/cli_test.dart @@ -3,11 +3,14 @@ import 'dart:io'; import 'package:test/test.dart'; -ProcessResult _run(List args) => Process.runSync( - Platform.resolvedExecutable, - ['run', 'bin/blocks_codegen.dart', ...args], - workingDirectory: Directory.current.path, -); +final _packageRoot = Directory.current.absolute.path; + +ProcessResult _run(List args, {String? workingDirectory}) => + Process.runSync(Platform.resolvedExecutable, [ + 'run', + '$_packageRoot/bin/blocks_codegen.dart', + ...args, + ], workingDirectory: workingDirectory ?? _packageRoot); const _tag = 'example-iot/device-link'; @@ -63,6 +66,54 @@ String _spec({String? pattern}) => jsonEncode({ }, }); +String _tupleSpec() => jsonEncode({ + 'openrpc': '1.3.2', + 'info': {'title': 'tuple', 'version': '1.0.0'}, + 'methods': [ + { + 'name': 'api.getPair', + 'params': [], + 'result': { + 'name': 'GetPairResult', + 'schema': { + 'type': 'array', + 'prefixItems': [ + {'type': 'string'}, + {'type': 'integer'}, + ], + }, + }, + }, + ], +}); + +typedef _ConfigPackage = ({ + String name, + Directory root, + String? languageVersion, +}); + +void _writePackageConfig( + Directory discoveryRoot, + List<_ConfigPackage> packages, +) { + final dartTool = Directory('${discoveryRoot.path}/.dart_tool')..createSync(); + File('${dartTool.path}/package_config.json').writeAsStringSync( + jsonEncode({ + 'configVersion': 2, + 'packages': [ + for (final package in packages) + { + 'name': package.name, + 'rootUri': package.root.absolute.uri.toString(), + 'packageUri': 'lib/', + 'languageVersion': ?package.languageVersion, + }, + ], + }), + ); +} + void main() { late Directory tmp; @@ -120,6 +171,167 @@ void main() { } }); + test('resolves output below nonexistent directories', () { + final target = Directory('${tmp.path}/target')..createSync(); + _writePackageConfig(target, [ + (name: 'target', root: target, languageVersion: '3.11'), + ]); + final outputPath = '${target.path}/missing/nested/client.dart'; + + final result = _run([ + '--spec', + writeSpec(_tupleSpec()), + '--output', + outputPath, + ], workingDirectory: tmp.path); + + expect(result.exitCode, 0, reason: result.stderr.toString()); + expect( + File(outputPath).readAsStringSync(), + startsWith('// dart format width=80\n'), + ); + }); + + test('prefers the output package language version over cwd', () { + final cwd = Directory('${tmp.path}/cwd')..createSync(); + final target = Directory('${tmp.path}/target')..createSync(); + _writePackageConfig(cwd, [ + (name: 'cwd', root: cwd, languageVersion: '2.19'), + ]); + _writePackageConfig(target, [ + (name: 'target', root: target, languageVersion: '3.11'), + ]); + final outputPath = '${target.path}/lib/client.dart'; + + final result = _run([ + '--spec', + writeSpec(_tupleSpec()), + '--output', + outputPath, + ], workingDirectory: cwd.path); + + expect(result.exitCode, 0, reason: result.stderr.toString()); + expect(File(outputPath).existsSync(), isTrue); + }); + + test( + 'falls back to cwd config only when output config cannot map target', + () { + final cwd = Directory('${tmp.path}/cwd')..createSync(); + final target = Directory('${tmp.path}/target')..createSync(); + final unrelated = Directory('${tmp.path}/unrelated')..createSync(); + _writePackageConfig(target, [ + (name: 'unrelated', root: unrelated, languageVersion: '2.19'), + ]); + _writePackageConfig(cwd, [ + (name: 'cwd', root: cwd, languageVersion: '2.19'), + (name: 'target', root: target, languageVersion: '3.11'), + ]); + final outputPath = '${target.path}/lib/client.dart'; + + final result = _run([ + '--spec', + writeSpec(_tupleSpec()), + '--output', + outputPath, + ], workingDirectory: cwd.path); + + expect(result.exitCode, 0, reason: result.stderr.toString()); + expect(File(outputPath).existsSync(), isTrue); + }, + ); + + test('uses the cwd package language version for stdout', () { + final cwd = Directory('${tmp.path}/cwd')..createSync(); + _writePackageConfig(cwd, [ + (name: 'cwd', root: cwd, languageVersion: '3.11'), + ]); + + final result = _run([ + '--spec', + writeSpec(_tupleSpec()), + ], workingDirectory: cwd.path); + + expect(result.exitCode, 0, reason: result.stderr.toString()); + expect(result.stdout, startsWith('// dart format width=80\n')); + }); + + test('uses Dart 3.11 when a mapped target has no language version', () { + final cwd = Directory('${tmp.path}/cwd')..createSync(); + final target = Directory('${tmp.path}/target')..createSync(); + _writePackageConfig(target, [ + (name: 'target', root: target, languageVersion: null), + ]); + _writePackageConfig(cwd, [ + (name: 'cwd', root: cwd, languageVersion: '3.11'), + (name: 'target', root: target, languageVersion: '2.19'), + ]); + final outputPath = '${target.path}/lib/client.dart'; + + final result = _run([ + '--spec', + writeSpec(_tupleSpec()), + '--output', + outputPath, + ], workingDirectory: cwd.path); + + expect(result.exitCode, 0, reason: result.stderr.toString()); + expect(File(outputPath).existsSync(), isTrue); + }); + + test('uses Dart 3.11 when no package config exists', () { + final cwd = Directory('${tmp.path}/no_config')..createSync(); + + final result = _run([ + '--spec', + writeSpec(_tupleSpec()), + ], workingDirectory: cwd.path); + + expect(result.exitCode, 0, reason: result.stderr.toString()); + expect(result.stdout, startsWith('// dart format width=80\n')); + }); + + test('formatter failure leaves an existing output unchanged', () { + final target = Directory('${tmp.path}/target')..createSync(); + _writePackageConfig(target, [ + (name: 'target', root: target, languageVersion: '2.19'), + ]); + final output = File('${target.path}/client.dart') + ..writeAsStringSync('sentinel'); + + final result = _run([ + '--spec', + writeSpec(_tupleSpec()), + '--output', + output.path, + ], workingDirectory: tmp.path); + + expect(result.exitCode, 1); + expect(result.stderr, startsWith('Error:')); + expect(result.stdout, isEmpty); + expect(output.readAsStringSync(), 'sentinel'); + }); + + test('malformed output package config is reported without writing', () { + final target = Directory('${tmp.path}/target')..createSync(); + final dartTool = Directory('${target.path}/.dart_tool')..createSync(); + File('${dartTool.path}/package_config.json').writeAsStringSync('{'); + final output = File('${target.path}/client.dart') + ..writeAsStringSync('sentinel'); + + final result = _run([ + '--spec', + writeSpec(_spec()), + '--output', + output.path, + ], workingDirectory: tmp.path); + + expect(result.exitCode, 1); + expect(result.stderr, startsWith('Error:')); + expect(result.stdout, isEmpty); + expect(output.readAsStringSync(), 'sentinel'); + }); + test('a spec the parser rejects exits 1 with the message', () { final result = _run(['--spec', writeSpec(_spec(pattern: r'abc\'))]); diff --git a/native/dart/packages/blocks_codegen/test/collision_test.dart b/native/dart/packages/blocks_codegen/test/collision_test.dart index 4b2c8d8051..f302856e4b 100644 --- a/native/dart/packages/blocks_codegen/test/collision_test.dart +++ b/native/dart/packages/blocks_codegen/test/collision_test.dart @@ -1,7 +1,9 @@ import 'package:blocks_codegen/src/model.dart'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; /// Irreducible collision: even full namespace+method+param qualification /// collapses to the same string. diff --git a/native/dart/packages/blocks_codegen/test/dart_source_matchers.dart b/native/dart/packages/blocks_codegen/test/dart_source_matchers.dart new file mode 100644 index 0000000000..7db37f04ea --- /dev/null +++ b/native/dart/packages/blocks_codegen/test/dart_source_matchers.dart @@ -0,0 +1,307 @@ +import 'package:test/test.dart' as test; + +/// Matches exact values, or Dart source strings that differ only in whitespace +/// and context-proven optional trailing commas. +test.Matcher contains(Object? expected) => _DartSourceContains(expected); + +final class _DartSourceContains extends test.Matcher { + _DartSourceContains(this.expected) : _exact = test.contains(expected); + + final Object? expected; + final test.Matcher _exact; + + @override + test.Description describe(test.Description description) => + _exact.describe(description); + + @override + bool matches(Object? item, Map matchState) { + if (_exact.matches(item, matchState)) return true; + if (item is! String || expected is! String) return false; + final source = item; + final expectedSource = expected! as String; + final normalizedExpected = _normalizeDart(expectedSource); + if (normalizedExpected.isEmpty) return false; + if (_normalizeDart(source).contains(normalizedExpected)) return true; + return _normalizeDart( + source, + removeOptionalCommas: true, + ).contains(_normalizeDart(expectedSource, removeOptionalCommas: true)); + } +} + +String _normalizeDart(String source, {bool removeOptionalCommas = false}) { + final output = StringBuffer(); + final delimiters = <({bool callLike, int opener})>[]; + int? lastCodeUnit; + void writeCodeUnit(int codeUnit) { + output.writeCharCode(codeUnit); + lastCodeUnit = codeUnit; + } + + var index = 0; + while (index < source.length) { + final codeUnit = source.codeUnitAt(index); + if (removeOptionalCommas && + codeUnit == 0x2c && + _isOptionalTrailingComma(source, index, delimiters)) { + index++; + continue; + } + if (_isWhitespace(codeUnit)) { + final previous = lastCodeUnit; + while (index < source.length && _isWhitespace(source.codeUnitAt(index))) { + index++; + } + if (previous != null && + index < source.length && + _needsSeparator(previous, source.codeUnitAt(index))) { + writeCodeUnit(0x20); + } + continue; + } + + if (codeUnit == 0x2f && index + 1 < source.length) { + final next = source.codeUnitAt(index + 1); + if (next == 0x2f) { + while (index < source.length) { + final commentCodeUnit = source.codeUnitAt(index++); + writeCodeUnit(commentCodeUnit); + if (commentCodeUnit == 0x0a) break; + } + continue; + } + if (next == 0x2a) { + var depth = 0; + while (index < source.length) { + final commentCodeUnit = source.codeUnitAt(index); + final following = index + 1 < source.length + ? source.codeUnitAt(index + 1) + : null; + if (commentCodeUnit == 0x2f && following == 0x2a) depth++; + if (commentCodeUnit == 0x2a && following == 0x2f) depth--; + writeCodeUnit(commentCodeUnit); + index++; + if (depth == 0) { + writeCodeUnit(source.codeUnitAt(index)); + index++; + break; + } + } + continue; + } + } + + final raw = + (codeUnit == 0x72 || codeUnit == 0x52) && + index + 1 < source.length && + _isQuote(source.codeUnitAt(index + 1)); + if (_isQuote(codeUnit) || raw) { + if (raw) { + writeCodeUnit(codeUnit); + index++; + } + final quote = source.codeUnitAt(index); + final triple = + index + 2 < source.length && + source.codeUnitAt(index + 1) == quote && + source.codeUnitAt(index + 2) == quote; + final quoteLength = triple ? 3 : 1; + for (var count = 0; count < quoteLength; count++) { + writeCodeUnit(source.codeUnitAt(index++)); + } + while (index < source.length) { + final stringCodeUnit = source.codeUnitAt(index); + if (!raw && stringCodeUnit == 0x5c && index + 1 < source.length) { + writeCodeUnit(stringCodeUnit); + writeCodeUnit(source.codeUnitAt(index + 1)); + index += 2; + continue; + } + if (stringCodeUnit == quote && + (!triple || + (index + 2 < source.length && + source.codeUnitAt(index + 1) == quote && + source.codeUnitAt(index + 2) == quote))) { + for (var count = 0; count < quoteLength; count++) { + writeCodeUnit(source.codeUnitAt(index++)); + } + break; + } + writeCodeUnit(stringCodeUnit); + index++; + } + continue; + } + + if (_isOpeningDelimiter(codeUnit)) { + delimiters.add(( + callLike: codeUnit == 0x28 && _isCallLikeParenthesis(source, index), + opener: codeUnit, + )); + } else if (_isClosingDelimiter(codeUnit) && delimiters.isNotEmpty) { + delimiters.removeLast(); + } + writeCodeUnit(codeUnit); + index++; + } + return output.toString(); +} + +bool _isOptionalTrailingComma( + String source, + int commaIndex, + List<({bool callLike, int opener})> delimiters, +) { + if (delimiters.isEmpty) return false; + var index = commaIndex + 1; + while (index < source.length && _isWhitespace(source.codeUnitAt(index))) { + index++; + } + if (index == source.length) return false; + + final delimiter = delimiters.last; + final closer = source.codeUnitAt(index); + if (delimiter.opener == 0x5b && closer == 0x5d) return true; + if (delimiter.opener == 0x7b && closer == 0x7d) return true; + if (delimiter.opener != 0x28 || closer != 0x29) return false; + + if (delimiter.callLike) return true; + + index++; + while (index < source.length && _isWhitespace(source.codeUnitAt(index))) { + index++; + } + return index < source.length && + (source.codeUnitAt(index) == 0x7b || source.startsWith('=>', index)); +} + +bool _isOpeningDelimiter(int codeUnit) => + codeUnit == 0x28 || codeUnit == 0x5b || codeUnit == 0x7b; + +bool _isClosingDelimiter(int codeUnit) => + codeUnit == 0x29 || codeUnit == 0x5d || codeUnit == 0x7d; + +bool _isCallLikeParenthesis(String source, int openerIndex) { + var index = openerIndex - 1; + while (index >= 0 && _isWhitespace(source.codeUnitAt(index))) { + index--; + } + if (index < 0) return false; + + final previous = source.codeUnitAt(index); + if (previous == 0x29 || previous == 0x5d || previous == 0x3e) return true; + if (!_isIdentifierPart(previous)) return false; + + final end = index + 1; + while (index >= 0 && _isIdentifierPart(source.codeUnitAt(index))) { + index--; + } + final identifier = source.substring(index + 1, end); + return !const { + 'abstract', + 'as', + 'assert', + 'async', + 'augment', + 'await', + 'base', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'covariant', + 'default', + 'deferred', + 'do', + 'dynamic', + 'else', + 'enum', + 'export', + 'extends', + 'extension', + 'external', + 'factory', + 'false', + 'final', + 'finally', + 'for', + 'get', + 'hide', + 'if', + 'implements', + 'import', + 'in', + 'interface', + 'is', + 'late', + 'library', + 'mixin', + 'new', + 'null', + 'of', + 'on', + 'operator', + 'part', + 'required', + 'rethrow', + 'return', + 'sealed', + 'set', + 'show', + 'static', + 'switch', + 'sync', + 'throw', + 'true', + 'try', + 'typedef', + 'var', + 'void', + 'when', + 'while', + 'with', + 'yield', + }.contains(identifier); +} + +bool _isWhitespace(int codeUnit) => + codeUnit == 0x20 || + codeUnit == 0x09 || + codeUnit == 0x0a || + codeUnit == 0x0d || + codeUnit == 0x0b || + codeUnit == 0x0c; + +bool _isQuote(int codeUnit) => codeUnit == 0x22 || codeUnit == 0x27; + +bool _isIdentifierPart(int codeUnit) => + codeUnit == 0x24 || + codeUnit == 0x5f || + (codeUnit >= 0x30 && codeUnit <= 0x39) || + (codeUnit >= 0x41 && codeUnit <= 0x5a) || + (codeUnit >= 0x61 && codeUnit <= 0x7a); + +bool _isOperator(int codeUnit) => const { + 0x21, + 0x25, + 0x26, + 0x2a, + 0x2b, + 0x2d, + 0x2f, + 0x3c, + 0x3d, + 0x3e, + 0x3f, + 0x5e, + 0x7c, + 0x7e, +}.contains(codeUnit); + +bool _needsSeparator(int before, int after) => + (_isIdentifierPart(before) && _isIdentifierPart(after)) || + (_isOperator(before) && _isOperator(after)) || + (_isQuote(before) && _isQuote(after)); diff --git a/native/dart/packages/blocks_codegen/test/dart_source_matchers_test.dart b/native/dart/packages/blocks_codegen/test/dart_source_matchers_test.dart new file mode 100644 index 0000000000..7ac24df1b1 --- /dev/null +++ b/native/dart/packages/blocks_codegen/test/dart_source_matchers_test.dart @@ -0,0 +1,36 @@ +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; + +void main() { + test('accepts formatter whitespace and optional call commas', () { + expect( + "call(\n value: 'wire value',\n);", + contains("call(value: 'wire value')"), + ); + }); + + test('preserves semantic record commas', () { + expect('(value,)', isNot(contains('(value)'))); + expect('(value)', isNot(contains('(value,)'))); + expect('return(value,);', isNot(contains('return(value);'))); + expect('return (value,);', isNot(contains('return (value);'))); + expect('required (int,) field', isNot(contains('required (int) field'))); + expect('var(value,) = record', isNot(contains('var(value) = record'))); + }); + + test('rejects different tokens and reordered arguments', () { + expect('call(first, second)', isNot(contains('call(first, third)'))); + expect('call(first, second)', isNot(contains('call(second, first)'))); + }); + + test('preserves string contents and token boundaries', () { + expect("call('wire value')", isNot(contains("call('wire value')"))); + expect('intValue', isNot(contains('int Value'))); + }); + + test('keeps whitespace-only checks exact', () { + expect(r'escaped\nnewline', isNot(contains('\n'))); + expect('physical\nnewline', contains('\n')); + }); +} diff --git a/native/dart/packages/blocks_codegen/test/formatting_test.dart b/native/dart/packages/blocks_codegen/test/formatting_test.dart new file mode 100644 index 0000000000..f2d66973cd --- /dev/null +++ b/native/dart/packages/blocks_codegen/test/formatting_test.dart @@ -0,0 +1,37 @@ +import 'dart:convert'; + +import 'package:blocks_codegen/blocks_codegen.dart'; +import 'package:dart_style/dart_style.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:test/test.dart'; + +void main() { + final model = CodegenModelBuilder().build( + const OpenRpcParser().parse( + jsonEncode({ + 'openrpc': '1.3.2', + 'info': {'title': 'formatting', 'version': '1.0.0'}, + 'methods': [], + }), + ), + ); + + test('generate returns deterministic formatted source', () { + const generator = DartCodeGenerator(); + final output = generator.generate(model); + final explicitOutput = generator.generate( + model, + languageVersion: Version(3, 11, 0), + ); + + expect(output.split('\n').take(2), [ + '// dart format width=80', + '// GENERATED CODE \u2014 DO NOT MODIFY BY HAND', + ]); + expect(output, explicitOutput); + expect( + DartFormatter(languageVersion: Version(3, 11, 0)).format(output), + output, + ); + }); +} diff --git a/native/dart/packages/blocks_codegen/test/generated_code_compiles_test.dart b/native/dart/packages/blocks_codegen/test/generated_code_compiles_test.dart index 792e932545..054e59245a 100644 --- a/native/dart/packages/blocks_codegen/test/generated_code_compiles_test.dart +++ b/native/dart/packages/blocks_codegen/test/generated_code_compiles_test.dart @@ -187,6 +187,18 @@ dependencies: if (scratch.existsSync()) scratch.deleteSync(recursive: true); }); + test('generated clients are already formatted', () async { + _expectSuccess( + await _dart([ + 'format', + '--output=none', + '--set-exit-if-changed', + 'lib', + ], scratch.path), + 'dart format', + ); + }); + test('generated clients analyze without errors or warnings', () async { _expectSuccess( await _dart(['analyze', '--fatal-warnings', 'lib', 'bin'], scratch.path), diff --git a/native/dart/packages/blocks_codegen/test/generator_test.dart b/native/dart/packages/blocks_codegen/test/generator_test.dart index b248c83b1e..08c7532e03 100644 --- a/native/dart/packages/blocks_codegen/test/generator_test.dart +++ b/native/dart/packages/blocks_codegen/test/generator_test.dart @@ -4,7 +4,9 @@ import 'dart:io'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; void main() { const gen = DartCodeGenerator(); @@ -831,7 +833,9 @@ void main() { // `_client.call('', ...)` that precedes the return. final rawOps = {}; final allOps = {}; - final re = RegExp(r"_client\.call\('([^']+)'[^;]*\);\s*return ([^\n]*);"); + final re = RegExp( + r"_client\.call\('([^']+)'[^;]*\);\s*return ([\s\S]*?);", + ); for (final m in re.allMatches(output)) { final fullName = m.group(1)!; allOps.add(fullName); @@ -1753,10 +1757,8 @@ void main() { test('inline enum values decode through fromJson', () { expect( output, - matches( - RegExp( - r" moods: \(json\['moods'\] as Map\)\.map\(\(k, v\) => MapEntry\(k, \w+\.fromJson\(v as String\)\)\),", - ), + contains( + "moods: (json['moods'] as Map).map((k, v) => MapEntry(k, HolderMoods.fromJson(v as String)))", ), ); }); diff --git a/native/dart/packages/blocks_codegen/test/golden_file_test.dart b/native/dart/packages/blocks_codegen/test/golden_file_test.dart index 43589faa9d..e342f55ccd 100644 --- a/native/dart/packages/blocks_codegen/test/golden_file_test.dart +++ b/native/dart/packages/blocks_codegen/test/golden_file_test.dart @@ -1,6 +1,8 @@ import 'dart:io'; import 'package:blocks_codegen/blocks_codegen.dart'; +import 'package:dart_style/dart_style.dart'; +import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; /// The golden of a fixture whose spec the generator refuses: its message. @@ -63,6 +65,11 @@ void main() { } return; } + expect( + DartFormatter(languageVersion: Version(3, 11, 0)).format(output), + output, + reason: '$name output must already be formatted', + ); if (regenerate) { goldenDir.createSync(recursive: true); diff --git a/native/dart/packages/blocks_codegen/test/language_version_test.dart b/native/dart/packages/blocks_codegen/test/language_version_test.dart new file mode 100644 index 0000000000..69e70abf31 --- /dev/null +++ b/native/dart/packages/blocks_codegen/test/language_version_test.dart @@ -0,0 +1,46 @@ +import 'package:blocks_codegen/src/language_version.dart'; +import 'package:package_config/package_config.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:test/test.dart'; + +void main() { + final config = PackageConfig([ + Package( + 'blocks_codegen', + Uri.parse('file:///workspace/blocks_codegen/'), + languageVersion: LanguageVersion(3, 11), + ), + Package( + 'input_package', + Uri.parse('file:///workspace/input_package/'), + languageVersion: LanguageVersion(3, 13), + ), + Package('no_version', Uri.parse('file:///workspace/no_version/')), + ]); + + test('selects and converts the requested package language version', () { + expect( + languageVersionForPackage(config, 'input_package'), + Version(3, 13, 0), + ); + }); + + test('returns null for an absent package or language version', () { + expect(languageVersionForPackage(config, 'absent'), isNull); + expect(languageVersionForPackage(config, 'no_version'), isNull); + }); + + test('maps a target URI and distinguishes an absent target', () { + expect( + languageVersionForUri( + config, + Uri.file('/workspace/input_package/lib/client.dart'), + ), + (found: true, version: Version(3, 13, 0)), + ); + expect(languageVersionForUri(config, Uri.file('/outside/client.dart')), ( + found: false, + version: null, + )); + }); +} diff --git a/native/dart/packages/blocks_codegen/test/local_name_collision_test.dart b/native/dart/packages/blocks_codegen/test/local_name_collision_test.dart index 781ec391b5..87c3fc0097 100644 --- a/native/dart/packages/blocks_codegen/test/local_name_collision_test.dart +++ b/native/dart/packages/blocks_codegen/test/local_name_collision_test.dart @@ -1,6 +1,8 @@ import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; /// The generated code declares its own names next to user-chosen ones: an /// operation's `params` array and `result`, the `==` parameter `other`, the @@ -77,7 +79,7 @@ void main() { test('a parameter named `result` keeps its name; the local yields', () { final body = runBody(gen.generate(model(params: [param('result')]))); expect(body, contains('Future run({required String result})')); - expect(body, contains(' result,\n')); + expect(body, contains('final params = [result];')); expect( body, contains(r" final $result = await _client.call('api.run', params);"), @@ -90,7 +92,7 @@ void main() { final body = runBody(gen.generate(model(params: [param('params')]))); expect(body, contains('Future run({required String params})')); expect(body, contains(r' final $params = [')); - expect(body, contains(' params,\n')); + expect(body, contains(r'final $params = [params];')); expect(body, contains(r"await _client.call('api.run', $params);")); expect(body, contains(' return result as String;')); }); @@ -134,14 +136,7 @@ void main() { final body = runBody( gen.generate(model(params: [param('result'), param(r'$result')])), ); - expect( - body, - contains( - ' result,\n' - r' $result,' - '\n', - ), - ); + expect(body, contains(r'final params = [result, $result];')); expect(body, contains(r' final $result2 = await _client.call(')); expect(body, contains(r' return $result2 as String;')); }); @@ -196,10 +191,7 @@ void main() { expect( body, ' Future run({required String id, required String name}) async {\n' - ' final params = [\n' - ' id,\n' - ' name,\n' - ' ];\n' + ' final params = [id, name];\n' " final result = await _client.call('api.run', params);\n" ' return result as String;', ); diff --git a/native/dart/packages/blocks_codegen/test/model_equality_test.dart b/native/dart/packages/blocks_codegen/test/model_equality_test.dart index 83b60f34bf..46135c49a8 100644 --- a/native/dart/packages/blocks_codegen/test/model_equality_test.dart +++ b/native/dart/packages/blocks_codegen/test/model_equality_test.dart @@ -3,7 +3,9 @@ import 'dart:convert'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; // A generated model's `==` and `hashCode` used to compare list and map fields // with `==` and `hashCode`, which Dart's `List` and `Map` implement by diff --git a/native/dart/packages/blocks_codegen/test/native_bindings_test.dart b/native/dart/packages/blocks_codegen/test/native_bindings_test.dart index ce52940e5f..1d5270cefc 100644 --- a/native/dart/packages/blocks_codegen/test/native_bindings_test.dart +++ b/native/dart/packages/blocks_codegen/test/native_bindings_test.dart @@ -5,7 +5,9 @@ import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/dart_source.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; /// The third-party tag the probes bind. A built-in tag short-circuits binding /// resolution, so a probe using one cannot reach the rule under test. @@ -62,10 +64,7 @@ void main() { test('the runtime import is kept and declared imports are sorted', () { final output = _generate(_build(_specJson(extras: _catalogs()))); - final directives = const LineSplitter() - .convert(output) - .where((l) => l.startsWith('import ') || l.startsWith('export ')) - .toList(); + final directives = _allDirectives(output); expect(directives, [ "import 'package:blocks_runtime/blocks_runtime.dart';", @@ -250,9 +249,17 @@ void main() { .replaceAll(RegExp(r"'(?:[^'\\\n]|\\.)*'"), "''") .replaceAll(RegExp(r'"(?:[^"\\\n]|\\.)*"'), "''"); - final shown = RegExp(r"^import '[^']+' show ([^;]+);", multiLine: true) - .allMatches(output) - .expand((m) => m.group(1)!.split(',').map((n) => n.trim())) + final shown = _allDirectives(output) + .where((directive) => directive.startsWith('import ')) + .where((directive) => directive.contains(' show ')) + .expand( + (directive) => directive + .split(' show ') + .last + .replaceFirst(RegExp(r';$'), '') + .split(',') + .map((name) => name.trim()), + ) .toSet(); // Every position a type can occupy: call, generic open, member access, // generic close, generic comma, statement end, index close, nullable, @@ -1017,7 +1024,7 @@ void main() { }), ), ); - final header = const LineSplitter().convert(output)[2]; + final header = const LineSplitter().convert(output)[3]; expect(header, startsWith('// Source: ')); expect(header, contains(r'\nvoid pwnedViaTitle() {}')); @@ -1406,8 +1413,16 @@ void main() { }); } +List _allDirectives(String output) => + RegExp( + r'^(?:import|export) [^;]+;', + multiLine: true, + ).allMatches(output).map((match) { + return match.group(0)!.replaceAll(RegExp(r'\s+'), ' '); + }).toList(); + List _directives(String output) => - output.split('\n').where((line) => line.startsWith('import ')).toList(); + _allDirectives(output).where((line) => line.startsWith('import ')).toList(); /// A spec whose arity-one type-arg `$ref` target is renamed by the collision /// pass, so the decoder it named no longer exists under that name. diff --git a/native/dart/packages/blocks_codegen/test/nested_container_test.dart b/native/dart/packages/blocks_codegen/test/nested_container_test.dart index b10a465f7f..ae4ca96202 100644 --- a/native/dart/packages/blocks_codegen/test/nested_container_test.dart +++ b/native/dart/packages/blocks_codegen/test/nested_container_test.dart @@ -3,7 +3,9 @@ import 'dart:convert'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; // Containers (lists, maps, nullables, tuples, and any nesting of them) whose // elements need converting used to decode with a bare cast: `v as List`, @@ -288,7 +290,7 @@ void main() { expect( output, contains( - ' .map((e) => MapEntry(e.key, Note.fromJson(e.value as Map))),', + ' .map((e) => MapEntry(e.key, Note.fromJson(e.value as Map)))', ), ); }); @@ -340,7 +342,7 @@ void main() { expect( output, contains( - " client: OidcClient.fromJson(json['client'] as Map, baseUrl: client.baseUrl, tokenStore: client.tokenStore, sessionStore: client.sessionStore),", + " client: OidcClient.fromJson(json['client'] as Map, baseUrl: client.baseUrl, tokenStore: client.tokenStore, sessionStore: client.sessionStore)", ), ); }); @@ -504,7 +506,7 @@ void main() { expect( output, contains( - " if (pair != null) 'pair': switch (pair) { final value? => [value.\$1, value.\$2.toJson()], _ => null },", + " if (pair != null) 'pair': switch (pair) { final value? => [value.\$1, value.\$2.toJson()], _ => null }", ), ); }); diff --git a/native/dart/packages/blocks_codegen/test/oidc_provider_enum_test.dart b/native/dart/packages/blocks_codegen/test/oidc_provider_enum_test.dart index 8b5d5b6a34..02e124759f 100644 --- a/native/dart/packages/blocks_codegen/test/oidc_provider_enum_test.dart +++ b/native/dart/packages/blocks_codegen/test/oidc_provider_enum_test.dart @@ -3,7 +3,9 @@ import 'dart:convert'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; // An `oidc/client` whose `x-blocks-type-args[0]` is a string enum names the // providers its client signs in with. A direct or optional result generates diff --git a/native/dart/packages/blocks_codegen/test/open_enum_test.dart b/native/dart/packages/blocks_codegen/test/open_enum_test.dart index 35697baa8a..b731f8d2eb 100644 --- a/native/dart/packages/blocks_codegen/test/open_enum_test.dart +++ b/native/dart/packages/blocks_codegen/test/open_enum_test.dart @@ -3,7 +3,9 @@ import 'dart:io'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; // A string enum a response carries is generated open: a value the client was // generated without decodes to `XUnknown` holding the string, instead of diff --git a/native/dart/packages/blocks_codegen/test/open_record_test.dart b/native/dart/packages/blocks_codegen/test/open_record_test.dart index 926c568908..9a7315f667 100644 --- a/native/dart/packages/blocks_codegen/test/open_record_test.dart +++ b/native/dart/packages/blocks_codegen/test/open_record_test.dart @@ -4,7 +4,9 @@ import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/model.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; // An open record is an object schema with `properties` and // `additionalProperties` (TS `T & Record`). Its extra keys sit flat @@ -247,7 +249,7 @@ void main() { notes, contains( '.map((e) => MapEntry(e.key, ' - 'Note.fromJson(e.value as Map))),', + 'Note.fromJson(e.value as Map)))', ), ); expect(notes, contains('.contains(e.key)) e.key: e.value.toJson(),')); diff --git a/native/dart/packages/blocks_codegen/test/open_union_test.dart b/native/dart/packages/blocks_codegen/test/open_union_test.dart index 57ced84285..886d7f244f 100644 --- a/native/dart/packages/blocks_codegen/test/open_union_test.dart +++ b/native/dart/packages/blocks_codegen/test/open_union_test.dart @@ -3,7 +3,9 @@ import 'dart:io'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; // A union with a string discriminator that a response carries is generated // open: an object whose discriminator names no arm decodes to `XUnknown`, diff --git a/native/dart/packages/blocks_codegen/test/positional_params_test.dart b/native/dart/packages/blocks_codegen/test/positional_params_test.dart index 81e4c8cc14..b81232c7cb 100644 --- a/native/dart/packages/blocks_codegen/test/positional_params_test.dart +++ b/native/dart/packages/blocks_codegen/test/positional_params_test.dart @@ -1,6 +1,8 @@ import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; /// JSON-RPC params are positional on an AWS Blocks server: `parseRpcRequest` /// (`packages/core`) passes an array as the method's argument list, and reads diff --git a/native/dart/packages/blocks_codegen/test/reserved_name_test.dart b/native/dart/packages/blocks_codegen/test/reserved_name_test.dart index c9fc8b8f80..d7a0bd7866 100644 --- a/native/dart/packages/blocks_codegen/test/reserved_name_test.dart +++ b/native/dart/packages/blocks_codegen/test/reserved_name_test.dart @@ -3,7 +3,9 @@ import 'dart:convert'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; // A name from the spec becomes a Dart identifier: a field, a named parameter, // a method, a `Blocks` field, an enum value or a `Servers` constant. Some @@ -158,15 +160,7 @@ void main() { ), ); // Params are positional, so the wire name isn't sent. - expect( - output, - contains( - r' $id,' - '\n' - r' $$v,' - '\n name,\n', - ), - ); + expect(output, contains(r'final params = [$id, $$v, name];')); }); test('is a public method that calls the original operation', () { @@ -374,7 +368,7 @@ void main() { ); expect(level, contains(' aB\$,\n aB\n;')); expect(level, contains(r" 'a-b': aB$,")); - expect(level, contains(" 'aB': aB,")); + expect(level, contains(" 'aB': aB")); }); }); @@ -441,14 +435,7 @@ void main() { expect( output, contains( - r' String$,' - '\n' - r' int$,' - '\n' - r' Map$,' - '\n' - r' Doc$.toJson(),' - '\n', + r'final params = [String$, int$, Map$, Doc$.toJson()];', ), ); }); @@ -586,14 +573,7 @@ void main() { r'required int $result}) async {', ), ); - expect( - output, - contains( - ' result,\n' - r' $result,' - '\n', - ), - ); + expect(output, contains(r'final params = [result, $result];')); expect(output, contains(r' final $result2 = await _client.call(')); expect(output, contains(r' return $result2 as String;')); }); diff --git a/native/dart/packages/blocks_codegen/test/schema_alias_ref_test.dart b/native/dart/packages/blocks_codegen/test/schema_alias_ref_test.dart index a0ad982686..5fc79fe1a4 100644 --- a/native/dart/packages/blocks_codegen/test/schema_alias_ref_test.dart +++ b/native/dart/packages/blocks_codegen/test/schema_alias_ref_test.dart @@ -3,7 +3,9 @@ import 'dart:convert'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; // A component schema that isn't a model, an enum or a discriminated union — // a string, an array, a map, a nullable, or a union the generator types as @@ -165,7 +167,7 @@ void main() { " one: json['one'] as dynamic,\n" " many: (json['many'] as List).cast(),\n" " kind: Kind.fromJson(json['kind'] as Map),\n" - " loop: json['loop'] as dynamic,\n", + " loop: json['loop'] as dynamic\n", ), ); }); diff --git a/native/dart/packages/blocks_codegen/test/schema_rename_ref_test.dart b/native/dart/packages/blocks_codegen/test/schema_rename_ref_test.dart index 843a186eb4..74c5f3b13a 100644 --- a/native/dart/packages/blocks_codegen/test/schema_rename_ref_test.dart +++ b/native/dart/packages/blocks_codegen/test/schema_rename_ref_test.dart @@ -3,7 +3,9 @@ import 'dart:convert'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; // The builder renames types after it resolves them: a schema whose one field // has a generic shape (`{value}`) takes a generic name (`ValueResult`), Pass 3 @@ -158,9 +160,12 @@ List _refs(CodegenModel model) { } String _signature(String output) { - final i = output.indexOf('Future make('); - expect(i, isNot(-1)); - return output.substring(i, output.indexOf('\n', i)); + final start = output.indexOf('Future make('); + expect(start, isNot(-1)); + const suffix = ') async {'; + final end = output.indexOf(suffix, start); + expect(end, isNot(-1)); + return output.substring(start, end + suffix.length); } void main() { diff --git a/native/dart/packages/blocks_codegen/test/spec_string_identifier_test.dart b/native/dart/packages/blocks_codegen/test/spec_string_identifier_test.dart index 47203f5850..c2749b6f95 100644 --- a/native/dart/packages/blocks_codegen/test/spec_string_identifier_test.dart +++ b/native/dart/packages/blocks_codegen/test/spec_string_identifier_test.dart @@ -3,7 +3,9 @@ import 'dart:convert'; import 'package:blocks_codegen/src/builder.dart'; import 'package:blocks_codegen/src/generator.dart'; import 'package:blocks_codegen/src/parser.dart'; -import 'package:test/test.dart'; +import 'package:test/test.dart' hide contains; + +import 'dart_source_matchers.dart'; // Names and values from the spec reach the generated library in two forms: // @@ -142,10 +144,7 @@ void main() { // Params are positional, so the spec name isn't sent. expect( output, - contains( - r' a$b,' - '\n itS,\n backSlash,\n', - ), + contains(r'final params = [a$b, itS, backSlash];'), ); expect( output, @@ -269,7 +268,7 @@ void main() { test('writes the escaped discriminant and value', () { expect(_decl(output, 'ItSEvent'), contains(r" 'k\$ind': 'it\'s',")); - expect(_decl(output, r'A$bEvent'), contains(r" 'k\$ind': 'a\$b',")); + expect(_decl(output, r'A$bEvent'), contains(r" 'k\$ind': 'a\$b'")); }); test("prints a variant whose class name holds `\$`", () { @@ -343,7 +342,7 @@ void main() { test('keeps a newline in the title out of the header comment', () { // Escaped (`\n` shown literally), so the header stays one comment line. expect(output, contains(r'// Source: My\nAPI v1')); - expect(output, isNot(contains('\nAPI v1'))); + expect(output.contains('\nAPI v1'), isFalse); }); }); @@ -416,7 +415,7 @@ void main() { 'required String xYZ}) async {', ), ); - expect(output, contains(' contentType,\n xYZ,\n')); + expect(output, contains('final params = [contentType, xYZ];')); }); test('a dotted namespace is a camel-cased field of a valid class', () { @@ -567,7 +566,7 @@ void main() { expect(output, contains(r' final $Doc d;')); expect( output, - contains(r" d: $Doc.fromJson(json['d'] as Map),"), + contains(r" d: $Doc.fromJson(json['d'] as Map)"), ); expect( output, @@ -690,7 +689,7 @@ void main() { test('is escaped in the literal; the identifier is camel-cased', () { final doc = _decl(output, 'Doc'); expect(doc, contains(r" aB: json['a\tb'] as String,")); - expect(doc, contains(r" 'c\u{1}d': cD,")); + expect(doc, contains(r" 'c\u{1}d': cD")); expect(output, isNot(contains('\t'))); expect(output, isNot(contains('\u0001'))); }); diff --git a/scripts/sink-guards/codegen.test.mjs b/scripts/sink-guards/codegen.test.mjs index f73394d89b..f2e1749a04 100644 --- a/scripts/sink-guards/codegen.test.mjs +++ b/scripts/sink-guards/codegen.test.mjs @@ -34,7 +34,7 @@ const SWIFT_CONTENT_LOCAL = (v) => const ALLOWLIST = [ { - at: 'native/dart/packages/blocks_codegen/lib/src/generator.dart:2168', + at: 'native/dart/packages/blocks_codegen/lib/src/generator.dart:2175', reason: "label is the generated class name, a Dart identifier, with its `$` escaped on the line above, so it holds no quote or interpolation.", }, ...[583, 678].map((l) => ({ at: `native/swift/Sources/BlocksCodegen/SwiftCodeGenerator.swift:${l}`, reason: SWIFT_TYPE_NAME })),